• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer Split Muxed File Source - Part reader
2  * Copyright (C) 2014 Jan Schmidt <jan@centricular.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 #ifndef __GST_SPLITMUX_PART_READER_H__
20 #define __GST_SPLITMUX_PART_READER_H__
21 
22 #include <gst/gst.h>
23 #include <gst/base/gstdataqueue.h>
24 
25 G_BEGIN_DECLS
26 
27 #define GST_TYPE_SPLITMUX_PART_READER \
28   (gst_splitmux_part_reader_get_type())
29 #define GST_SPLITMUX_PART_READER(obj) \
30   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SPLITMUX_PART_READER,GstSplitMuxSrc))
31 #define GST_SPLITMUX_PART_READER_CLASS(klass) \
32   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SPLITMUX_PART_READER,GstSplitMuxSrcClass))
33 #define GST_IS_SPLITMUX_PART_READER(obj) \
34   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SPLITMUX_PART_READER))
35 #define GST_IS_SPLITMUX_PART_READER_CLASS(klass) \
36   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SPLITMUX_PART_READER))
37 
38 typedef struct _GstSplitMuxPartReader GstSplitMuxPartReader;
39 typedef struct _GstSplitMuxPartReaderClass GstSplitMuxPartReaderClass;
40 typedef struct _SplitMuxSrcPad SplitMuxSrcPad;
41 typedef struct _SplitMuxSrcPadClass SplitMuxSrcPadClass;
42 
43 typedef enum
44 {
45   PART_STATE_NULL,
46   PART_STATE_PREPARING_COLLECT_STREAMS,
47   PART_STATE_PREPARING_MEASURE_STREAMS,
48   PART_STATE_PREPARING_RESET_FOR_READY,
49   PART_STATE_READY,
50   PART_STATE_FAILED,
51 } GstSplitMuxPartState;
52 
53 typedef GstPad *(*GstSplitMuxPartReaderPadCb)(GstSplitMuxPartReader *reader, GstPad *src_pad, gpointer cb_data);
54 
55 struct _GstSplitMuxPartReader
56 {
57   GstPipeline parent;
58 
59   GstSplitMuxPartState prep_state;
60 
61   gchar *path;
62 
63   GstElement *src;
64   GstElement *typefind;
65   GstElement *demux;
66 
67   gboolean async_pending;
68   gboolean active;
69   gboolean running;
70   gboolean prepared;
71   gboolean flushing;
72   gboolean no_more_pads;
73 
74   GstClockTime duration;
75   GstClockTime start_offset;
76   GstClockTime ts_offset;
77 
78   GList *pads;
79 
80   GCond inactive_cond;
81   GMutex lock;
82   GMutex type_lock;
83   GMutex msg_lock;
84 
85   GstSplitMuxPartReaderPadCb get_pad_cb;
86   gpointer cb_data;
87 };
88 
89 struct _GstSplitMuxPartReaderClass
90 {
91   GstPipelineClass parent_class;
92 
93   void (*prepared)  (GstSplitMuxPartReader *reader);
94   void (*end_of_part) (GstSplitMuxPartReader *reader);
95 };
96 
97 GType gst_splitmux_part_reader_get_type (void);
98 
99 void gst_splitmux_part_reader_set_callbacks (GstSplitMuxPartReader *reader,
100     gpointer cb_data, GstSplitMuxPartReaderPadCb get_pad_cb);
101 gboolean gst_splitmux_part_reader_prepare (GstSplitMuxPartReader *part);
102 void gst_splitmux_part_reader_unprepare (GstSplitMuxPartReader *part);
103 void gst_splitmux_part_reader_set_location (GstSplitMuxPartReader *reader,
104     const gchar *path);
105 gboolean gst_splitmux_part_is_eos (GstSplitMuxPartReader *reader);
106 
107 gboolean gst_splitmux_part_reader_activate (GstSplitMuxPartReader *part, GstSegment *seg, GstSeekFlags extra_flags);
108 void gst_splitmux_part_reader_deactivate (GstSplitMuxPartReader *part);
109 gboolean gst_splitmux_part_reader_is_active (GstSplitMuxPartReader *part);
110 
111 gboolean gst_splitmux_part_reader_src_query (GstSplitMuxPartReader *part, GstPad *src_pad, GstQuery * query);
112 void gst_splitmux_part_reader_set_start_offset (GstSplitMuxPartReader *part, GstClockTime time_offset, GstClockTime ts_offset);
113 GstClockTime gst_splitmux_part_reader_get_start_offset (GstSplitMuxPartReader *part);
114 GstClockTime gst_splitmux_part_reader_get_end_offset (GstSplitMuxPartReader *part);
115 GstClockTime gst_splitmux_part_reader_get_duration (GstSplitMuxPartReader * reader);
116 
117 GstPad *gst_splitmux_part_reader_lookup_pad (GstSplitMuxPartReader *reader, GstPad *target);
118 GstFlowReturn gst_splitmux_part_reader_pop (GstSplitMuxPartReader *reader, GstPad *part_pad, GstDataQueueItem ** item);
119 
120 G_END_DECLS
121 
122 #endif
123