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 77 GList *pads; 78 79 GCond inactive_cond; 80 GMutex lock; 81 GMutex type_lock; 82 83 GstSplitMuxPartReaderPadCb get_pad_cb; 84 gpointer cb_data; 85 }; 86 87 struct _GstSplitMuxPartReaderClass 88 { 89 GstPipelineClass parent_class; 90 91 void (*prepared) (GstSplitMuxPartReader *reader); 92 void (*end_of_part) (GstSplitMuxPartReader *reader); 93 }; 94 95 GType gst_splitmux_part_reader_get_type (void); 96 97 void gst_splitmux_part_reader_set_callbacks (GstSplitMuxPartReader *reader, 98 gpointer cb_data, GstSplitMuxPartReaderPadCb get_pad_cb); 99 gboolean gst_splitmux_part_reader_prepare (GstSplitMuxPartReader *part); 100 void gst_splitmux_part_reader_unprepare (GstSplitMuxPartReader *part); 101 void gst_splitmux_part_reader_set_location (GstSplitMuxPartReader *reader, 102 const gchar *path); 103 gboolean gst_splitmux_part_is_eos (GstSplitMuxPartReader *reader); 104 105 gboolean gst_splitmux_part_reader_activate (GstSplitMuxPartReader *part, GstSegment *seg, GstSeekFlags extra_flags); 106 void gst_splitmux_part_reader_deactivate (GstSplitMuxPartReader *part); 107 gboolean gst_splitmux_part_reader_is_active (GstSplitMuxPartReader *part); 108 109 gboolean gst_splitmux_part_reader_src_query (GstSplitMuxPartReader *part, GstPad *src_pad, GstQuery * query); 110 void gst_splitmux_part_reader_set_start_offset (GstSplitMuxPartReader *part, GstClockTime offset); 111 GstClockTime gst_splitmux_part_reader_get_start_offset (GstSplitMuxPartReader *part); 112 GstClockTime gst_splitmux_part_reader_get_end_offset (GstSplitMuxPartReader *part); 113 GstClockTime gst_splitmux_part_reader_get_duration (GstSplitMuxPartReader * reader); 114 115 GstPad *gst_splitmux_part_reader_lookup_pad (GstSplitMuxPartReader *reader, GstPad *target); 116 GstFlowReturn gst_splitmux_part_reader_pop (GstSplitMuxPartReader *reader, GstPad *part_pad, GstDataQueueItem ** item); 117 118 G_END_DECLS 119 120 #endif 121