Commit 22ecf13e authored by Janne Grunau's avatar Janne Grunau Committed by Edward Hervey

mpegtsdemux: add MPEG TS demuxer rewrite from Edward Hervey

with contributions from Miquel Angel Farre Guiu and Zaheer Abbas Merali
parent 2bb835f6
......@@ -320,6 +320,7 @@ AG_GST_CHECK_PLUGIN(legacyresample)
AG_GST_CHECK_PLUGIN(librfb)
AG_GST_CHECK_PLUGIN(liveadder)
AG_GST_CHECK_PLUGIN(mpegdemux)
AG_GST_CHECK_PLUGIN(mpegtsdemux)
AG_GST_CHECK_PLUGIN(mpegtsmux)
AG_GST_CHECK_PLUGIN(mpegpsmux)
AG_GST_CHECK_PLUGIN(mpeg4videoparse)
......@@ -1748,6 +1749,7 @@ gst/legacyresample/Makefile
gst/librfb/Makefile
gst/liveadder/Makefile
gst/mpegdemux/Makefile
gst/mpegtsdemux/Makefile
gst/mpegtsmux/Makefile
gst/mpegtsmux/tsmux/Makefile
gst/mpegpsmux/Makefile
......
......@@ -103,6 +103,7 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/gstreamer-%{majorminor}/libgstmpegtsmux.so
%{_libdir}/gstreamer-%{majorminor}/libgstscaletempoplugin.so
%{_libdir}/gstreamer-%{majorminor}/libgstmpegdemux.so
%{_libdir}/gstreamer-%{majorminor}/libgstmpegtsdemux.so
%{_libdir}/gstreamer-%{majorminor}/libgstjp2k.so
%{_libdir}/gstreamer-%{majorminor}/libgstapexsink.so
%{_libdir}/gstreamer-%{majorminor}/libgstqtmux.so
......
plugin_LTLIBRARIES = libgstmpegtsdemux.la
libgstmpegtsdemux_la_SOURCES = \
gsttsdemux.c \
gstmpegdesc.c \
mpegtsbase.c \
mpegtspacketizer.c \
mpegtsparse.c \
tsdemux.c
libgstmpegtsdemux_la_CFLAGS = \
$(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) $(GST_CFLAGS)
libgstmpegtsdemux_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) -lgsttag-$(GST_MAJORMINOR) \
$(GST_BASE_LIBS) $(GST_LIBS)
libgstmpegtsdemux_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstmpegtsdemux_la_LIBTOOLFLAGS = --tag=disable-static
noinst_HEADERS = \
gstmpegdefs.h \
gstmpegdesc.h \
mpegtsbase.h \
mpegtspacketizer.h \
mpegtsparse.c \
tsdemux.h
mpegtsparse rebasing
--------------------
Rationale :
-----------
mpegtsparse code is more sane to handle and work with.
We need a modular demuxer
We need to avoid duplicating code regarding mpeg-ts in a gazillion
elements and allow easy creatiof new elements.
Battleplan :
------------
* Figure out code from mpegtsparse which would be also needed for a
mpeg-ts demuxer (ex: packet/psi/pcr parsing).
* Extract common code into a base mpegtsbase class.
* Refactor mpegtsparse to subclass that base class.
* Create a minimalistic demuxer that creates pads (based on PSI info)
and outputs ES packets (let's say mpeg audio and video to start with)
Potential subclasses :
----------------------
* MpegTSParse : Program splitter. Given an incoming multi-program
mpeg-ts stream, it can provide request pads for each program. Each
of those pads will contain the ts packets specific to that program.
* TSDemux : Program demuxer. Given an incoming single or multi-program
mpeg-ts stream, it will reconstruct the original Program Streams of
the selected program and output them on dynamically created pads.
* HDVSplitter : Given an incoming HDV mpeg-ts stream, it will locate
the beginning of new scenes and output a mpeg-ts stream with the
PAT/PMT/AUX packets properly ordered and marked with DISCONT, so
that the following pipeline will automatically cut up a tape dump
into individual scenes:
filesrc ! hdvsplit ! multifilesink next-file=discont
Code/Design common to a program-spliter and a demuxer :
-------------------------------------------------------
* Parsing TS packets
* Establishing PAT/PMT mapping
* Handling the notions of Programs/Streams
* Seeking ?
One proposal... would be to have the base class automatically create
all the structures (and relationships) for the following objects:
* Programs (from PAT/PMT, dunno if it could come from something
else)
* Program id
* Streams contained in that program (with links to them)
* Which stream contains the PCR
* Metadata ?
* Streams (ideally... in a table for fast access)
* We want to be able to have stream-type specific information
easily accessible also (like mpeg video specific data)
* Maybe some other info ???
The subclasses would then be able to make their own decision based
on those objects.
Maybe we could have some virtual methods that will be called when a
new program is detected, a new stream is added, etc...
It is the subclass who decides what's to do with a given packet once
it's been parsed.
tsparse : forward it as-is to the pad corresponding to the program
tsdemux : forward it to the proper PS parser
hdvsplit : ?
Ideas to be taken into account for a proper demuxer :
-----------------------------------------------------
* Push-based (with inacurrate seeking)
* Pull-based (with fast *AND* accurate seeking)
* Modular system to add stream-type specific helper parsing
* Doesn't have to be fully fledged, just enough to help any kind of
seeking and scanning code.
* ...
Problems to figure out :
------------------------
* clock
Needed for proper dvb playback. mpegtsdemux currently does internal
clock estimation... to provide a clock with PCR estimations.
A proper way to solve that would be to timestamp the buffers at the
source element using the system clock, and then adjusting the PCR
against those values. (i.e. doing the opposite of what's done in
mpegtsdemux, but it will be more accurate since the timestamping is
done at the source).
Bugs that need fixing :
-----------------------
* Perfomance : Creation/Destruction of buffers is slow
* => This is due to g_type_instance_create using a dogslow rwlock
which take up to 50% of gst_adapter_take_buffer()
=> Bugzilla #585375 (performance and contention problems)
Code structure:
MpegTSBase
+--- MpegTSParse
+--- TSDemux
Known limitations and problems :
--------------------------------
* mpegtspacketizer
* Assumes 188 bytes packets. It should support all modes.
* offset/timestamp of incoming buffers need to be carried on to the
sub-buffers in order for several demuxer features to work correctly.
* mpegtsparser
* SERIOUS room for improvement performance-wise (see callgrind)
/*
* This library is licensed under 2 different licenses and you
* can choose to use it under the terms of either one of them. The
* two licenses are the MPL 1.1 and the LGPL.
*
* MPL:
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/.
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* LGPL:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* The Original Code is Fluendo MPEG Demuxer plugin.
*
* The Initial Developer of the Original Code is Fluendo, S.L.
* Portions created by Fluendo, S.L. are Copyright (C) 2005
* Fluendo, S.L. All Rights Reserved.
*
* Contributor(s): Wim Taymans <wim@fluendo.com>
*/
#ifndef __GST_MPEG_DEFS_H__
#define __GST_MPEG_DEFS_H__
/*
* 1011 1100 program_stream_map
* 1011 1101 private_stream_1
* 1011 1110 padding_stream
* 1011 1111 private_stream_2
* 110x xxxx ISO/IEC 13818-3 or ISO/IEC 11172-3 audio stream number x xxxx
* 1110 xxxx ITU-T Rec. H.262 | ISO/IEC 13818-2 or ISO/IEC 11172-2 video stream number xxxx
* 1111 0000 ECM_stream
* 1111 0001 EMM_stream
* 1111 0010 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A or ISO/IEC 13818-6_DSMCC_stream
* 1111 0011 ISO/IEC_13522_stream
* 1111 0100 ITU-T Rec. H.222.1 type A
* 1111 0101 ITU-T Rec. H.222.1 type B
* 1111 0110 ITU-T Rec. H.222.1 type C
* 1111 0111 ITU-T Rec. H.222.1 type D
* 1111 1000 ITU-T Rec. H.222.1 type E
* 1111 1001 ancillary_stream
* 1111 1010 E 1111 1110 reserved data stream
* 1111 1111 program_stream_directory
*/
#define ID_PS_END_CODE 0x000001B9
#define ID_PS_PACK_START_CODE 0x000001BA
#define ID_PS_SYSTEM_HEADER_START_CODE 0x000001BB
#define ID_PS_PROGRAM_STREAM_MAP 0x000001BC
#define ID_PRIVATE_STREAM_1 0x000001BD
#define ID_PADDING_STREAM 0x000001BE
#define ID_PRIVATE_STREAM_2 0x000001BF
#define ID_ISO_IEC_MPEG12_AUDIO_STREAM_0 0x000001C0
#define ID_ISO_IEC_MPEG12_AUDIO_STREAM_32 0x000001DF
#define ID_ISO_IEC_MPEG12_VIDEO_STREAM_0 0x000001E0
#define ID_ISO_IEC_MPEG12_VIDEO_STREAM_16 0x000001EF
#define ID_ECM_STREAM 0x000001F0
#define ID_EMM_STREAM 0x000001F1
#define ID_DSMCC_STREAM 0x000001F2
#define ID_ISO_IEC_13522_STREAM 0x000001F3
#define ID_ITU_TREC_H222_TYPE_A_STREAM 0x000001F4
#define ID_ITU_TREC_H222_TYPE_B_STREAM 0x000001F5
#define ID_ITU_TREC_H222_TYPE_C_STREAM 0x000001F6
#define ID_ITU_TREC_H222_TYPE_D_STREAM 0x000001F7
#define ID_ITU_TREC_H222_TYPE_E_STREAM 0x000001F8
#define ID_ANCILLARY_STREAM 0x000001F9
#define ID_RESERVED_STREAM_1 0x000001FA
#define ID_RESERVED_STREAM_2 0x000001FB
#define ID_EXTENDED_METADATA 0x000001FC
#define ID_EXTENDED_STREAM_ID 0x000001FD
#define ID_RESERVED_STREAM_3 0x000001FE
#define ID_PROGRAM_STREAM_DIRECTORY 0x000001FF
#define PACKET_VIDEO_START_CODE 0x000001E0
#define PACKET_AUDIO_START_CODE 0x000001C0
#define PICTURE_START_CODE 0x00000100
#define USER_DATA_START_CODE 0x000001B2
#define SEQUENCE_HEADER_CODE 0x000001B3
#define SEQUENCE_ERROR_CODE 0x000001B4
#define EXTENSION_START_CODE 0x000001B5
#define SEQUENCE_END_CODE 0x000001B7
#define GROUP_START_CODE 0x000001B8
#define AC3_SYNC_WORD 0x0b770000
#define MPEG_TS_SYNC_BYTE 0x00000047
#define PID_PROGRAM_ASSOCIATION_TABLE 0x0000
#define PID_CONDITIONAL_ACCESS_TABLE 0x0001
#define PID_RESERVED_FIRST 0x0002
#define PID_RESERVED_LAST 0x0010
#define PID_NULL_PACKET 0x1FFF
#define PID_TYPE_UNKNOWN 0
#define PID_TYPE_RESERVED 1
#define PID_TYPE_PROGRAM_ASSOCIATION 2
#define PID_TYPE_CONDITIONAL_ACCESS 3
#define PID_TYPE_PROGRAM_MAP 4
#define PID_TYPE_ELEMENTARY 5
#define PID_TYPE_NULL_PACKET 6
#define PID_TYPE_PRIVATE_SECTION 7
/* Stream type assignments
*
* 0x00 ITU-T | ISO/IEC Reserved
* 0x01 ISO/IEC 11172 Video
* 0x02 ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or
* ISO/IEC 11172-2 constrained parameter video
* stream
* 0x03 ISO/IEC 11172 Audio
* 0x04 ISO/IEC 13818-3 Audio
* 0x05 ITU-T Rec. H.222.0 | ISO/IEC 13818-1
* private_sections
* 0x06 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES
* packets containing private data
* 0x07 ISO/IEC 13522 MHEG
* 0x08 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A
* DSM CC
* 0x09 ITU-T Rec. H.222.1
* 0x0A ISO/IEC 13818-6 type A
* 0x0B ISO/IEC 13818-6 type B
* 0x0C ISO/IEC 13818-6 type C
* 0x0D ISO/IEC 13818-6 type D
* 0x0E ISO/IEC 13818-1 auxiliary
* 0x0F-0x7F ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved
* 0x80-0xFF User Private
*/
#define ST_RESERVED 0x00
#define ST_VIDEO_MPEG1 0x01
#define ST_VIDEO_MPEG2 0x02
#define ST_AUDIO_MPEG1 0x03
#define ST_AUDIO_MPEG2 0x04
#define ST_PRIVATE_SECTIONS 0x05
#define ST_PRIVATE_DATA 0x06
#define ST_MHEG 0x07
#define ST_DSMCC 0x08
#define ST_H222_1 0x09
/* later extensions */
#define ST_AUDIO_AAC 0x0f
#define ST_VIDEO_MPEG4 0x10
#define ST_VIDEO_H264 0x1b
/* Un-official Dirac extension */
#define ST_VIDEO_DIRAC 0xd1
/* private stream types */
#define ST_PS_AUDIO_AC3 0x81
#define ST_PS_AUDIO_DTS 0x8a
#define ST_PS_AUDIO_LPCM 0x8b
#define ST_PS_DVD_SUBPICTURE 0xff
/* Blu-ray related */
#define ST_BD_AUDIO_LPCM 0x80
#define ST_BD_AUDIO_AC3 0x81
#define ST_BD_AUDIO_DTS 0x82
#define ST_BD_AUDIO_AC3_TRUE_HD 0x83
#define ST_BD_AUDIO_AC3_PLUS 0x84
#define ST_BD_AUDIO_DTS_HD 0x85
#define ST_BD_AUDIO_DTS_HD_MASTER_AUDIO 0x86
#define ST_BD_AUDIO_EAC3 0x87
#define ST_BD_PGS_SUBPICTURE 0x90
#define ST_BD_IGS 0x91
#define ST_BD_SUBTITLE 0x92
#define ST_BD_SECONDARY_AC3_PLUS 0xa1
#define ST_BD_SECONDARY_DTS_HD 0xa2
/* defined for VC1 extension in RP227 */
#define ST_PRIVATE_EA 0xea
/* HDV AUX stream mapping
* 0xA0 ISO/IEC 61834-11
* 0xA1 ISO/IEC 61834-11
*/
#define ST_HDV_AUX_A 0xa0
#define ST_HDV_AUX_V 0xa1
/* Un-official time-code stream */
#define ST_PS_TIMECODE 0xd2
/* Internal stream types >= 0x100 */
#define ST_GST_AUDIO_RAWA52 0x181
/* Used when we don't yet know which stream type it will be in a PS stream */
#define ST_GST_VIDEO_MPEG1_OR_2 0x102
#define CLOCK_BASE 9LL
#define CLOCK_FREQ (CLOCK_BASE * 10000)
#define PCRTIME_TO_GSTTIME(time) (gst_util_uint64_scale ((time), \
GST_MSECOND/10, 300 * CLOCK_BASE))
#define MPEGTIME_TO_GSTTIME(time) (gst_util_uint64_scale ((time), \
GST_MSECOND/10, CLOCK_BASE))
#define GSTTIME_TO_MPEGTIME(time) (gst_util_uint64_scale ((time), \
CLOCK_BASE, GST_MSECOND/10))
#define MPEG_MUX_RATE_MULT 50
/* sync:4 == 00xx ! pts:3 ! 1 ! pts:15 ! 1 | pts:15 ! 1 */
#define READ_TS(data, target, lost_sync_label) \
if ((*data & 0x01) != 0x01) goto lost_sync_label; \
target = ((guint64) (*data++ & 0x0E)) << 29; \
target |= ((guint64) (*data++ )) << 22; \
if ((*data & 0x01) != 0x01) goto lost_sync_label; \
target |= ((guint64) (*data++ & 0xFE)) << 14; \
target |= ((guint64) (*data++ )) << 7; \
if ((*data & 0x01) != 0x01) goto lost_sync_label; \
target |= ((guint64) (*data++ & 0xFE)) >> 1;
/* some extra GstFlowReturn values used internally */
#define GST_FLOW_NEED_MORE_DATA GST_FLOW_CUSTOM_SUCCESS
#define GST_FLOW_LOST_SYNC GST_FLOW_CUSTOM_SUCCESS_1
#endif /* __GST_MPEG_DEFS_H__ */
/*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/.
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Fluendo MPEG Demuxer plugin.
*
* The Initial Developer of the Original Code is Fluendo, S.L.
* Portions created by Fluendo, S.L. are Copyright (C) 2005
* Fluendo, S.L. All Rights Reserved.
*
* Contributor(s): Wim Taymans <wim@fluendo.com>
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU Lesser General Public License Version 2 or later (the "LGPL"),
* in which case the provisions of the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of the MPL or the LGPL.
*/
#include <string.h>
#include <gst/gst.h>
#include "gstmpegdesc.h"
GST_DEBUG_CATEGORY (gstmpegtsdesc_debug);
#define GST_CAT_DEFAULT (gstmpegtsdesc_debug)
void
gst_mpeg_descriptor_free (GstMPEGDescriptor * desc)
{
g_return_if_fail (desc != NULL);
g_free (desc);
}
static guint
gst_mpeg_descriptor_parse_1 (guint8 * data, guint size)
{
guint8 tag;
guint8 length;
/* need at least 2 bytes for tag and length */
if (size < 2)
return 0;
tag = *data++;
length = *data++;
size -= 2;
GST_DEBUG ("tag: 0x%02x, length: %d", tag, length);
if (length > size)
return 0;
GST_MEMDUMP ("tag contents:", data, length);
return length + 2;
}
GstMPEGDescriptor *
gst_mpeg_descriptor_parse (guint8 * data, guint size)
{
guint8 *current;
guint consumed, total, n_desc;
GstMPEGDescriptor *result;
g_return_val_if_fail (data != NULL, NULL);
current = data;
total = 0;
n_desc = 0;
do {
consumed = gst_mpeg_descriptor_parse_1 (current, size);
if (consumed > 0) {
current += consumed;
total += consumed;
size -= consumed;
n_desc++;
}
}
while (consumed > 0);
GST_DEBUG ("parsed %d descriptors", n_desc);
if (total == 0)
return NULL;
result = g_malloc (sizeof (GstMPEGDescriptor) + total);
result->n_desc = n_desc;
result->data_length = total;
result->data = ((guint8 *) result) + sizeof (GstMPEGDescriptor);
memcpy (result->data, data, total);
return result;
}
guint
gst_mpeg_descriptor_n_desc (GstMPEGDescriptor * desc)
{
g_return_val_if_fail (desc != NULL, 0);
return desc->n_desc;
}
guint8 *
gst_mpeg_descriptor_find (GstMPEGDescriptor * desc, gint tag)
{
guint8 length;
guint8 *current;
guint size;
g_return_val_if_fail (desc != NULL, NULL);
current = desc->data;
length = desc->data_length;
while (length > 0) {
if (DESC_TAG (current) == tag)
return current;
size = DESC_LENGTH (current) + 2;
current += size;
length -= size;
}
return NULL;
}
/* array needs freeing afterwards */
GArray *
gst_mpeg_descriptor_find_all (GstMPEGDescriptor * desc, gint tag)
{
GArray *all;
guint8 length;
guint8 *current;
guint size;
g_return_val_if_fail (desc != NULL, NULL);
all = g_array_new (TRUE, TRUE, sizeof (guint8 *));
current = desc->data;
length = desc->data_length;
while (length > 0) {
if (DESC_TAG (current) == tag)
g_array_append_val (all, current);
size = DESC_LENGTH (current) + 2;
current += size;
length -= size;
}
GST_DEBUG ("found tag 0x%02x %d times", tag, all->len);
return all;
}
guint8 *
gst_mpeg_descriptor_nth (GstMPEGDescriptor * desc, guint i)
{
guint8 length;
guint8 *current;
guint size;
g_return_val_if_fail (desc != NULL, NULL);
if (i > desc->n_desc)
return NULL;
current = desc->data;
length = desc->data_length;
while (length > 0) {
if (i == 0)
return current;
size = DESC_LENGTH (current) + 2;
current += size;
length -= size;
i--;
}
return NULL;
}
void
gst_mpegtsdesc_init_debug (void)
{
GST_DEBUG_CATEGORY_INIT (gstmpegtsdesc_debug, "mpegtsdesc", 0,
"MPEG transport stream parser (descriptor)");
}
This diff is collapsed.
/*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "mpegtsbase.h"
#include "mpegtspacketizer.h"
#include "mpegtsparse.h"
#include "tsdemux.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_mpegtsbase_plugin_init (plugin))
return FALSE;
if (!gst_mpegtsparse_plugin_init (plugin))
return FALSE;
if (!gst_ts_demux_plugin_init (plugin))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"mpegtsdemux",
"MPEG TS demuxer",
plugin_init, VERSION,
GST_LICENSE_UNKNOWN, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
This diff is collapsed.
/*
* mpegtsbase.h - GStreamer MPEG transport stream base class
* Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
* 2007 Alessandro Decina
*
* Authors:
* Alessandro Decina <alessandro@nnva.org>
* Edward Hervey <edward.hervey@collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef GST_MPEG_TS_BASE_H
#define GST_MPEG_TS_BASE_H
#include <gst/gst.h>
#include "mpegtspacketizer.h"
G_BEGIN_DECLS
#define GST_TYPE_MPEGTS_BASE \
(mpegts_base_get_type())
#define GST_MPEGTS_BASE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MPEGTS_BASE,MpegTSBase))
#define GST_MPEGTS_BASE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MPEGTS_BASE,MpegTSBaseClass))
#define GST_IS_MPEGTS_BASE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MPEGTS_BASE))
#define GST_IS_MPEGTS_BASE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MPEGTS_BASE))
#define GST_MPEGTS_BASE_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_MPEGTS_BASE, MpegTSBaseClass))
typedef struct _MpegTSBase MpegTSBase;
typedef struct _MpegTSBaseClass MpegTSBaseClass;
typedef struct _MpegTSBaseStream MpegTSBaseStream;
typedef struct _MpegTSBaseProgram MpegTSBaseProgram;
struct _MpegTSBaseStream
{
guint16 pid;
guint8 stream_type;
GstStructure* stream_info;
};
struct _MpegTSBaseProgram
{
gint program_number;
guint16 pmt_pid;
guint16 pcr_pid;
GstStructure *pmt_info;
MpegTSBaseStream **streams;
gint patcount;
/* Pending Tags for the program */
GstTagList *tags;
guint event_id;
};
typedef enum {
BASE_MODE_SCANNING,
BASE_MODE_SEEKING,
BASE_MODE_STREAMING
} MpegTSBaseMode;
struct _MpegTSBase {
GstElement element;
GstPad *sinkpad;
/* pull-based behaviour */
MpegTSBaseMode mode;
/* location of first sync point */
guint64 initial_sync_point;
/* Current pull offset (also set by seek handler) */
guint64 seek_offset;