splitmuxsink: Don't leak old muxer/sink in async mode
[platform/upstream/gst-plugins-good.git] / gst / multifile / gstsplitmuxpartreader.h
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 active;
68   gboolean running;
69   gboolean prepared;
70   gboolean flushing;
71   gboolean no_more_pads;
72
73   GstClockTime duration;
74   GstClockTime start_offset;
75
76   GList *pads;
77
78   GCond inactive_cond;
79   GMutex lock;
80   GMutex type_lock;
81
82   GstSplitMuxPartReaderPadCb get_pad_cb;
83   gpointer cb_data;
84 };
85
86 struct _GstSplitMuxPartReaderClass
87 {
88   GstPipelineClass parent_class;
89
90   void (*prepared)  (GstSplitMuxPartReader *reader);
91   void (*end_of_part) (GstSplitMuxPartReader *reader);
92 };
93
94 GType gst_splitmux_part_reader_get_type (void);
95
96 void gst_splitmux_part_reader_set_callbacks (GstSplitMuxPartReader *reader,
97     gpointer cb_data, GstSplitMuxPartReaderPadCb get_pad_cb);
98 gboolean gst_splitmux_part_reader_prepare (GstSplitMuxPartReader *part);
99 void gst_splitmux_part_reader_unprepare (GstSplitMuxPartReader *part);
100 void gst_splitmux_part_reader_set_location (GstSplitMuxPartReader *reader,
101     const gchar *path);
102 gboolean gst_splitmux_part_is_eos (GstSplitMuxPartReader *reader);
103
104 gboolean gst_splitmux_part_reader_activate (GstSplitMuxPartReader *part, GstSegment *seg, GstSeekFlags extra_flags);
105 void gst_splitmux_part_reader_deactivate (GstSplitMuxPartReader *part);
106 gboolean gst_splitmux_part_reader_is_active (GstSplitMuxPartReader *part);
107
108 gboolean gst_splitmux_part_reader_src_query (GstSplitMuxPartReader *part, GstPad *src_pad, GstQuery * query);
109 void gst_splitmux_part_reader_set_start_offset (GstSplitMuxPartReader *part, GstClockTime offset);
110 GstClockTime gst_splitmux_part_reader_get_start_offset (GstSplitMuxPartReader *part);
111 GstClockTime gst_splitmux_part_reader_get_end_offset (GstSplitMuxPartReader *part);
112 GstClockTime gst_splitmux_part_reader_get_duration (GstSplitMuxPartReader * reader);
113
114 GstPad *gst_splitmux_part_reader_lookup_pad (GstSplitMuxPartReader *reader, GstPad *target);
115 GstFlowReturn gst_splitmux_part_reader_pop (GstSplitMuxPartReader *reader, GstPad *part_pad, GstDataQueueItem ** item);
116
117 G_END_DECLS
118
119 #endif