• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *                    2006 Wim Taymans <wim@fluendo.com>
5  *                    2006 David A. Schleef <ds@schleef.org>
6  *
7  * gstmultifilesink.h:
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public
20  * License along with this library; if not, write to the
21  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  */
24 
25 #ifndef __GST_MULTIFILESINK_H__
26 #define __GST_MULTIFILESINK_H__
27 
28 #include <gst/gst.h>
29 #include <gst/base/base.h>
30 #include <errno.h>
31 #include <stdio.h>
32 #include <string.h>
33 #include <sys/stat.h>
34 #include <sys/types.h>
35 #ifdef HAVE_UNISTD_H
36 #include <unistd.h>
37 #endif
38 
39 G_BEGIN_DECLS
40 
41 #define GST_TYPE_MULTI_FILE_SINK \
42   (gst_multi_file_sink_get_type())
43 #define GST_MULTI_FILE_SINK(obj) \
44   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MULTI_FILE_SINK,GstMultiFileSink))
45 #define GST_MULTI_FILE_SINK_CLASS(klass) \
46   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MULTI_FILE_SINK,GstMultiFileSinkClass))
47 #define GST_IS_MULTI_FILE_SINK(obj) \
48   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MULTI_FILE_SINK))
49 #define GST_IS_MULTI_FILE_SINK_CLASS(klass) \
50   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULTI_FILE_SINK))
51 
52 typedef struct _GstMultiFileSink GstMultiFileSink;
53 typedef struct _GstMultiFileSinkClass GstMultiFileSinkClass;
54 
55 /**
56  * GstMultiFileSinkNext:
57  * @GST_MULTI_FILE_SINK_NEXT_BUFFER: New file for each buffer
58  * @GST_MULTI_FILE_SINK_NEXT_DISCONT: New file after each discontinuity
59  * @GST_MULTI_FILE_SINK_NEXT_KEY_FRAME: New file at each key frame
60  *  (Useful for MPEG-TS segmenting)
61  * @GST_MULTI_FILE_SINK_NEXT_KEY_UNIT_EVENT: New file after a force key unit
62  *  event
63  * @GST_MULTI_FILE_SINK_NEXT_MAX_SIZE: New file when the configured maximum file
64  *  size would be exceeded with the next buffer or buffer list
65  * @GST_MULTI_FILE_SINK_NEXT_MAX_DURATION: New file when the configured maximum duration
66  *  would be exceeded with the next buffer or buffer list
67  *
68  * File splitting modes.
69  */
70 typedef enum {
71   GST_MULTI_FILE_SINK_NEXT_BUFFER,
72   GST_MULTI_FILE_SINK_NEXT_DISCONT,
73   GST_MULTI_FILE_SINK_NEXT_KEY_FRAME,
74   GST_MULTI_FILE_SINK_NEXT_KEY_UNIT_EVENT,
75   GST_MULTI_FILE_SINK_NEXT_MAX_SIZE,
76   GST_MULTI_FILE_SINK_NEXT_MAX_DURATION
77 } GstMultiFileSinkNext;
78 
79 struct _GstMultiFileSink
80 {
81   GstBaseSink parent;
82 
83   gchar *filename;
84   gint index;
85   gboolean post_messages;
86   GstMultiFileSinkNext next_file;
87   FILE *file;
88 
89   guint max_files;
90   GQueue old_files;        /* keep track of old files for max_files handling */
91 
92   gint64 next_segment;
93 
94   int n_streamheaders;
95   GstBuffer **streamheaders;
96   guint force_key_unit_count;
97 
98   guint64 cur_file_size;
99   guint64 max_file_size;
100 
101   GstClockTime file_pts;
102   GstClockTime max_file_duration;
103   GstClockTime min_keyframe_distance;
104 
105   gboolean aggregate_gops;
106   GstAdapter *gop_adapter;  /* to aggregate GOPs */
107   GList *potential_next_gop;	/* To detect false-positives */
108 };
109 
110 struct _GstMultiFileSinkClass
111 {
112   GstBaseSinkClass parent_class;
113 };
114 
115 GType gst_multi_file_sink_get_type (void);
116 
117 GST_ELEMENT_REGISTER_DECLARE (multifilesink);
118 
119 G_END_DECLS
120 
121 #endif /* __GST_MULTIFILESINK_H__ */
122