1 /*
2  * tsdemux - GStreamer MPEG transport stream demuxer
3  * Copyright (C) 2009 Zaheer Abbas Merali
4  *               2010 Edward Hervey
5  *
6  * Authors:
7  *   Zaheer Abbas Merali <zaheerabbas at merali dot org>
8  *   Edward Hervey <edward.hervey@collabora.co.uk>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23  * Boston, MA 02110-1301, USA.
24  */
25 
26 
27 #ifndef GST_TS_DEMUX_H
28 #define GST_TS_DEMUX_H
29 
30 #include <gst/gst.h>
31 #include <gst/base/gstbytereader.h>
32 #include <gst/base/gstflowcombiner.h>
33 #include "mpegtsbase.h"
34 #include "mpegtspacketizer.h"
35 
36 /* color specifications for JPEG 2000 stream over MPEG TS */
37 typedef enum
38 {
39   GST_MPEGTSDEMUX_JPEG2000_COLORSPEC_UNKNOWN,
40   GST_MPEGTSDEMUX_JPEG2000_COLORSPEC_SRGB,
41   GST_MPEGTSDEMUX_JPEG2000_COLORSPEC_REC601,
42   GST_MPEGTSDEMUX_JPEG2000_COLORSPEC_REC709,
43   GST_MPEGTSDEMUX_JPEG2000_COLORSPEC_CIELUV,
44   GST_MPEGTSDEMUX_JPEG2000_COLORSPEC_CIEXYZ,
45   GST_MPEGTSDEMUX_JPEG2000_COLORSPEC_REC2020,
46   GST_MPEGTSDEMUX_JPEG2000_COLORSPEC_SMPTE2084
47 } GstMpegTsDemuxJpeg2000ColorSpec;
48 
49 
50 G_BEGIN_DECLS
51 #define GST_TYPE_TS_DEMUX \
52   (gst_ts_demux_get_type())
53 #define GST_TS_DEMUX(obj) \
54   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TS_DEMUX,GstTSDemux))
55 #define GST_TS_DEMUX_CLASS(klass) \
56   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TS_DEMUX,GstTSDemuxClass))
57 #define GST_IS_TS_DEMUX(obj) \
58   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TS_DEMUX))
59 #define GST_IS_TS_DEMUX_CLASS(klass) \
60   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TS_DEMUX))
61 #define GST_TS_DEMUX_GET_CLASS(obj) \
62   (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TS_DEMUX, GstTSDemuxClass))
63 #define GST_TS_DEMUX_CAST(obj) ((GstTSDemux*) obj)
64 typedef struct _GstTSDemux GstTSDemux;
65 typedef struct _GstTSDemuxClass GstTSDemuxClass;
66 
67 struct _GstTSDemux
68 {
69   MpegTSBase parent;
70 
71   gboolean have_group_id;
72   guint group_id;
73 
74   /* the following vars must be protected with the OBJECT_LOCK as they can be
75    * accessed from the application thread and the streaming thread */
76   gint requested_program_number; /* Required program number (ignore:-1) */
77   guint program_number;
78   gboolean emit_statistics;
79 
80   /*< private >*/
81   gint program_generation; /* Incremented each time we switch program 0..15 */
82   MpegTSBaseProgram *program;	/* Current program */
83   MpegTSBaseProgram *previous_program; /* Previous program, to deactivate once
84 					* the new program becomes active */
85 
86   /* segments to be sent */
87   GstSegment segment;
88   GstEvent *segment_event;
89   gboolean reset_segment;
90 
91   /* global taglist */
92   GstTagList *global_tags;
93 
94   /* Full stream duration */
95   GstClockTime duration;
96 
97   /* Pending seek rate (default 1.0) */
98   gdouble rate;
99 
100   GstFlowCombiner *flowcombiner;
101 
102   /* Used when seeking for a keyframe to go backward in the stream */
103   guint64 last_seek_offset;
104 };
105 
106 struct _GstTSDemuxClass
107 {
108   MpegTSBaseClass parent_class;
109 };
110 
111 G_GNUC_INTERNAL GType gst_ts_demux_get_type (void);
112 
113 G_GNUC_INTERNAL gboolean gst_ts_demux_plugin_init (GstPlugin * plugin);
114 
115 G_END_DECLS
116 #endif /* GST_TS_DEMUX_H */
117