mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
Add Fluendo MPEG PS and TS demuxers to gst-plugins-bad. This is now dual licensed MPL and LGPL.
Original commit message from CVS: * configure.ac: * gst/mpegdemux/Makefile.am: * gst/mpegdemux/flumpegdemux.c: * gst/mpegdemux/flutspatinfo.c: * gst/mpegdemux/flutspatinfo.h: * gst/mpegdemux/flutspmtinfo.c: * gst/mpegdemux/flutspmtinfo.h: * gst/mpegdemux/flutspmtstreaminfo.c: * gst/mpegdemux/flutspmtstreaminfo.h: * gst/mpegdemux/gstmpegdefs.h: * gst/mpegdemux/gstmpegdemux.c: * gst/mpegdemux/gstmpegdemux.h: * gst/mpegdemux/gstmpegdesc.c: * gst/mpegdemux/gstmpegdesc.h: * gst/mpegdemux/gstmpegtsdemux.c: * gst/mpegdemux/gstmpegtsdemux.h: * gst/mpegdemux/gstpesfilter.c: * gst/mpegdemux/gstpesfilter.h: * gst/mpegdemux/gstsectionfilter.c: * gst/mpegdemux/gstsectionfilter.h: Add Fluendo MPEG PS and TS demuxers to gst-plugins-bad. This is now dual licensed MPL and LGPL.
This commit is contained in:
parent
0ce15bab49
commit
555486f865
21 changed files with 7428 additions and 0 deletions
25
ChangeLog
25
ChangeLog
|
@ -1,3 +1,28 @@
|
||||||
|
2008-09-02 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
||||||
|
|
||||||
|
* configure.ac:
|
||||||
|
* gst/mpegdemux/Makefile.am:
|
||||||
|
* gst/mpegdemux/flumpegdemux.c:
|
||||||
|
* gst/mpegdemux/flutspatinfo.c:
|
||||||
|
* gst/mpegdemux/flutspatinfo.h:
|
||||||
|
* gst/mpegdemux/flutspmtinfo.c:
|
||||||
|
* gst/mpegdemux/flutspmtinfo.h:
|
||||||
|
* gst/mpegdemux/flutspmtstreaminfo.c:
|
||||||
|
* gst/mpegdemux/flutspmtstreaminfo.h:
|
||||||
|
* gst/mpegdemux/gstmpegdefs.h:
|
||||||
|
* gst/mpegdemux/gstmpegdemux.c:
|
||||||
|
* gst/mpegdemux/gstmpegdemux.h:
|
||||||
|
* gst/mpegdemux/gstmpegdesc.c:
|
||||||
|
* gst/mpegdemux/gstmpegdesc.h:
|
||||||
|
* gst/mpegdemux/gstmpegtsdemux.c:
|
||||||
|
* gst/mpegdemux/gstmpegtsdemux.h:
|
||||||
|
* gst/mpegdemux/gstpesfilter.c:
|
||||||
|
* gst/mpegdemux/gstpesfilter.h:
|
||||||
|
* gst/mpegdemux/gstsectionfilter.c:
|
||||||
|
* gst/mpegdemux/gstsectionfilter.h:
|
||||||
|
Add Fluendo MPEG PS and TS demuxers to gst-plugins-bad. This
|
||||||
|
is now dual licensed MPL and LGPL.
|
||||||
|
|
||||||
2008-09-02 Wim Taymans <wim.taymans@collabora.co.uk>
|
2008-09-02 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
* gst/mpegtsmux/mpegtsmux.c: (new_packet_cb):
|
* gst/mpegtsmux/mpegtsmux.c: (new_packet_cb):
|
||||||
|
|
|
@ -256,6 +256,7 @@ AG_GST_CHECK_PLUGIN(freeze)
|
||||||
AG_GST_CHECK_PLUGIN(h264parse)
|
AG_GST_CHECK_PLUGIN(h264parse)
|
||||||
AG_GST_CHECK_PLUGIN(librfb)
|
AG_GST_CHECK_PLUGIN(librfb)
|
||||||
AG_GST_CHECK_PLUGIN(modplug)
|
AG_GST_CHECK_PLUGIN(modplug)
|
||||||
|
AG_GST_CHECK_PLUGIN(mpegdemux)
|
||||||
AG_GST_CHECK_PLUGIN(mpegtsparse)
|
AG_GST_CHECK_PLUGIN(mpegtsparse)
|
||||||
AG_GST_CHECK_PLUGIN(mpegtsmux)
|
AG_GST_CHECK_PLUGIN(mpegtsmux)
|
||||||
AG_GST_CHECK_PLUGIN(mpeg4videoparse)
|
AG_GST_CHECK_PLUGIN(mpeg4videoparse)
|
||||||
|
@ -1399,6 +1400,7 @@ gst/h264parse/Makefile
|
||||||
gst/librfb/Makefile
|
gst/librfb/Makefile
|
||||||
gst/modplug/Makefile
|
gst/modplug/Makefile
|
||||||
gst/modplug/libmodplug/Makefile
|
gst/modplug/libmodplug/Makefile
|
||||||
|
gst/mpegdemux/Makefile
|
||||||
gst/mpegtsparse/Makefile
|
gst/mpegtsparse/Makefile
|
||||||
gst/mpegtsmux/Makefile
|
gst/mpegtsmux/Makefile
|
||||||
gst/mpegtsmux/tsmux/Makefile
|
gst/mpegtsmux/tsmux/Makefile
|
||||||
|
|
28
gst/mpegdemux/Makefile.am
Normal file
28
gst/mpegdemux/Makefile.am
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
plugin_LTLIBRARIES = libgstmpegdemux.la
|
||||||
|
|
||||||
|
libgstmpegdemux_la_SOURCES = \
|
||||||
|
flumpegdemux.c \
|
||||||
|
flutspatinfo.c \
|
||||||
|
flutspmtinfo.c \
|
||||||
|
flutspmtstreaminfo.c \
|
||||||
|
gstmpegdemux.c \
|
||||||
|
gstmpegdesc.c \
|
||||||
|
gstmpegtsdemux.c \
|
||||||
|
gstpesfilter.c \
|
||||||
|
gstsectionfilter.c
|
||||||
|
|
||||||
|
libgstmpegdemux_la_CFLAGS = $(GST_CFLAGS) $(LIBOIL_CFLAGS)
|
||||||
|
libgstmpegdemux_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(LIBOIL_LIBS)
|
||||||
|
libgstmpegdemux_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||||
|
|
||||||
|
noinst_HEADERS = \
|
||||||
|
gstmpegdefs.h \
|
||||||
|
gstmpegdesc.h \
|
||||||
|
gstmpegdemux.h \
|
||||||
|
gstpesfilter.h \
|
||||||
|
gstmpegtsdemux.h \
|
||||||
|
flutspatinfo.h \
|
||||||
|
flutspmtinfo.h \
|
||||||
|
flutspmtstreaminfo.h \
|
||||||
|
gstsectionfilter.h
|
||||||
|
|
74
gst/mpegdemux/flumpegdemux.c
Normal file
74
gst/mpegdemux/flumpegdemux.c
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* 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>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "gstmpegdemux.h"
|
||||||
|
#include "gstmpegtsdemux.h"
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_EXTERN (gstflupesfilter_debug);
|
||||||
|
GST_DEBUG_CATEGORY_EXTERN (gstflusectionfilter_debug);
|
||||||
|
static gboolean
|
||||||
|
plugin_init (GstPlugin * plugin)
|
||||||
|
{
|
||||||
|
GST_DEBUG_CATEGORY_INIT (gstflupesfilter_debug, "flupesfilter", 0,
|
||||||
|
"MPEG-TS/PS PES filter output");
|
||||||
|
GST_DEBUG_CATEGORY_INIT (gstflusectionfilter_debug, "flusectionfilter", 0,
|
||||||
|
"MPEG-TS Section filter output");
|
||||||
|
|
||||||
|
if (!gst_flups_demux_plugin_init (plugin))
|
||||||
|
return FALSE;
|
||||||
|
if (!gst_fluts_demux_plugin_init (plugin))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||||
|
GST_VERSION_MINOR,
|
||||||
|
"flumpegdemux",
|
||||||
|
"MPEG demuxers",
|
||||||
|
plugin_init, VERSION,
|
||||||
|
GST_LICENSE_UNKNOWN, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
|
139
gst/mpegdemux/flutspatinfo.c
Normal file
139
gst/mpegdemux/flutspatinfo.c
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
/*
|
||||||
|
* 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): Jan Schmidt <jan@fluendo.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#include "flutspatinfo.h"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_PROGRAM_NO,
|
||||||
|
PROP_PID
|
||||||
|
};
|
||||||
|
|
||||||
|
static void fluts_pat_info_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * spec);
|
||||||
|
static void fluts_pat_info_get_property (GObject * object, guint prop_id,
|
||||||
|
GValue * value, GParamSpec * spec);
|
||||||
|
|
||||||
|
GST_BOILERPLATE (FluTsPatInfo, fluts_pat_info, GObject, G_TYPE_OBJECT);
|
||||||
|
|
||||||
|
FluTsPatInfo *
|
||||||
|
fluts_pat_info_new (guint16 program_no, guint16 pid)
|
||||||
|
{
|
||||||
|
FluTsPatInfo *info;
|
||||||
|
|
||||||
|
info = g_object_new (FLUTS_TYPE_PAT_INFO, NULL);
|
||||||
|
|
||||||
|
info->program_no = program_no;
|
||||||
|
info->pid = pid;
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pat_info_base_init (gpointer klass)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pat_info_class_init (FluTsPatInfoClass * klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_klass = (GObjectClass *) klass;
|
||||||
|
|
||||||
|
gobject_klass->set_property = fluts_pat_info_set_property;
|
||||||
|
gobject_klass->get_property = fluts_pat_info_get_property;
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_klass, PROP_PROGRAM_NO,
|
||||||
|
g_param_spec_uint ("program-number", "Program Number",
|
||||||
|
"Program Number for this program", 0, G_MAXUINT16, 1,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_klass, PROP_PID,
|
||||||
|
g_param_spec_uint ("pid", "PID carrying PMT",
|
||||||
|
"PID which carries the PMT for this program", 1, G_MAXUINT16, 1,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pat_info_init (FluTsPatInfo * pat_info, FluTsPatInfoClass * klass)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pat_info_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * spec)
|
||||||
|
{
|
||||||
|
g_return_if_fail (FLUTS_IS_PAT_INFO (object));
|
||||||
|
|
||||||
|
/* No settable properties */
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pat_info_get_property (GObject * object, guint prop_id,
|
||||||
|
GValue * value, GParamSpec * spec)
|
||||||
|
{
|
||||||
|
FluTsPatInfo *pat_info;
|
||||||
|
|
||||||
|
g_return_if_fail (FLUTS_IS_PAT_INFO (object));
|
||||||
|
|
||||||
|
pat_info = FLUTS_PAT_INFO (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_PROGRAM_NO:
|
||||||
|
g_value_set_uint (value, pat_info->program_no);
|
||||||
|
break;
|
||||||
|
case PROP_PID:
|
||||||
|
g_value_set_uint (value, pat_info->pid);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
72
gst/mpegdemux/flutspatinfo.h
Normal file
72
gst/mpegdemux/flutspatinfo.h
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* 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): Jan Schmidt <jan@fluendo.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __FLUTS_PAT_INFO_H__
|
||||||
|
#define __FLUTS_PAT_INFO_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef struct FluTsPatInfoClass {
|
||||||
|
GObjectClass parent_class;
|
||||||
|
} FluTsPatInfoClass;
|
||||||
|
|
||||||
|
typedef struct FluTsPatInfo {
|
||||||
|
GObject parent;
|
||||||
|
|
||||||
|
guint16 pid;
|
||||||
|
guint16 program_no;
|
||||||
|
} FluTsPatInfo;
|
||||||
|
|
||||||
|
#define FLUTS_TYPE_PAT_INFO (fluts_pat_info_get_type ())
|
||||||
|
#define FLUTS_IS_PAT_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), FLUTS_TYPE_PAT_INFO))
|
||||||
|
#define FLUTS_PAT_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),FLUTS_TYPE_PAT_INFO, FluTsPatInfo))
|
||||||
|
|
||||||
|
GType fluts_pat_info_get_type (void);
|
||||||
|
|
||||||
|
FluTsPatInfo *fluts_pat_info_new (guint16 program_no, guint16 pid);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif
|
218
gst/mpegdemux/flutspmtinfo.c
Normal file
218
gst/mpegdemux/flutspmtinfo.c
Normal file
|
@ -0,0 +1,218 @@
|
||||||
|
/*
|
||||||
|
* 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): Jan Schmidt <jan@fluendo.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#include "flutspmtinfo.h"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_PROGRAM_NO,
|
||||||
|
PROP_VERSION_NO,
|
||||||
|
PROP_PCR_PID,
|
||||||
|
PROP_DESCRIPTORS,
|
||||||
|
PROP_STREAMINFO
|
||||||
|
};
|
||||||
|
|
||||||
|
GST_BOILERPLATE (FluTsPmtInfo, fluts_pmt_info, GObject, G_TYPE_OBJECT);
|
||||||
|
|
||||||
|
static void fluts_pmt_info_finalize (GObject * object);
|
||||||
|
static void fluts_pmt_info_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * spec);
|
||||||
|
static void fluts_pmt_info_get_property (GObject * object, guint prop_id,
|
||||||
|
GValue * value, GParamSpec * spec);
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pmt_info_base_init (gpointer klass)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pmt_info_class_init (FluTsPmtInfoClass * klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_klass = (GObjectClass *) klass;
|
||||||
|
|
||||||
|
gobject_klass->finalize = fluts_pmt_info_finalize;
|
||||||
|
gobject_klass->set_property = fluts_pmt_info_set_property;
|
||||||
|
gobject_klass->get_property = fluts_pmt_info_get_property;
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_klass, PROP_PROGRAM_NO,
|
||||||
|
g_param_spec_uint ("program-number", "Program Number",
|
||||||
|
"Program Number for this program", 0, G_MAXUINT16, 1,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_klass, PROP_PCR_PID,
|
||||||
|
g_param_spec_uint ("pcr-pid", "PID carrying the PCR for this program",
|
||||||
|
"PID which carries the PCR for this program", 1, G_MAXUINT16, 1,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_klass, PROP_STREAMINFO,
|
||||||
|
g_param_spec_value_array ("stream-info",
|
||||||
|
"GValueArray containing GObjects with properties",
|
||||||
|
"Array of GObjects containing information about the program streams",
|
||||||
|
g_param_spec_object ("flu-pmt-streaminfo", "FluPMTStreamInfo",
|
||||||
|
"Fluendo TS Demuxer PMT Stream info object",
|
||||||
|
FLUTS_TYPE_PMT_STREAM_INFO, G_PARAM_READABLE), G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_klass, PROP_VERSION_NO,
|
||||||
|
g_param_spec_uint ("version-number", "Version Number",
|
||||||
|
"Version number of this program information", 0, G_MAXUINT8, 1,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_klass, PROP_DESCRIPTORS,
|
||||||
|
g_param_spec_value_array ("descriptors",
|
||||||
|
"Descriptors",
|
||||||
|
"Value array of strings containing program descriptors",
|
||||||
|
g_param_spec_boxed ("descriptor",
|
||||||
|
"descriptor",
|
||||||
|
"", G_TYPE_GSTRING, G_PARAM_READABLE), G_PARAM_READABLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pmt_info_init (FluTsPmtInfo * pmt_info, FluTsPmtInfoClass * klass)
|
||||||
|
{
|
||||||
|
pmt_info->streams = g_value_array_new (0);
|
||||||
|
pmt_info->descriptors = g_value_array_new (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
FluTsPmtInfo *
|
||||||
|
fluts_pmt_info_new (guint16 program_no, guint16 pcr_pid, guint8 version_no)
|
||||||
|
{
|
||||||
|
FluTsPmtInfo *info;
|
||||||
|
|
||||||
|
info = g_object_new (FLUTS_TYPE_PMT_INFO, NULL);
|
||||||
|
|
||||||
|
info->program_no = program_no;
|
||||||
|
info->pcr_pid = pcr_pid;
|
||||||
|
info->version_no = version_no;
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pmt_info_finalize (GObject * object)
|
||||||
|
{
|
||||||
|
FluTsPmtInfo *info = FLUTS_PMT_INFO (object);
|
||||||
|
|
||||||
|
g_value_array_free (info->streams);
|
||||||
|
g_value_array_free (info->descriptors);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pmt_info_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * spec)
|
||||||
|
{
|
||||||
|
g_return_if_fail (FLUTS_IS_PMT_INFO (object));
|
||||||
|
|
||||||
|
/* No settable properties */
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pmt_info_get_property (GObject * object, guint prop_id,
|
||||||
|
GValue * value, GParamSpec * spec)
|
||||||
|
{
|
||||||
|
FluTsPmtInfo *pmt_info;
|
||||||
|
|
||||||
|
g_return_if_fail (FLUTS_IS_PMT_INFO (object));
|
||||||
|
|
||||||
|
pmt_info = FLUTS_PMT_INFO (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_PROGRAM_NO:
|
||||||
|
g_value_set_uint (value, pmt_info->program_no);
|
||||||
|
break;
|
||||||
|
case PROP_PCR_PID:
|
||||||
|
g_value_set_uint (value, pmt_info->pcr_pid);
|
||||||
|
break;
|
||||||
|
case PROP_STREAMINFO:
|
||||||
|
g_value_set_boxed (value, pmt_info->streams);
|
||||||
|
break;
|
||||||
|
case PROP_VERSION_NO:
|
||||||
|
g_value_set_uint (value, pmt_info->version_no);
|
||||||
|
break;
|
||||||
|
case PROP_DESCRIPTORS:
|
||||||
|
g_value_set_boxed (value, pmt_info->descriptors);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fluts_pmt_info_add_descriptor (FluTsPmtInfo * pmt_info,
|
||||||
|
const gchar * descriptor, guint length)
|
||||||
|
{
|
||||||
|
GValue value = { 0 };
|
||||||
|
GString *string;
|
||||||
|
|
||||||
|
g_return_if_fail (FLUTS_IS_PMT_INFO (pmt_info));
|
||||||
|
|
||||||
|
string = g_string_new_len (descriptor, length);
|
||||||
|
|
||||||
|
g_value_init (&value, G_TYPE_GSTRING);
|
||||||
|
g_value_take_boxed (&value, string);
|
||||||
|
g_value_array_append (pmt_info->descriptors, &value);
|
||||||
|
g_value_unset (&value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fluts_pmt_info_add_stream (FluTsPmtInfo * pmt_info, FluTsPmtStreamInfo * stream)
|
||||||
|
{
|
||||||
|
GValue v = { 0, };
|
||||||
|
|
||||||
|
g_return_if_fail (FLUTS_IS_PMT_INFO (pmt_info));
|
||||||
|
g_return_if_fail (FLUTS_IS_PMT_STREAM_INFO (stream));
|
||||||
|
|
||||||
|
g_value_init (&v, G_TYPE_OBJECT);
|
||||||
|
g_value_take_object (&v, stream);
|
||||||
|
g_value_array_append (pmt_info->streams, &v);
|
||||||
|
}
|
81
gst/mpegdemux/flutspmtinfo.h
Normal file
81
gst/mpegdemux/flutspmtinfo.h
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
/*
|
||||||
|
* 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): Jan Schmidt <jan@fluendo.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __FLUTS_PMT_INFO_H__
|
||||||
|
#define __FLUTS_PMT_INFO_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include "flutspmtstreaminfo.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef struct FluTsPmtInfoClass {
|
||||||
|
GObjectClass parent_class;
|
||||||
|
} FluTsPmtInfoClass;
|
||||||
|
|
||||||
|
typedef struct FluTsPmtInfo {
|
||||||
|
GObject parent;
|
||||||
|
|
||||||
|
guint16 program_no;
|
||||||
|
guint16 pcr_pid;
|
||||||
|
|
||||||
|
guint8 version_no;
|
||||||
|
|
||||||
|
GValueArray *descriptors;
|
||||||
|
GValueArray *streams;
|
||||||
|
} FluTsPmtInfo;
|
||||||
|
|
||||||
|
FluTsPmtInfo *fluts_pmt_info_new (guint16 program_no, guint16 pcr_pid, guint8 version);
|
||||||
|
void fluts_pmt_info_add_stream (FluTsPmtInfo *pmt_info, FluTsPmtStreamInfo *stream);
|
||||||
|
void fluts_pmt_info_add_descriptor (FluTsPmtInfo *pmt_info,
|
||||||
|
const gchar *descriptor, guint length);
|
||||||
|
|
||||||
|
GType fluts_pmt_info_get_type (void);
|
||||||
|
|
||||||
|
#define FLUTS_TYPE_PMT_INFO (fluts_pmt_info_get_type ())
|
||||||
|
#define FLUTS_IS_PMT_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), FLUTS_TYPE_PMT_INFO))
|
||||||
|
#define FLUTS_PMT_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),FLUTS_TYPE_PMT_INFO, FluTsPmtInfo))
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif
|
203
gst/mpegdemux/flutspmtstreaminfo.c
Normal file
203
gst/mpegdemux/flutspmtstreaminfo.c
Normal file
|
@ -0,0 +1,203 @@
|
||||||
|
/*
|
||||||
|
* 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): Jan Schmidt <jan@fluendo.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#include "flutspmtstreaminfo.h"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_PID,
|
||||||
|
PROP_LANGUAGES,
|
||||||
|
PROP_STREAM_TYPE,
|
||||||
|
PROP_DESCRIPTORS,
|
||||||
|
};
|
||||||
|
|
||||||
|
GST_BOILERPLATE (FluTsPmtStreamInfo, fluts_pmt_stream_info, GObject,
|
||||||
|
G_TYPE_OBJECT);
|
||||||
|
|
||||||
|
static void fluts_pmt_stream_info_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * spec);
|
||||||
|
static void fluts_pmt_stream_info_get_property (GObject * object, guint prop_id,
|
||||||
|
GValue * value, GParamSpec * spec);
|
||||||
|
static void fluts_pmt_stream_info_finalize (GObject * object);
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pmt_stream_info_base_init (gpointer klass)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pmt_stream_info_class_init (FluTsPmtStreamInfoClass * klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_klass = (GObjectClass *) klass;
|
||||||
|
|
||||||
|
gobject_klass->set_property = fluts_pmt_stream_info_set_property;
|
||||||
|
gobject_klass->get_property = fluts_pmt_stream_info_get_property;
|
||||||
|
gobject_klass->finalize = fluts_pmt_stream_info_finalize;
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_klass, PROP_PID,
|
||||||
|
g_param_spec_uint ("pid", "PID carrying this stream",
|
||||||
|
"PID which carries this stream", 1, G_MAXUINT16, 1,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
g_object_class_install_property (gobject_klass, PROP_LANGUAGES,
|
||||||
|
g_param_spec_value_array ("languages", "Languages of this stream",
|
||||||
|
"Value array of the languages of this stream",
|
||||||
|
g_param_spec_string ("language", "language", "language", "",
|
||||||
|
G_PARAM_READABLE), G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_klass, PROP_STREAM_TYPE,
|
||||||
|
g_param_spec_uint ("stream-type",
|
||||||
|
"Stream type", "Stream type", 0, G_MAXUINT8, 0, G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_klass, PROP_DESCRIPTORS,
|
||||||
|
g_param_spec_value_array ("descriptors",
|
||||||
|
"Descriptors",
|
||||||
|
"Value array of strings containing stream descriptors",
|
||||||
|
g_param_spec_boxed ("descriptor",
|
||||||
|
"descriptor",
|
||||||
|
"", G_TYPE_GSTRING, G_PARAM_READABLE), G_PARAM_READABLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pmt_stream_info_init (FluTsPmtStreamInfo * pmt_stream_info,
|
||||||
|
FluTsPmtStreamInfoClass * klass)
|
||||||
|
{
|
||||||
|
pmt_stream_info->languages = g_value_array_new (0);
|
||||||
|
pmt_stream_info->descriptors = g_value_array_new (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pmt_stream_info_finalize (GObject * object)
|
||||||
|
{
|
||||||
|
FluTsPmtStreamInfo *info = FLUTS_PMT_STREAM_INFO (object);
|
||||||
|
|
||||||
|
g_value_array_free (info->languages);
|
||||||
|
g_value_array_free (info->descriptors);
|
||||||
|
}
|
||||||
|
|
||||||
|
FluTsPmtStreamInfo *
|
||||||
|
fluts_pmt_stream_info_new (guint16 pid, guint8 type)
|
||||||
|
{
|
||||||
|
FluTsPmtStreamInfo *info;
|
||||||
|
info = g_object_new (FLUTS_TYPE_PMT_STREAM_INFO, NULL);
|
||||||
|
|
||||||
|
info->pid = pid;
|
||||||
|
info->stream_type = type;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fluts_pmt_stream_info_add_language (FluTsPmtStreamInfo * pmt_info,
|
||||||
|
gchar * language)
|
||||||
|
{
|
||||||
|
GValue v = { 0, };
|
||||||
|
|
||||||
|
g_return_if_fail (FLUTS_IS_PMT_STREAM_INFO (pmt_info));
|
||||||
|
|
||||||
|
g_value_init (&v, G_TYPE_STRING);
|
||||||
|
g_value_take_string (&v, language);
|
||||||
|
g_value_array_append (pmt_info->languages, &v);
|
||||||
|
g_value_unset (&v);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fluts_pmt_stream_info_add_descriptor (FluTsPmtStreamInfo * pmt_info,
|
||||||
|
const gchar * descriptor, guint length)
|
||||||
|
{
|
||||||
|
GValue value = { 0 };
|
||||||
|
GString *string;
|
||||||
|
|
||||||
|
g_return_if_fail (FLUTS_IS_PMT_STREAM_INFO (pmt_info));
|
||||||
|
|
||||||
|
string = g_string_new_len (descriptor, length);
|
||||||
|
|
||||||
|
g_value_init (&value, G_TYPE_GSTRING);
|
||||||
|
g_value_take_boxed (&value, string);
|
||||||
|
g_value_array_append (pmt_info->descriptors, &value);
|
||||||
|
g_value_unset (&value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pmt_stream_info_set_property (GObject * object, guint prop_id,
|
||||||
|
const GValue * value, GParamSpec * spec)
|
||||||
|
{
|
||||||
|
g_return_if_fail (FLUTS_IS_PMT_STREAM_INFO (object));
|
||||||
|
|
||||||
|
/* No settable properties */
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fluts_pmt_stream_info_get_property (GObject * object, guint prop_id,
|
||||||
|
GValue * value, GParamSpec * spec)
|
||||||
|
{
|
||||||
|
FluTsPmtStreamInfo *si;
|
||||||
|
|
||||||
|
g_return_if_fail (FLUTS_IS_PMT_STREAM_INFO (object));
|
||||||
|
|
||||||
|
si = FLUTS_PMT_STREAM_INFO (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_STREAM_TYPE:
|
||||||
|
g_value_set_uint (value, si->stream_type);
|
||||||
|
break;
|
||||||
|
case PROP_PID:
|
||||||
|
g_value_set_uint (value, si->pid);
|
||||||
|
break;
|
||||||
|
case PROP_LANGUAGES:
|
||||||
|
g_value_set_boxed (value, si->languages);
|
||||||
|
break;
|
||||||
|
case PROP_DESCRIPTORS:
|
||||||
|
g_value_set_boxed (value, si->descriptors);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
80
gst/mpegdemux/flutspmtstreaminfo.h
Normal file
80
gst/mpegdemux/flutspmtstreaminfo.h
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
* 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): Jan Schmidt <jan@fluendo.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __FLUTS_PMT_STREAM_INFO_H__
|
||||||
|
#define __FLUTS_PMT_STREAM_INFO_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct FluTsPmtStreamInfoClass {
|
||||||
|
GObjectClass parent_class;
|
||||||
|
} FluTsPmtStreamInfoClass;
|
||||||
|
|
||||||
|
typedef struct FluTsPmtStreamInfo {
|
||||||
|
GObject parent;
|
||||||
|
|
||||||
|
guint16 pid;
|
||||||
|
GValueArray *languages; /* null terminated 3 character ISO639 language code */
|
||||||
|
guint8 stream_type;
|
||||||
|
GValueArray *descriptors;
|
||||||
|
} FluTsPmtStreamInfo;
|
||||||
|
|
||||||
|
FluTsPmtStreamInfo *fluts_pmt_stream_info_new (guint16 pid, guint8 type);
|
||||||
|
void fluts_pmt_stream_info_add_language(FluTsPmtStreamInfo* si,
|
||||||
|
gchar* language);
|
||||||
|
void fluts_pmt_stream_info_add_descriptor (FluTsPmtStreamInfo *pmt_info,
|
||||||
|
const gchar *descriptor, guint length);
|
||||||
|
|
||||||
|
GType fluts_pmt_stream_info_get_type (void);
|
||||||
|
|
||||||
|
#define FLUTS_TYPE_PMT_STREAM_INFO (fluts_pmt_stream_info_get_type ())
|
||||||
|
|
||||||
|
#define FLUTS_IS_PMT_STREAM_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), FLUTS_TYPE_PMT_STREAM_INFO))
|
||||||
|
#define FLUTS_PMT_STREAM_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),FLUTS_TYPE_PMT_STREAM_INFO, FluTsPmtStreamInfo))
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif
|
197
gst/mpegdemux/gstmpegdefs.h
Normal file
197
gst/mpegdemux/gstmpegdefs.h
Normal file
|
@ -0,0 +1,197 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
/* 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 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
|
||||||
|
|
||||||
|
/* some extra GstFlowReturn values used internally */
|
||||||
|
#define GST_FLOW_NEED_MORE_DATA -100
|
||||||
|
#define GST_FLOW_LOST_SYNC -101
|
||||||
|
|
||||||
|
#endif /* __GST_MPEG_DEFS_H__ */
|
1869
gst/mpegdemux/gstmpegdemux.c
Normal file
1869
gst/mpegdemux/gstmpegdemux.c
Normal file
File diff suppressed because it is too large
Load diff
152
gst/mpegdemux/gstmpegdemux.h
Normal file
152
gst/mpegdemux/gstmpegdemux.h
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
/*
|
||||||
|
* 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_FLUPS_DEMUX_H__
|
||||||
|
#define __GST_FLUPS_DEMUX_H__
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <gst/base/gstadapter.h>
|
||||||
|
|
||||||
|
#include "gstpesfilter.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GST_TYPE_FLUPS_DEMUX (gst_flups_demux_get_type())
|
||||||
|
#define GST_FLUPS_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FLUPS_DEMUX,GstFluPSDemux))
|
||||||
|
#define GST_FLUPS_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FLUPS_DEMUX,GstFluPSDemuxClass))
|
||||||
|
#define GST_FLUPS_DEMUX_GET_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS((klass),GST_TYPE_FLUPS_DEMUX,GstFluPSDemuxClass))
|
||||||
|
#define GST_IS_FLUPS_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FLUPS_DEMUX))
|
||||||
|
#define GST_IS_FLUPS_DEMUX_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FLUPS_DEMUX))
|
||||||
|
|
||||||
|
typedef struct _GstFluPSStream GstFluPSStream;
|
||||||
|
typedef struct _GstFluPSDemux GstFluPSDemux;
|
||||||
|
typedef struct _GstFluPSDemuxClass GstFluPSDemuxClass;
|
||||||
|
|
||||||
|
#define GST_FLUPS_DEMUX_MAX_STREAMS 256
|
||||||
|
#define GST_FLUPS_DEMUX_MAX_PSM 256
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GST_FLUPS_DEMUX_SYNC_AUTO = 0,
|
||||||
|
GST_FLUPS_DEMUX_SYNC_SCR = 1,
|
||||||
|
GST_FLUPS_DEMUX_SYNC_DTS = 2
|
||||||
|
} GstFluPSDemuxSync;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
STATE_FLUPS_DEMUX_NEED_SYNC,
|
||||||
|
STATE_FLUPS_DEMUX_SYNCED,
|
||||||
|
STATE_FLUPS_DEMUX_NEED_MORE_DATA,
|
||||||
|
} GstFluPSDemuxState;
|
||||||
|
|
||||||
|
/* Information associated with a single FluPS stream. */
|
||||||
|
struct _GstFluPSStream {
|
||||||
|
GstPad * pad;
|
||||||
|
|
||||||
|
gint id;
|
||||||
|
gint type;
|
||||||
|
gint size_bound;
|
||||||
|
|
||||||
|
gboolean discont;
|
||||||
|
gboolean notlinked;
|
||||||
|
gboolean need_segment;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstFluPSDemux {
|
||||||
|
GstElement parent;
|
||||||
|
|
||||||
|
GstPad * sinkpad;
|
||||||
|
|
||||||
|
GstAdapter * adapter;
|
||||||
|
GstAdapter * rev_adapter;
|
||||||
|
guint64 adapter_offset;
|
||||||
|
guint32 last_sync_code;
|
||||||
|
GstPESFilter filter;
|
||||||
|
|
||||||
|
gint64 mux_rate;
|
||||||
|
guint64 first_scr;
|
||||||
|
guint64 first_dts;
|
||||||
|
guint64 base_time;
|
||||||
|
guint64 current_scr;
|
||||||
|
guint64 next_scr;
|
||||||
|
guint64 bytes_since_scr;
|
||||||
|
gint64 scr_adjust;
|
||||||
|
guint64 scr_rate_n;
|
||||||
|
guint64 scr_rate_d;
|
||||||
|
guint64 first_scr_offset;
|
||||||
|
guint64 last_scr_offset;
|
||||||
|
|
||||||
|
gint16 psm[GST_FLUPS_DEMUX_MAX_PSM];
|
||||||
|
|
||||||
|
GstSegment sink_segment;
|
||||||
|
GstSegment src_segment;
|
||||||
|
|
||||||
|
/* stream output */
|
||||||
|
GstFluPSStream * current_stream;
|
||||||
|
guint64 next_pts;
|
||||||
|
guint64 next_dts;
|
||||||
|
GstFluPSStream ** streams;
|
||||||
|
gboolean need_no_more_pads;
|
||||||
|
|
||||||
|
/* Indicates an MPEG-2 stream */
|
||||||
|
gboolean is_mpeg2_pack;
|
||||||
|
|
||||||
|
/* Language codes event is stored when a dvd-lang-codes
|
||||||
|
* custom event arrives from upstream */
|
||||||
|
GstEvent * lang_codes;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstFluPSDemuxClass {
|
||||||
|
GstElementClass parent_class;
|
||||||
|
|
||||||
|
GstPadTemplate *sink_template;
|
||||||
|
GstPadTemplate *video_template;
|
||||||
|
GstPadTemplate *audio_template;
|
||||||
|
GstPadTemplate *private_template;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType gst_flups_demux_get_type (void);
|
||||||
|
|
||||||
|
gboolean gst_flups_demux_plugin_init (GstPlugin *plugin);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GST_FLUPS_DEMUX_H__ */
|
178
gst/mpegdemux/gstmpegdesc.c
Normal file
178
gst/mpegdemux/gstmpegdesc.c
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
/*
|
||||||
|
* 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>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#include "gstmpegdesc.h"
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
gint 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint8 *
|
||||||
|
gst_mpeg_descriptor_nth (GstMPEGDescriptor * desc, guint i)
|
||||||
|
{
|
||||||
|
gint 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;
|
||||||
|
}
|
271
gst/mpegdemux/gstmpegdesc.h
Normal file
271
gst/mpegdemux/gstmpegdesc.h
Normal file
|
@ -0,0 +1,271 @@
|
||||||
|
/*
|
||||||
|
* 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_DESC_H__
|
||||||
|
#define __GST_MPEG_DESC_H__
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
/*
|
||||||
|
* descriptor_tag TS PS Identification
|
||||||
|
* 0 n/a n/a Reserved
|
||||||
|
* 1 n/a n/a Reserved
|
||||||
|
* 2 X X video_stream_descriptor
|
||||||
|
* 3 X X audio_stream_descriptor
|
||||||
|
* 4 X X hierarchy_descriptor
|
||||||
|
* 5 X X registration_descriptor
|
||||||
|
* 6 X X data_stream_alignment_descriptor
|
||||||
|
* 7 X X target_background_grid_descriptor
|
||||||
|
* 8 X X video_window_descriptor
|
||||||
|
* 9 X X CA_descriptor
|
||||||
|
* 10 X X ISO_639_language_descriptor
|
||||||
|
* 11 X X system_clock_descriptor
|
||||||
|
* 12 X X multiplex_buffer_utilization_descriptor
|
||||||
|
* 13 X X copyright_descriptor
|
||||||
|
* 14 X maximum bitrate descriptor
|
||||||
|
* 15 X X private data indicator descriptor
|
||||||
|
* 16 X X smoothing buffer descriptor
|
||||||
|
* 17 X STD_descriptor
|
||||||
|
* 18 X X IBP descriptor
|
||||||
|
* 19-63 n/a n/a ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved
|
||||||
|
* 64-255 n/a n/a User Private
|
||||||
|
*/
|
||||||
|
#define DESC_VIDEO_STREAM 2
|
||||||
|
#define DESC_AUDIO_STREAM 3
|
||||||
|
#define DESC_HIERARCHY 4
|
||||||
|
#define DESC_REGISTRATION 5
|
||||||
|
#define DESC_DATA_STREAM_ALIGNMENT 6
|
||||||
|
#define DESC_TARGET_BACKGROUND_GRID 7
|
||||||
|
#define DESC_VIDEO_WINDOW 8
|
||||||
|
#define DESC_CA 9
|
||||||
|
#define DESC_ISO_639_LANGUAGE 10
|
||||||
|
#define DESC_SYSTEM_CLOCK 11
|
||||||
|
#define DESC_MULTIPLEX_BUFFER_UTILISATION 12
|
||||||
|
#define DESC_COPYRIGHT 13
|
||||||
|
#define DESC_MAXIMUM_BITRATE 14
|
||||||
|
#define DESC_PRIVATE_DATA_INDICATOR 15
|
||||||
|
#define DESC_SMOOTHING_BUFFER 16
|
||||||
|
#define DESC_STD 17
|
||||||
|
#define DESC_IBP 18
|
||||||
|
|
||||||
|
#define DESC_DIRAC_TC_PRIVATE 0xAC
|
||||||
|
|
||||||
|
/* DVB tags */
|
||||||
|
#define DESC_DVB_NETWORK_NAME 0x40
|
||||||
|
#define DESC_DVB_SERVICE_LIST 0x41
|
||||||
|
#define DESC_DVB_STUFFING 0x42
|
||||||
|
#define DESC_DVB_SATELLITE_DELIVERY_SYSTEM 0x43
|
||||||
|
#define DESC_DVB_CABLE_DELIVERY_SYSTEM 0x44
|
||||||
|
#define DESC_DVB_VBI_DATA 0x45
|
||||||
|
#define DESC_DVB_VBI_TELETEXT 0x46
|
||||||
|
#define DESC_DVB_BOUQUET_NAME 0x47
|
||||||
|
#define DESC_DVB_SERVICE 0x48
|
||||||
|
#define DESC_DVB_COUNTRY_AVAILABILITY 0x49
|
||||||
|
#define DESC_DVB_LINKAGE 0x4A
|
||||||
|
#define DESC_DVB_NVOD_REFERENCE 0x4B
|
||||||
|
#define DESC_DVB_TIME_SHIFTED_SERVICE 0x4C
|
||||||
|
#define DESC_DVB_SHORT_EVENT 0x4D
|
||||||
|
#define DESC_DVB_EXTENDED_EVENT 0x4E
|
||||||
|
#define DESC_DVB_TIME_SHIFTED_EVENT 0x4F
|
||||||
|
#define DESC_DVB_COMPONENT 0x50
|
||||||
|
#define DESC_DVB_MOSAIC 0x51
|
||||||
|
#define DESC_DVB_STREAM_IDENTIFIER 0x52
|
||||||
|
#define DESC_DVB_CA_IDENTIFIER 0x53
|
||||||
|
#define DESC_DVB_CONTENT 0x54
|
||||||
|
#define DESC_DVB_PARENTAL_RATING 0x55
|
||||||
|
#define DESC_DVB_TELETEXT 0x56
|
||||||
|
#define DESC_DVB_TELEPHONE 0x57
|
||||||
|
#define DESC_DVB_LOCAL_TIME_OFFSET 0x58
|
||||||
|
#define DESC_DVB_SUBTITLING 0x59
|
||||||
|
#define DESC_DVB_TERRESTRIAL_DELIVERY_SYSTEM 0x5A
|
||||||
|
#define DESC_DVB_MULTILINGUAL_NETWORK_NAME 0x5B
|
||||||
|
#define DESC_DVB_MULTILINGUAL_BOUQUET_NAME 0x5C
|
||||||
|
#define DESC_DVB_MULTILINGUAL_SERVICE_NAME 0x5D
|
||||||
|
#define DESC_DVB_MULTILINGUAL_COMPONENT 0x5E
|
||||||
|
#define DESC_DVB_PRIVATE_DATA 0x5F
|
||||||
|
#define DESC_DVB_SERVICE_MOVE 0x60
|
||||||
|
#define DESC_DVB_SHORT_SMOOTHING_BUFFER 0x61
|
||||||
|
#define DESC_DVB_FREQUENCY_LIST 0x62
|
||||||
|
#define DESC_DVB_PARTIAL_TRANSPORT_STREAM 0x63
|
||||||
|
#define DESC_DVB_DATA_BROADCAST 0x64
|
||||||
|
#define DESC_DVB_SCRAMBLING 0x65
|
||||||
|
#define DESC_DVB_DATA_BROADCAST_ID 0x66
|
||||||
|
#define DESC_DVB_TRANSPORT_STREAM 0x67
|
||||||
|
#define DESC_DVB_DSNG 0x68
|
||||||
|
#define DESC_DVB_PDC 0x69
|
||||||
|
#define DESC_DVB_AC3 0x6A
|
||||||
|
#define DESC_DVB_ANCILLARY_DATA 0x6B
|
||||||
|
#define DESC_DVB_CELL_LIST 0x6C
|
||||||
|
#define DESC_DVB_CELL_FREQUENCY_LINK 0x6D
|
||||||
|
#define DESC_DVB_ANNOUNCEMENT_SUPPORT 0x6E
|
||||||
|
#define DESC_DVB_APPLICATION_SIGNALLING 0x6F
|
||||||
|
#define DESC_DVB_ADAPTATION_FIELD_DATA 0x70
|
||||||
|
#define DESC_DVB_SERVICE_IDENTIFIER 0x71
|
||||||
|
#define DESC_DVB_SERVICE_AVAILABILITY 0x72
|
||||||
|
#define DESC_DVB_DEFAULT_AUTHORITY 0x73
|
||||||
|
#define DESC_DVB_RELATED_CONTENT 0x74
|
||||||
|
#define DESC_DVB_TVA_ID 0x75
|
||||||
|
#define DESC_DVB_CONTENT_IDENTIFIER 0x76
|
||||||
|
#define DESC_DVB_TIMESLICE_FEC_IDENTIFIER 0x77
|
||||||
|
#define DESC_DVB_ECM_REPETITION_RATE 0x78
|
||||||
|
#define DESC_DVB_S2_SATELLITE_DELIVERY_SYSTEM 0x79
|
||||||
|
#define DESC_DVB_ENHANCED_AC3 0x7A
|
||||||
|
#define DESC_DVB_DTS 0x7B
|
||||||
|
#define DESC_DVB_AAC 0x7C
|
||||||
|
/* 0x7D and 0x7E are reserved for future use */
|
||||||
|
#define DESC_DVB_EXTENSION 0x7F
|
||||||
|
/* 0x80 - 0xFE are user defined */
|
||||||
|
/* 0xFF is forbidden */
|
||||||
|
|
||||||
|
/* common for all descriptors */
|
||||||
|
#define DESC_TAG(desc) (desc[0])
|
||||||
|
#define DESC_LENGTH(desc) (desc[1])
|
||||||
|
|
||||||
|
/* video_stream_descriptor */
|
||||||
|
#define DESC_VIDEO_STREAM_multiple_framerate_flag(desc) (((desc)[2] & 0x80) == 0x80)
|
||||||
|
#define DESC_VIDEO_STREAM_frame_rate_code(desc) (((desc)[2] & 0x38) >> 3)
|
||||||
|
#define DESC_VIDEO_STREAM_MPEG_1_only_flag(desc) (((desc)[2] & 0x04) == 0x04)
|
||||||
|
#define DESC_VIDEO_STREAM_constrained_parameter_flag(desc) (((desc)[2] & 0x02) == 0x02)
|
||||||
|
#define DESC_VIDEO_STREAM_still_picture_flag(desc) (((desc)[2] & 0x01) == 0x01)
|
||||||
|
/* if (MPEG_1_only_flag == 1) */
|
||||||
|
#define DESC_VIDEO_STREAM_profile_and_level_indication(desc) ((desc)[3])
|
||||||
|
#define DESC_VIDEO_STREAM_chroma_format(desc) (((desc)[4] & 0xc0) >> 6)
|
||||||
|
#define DESC_VIDEO_STREAM_frame_rate_extension_flag(desc) (((desc)[4] & 0x20) == 0x20)
|
||||||
|
|
||||||
|
/* audio_stream_descriptor */
|
||||||
|
#define DESC_AUDIO_STREAM_free_format_flag(desc) (((desc)[2] & 0x80) == 0x80)
|
||||||
|
#define DESC_AUDIO_STREAM_ID(desc) (((desc)[2] & 0x40) == 0x40)
|
||||||
|
#define DESC_AUDIO_STREAM_layer(desc) (((desc)[2] & 0x30) >> 4)
|
||||||
|
#define DESC_AUDIO_STREAM_variable_rate_audio_indicator(desc) (((desc)[2] & 0x08) == 0x08)
|
||||||
|
|
||||||
|
/* hierarchy_descriptor */
|
||||||
|
#define DESC_HIERARCHY_hierarchy_type(desc) (((desc)[2] & 0x0f))
|
||||||
|
#define DESC_HIERARCHY_hierarchy_layer_index(desc) (((desc)[3] & 0x3f))
|
||||||
|
#define DESC_HIERARCHY_hierarchy_embedded_layer_index(desc) (((desc)[4] & 0x3f))
|
||||||
|
#define DESC_HIERARCHY_hierarchy_channel(desc) (((desc)[5] & 0x3f))
|
||||||
|
|
||||||
|
/* registration_descriptor */
|
||||||
|
#define DESC_REGISTRATION_format_identifier(desc) (GST_READ_UINT32_BE ((desc)+2))
|
||||||
|
#define DESC_REGISTRATION_additional_ident_info_len(desc) ((desc)[1] - 4)
|
||||||
|
#define DESC_REGISTRATION_additional_ident_info(desc) (&(desc)[6])
|
||||||
|
|
||||||
|
/* data_stream_alignment_descriptor */
|
||||||
|
#define DESC_DATA_STREAM_ALIGNMENT_alignment_type(desc) ((desc)[2])
|
||||||
|
|
||||||
|
/* target_background_grid_descriptor */
|
||||||
|
#define DESC_TARGET_BACKGROUND_GRID_horizontal_size(desc) (GST_READ_UINT16_BE ((desc)+2) >> 2)
|
||||||
|
#define DESC_TARGET_BACKGROUND_GRID_vertical_size(desc) ((GST_READ_UINT32_BE ((desc)+2) & 0x0003fff0) >> 4)
|
||||||
|
#define DESC_TARGET_BACKGROUND_GRID_aspect_ratio_information(desc) ((desc)[5] & 0x0f)
|
||||||
|
|
||||||
|
/* video_window_descriptor */
|
||||||
|
#define DESC_VIDEO_WINDOW_horizontal_offset(desc) (GST_READ_UINT16_BE ((desc)+2) >> 2)
|
||||||
|
#define DESC_VIDEO_WINDOW_vertical_offset(desc) ((GST_READ_UINT32_BE ((desc)+2) & 0x0003fff0) >> 4)
|
||||||
|
#define DESC_VIDEO_WINDOW_window_priority(desc) ((desc)[5] & 0x0f)
|
||||||
|
|
||||||
|
/* CA_descriptor */
|
||||||
|
#define DESC_CA_system_ID(desc) (GST_READ_UINT16_BE ((desc)+2))
|
||||||
|
#define DESC_CA_PID(desc) (GST_READ_UINT16_BE ((desc)+2) & 0x1fff)
|
||||||
|
|
||||||
|
/* ISO_639_language_descriptor */
|
||||||
|
#define DESC_ISO_639_LANGUAGE_codes_n(desc) ((desc[1]) >> 2)
|
||||||
|
#define DESC_ISO_639_LANGUAGE_language_code_nth(desc,i) (&(desc[2 + (4*i)]))
|
||||||
|
#define DESC_ISO_639_LANGUAGE_audio_type_nth(desc,i) ((desc)[5 + (4*i)])
|
||||||
|
|
||||||
|
/* system_clock_descriptor */
|
||||||
|
#define DESC_SYSTEM_CLOCK_external_clock_reference_indicator(desc) (((desc)[2] & 0x80) == 0x80)
|
||||||
|
#define DESC_SYSTEM_CLOCK_clock_accuracy_integer(desc) ((desc)[2] & 0x3f)
|
||||||
|
#define DESC_SYSTEM_CLOCK_clock_accuracy_exponent(desc) (((desc)[3] & 0xe0) >> 5)
|
||||||
|
|
||||||
|
/* multiplex_buffer_utilization_descriptor */
|
||||||
|
#define DESC_MULTIPLEX_BUFFER_UTILISATION_bound_valid_flag(desc) (((desc)[2] & 0x80) == 0x80)
|
||||||
|
#define DESC_MULTIPLEX_BUFFER_UTILISATION_LTW_offset_lower_bound(desc) (GST_READ_UINT16_BE ((desc)+2) & 0x7fff)
|
||||||
|
#define DESC_MULTIPLEX_BUFFER_UTILISATION_LTW_offset_upper_bound(desc) (GST_READ_UINT16_BE ((desc)+4) & 0x7fff)
|
||||||
|
|
||||||
|
/* copyright_descriptor */
|
||||||
|
#define DESC_COPYRIGHT_copyright_identifier(desc) (GST_READ_UINT32_BE ((desc)+2))
|
||||||
|
#define DESC_COPYRIGHT_additional_copyright_info_len(desc) ((desc)[1] - 4)
|
||||||
|
#define DESC_COPYRIGHT_additional_copyright_info(desc) (&(desc)[6])
|
||||||
|
|
||||||
|
/* maximum_bitrate_descriptor */
|
||||||
|
#define DESC_MAXIMUM_BITRAT_maximum_bitrate(desc) (((((guint32)desc[2]) & 0x3f) << 16) | \
|
||||||
|
GST_READ_UINT16_BE ((desc)+3))
|
||||||
|
|
||||||
|
/* private_data_indicator_descriptor */
|
||||||
|
#define DESC_PRIVATE_DATA_INDICATOR_indicator(desc) (GST_READ_UINT32_BE(&desc[2]))
|
||||||
|
|
||||||
|
/* smoothing_buffer_descriptor */
|
||||||
|
#define DESC_SMOOTHING_BUFFER_sb_leak_rate(desc) (((((guint32)desc[2]) & 0x3f) << 16) | \
|
||||||
|
GST_READ_UINT16_BE ((desc)+3))
|
||||||
|
#define DESC_SMOOTHING_BUFFER_sb_size(desc) (((((guint32)desc[5]) & 0x3f) << 16) | \
|
||||||
|
GST_READ_UINT16_BE ((desc)+6))
|
||||||
|
/* STD_descriptor */
|
||||||
|
#define DESC_STD_leak_valid_flag(desc) (((desc)[2] & 0x01) == 0x01)
|
||||||
|
|
||||||
|
/* ibp_descriptor */
|
||||||
|
#define DESC_IBP_closed_gop_flag(desc) (((desc)[2] & 0x80) == 0x80)
|
||||||
|
#define DESC_IBP_identical_gop_flag(desc) (((desc)[2] & 0x40) == 0x40)
|
||||||
|
#define DESC_IBP_max_gop_length(desc) (GST_READ_UINT16_BE ((desc)+6) & 0x3fff)
|
||||||
|
|
||||||
|
/* time_code descriptor */
|
||||||
|
#define DESC_TIMECODE_video_pid(desc) (GST_READ_UINT16_BE ((desc) + 2) & 0x1fff)
|
||||||
|
|
||||||
|
/* Stream identifier descriptor */
|
||||||
|
#define DESC_DVB_STREAM_IDENTIFIER_component_tag(desc) (desc[2])
|
||||||
|
|
||||||
|
/* DVB Network Name descriptor */
|
||||||
|
#define DESC_DVB_NETWORK_NAME_length(desc) (GST_READ_UINT8((desc)+1))
|
||||||
|
#define DESC_DVB_NETWORK_NAME_text(desc) (desc+2)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
guint n_desc;
|
||||||
|
guint8 data_length;
|
||||||
|
guint8 *data;
|
||||||
|
} GstMPEGDescriptor;
|
||||||
|
|
||||||
|
GstMPEGDescriptor* gst_mpeg_descriptor_parse (guint8 *data, guint size);
|
||||||
|
void gst_mpeg_descriptor_free (GstMPEGDescriptor *desc);
|
||||||
|
|
||||||
|
guint gst_mpeg_descriptor_n_desc (GstMPEGDescriptor *desc);
|
||||||
|
guint8* gst_mpeg_descriptor_find (GstMPEGDescriptor *desc, gint tag);
|
||||||
|
guint8* gst_mpeg_descriptor_nth (GstMPEGDescriptor *desc, guint i);
|
||||||
|
|
||||||
|
#endif /* __GST_MPEG_DESC_H__ */
|
2630
gst/mpegdemux/gstmpegtsdemux.c
Normal file
2630
gst/mpegdemux/gstmpegtsdemux.c
Normal file
File diff suppressed because it is too large
Load diff
224
gst/mpegdemux/gstmpegtsdemux.h
Normal file
224
gst/mpegdemux/gstmpegtsdemux.h
Normal file
|
@ -0,0 +1,224 @@
|
||||||
|
/*
|
||||||
|
* 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_FLUTS_DEMUX_H__
|
||||||
|
#define __GST_FLUTS_DEMUX_H__
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <gst/base/gstadapter.h>
|
||||||
|
|
||||||
|
#include "gstmpegdesc.h"
|
||||||
|
#include "gstpesfilter.h"
|
||||||
|
#include "gstsectionfilter.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#if (POST_10_12)
|
||||||
|
#define HAVE_LATENCY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define FLUTS_MAX_PID 0x1fff
|
||||||
|
#define FLUTS_NORMAL_TS_PACKETSIZE 188
|
||||||
|
#define FLUTS_M2TS_TS_PACKETSIZE 192
|
||||||
|
|
||||||
|
#define LENGHT_SYNC_LUT 256
|
||||||
|
|
||||||
|
#define IS_MPEGTS_SYNC(data) (((data)[0] == 0x47) && \
|
||||||
|
(((data)[1] & 0x80) == 0x00) && \
|
||||||
|
(((data)[3] & 0x10) == 0x10))
|
||||||
|
|
||||||
|
#define GST_TYPE_FLUTS_DEMUX (gst_fluts_demux_get_type())
|
||||||
|
#define GST_FLUTS_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
|
||||||
|
GST_TYPE_FLUTS_DEMUX,GstFluTSDemux))
|
||||||
|
#define GST_FLUTS_DEMUX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\
|
||||||
|
GST_TYPE_FLUTS_DEMUX,GstFluTSDemuxClass))
|
||||||
|
#define GST_FLUTS_DEMUX_GET_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS((klass),\
|
||||||
|
GST_TYPE_FLUTS_DEMUX,GstFluTSDemuxClass))
|
||||||
|
#define GST_IS_FLUTS_DEMUX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
|
||||||
|
GST_TYPE_FLUTS_DEMUX))
|
||||||
|
#define GST_IS_FLUTS_DEMUX_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),\
|
||||||
|
GST_TYPE_FLUTS_DEMUX))
|
||||||
|
|
||||||
|
typedef struct _GstFluTSStream GstFluTSStream;
|
||||||
|
typedef struct _GstFluTSPMTEntry GstFluTSPMTEntry;
|
||||||
|
typedef struct _GstFluTSPMT GstFluTSPMT;
|
||||||
|
typedef struct _GstFluTSPATEntry GstFluTSPATEntry;
|
||||||
|
typedef struct _GstFluTSPAT GstFluTSPAT;
|
||||||
|
typedef struct _GstFluTSDemux GstFluTSDemux;
|
||||||
|
typedef struct _GstFluTSDemuxClass GstFluTSDemuxClass;
|
||||||
|
|
||||||
|
struct _GstFluTSPMTEntry {
|
||||||
|
guint16 PID;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstFluTSPMT {
|
||||||
|
guint16 program_number;
|
||||||
|
guint8 version_number;
|
||||||
|
gboolean current_next_indicator;
|
||||||
|
guint8 section_number;
|
||||||
|
guint8 last_section_number;
|
||||||
|
guint16 PCR_PID;
|
||||||
|
guint16 program_info_length;
|
||||||
|
GstMPEGDescriptor * program_info;
|
||||||
|
|
||||||
|
GArray * entries;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstFluTSPATEntry {
|
||||||
|
guint16 program_number;
|
||||||
|
guint16 PID;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstFluTSPAT {
|
||||||
|
guint16 transport_stream_id;
|
||||||
|
guint8 version_number;
|
||||||
|
gboolean current_next_indicator;
|
||||||
|
guint8 section_number;
|
||||||
|
guint8 last_section_number;
|
||||||
|
|
||||||
|
GArray * entries;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum _FluTsStreamFlags {
|
||||||
|
FLUTS_STREAM_FLAG_STREAM_TYPE_UNKNOWN = 0x01,
|
||||||
|
FLUTS_STREAM_FLAG_PMT_VALID = 0x02,
|
||||||
|
FLUTS_STREAM_FLAG_IS_VIDEO = 0x04
|
||||||
|
} FluTsStreamFlags;
|
||||||
|
|
||||||
|
/* Information associated to a single MPEG stream. */
|
||||||
|
struct _GstFluTSStream {
|
||||||
|
GstFluTSDemux * demux;
|
||||||
|
|
||||||
|
FluTsStreamFlags flags;
|
||||||
|
|
||||||
|
/* PID and type */
|
||||||
|
guint16 PID;
|
||||||
|
guint8 PID_type;
|
||||||
|
|
||||||
|
/* adaptation_field data */
|
||||||
|
guint64 last_PCR;
|
||||||
|
guint64 base_PCR;
|
||||||
|
guint64 last_OPCR;
|
||||||
|
guint64 last_PCR_difference;
|
||||||
|
gboolean discont_PCR;
|
||||||
|
GstClockTimeDiff discont_difference;
|
||||||
|
|
||||||
|
/* for PAT streams */
|
||||||
|
GstFluTSPAT PAT;
|
||||||
|
|
||||||
|
/* for PMT streams */
|
||||||
|
GstFluTSPMT PMT;
|
||||||
|
|
||||||
|
/* for CA streams */
|
||||||
|
|
||||||
|
/* for PAT, PMT, CA and private streams */
|
||||||
|
GstSectionFilter section_filter;
|
||||||
|
|
||||||
|
/* for PES streams */
|
||||||
|
guint8 id;
|
||||||
|
guint8 stream_type;
|
||||||
|
GstPESFilter filter;
|
||||||
|
GstPad * pad;
|
||||||
|
GstFlowReturn last_ret;
|
||||||
|
GstMPEGDescriptor *ES_info;
|
||||||
|
/* needed because 33bit mpeg timestamps wrap around every (approx) 26.5 hrs */
|
||||||
|
GstClockTimeDiff base_time;
|
||||||
|
GstClockTime last_time;
|
||||||
|
/* pid of PMT that this stream belongs to */
|
||||||
|
guint16 PMT_pid;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstFluTSDemux {
|
||||||
|
GstElement parent;
|
||||||
|
|
||||||
|
/* properties */
|
||||||
|
gboolean check_crc;
|
||||||
|
|
||||||
|
/* sink pad and adapter */
|
||||||
|
GstPad * sinkpad;
|
||||||
|
GstAdapter * adapter;
|
||||||
|
guint8 ** sync_lut;
|
||||||
|
|
||||||
|
/* current PMT PID */
|
||||||
|
guint16 current_PMT;
|
||||||
|
|
||||||
|
/* Array of FLUTS_MAX_PID + 1 stream entries */
|
||||||
|
GstFluTSStream ** streams;
|
||||||
|
/* Array to perform pmts checks at gst_fluts_demux_parse_adaptation_field */
|
||||||
|
gboolean pmts_checked[FLUTS_MAX_PID + 1];
|
||||||
|
|
||||||
|
/* Array of Elementary Stream pids for ts with PMT */
|
||||||
|
guint16 * elementary_pids;
|
||||||
|
guint nb_elementary_pids;
|
||||||
|
|
||||||
|
/* Program number to use */
|
||||||
|
gint program_number;
|
||||||
|
|
||||||
|
/* indicates that we need to close our pad group, because we've added
|
||||||
|
* at least one pad */
|
||||||
|
gboolean need_no_more_pads;
|
||||||
|
guint16 packetsize;
|
||||||
|
gboolean m2ts_mode;
|
||||||
|
#ifdef HAVE_LATENCY
|
||||||
|
/* clocking */
|
||||||
|
GstClock * clock;
|
||||||
|
GstClockTime clock_base;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstFluTSDemuxClass {
|
||||||
|
GstElementClass parent_class;
|
||||||
|
|
||||||
|
GstPadTemplate * sink_template;
|
||||||
|
GstPadTemplate * video_template;
|
||||||
|
GstPadTemplate * audio_template;
|
||||||
|
GstPadTemplate * private_template;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType gst_fluts_demux_get_type (void);
|
||||||
|
|
||||||
|
gboolean gst_fluts_demux_plugin_init (GstPlugin *plugin);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GST_FLUTS_DEMUX_H__ */
|
645
gst/mpegdemux/gstpesfilter.c
Normal file
645
gst/mpegdemux/gstpesfilter.c
Normal file
|
@ -0,0 +1,645 @@
|
||||||
|
/*
|
||||||
|
* 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>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "gstmpegdefs.h"
|
||||||
|
#include "gstpesfilter.h"
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY (gstflupesfilter_debug);
|
||||||
|
#define GST_CAT_DEFAULT (gstflupesfilter_debug)
|
||||||
|
|
||||||
|
static GstFlowReturn gst_pes_filter_data_push (GstPESFilter * filter,
|
||||||
|
gboolean first, GstBuffer * buffer);
|
||||||
|
|
||||||
|
#define ADAPTER_OFFSET_FLUSH(_bytes_) if (filter->adapter_offset) *filter->adapter_offset = *filter->adapter_offset + (_bytes_)
|
||||||
|
|
||||||
|
/* May pass null for adapter to have the filter create one */
|
||||||
|
void
|
||||||
|
gst_pes_filter_init (GstPESFilter * filter, GstAdapter * adapter,
|
||||||
|
guint64 * adapter_offset)
|
||||||
|
{
|
||||||
|
g_return_if_fail (filter != NULL);
|
||||||
|
|
||||||
|
if (adapter != NULL)
|
||||||
|
g_object_ref (adapter);
|
||||||
|
else
|
||||||
|
adapter = gst_adapter_new ();
|
||||||
|
|
||||||
|
filter->adapter = adapter;
|
||||||
|
filter->adapter_offset = adapter_offset;
|
||||||
|
filter->state = STATE_HEADER_PARSE;
|
||||||
|
filter->gather_pes = FALSE;
|
||||||
|
filter->allow_unbounded = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_pes_filter_uninit (GstPESFilter * filter)
|
||||||
|
{
|
||||||
|
g_return_if_fail (filter != NULL);
|
||||||
|
|
||||||
|
if (filter->adapter)
|
||||||
|
g_object_unref (filter->adapter);
|
||||||
|
filter->adapter = NULL;
|
||||||
|
filter->adapter_offset = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_pes_filter_set_callbacks (GstPESFilter * filter,
|
||||||
|
GstPESFilterData data_cb, GstPESFilterResync resync_cb, gpointer user_data)
|
||||||
|
{
|
||||||
|
g_return_if_fail (filter != NULL);
|
||||||
|
|
||||||
|
filter->data_cb = data_cb;
|
||||||
|
filter->resync_cb = resync_cb;
|
||||||
|
filter->user_data = user_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_pes_filter_is_sync (guint32 sync)
|
||||||
|
{
|
||||||
|
return ((sync & 0xfffffffc) == 0x000001bc) ||
|
||||||
|
((sync & 0xffffffe0) == 0x000001c0) ||
|
||||||
|
((sync & 0xfffffff0) == 0x000001f0) ||
|
||||||
|
((sync & 0xfffffff0) == 0x000001e0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstFlowReturn
|
||||||
|
gst_pes_filter_parse (GstPESFilter * filter)
|
||||||
|
{
|
||||||
|
GstFlowReturn ret;
|
||||||
|
guint32 start_code;
|
||||||
|
|
||||||
|
gboolean STD_buffer_bound_scale;
|
||||||
|
guint16 STD_buffer_size_bound;
|
||||||
|
const guint8 *data;
|
||||||
|
gint avail, datalen;
|
||||||
|
gboolean have_size = FALSE;
|
||||||
|
|
||||||
|
/* read start code and length */
|
||||||
|
if (!(data = gst_adapter_peek (filter->adapter, 6)))
|
||||||
|
goto need_more_data;
|
||||||
|
|
||||||
|
/* get start code */
|
||||||
|
start_code = GST_READ_UINT32_BE (data);
|
||||||
|
if (!gst_pes_filter_is_sync (start_code))
|
||||||
|
goto lost_sync;
|
||||||
|
|
||||||
|
filter->start_code = start_code;
|
||||||
|
filter->id = data[3];
|
||||||
|
|
||||||
|
/* skip start code */
|
||||||
|
data += 4;
|
||||||
|
|
||||||
|
/* start parsing length */
|
||||||
|
filter->length = GST_READ_UINT16_BE (data);
|
||||||
|
|
||||||
|
/* see how much is available */
|
||||||
|
avail = gst_adapter_available (filter->adapter);
|
||||||
|
|
||||||
|
GST_DEBUG ("id 0x%02x length %d, avail %d start code 0x%02x", filter->id,
|
||||||
|
filter->length, avail, filter->start_code);
|
||||||
|
|
||||||
|
/* A data length of 0 indicates an unbounded packet in transport
|
||||||
|
* streams, but actually a 0 sized packet in program streams or
|
||||||
|
* for anything except video packets */
|
||||||
|
|
||||||
|
/* FIXME: Remove this hack that is checking start_code. Instead, we need
|
||||||
|
* a callback that a start_code has been collected, giving the caller a chance
|
||||||
|
* to set the allow_unbounded flag if they want */
|
||||||
|
if (filter->length == 0 &&
|
||||||
|
((filter->start_code & 0xFFFFFFF0) == PACKET_VIDEO_START_CODE ||
|
||||||
|
filter->allow_unbounded)) {
|
||||||
|
GST_DEBUG ("id 0x%02x, unbounded length", filter->id);
|
||||||
|
filter->unbounded_packet = TRUE;
|
||||||
|
} else {
|
||||||
|
filter->unbounded_packet = FALSE;
|
||||||
|
|
||||||
|
if (filter->gather_pes && avail < filter->length + 6) {
|
||||||
|
GST_DEBUG ("id 0x%02x, bounded length %d, only have %d",
|
||||||
|
filter->id, filter->length + 6, avail);
|
||||||
|
goto need_more_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if we need more data from now on, we lost sync */
|
||||||
|
avail = MIN (avail, filter->length + 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read more data, either the whole packet if there is a length
|
||||||
|
* or whatever we have available if this in an unbounded packet. */
|
||||||
|
if (!(data = gst_adapter_peek (filter->adapter, avail)))
|
||||||
|
goto need_more_data;
|
||||||
|
|
||||||
|
/* This will make us flag LOST_SYNC if we run out of data from here onward */
|
||||||
|
have_size = TRUE;
|
||||||
|
|
||||||
|
/* skip start code and length */
|
||||||
|
data += 6;
|
||||||
|
datalen = avail - 6;
|
||||||
|
|
||||||
|
GST_DEBUG ("datalen %d", datalen);
|
||||||
|
|
||||||
|
switch (filter->start_code) {
|
||||||
|
case ID_PS_PROGRAM_STREAM_MAP:
|
||||||
|
case ID_PRIVATE_STREAM_2:
|
||||||
|
case ID_ECM_STREAM:
|
||||||
|
case ID_EMM_STREAM:
|
||||||
|
case ID_PROGRAM_STREAM_DIRECTORY:
|
||||||
|
case ID_DSMCC_STREAM:
|
||||||
|
case ID_ITU_TREC_H222_TYPE_E_STREAM:
|
||||||
|
goto skip;
|
||||||
|
case ID_PADDING_STREAM:
|
||||||
|
GST_DEBUG ("skipping padding stream");
|
||||||
|
goto skip;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (datalen < 1)
|
||||||
|
goto need_more_data;
|
||||||
|
|
||||||
|
filter->pts = filter->dts = -1;
|
||||||
|
|
||||||
|
/* stuffing bits, first two bits are '10' for mpeg2 pes so this code is
|
||||||
|
* not triggered. */
|
||||||
|
while (TRUE) {
|
||||||
|
if (*data != 0xff)
|
||||||
|
break;
|
||||||
|
|
||||||
|
data++;
|
||||||
|
datalen--;
|
||||||
|
|
||||||
|
GST_DEBUG ("got stuffing bit");
|
||||||
|
|
||||||
|
if (datalen < 1)
|
||||||
|
goto need_more_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* STD buffer size, never for mpeg2 */
|
||||||
|
if ((*data & 0xc0) == 0x40) {
|
||||||
|
GST_DEBUG ("have STD");
|
||||||
|
|
||||||
|
if (datalen < 3)
|
||||||
|
goto need_more_data;
|
||||||
|
|
||||||
|
STD_buffer_bound_scale = *data & 0x20;
|
||||||
|
STD_buffer_size_bound = ((guint16) (*data++ & 0x1F)) << 8;
|
||||||
|
STD_buffer_size_bound |= *data++;
|
||||||
|
|
||||||
|
datalen -= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* PTS but no DTS, never for mpeg2 */
|
||||||
|
if ((*data & 0xf0) == 0x20) {
|
||||||
|
GST_DEBUG ("PTS without DTS");
|
||||||
|
|
||||||
|
if (datalen < 5)
|
||||||
|
goto need_more_data;
|
||||||
|
READ_TS (data, filter->pts, lost_sync);
|
||||||
|
GST_DEBUG ("PTS found %" G_GUINT64_FORMAT, filter->pts);
|
||||||
|
datalen -= 5;
|
||||||
|
}
|
||||||
|
/* PTS and DTS, never for mpeg2 */
|
||||||
|
else if ((*data & 0xf0) == 0x30) {
|
||||||
|
GST_DEBUG ("PTS and DTS");
|
||||||
|
|
||||||
|
if (datalen < 10)
|
||||||
|
goto need_more_data;
|
||||||
|
READ_TS (data, filter->pts, lost_sync);
|
||||||
|
READ_TS (data, filter->dts, lost_sync);
|
||||||
|
GST_DEBUG ("PTS found %" G_GUINT64_FORMAT, filter->pts);
|
||||||
|
GST_DEBUG ("DTS found %" G_GUINT64_FORMAT, filter->dts);
|
||||||
|
datalen -= 10;
|
||||||
|
} else if ((*data & 0xc0) == 0x80) {
|
||||||
|
/* mpeg2 case */
|
||||||
|
guchar flags;
|
||||||
|
guint8 header_data_length = 0;
|
||||||
|
|
||||||
|
GST_DEBUG ("MPEG2 PES packet");
|
||||||
|
|
||||||
|
if (datalen < 3)
|
||||||
|
goto need_more_data;
|
||||||
|
/* 2: '10'
|
||||||
|
* 2: PES_scrambling_control
|
||||||
|
* 1: PES_priority
|
||||||
|
* 1: data_alignment_indicator
|
||||||
|
* 1: copyright
|
||||||
|
* 1: original_or_copy
|
||||||
|
*/
|
||||||
|
flags = *data++;
|
||||||
|
|
||||||
|
GST_DEBUG ("flags: 0x%02x", flags);
|
||||||
|
if ((flags & 0xc0) != 0x80)
|
||||||
|
goto lost_sync;
|
||||||
|
|
||||||
|
/* check PES scrambling control */
|
||||||
|
if ((flags & 0x30) != 0)
|
||||||
|
goto encrypted;
|
||||||
|
|
||||||
|
/* 2: PTS_DTS_flags
|
||||||
|
* 1: ESCR_flag
|
||||||
|
* 1: ES_rate_flag
|
||||||
|
* 1: DSM_trick_mode_flag
|
||||||
|
* 1: additional_copy_info_flag
|
||||||
|
* 1: PES_CRC_flag
|
||||||
|
* 1: PES_extension_flag
|
||||||
|
*/
|
||||||
|
flags = *data++;
|
||||||
|
|
||||||
|
/* 8: PES_header_data_length */
|
||||||
|
header_data_length = *data++;
|
||||||
|
datalen -= 3;
|
||||||
|
|
||||||
|
GST_DEBUG ("header_data_length: %d, flags 0x%02x",
|
||||||
|
header_data_length, flags);
|
||||||
|
|
||||||
|
if (header_data_length > datalen)
|
||||||
|
goto need_more_data;
|
||||||
|
|
||||||
|
/* only DTS: this is invalid */
|
||||||
|
if ((flags & 0xc0) == 0x40)
|
||||||
|
goto lost_sync;
|
||||||
|
|
||||||
|
/* check for PTS */
|
||||||
|
if ((flags & 0x80)) {
|
||||||
|
if (datalen < 5)
|
||||||
|
goto need_more_data;
|
||||||
|
|
||||||
|
READ_TS (data, filter->pts, lost_sync);
|
||||||
|
GST_DEBUG ("PTS found %" G_GUINT64_FORMAT, filter->pts);
|
||||||
|
header_data_length -= 5;
|
||||||
|
datalen -= 5;
|
||||||
|
}
|
||||||
|
/* check for DTS */
|
||||||
|
if ((flags & 0x40)) {
|
||||||
|
READ_TS (data, filter->dts, lost_sync);
|
||||||
|
if (datalen < 5)
|
||||||
|
goto need_more_data;
|
||||||
|
GST_DEBUG ("DTS found %" G_GUINT64_FORMAT, filter->dts);
|
||||||
|
header_data_length -= 5;
|
||||||
|
datalen -= 5;
|
||||||
|
}
|
||||||
|
/* ESCR_flag */
|
||||||
|
if ((flags & 0x20)) {
|
||||||
|
GST_DEBUG ("%x ESCR found", filter->id);
|
||||||
|
if (datalen < 6)
|
||||||
|
goto need_more_data;
|
||||||
|
data += 6;
|
||||||
|
header_data_length -= 6;
|
||||||
|
datalen -= 6;
|
||||||
|
}
|
||||||
|
/* ES_rate_flag */
|
||||||
|
if ((flags & 0x10)) {
|
||||||
|
guint32 es_rate;
|
||||||
|
|
||||||
|
if (datalen < 3)
|
||||||
|
goto need_more_data;
|
||||||
|
|
||||||
|
es_rate = ((guint32) (*data++ & 0x07)) << 14;
|
||||||
|
es_rate |= ((guint32) (*data++)) << 7;
|
||||||
|
es_rate |= ((guint32) (*data++ & 0xFE)) >> 1;
|
||||||
|
GST_DEBUG ("%x ES Rate found %u", filter->id, es_rate);
|
||||||
|
header_data_length -= 3;
|
||||||
|
datalen -= 3;
|
||||||
|
}
|
||||||
|
/* DSM_trick_mode_flag */
|
||||||
|
if ((flags & 0x08)) {
|
||||||
|
guint8 trick_mode_flags;
|
||||||
|
|
||||||
|
if (datalen < 1)
|
||||||
|
goto need_more_data;
|
||||||
|
|
||||||
|
/* 3: trick_mode_control */
|
||||||
|
trick_mode_flags = *data++;
|
||||||
|
GST_DEBUG ("%x DSM trick mode found, flags 0x%02x", filter->id,
|
||||||
|
trick_mode_flags);
|
||||||
|
|
||||||
|
/* fast_forward */
|
||||||
|
if ((trick_mode_flags & 0xe0) == 0x00) {
|
||||||
|
}
|
||||||
|
/* slow motion */
|
||||||
|
else if ((trick_mode_flags & 0xe0) == 0x20) {
|
||||||
|
}
|
||||||
|
/* freeze frame */
|
||||||
|
else if ((trick_mode_flags & 0xe0) == 0x40) {
|
||||||
|
}
|
||||||
|
/* fast reverse */
|
||||||
|
else if ((trick_mode_flags & 0xe0) == 0x60) {
|
||||||
|
}
|
||||||
|
/* slow reverse */
|
||||||
|
else if ((trick_mode_flags & 0xe0) == 0x80) {
|
||||||
|
}
|
||||||
|
/* reserved */
|
||||||
|
else {
|
||||||
|
}
|
||||||
|
|
||||||
|
header_data_length -= 1;
|
||||||
|
datalen -= 1;
|
||||||
|
}
|
||||||
|
/* additional_copy_info_flag */
|
||||||
|
if ((flags & 0x04)) {
|
||||||
|
GST_DEBUG ("%x additional copy info, flags 0x%02x", filter->id, *data);
|
||||||
|
}
|
||||||
|
/* PES_CRC_flag */
|
||||||
|
if ((flags & 0x02)) {
|
||||||
|
GST_DEBUG ("%x PES_CRC", filter->id);
|
||||||
|
}
|
||||||
|
/* PES_extension_flag */
|
||||||
|
if ((flags & 0x01)) {
|
||||||
|
GST_DEBUG ("%x PES_extension", filter->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate the amount of real data in this PES packet */
|
||||||
|
data += header_data_length;
|
||||||
|
datalen -= header_data_length;
|
||||||
|
} else if (*data == 0x0f) {
|
||||||
|
/* Not sure what this clause is for */
|
||||||
|
data++;
|
||||||
|
datalen--;
|
||||||
|
} else {
|
||||||
|
/* Data byte wasn't recognised as a flags byte */
|
||||||
|
GST_DEBUG ("Unrecognised flags byte 0x%02x\n", *data);
|
||||||
|
goto lost_sync;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
GstBuffer *out;
|
||||||
|
guint16 consumed;
|
||||||
|
|
||||||
|
consumed = avail - 6 - datalen;
|
||||||
|
|
||||||
|
if (filter->unbounded_packet == FALSE) {
|
||||||
|
filter->length -= avail - 6;
|
||||||
|
GST_DEBUG ("pushing %d, need %d more, consumed %d",
|
||||||
|
datalen, filter->length, consumed);
|
||||||
|
} else {
|
||||||
|
GST_DEBUG ("pushing %d, unbounded packet, consumed %d",
|
||||||
|
datalen, consumed);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (datalen > 0) {
|
||||||
|
out = gst_buffer_new ();
|
||||||
|
GST_BUFFER_DATA (out) = g_memdup (data, datalen);
|
||||||
|
GST_BUFFER_SIZE (out) = datalen;
|
||||||
|
GST_BUFFER_MALLOCDATA (out) = GST_BUFFER_DATA (out);
|
||||||
|
|
||||||
|
ret = gst_pes_filter_data_push (filter, TRUE, out);
|
||||||
|
filter->first = FALSE;
|
||||||
|
} else {
|
||||||
|
GST_LOG ("first being set to TRUE");
|
||||||
|
filter->first = TRUE;
|
||||||
|
ret = GST_FLOW_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter->length > 0 || filter->unbounded_packet)
|
||||||
|
filter->state = STATE_DATA_PUSH;
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_adapter_flush (filter->adapter, avail);
|
||||||
|
ADAPTER_OFFSET_FLUSH (avail);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
need_more_data:
|
||||||
|
{
|
||||||
|
if (filter->unbounded_packet == FALSE) {
|
||||||
|
if (have_size == TRUE) {
|
||||||
|
GST_DEBUG ("bounded need more data %d, lost sync",
|
||||||
|
gst_adapter_available (filter->adapter));
|
||||||
|
ret = GST_FLOW_LOST_SYNC;
|
||||||
|
} else {
|
||||||
|
GST_DEBUG ("bounded need more data %d, breaking for more",
|
||||||
|
gst_adapter_available (filter->adapter));
|
||||||
|
ret = GST_FLOW_NEED_MORE_DATA;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
GST_DEBUG ("unbounded need more data %d",
|
||||||
|
gst_adapter_available (filter->adapter));
|
||||||
|
ret = GST_FLOW_NEED_MORE_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
skip:
|
||||||
|
{
|
||||||
|
GST_DEBUG ("skipping 0x%02x", filter->id);
|
||||||
|
gst_adapter_flush (filter->adapter, avail);
|
||||||
|
ADAPTER_OFFSET_FLUSH (avail);
|
||||||
|
|
||||||
|
filter->length -= avail - 6;
|
||||||
|
if (filter->length > 0 || filter->unbounded_packet)
|
||||||
|
filter->state = STATE_DATA_SKIP;
|
||||||
|
return GST_FLOW_OK;
|
||||||
|
}
|
||||||
|
encrypted:
|
||||||
|
{
|
||||||
|
GST_DEBUG ("skipping encrypted 0x%02x", filter->id);
|
||||||
|
gst_adapter_flush (filter->adapter, avail);
|
||||||
|
ADAPTER_OFFSET_FLUSH (avail);
|
||||||
|
|
||||||
|
filter->length -= avail - 6;
|
||||||
|
if (filter->length > 0 || filter->unbounded_packet)
|
||||||
|
filter->state = STATE_DATA_SKIP;
|
||||||
|
return GST_FLOW_OK;
|
||||||
|
}
|
||||||
|
lost_sync:
|
||||||
|
{
|
||||||
|
GST_DEBUG ("lost sync");
|
||||||
|
gst_adapter_flush (filter->adapter, 4);
|
||||||
|
ADAPTER_OFFSET_FLUSH (4);
|
||||||
|
|
||||||
|
return GST_FLOW_LOST_SYNC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstFlowReturn
|
||||||
|
gst_pes_filter_data_push (GstPESFilter * filter, gboolean first,
|
||||||
|
GstBuffer * buffer)
|
||||||
|
{
|
||||||
|
GstFlowReturn ret;
|
||||||
|
|
||||||
|
GST_LOG ("pushing, first: %d", first);
|
||||||
|
|
||||||
|
if (filter->data_cb) {
|
||||||
|
ret = filter->data_cb (filter, first, buffer, filter->user_data);
|
||||||
|
} else {
|
||||||
|
gst_buffer_unref (buffer);
|
||||||
|
ret = GST_FLOW_OK;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
GstFlowReturn
|
||||||
|
gst_pes_filter_push (GstPESFilter * filter, GstBuffer * buffer)
|
||||||
|
{
|
||||||
|
GstFlowReturn ret;
|
||||||
|
|
||||||
|
g_return_val_if_fail (filter != NULL, GST_FLOW_ERROR);
|
||||||
|
g_return_val_if_fail (buffer != NULL, GST_FLOW_ERROR);
|
||||||
|
|
||||||
|
switch (filter->state) {
|
||||||
|
case STATE_HEADER_PARSE:
|
||||||
|
gst_adapter_push (filter->adapter, buffer);
|
||||||
|
ret = gst_pes_filter_parse (filter);
|
||||||
|
break;
|
||||||
|
case STATE_DATA_PUSH:
|
||||||
|
ret = gst_pes_filter_data_push (filter, filter->first, buffer);
|
||||||
|
filter->first = FALSE;
|
||||||
|
break;
|
||||||
|
case STATE_DATA_SKIP:
|
||||||
|
gst_buffer_unref (buffer);
|
||||||
|
ret = GST_FLOW_OK;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goto wrong_state;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
/* ERROR */
|
||||||
|
wrong_state:
|
||||||
|
{
|
||||||
|
GST_DEBUG ("wrong internal state %d", filter->state);
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GstFlowReturn
|
||||||
|
gst_pes_filter_process (GstPESFilter * filter)
|
||||||
|
{
|
||||||
|
GstFlowReturn ret;
|
||||||
|
gboolean skip = FALSE;
|
||||||
|
|
||||||
|
g_return_val_if_fail (filter != NULL, GST_FLOW_ERROR);
|
||||||
|
|
||||||
|
switch (filter->state) {
|
||||||
|
case STATE_HEADER_PARSE:
|
||||||
|
ret = gst_pes_filter_parse (filter);
|
||||||
|
break;
|
||||||
|
case STATE_DATA_SKIP:
|
||||||
|
skip = TRUE;
|
||||||
|
/* fallthrough */
|
||||||
|
case STATE_DATA_PUSH:
|
||||||
|
if (filter->length > 0 || filter->unbounded_packet) {
|
||||||
|
gint avail;
|
||||||
|
|
||||||
|
avail = gst_adapter_available (filter->adapter);
|
||||||
|
if (filter->unbounded_packet == FALSE)
|
||||||
|
avail = MIN (avail, filter->length);
|
||||||
|
|
||||||
|
if (skip) {
|
||||||
|
gst_adapter_flush (filter->adapter, avail);
|
||||||
|
ADAPTER_OFFSET_FLUSH (avail);
|
||||||
|
ret = GST_FLOW_OK;
|
||||||
|
} else {
|
||||||
|
GstBuffer *out;
|
||||||
|
guint8 *data;
|
||||||
|
|
||||||
|
data = gst_adapter_take (filter->adapter, avail);
|
||||||
|
|
||||||
|
out = gst_buffer_new ();
|
||||||
|
GST_BUFFER_DATA (out) = data;
|
||||||
|
GST_BUFFER_SIZE (out) = avail;
|
||||||
|
GST_BUFFER_MALLOCDATA (out) = data;
|
||||||
|
|
||||||
|
ret = gst_pes_filter_data_push (filter, filter->first, out);
|
||||||
|
filter->first = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter->unbounded_packet == FALSE) {
|
||||||
|
filter->length -= avail;
|
||||||
|
if (filter->length == 0)
|
||||||
|
filter->state = STATE_HEADER_PARSE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
filter->state = STATE_HEADER_PARSE;
|
||||||
|
ret = GST_FLOW_OK;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goto wrong_state;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
/* ERROR */
|
||||||
|
wrong_state:
|
||||||
|
{
|
||||||
|
GST_DEBUG ("wrong internal state %d", filter->state);
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_pes_filter_flush (GstPESFilter * filter)
|
||||||
|
{
|
||||||
|
g_return_if_fail (filter != NULL);
|
||||||
|
|
||||||
|
if (filter->adapter) {
|
||||||
|
gst_adapter_clear (filter->adapter);
|
||||||
|
if (filter->adapter_offset)
|
||||||
|
*filter->adapter_offset = G_MAXUINT64;
|
||||||
|
}
|
||||||
|
filter->state = STATE_HEADER_PARSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GstFlowReturn
|
||||||
|
gst_pes_filter_drain (GstPESFilter * filter)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (filter != NULL, GST_FLOW_ERROR);
|
||||||
|
|
||||||
|
gst_pes_filter_flush (filter);
|
||||||
|
|
||||||
|
return GST_FLOW_OK;
|
||||||
|
}
|
110
gst/mpegdemux/gstpesfilter.h
Normal file
110
gst/mpegdemux/gstpesfilter.h
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
* 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_PES_FILTER_H__
|
||||||
|
#define __GST_PES_FILTER_H__
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <gst/base/gstadapter.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef struct _GstPESFilter GstPESFilter;
|
||||||
|
|
||||||
|
typedef GstFlowReturn (*GstPESFilterData) (GstPESFilter * filter, gboolean first, GstBuffer * buffer,
|
||||||
|
gpointer user_data);
|
||||||
|
typedef void (*GstPESFilterResync) (GstPESFilter * filter, gpointer user_data);
|
||||||
|
typedef void (*GstPESFilterIndex) (GstPESFilter * filter, gpointer user_data);
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
STATE_HEADER_PARSE,
|
||||||
|
STATE_DATA_PUSH,
|
||||||
|
STATE_DATA_SKIP
|
||||||
|
} GstPESFilterState;
|
||||||
|
|
||||||
|
struct _GstPESFilter {
|
||||||
|
GstAdapter * adapter;
|
||||||
|
guint64 * adapter_offset;
|
||||||
|
|
||||||
|
GstPESFilterState state;
|
||||||
|
/* Whether to collect entire PES packets before
|
||||||
|
* outputting */
|
||||||
|
gboolean gather_pes;
|
||||||
|
/* Whether unbounded packets are allowed in this
|
||||||
|
* stream */
|
||||||
|
gboolean allow_unbounded;
|
||||||
|
|
||||||
|
gboolean first;
|
||||||
|
GstPESFilterData data_cb;
|
||||||
|
GstPESFilterResync resync_cb;
|
||||||
|
gpointer user_data;
|
||||||
|
|
||||||
|
guint32 start_code;
|
||||||
|
guint8 id;
|
||||||
|
gboolean unbounded_packet;
|
||||||
|
guint16 length;
|
||||||
|
|
||||||
|
guint8 type;
|
||||||
|
|
||||||
|
gint64 pts;
|
||||||
|
gint64 dts;
|
||||||
|
};
|
||||||
|
|
||||||
|
void gst_pes_filter_init (GstPESFilter * filter, GstAdapter * adapter, guint64 * adapter_offset);
|
||||||
|
|
||||||
|
void gst_pes_filter_uninit (GstPESFilter * filter);
|
||||||
|
|
||||||
|
void gst_pes_filter_set_callbacks (GstPESFilter * filter,
|
||||||
|
GstPESFilterData data_cb,
|
||||||
|
GstPESFilterResync resync_cb,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
GstFlowReturn gst_pes_filter_push (GstPESFilter * filter, GstBuffer * buffer);
|
||||||
|
GstFlowReturn gst_pes_filter_process (GstPESFilter * filter);
|
||||||
|
|
||||||
|
void gst_pes_filter_flush (GstPESFilter * filter);
|
||||||
|
GstFlowReturn gst_pes_filter_drain (GstPESFilter * filter);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GST_PES_FILTER_H__ */
|
161
gst/mpegdemux/gstsectionfilter.c
Normal file
161
gst/mpegdemux/gstsectionfilter.c
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
/*
|
||||||
|
* 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>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "gstsectionfilter.h"
|
||||||
|
|
||||||
|
#ifndef __always_inline
|
||||||
|
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
|
||||||
|
#define __always_inline inline __attribute__((always_inline))
|
||||||
|
#else
|
||||||
|
#define __always_inline inline
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DISABLE_INLINE
|
||||||
|
#define FORCE_INLINE __always_inline
|
||||||
|
#else
|
||||||
|
#define FORCE_INLINE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY (gstflusectionfilter_debug);
|
||||||
|
#define GST_CAT_DEFAULT (gstflusectionfilter_debug)
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_section_filter_init (GstSectionFilter * filter)
|
||||||
|
{
|
||||||
|
g_return_if_fail (filter != NULL);
|
||||||
|
filter->adapter = gst_adapter_new ();
|
||||||
|
/* continuity counter can at max be 15
|
||||||
|
* we make 255 as an indication that
|
||||||
|
* there is no last continuity counter */
|
||||||
|
filter->last_continuity_counter = 255;
|
||||||
|
filter->section_length = G_MAXUINT16;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_section_filter_uninit (GstSectionFilter * filter)
|
||||||
|
{
|
||||||
|
g_return_if_fail (filter != NULL);
|
||||||
|
if (filter->adapter)
|
||||||
|
g_object_unref (filter->adapter);
|
||||||
|
filter->adapter = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_section_filter_clear (GstSectionFilter * filter)
|
||||||
|
{
|
||||||
|
g_return_if_fail (filter != NULL);
|
||||||
|
if (filter->adapter) {
|
||||||
|
gst_adapter_clear (filter->adapter);
|
||||||
|
filter->last_continuity_counter = 255;
|
||||||
|
filter->section_length = G_MAXUINT16;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCE_INLINE gboolean
|
||||||
|
gst_section_is_complete (GstSectionFilter * filter)
|
||||||
|
{
|
||||||
|
/* section length measures size of section from 3 bytes into section
|
||||||
|
* (ie after section length field finished) until end of section)
|
||||||
|
*/
|
||||||
|
guint avail_bytes = gst_adapter_available (filter->adapter);
|
||||||
|
if (filter->section_length == avail_bytes - 3) {
|
||||||
|
return TRUE;
|
||||||
|
} else if (filter->section_length < (int) (avail_bytes - 3)) {
|
||||||
|
GST_DEBUG ("section length seems to be less than available bytes for "
|
||||||
|
"rest of section.");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* returns True when section finished and ready to parse */
|
||||||
|
/* FIXME: especially for multi-section tables, we need to handle pusi correctly
|
||||||
|
* and handle cases where a new section starts in the same transport packet.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_section_filter_push (GstSectionFilter * filter, gboolean pusi, /* determines whether start or not */
|
||||||
|
guint8 continuity_counter, GstBuffer * buf)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (filter != NULL, FALSE);
|
||||||
|
|
||||||
|
/* check if it's the first packet of a section or
|
||||||
|
* if it continues the section */
|
||||||
|
if (pusi) {
|
||||||
|
const guint8 *data = GST_BUFFER_DATA (buf);
|
||||||
|
if (filter->last_continuity_counter != 255) {
|
||||||
|
GST_WARNING ("section lost, last continuity counter: %d"
|
||||||
|
"we now have a pusi at continuity counter: %d",
|
||||||
|
filter->last_continuity_counter, continuity_counter);
|
||||||
|
gst_section_filter_clear (filter);
|
||||||
|
}
|
||||||
|
filter->section_length = GST_READ_UINT16_BE (data + 1);
|
||||||
|
filter->section_length &= 0x0fff;
|
||||||
|
if (filter->section_length > 1021) {
|
||||||
|
GST_DEBUG ("section length too big");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
gst_adapter_push (filter->adapter, buf);
|
||||||
|
filter->last_continuity_counter = continuity_counter;
|
||||||
|
return gst_section_is_complete (filter);
|
||||||
|
} else if (filter->last_continuity_counter == continuity_counter - 1 ||
|
||||||
|
(filter->last_continuity_counter == 15 && continuity_counter == 0)) {
|
||||||
|
GST_DEBUG ("section still going, no pusi");
|
||||||
|
gst_adapter_push (filter->adapter, buf);
|
||||||
|
filter->last_continuity_counter = continuity_counter;
|
||||||
|
return gst_section_is_complete (filter);
|
||||||
|
}
|
||||||
|
/* we have lost the section and we are not a start
|
||||||
|
* section, so clear what was in it */
|
||||||
|
else {
|
||||||
|
GST_WARNING ("section lost, last continuity counter: %d"
|
||||||
|
"new continuity counter but not pusi: %d",
|
||||||
|
filter->last_continuity_counter, continuity_counter);
|
||||||
|
gst_section_filter_clear (filter);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
69
gst/mpegdemux/gstsectionfilter.h
Normal file
69
gst/mpegdemux/gstsectionfilter.h
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* 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_SECTION_FILTER_H__
|
||||||
|
#define __GST_SECTION_FILTER_H__
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <gst/base/gstadapter.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef struct _GstSectionFilter GstSectionFilter;
|
||||||
|
|
||||||
|
struct _GstSectionFilter {
|
||||||
|
GstAdapter *adapter;
|
||||||
|
guint8 last_continuity_counter;
|
||||||
|
guint16 section_length;
|
||||||
|
};
|
||||||
|
|
||||||
|
void gst_section_filter_init (GstSectionFilter *filter);
|
||||||
|
void gst_section_filter_uninit (GstSectionFilter *filter);
|
||||||
|
gboolean gst_section_filter_push (GstSectionFilter *filter,
|
||||||
|
gboolean pusi,
|
||||||
|
guint8 continuity_counter,
|
||||||
|
GstBuffer *buf);
|
||||||
|
void gst_section_filter_clear (GstSectionFilter *filter);
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GST_SECTION_FILTER_H__ */
|
Loading…
Reference in a new issue