• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This library is licensed under 2 different licenses and you
3  * can choose to use it under the terms of either one of them. The
4  * two licenses are the MPL 1.1 and the LGPL.
5  *
6  * MPL:
7  *
8  * The contents of this file are subject to the Mozilla Public License
9  * Version 1.1 (the "License"); you may not use this file except in
10  * compliance with the License. You may obtain a copy of the License at
11  * http://www.mozilla.org/MPL/.
12  *
13  * Software distributed under the License is distributed on an "AS IS"
14  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
15  * License for the specific language governing rights and limitations
16  * under the License.
17  *
18  * LGPL:
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Library General Public
22  * License as published by the Free Software Foundation; either
23  * version 2 of the License, or (at your option) any later version.
24  *
25  * This library is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
28  * Library General Public License for more details.
29  *
30  * You should have received a copy of the GNU Library General Public
31  * License along with this library; if not, write to the
32  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
33  * Boston, MA 02110-1301, USA.
34  *
35  * The Original Code is Fluendo MPEG Demuxer plugin.
36  *
37  * The Initial Developer of the Original Code is Fluendo, S.L.
38  * Portions created by Fluendo, S.L. are Copyright (C) 2005
39  * Fluendo, S.L. All Rights Reserved.
40  *
41  * Contributor(s): Wim Taymans <wim@fluendo.com>
42  *                 Jan Schmidt <thaytan@noraisin.net>
43  */
44 
45 #ifndef __GST_PS_DEMUX_H__
46 #define __GST_PS_DEMUX_H__
47 
48 #include <gst/gst.h>
49 #include <gst/base/gstadapter.h>
50 #include <gst/base/gstflowcombiner.h>
51 
52 #include "gstpesfilter.h"
53 
54 G_BEGIN_DECLS
55 
56 #define GST_TYPE_PS_DEMUX		(gst_ps_demux_get_type())
57 #define GST_PS_DEMUX(obj)		(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PS_DEMUX,GstPsDemux))
58 #define GST_PS_DEMUX_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PS_DEMUX,GstPsDemuxClass))
59 #define GST_PS_DEMUX_GET_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS((klass),GST_TYPE_PS_DEMUX,GstPsDemuxClass))
60 #define GST_IS_PS_DEMUX(obj)		(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PS_DEMUX))
61 #define GST_IS_PS_DEMUX_CLASS(obj)	(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PS_DEMUX))
62 
63 typedef struct _GstPsStream GstPsStream;
64 typedef struct _GstPsDemux GstPsDemux;
65 typedef struct _GstPsDemuxClass GstPsDemuxClass;
66 
67 #define GST_PS_DEMUX_MAX_STREAMS	256
68 #define GST_PS_DEMUX_MAX_PSM		256
69 
70 #define MAX_DVD_AUDIO_STREAMS       8
71 #define MAX_DVD_SUBPICTURE_STREAMS  32
72 
73 typedef enum
74 {
75   GST_PS_DEMUX_SYNC_AUTO = 0,
76   GST_PS_DEMUX_SYNC_SCR = 1,
77   GST_PS_DEMUX_SYNC_DTS = 2
78 } GstPsDemuxSync;
79 
80 typedef enum
81 {
82   STATE_PS_DEMUX_NEED_SYNC,
83   STATE_PS_DEMUX_SYNCED,
84   STATE_PS_DEMUX_NEED_MORE_DATA,
85 } GstPsDemuxState;
86 
87 /* Information associated with a single FluPS stream. */
88 struct _GstPsStream
89 {
90   GstPad *pad;
91 
92   gint id;
93   gint type;
94 
95   GstClockTime segment_thresh;
96   GstClockTime last_ts;
97 
98   gboolean discont;
99   gboolean notlinked;
100   gboolean need_segment;
101 
102   GstTagList *pending_tags;
103 };
104 
105 struct _GstPsDemux
106 {
107   GstElement parent;
108 
109   GstPad *sinkpad;
110   gboolean random_access;       /* If we operate in pull mode */
111   gboolean flushing;
112 
113   gboolean have_group_id;
114   guint group_id;
115 
116   GstAdapter *adapter;
117   GstAdapter *rev_adapter;
118   guint64 adapter_offset;
119   guint32 last_sync_code;
120   GstPESFilter filter;
121 
122   gint64 mux_rate;
123   guint64 first_scr;
124   guint64 last_scr;
125   guint64 first_dts;
126   guint64 base_time;
127   guint64 current_scr;
128   guint64 next_scr;
129   guint64 bytes_since_scr;
130   gint64 scr_adjust;
131   guint64 scr_rate_n;
132   guint64 scr_rate_d;
133   guint64 first_scr_offset;
134   guint64 last_scr_offset;
135   guint64 cur_scr_offset;
136 
137   guint64 first_pts;
138   guint64 last_pts;
139 
140   gint16 psm[GST_PS_DEMUX_MAX_PSM];
141 
142   GstSegment sink_segment;
143   GstSegment src_segment;
144   guint32 segment_seqnum;
145 
146   /* stream output */
147   GstPsStream *current_stream;
148   guint64 next_pts;
149   guint64 next_dts;
150   GstPsStream **streams;
151   GstPsStream **streams_found;
152   gint found_count;
153   gboolean need_no_more_pads;
154 
155   GstFlowCombiner *flowcombiner;
156 
157   /* Indicates an MPEG-2 stream */
158   gboolean is_mpeg2_pack;
159 
160   /* properties */
161   gboolean ignore_scr;
162 };
163 
164 struct _GstPsDemuxClass
165 {
166   GstElementClass parent_class;
167 
168   GstPadTemplate *sink_template;
169   GstPadTemplate *video_template;
170   GstPadTemplate *audio_template;
171   GstPadTemplate *subpicture_template;
172   GstPadTemplate *private_template;
173 };
174 
175 GType gst_ps_demux_get_type (void);
176 GST_ELEMENT_REGISTER_DECLARE (mpegpsdemux);
177 
178 G_END_DECLS
179 #endif /* __GST_PS_DEMUX_H__ */
180