Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
/* GStreamer
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
* Copyright (C) <2008> Mindfruit B.V.
|
|
|
|
* @author Sjoerd Simons <sjoerd@luon.net>
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
* Copyright (C) <2007> Julien Moutte <julien@fluendo.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
#include <string.h>
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
#include "mpeg4videoparse.h"
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (mpeg4v_parse_debug);
|
|
|
|
#define GST_CAT_DEFAULT mpeg4v_parse_debug
|
|
|
|
|
|
|
|
static GstStaticPadTemplate src_template =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/mpeg, "
|
|
|
|
"mpegversion = (int) 4, "
|
|
|
|
"parsed = (boolean) true, " "systemstream = (boolean) false")
|
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate sink_template =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/mpeg, "
|
|
|
|
"mpegversion = (int) 4, "
|
|
|
|
"parsed = (boolean) false, " "systemstream = (boolean) false")
|
|
|
|
);
|
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
/* Properties */
|
|
|
|
#define DEFAULT_PROP_DROP TRUE
|
2010-06-15 09:16:34 +00:00
|
|
|
#define DEFAULT_CONFIG_INTERVAL (0)
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_DROP,
|
2010-06-15 09:16:34 +00:00
|
|
|
PROP_CONFIG_INTERVAL,
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
PROP_LAST
|
|
|
|
};
|
|
|
|
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
GST_BOILERPLATE (GstMpeg4VParse, gst_mpeg4vparse, GstElement, GST_TYPE_ELEMENT);
|
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
static gboolean
|
|
|
|
gst_mpeg4vparse_set_new_caps (GstMpeg4VParse * parse,
|
|
|
|
guint16 time_increment_resolution, guint16 fixed_time_increment,
|
|
|
|
gint aspect_ratio_width, gint aspect_ratio_height, gint width, gint height)
|
|
|
|
{
|
|
|
|
gboolean res;
|
2010-11-18 17:59:51 +00:00
|
|
|
GstCaps *out_caps;
|
|
|
|
|
|
|
|
if (parse->sink_caps) {
|
|
|
|
out_caps = gst_caps_copy (parse->sink_caps);
|
|
|
|
} else {
|
|
|
|
out_caps = gst_caps_new_simple ("video/mpeg",
|
|
|
|
"mpegversion", G_TYPE_INT, 4, NULL);
|
|
|
|
}
|
|
|
|
gst_caps_set_simple (out_caps, "systemstream", G_TYPE_BOOLEAN, FALSE,
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
"parsed", G_TYPE_BOOLEAN, TRUE, NULL);
|
|
|
|
|
|
|
|
if (parse->profile != 0) {
|
|
|
|
gchar *profile = NULL;
|
|
|
|
|
|
|
|
/* FIXME does it make sense to expose the profile in the caps ? */
|
|
|
|
profile = g_strdup_printf ("%d", parse->profile);
|
|
|
|
gst_caps_set_simple (out_caps, "profile-level-id",
|
|
|
|
G_TYPE_STRING, profile, NULL);
|
|
|
|
g_free (profile);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parse->config != NULL) {
|
|
|
|
gst_caps_set_simple (out_caps, "codec_data",
|
|
|
|
GST_TYPE_BUFFER, parse->config, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fixed_time_increment != 0) {
|
|
|
|
/* we have a framerate */
|
|
|
|
gst_caps_set_simple (out_caps, "framerate",
|
|
|
|
GST_TYPE_FRACTION, time_increment_resolution, fixed_time_increment,
|
|
|
|
NULL);
|
|
|
|
parse->frame_duration = gst_util_uint64_scale_int (GST_SECOND,
|
|
|
|
fixed_time_increment, time_increment_resolution);
|
|
|
|
} else {
|
|
|
|
/* unknown duration */
|
|
|
|
parse->frame_duration = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aspect_ratio_width > 0 && aspect_ratio_height > 0) {
|
|
|
|
gst_caps_set_simple (out_caps, "pixel-aspect-ratio",
|
|
|
|
GST_TYPE_FRACTION, aspect_ratio_width, aspect_ratio_height, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (width > 0 && height > 0) {
|
|
|
|
gst_caps_set_simple (out_caps,
|
|
|
|
"width", G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (parse, "setting downstream caps to %" GST_PTR_FORMAT,
|
|
|
|
out_caps);
|
|
|
|
res = gst_pad_set_caps (parse->srcpad, out_caps);
|
|
|
|
gst_caps_unref (out_caps);
|
|
|
|
|
2010-11-18 08:09:23 +00:00
|
|
|
parse->have_src_caps = TRUE;
|
|
|
|
if (parse->pending_segment != NULL) {
|
|
|
|
/* We can send pending events since we now have caps for the srcpad */
|
|
|
|
gst_pad_push_event (parse->srcpad, parse->pending_segment);
|
|
|
|
parse->pending_segment = NULL;
|
|
|
|
|
|
|
|
if (G_UNLIKELY (parse->pending_events != NULL)) {
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = parse->pending_events; l != NULL; l = l->next)
|
|
|
|
gst_pad_push_event (parse->srcpad, GST_EVENT (l->data));
|
|
|
|
|
|
|
|
g_list_free (parse->pending_events);
|
|
|
|
parse->pending_events = NULL;
|
|
|
|
}
|
|
|
|
}
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2010-01-16 21:17:08 +00:00
|
|
|
#define VIDEO_OBJECT_STARTCODE_MIN 0x00
|
|
|
|
#define VIDEO_OBJECT_STARTCODE_MAX 0x1F
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
#define VOS_STARTCODE 0xB0
|
|
|
|
#define VOS_ENDCODE 0xB1
|
|
|
|
#define USER_DATA_STARTCODE 0xB2
|
|
|
|
#define GOP_STARTCODE 0xB3
|
|
|
|
#define VISUAL_OBJECT_STARTCODE 0xB5
|
|
|
|
#define VOP_STARTCODE 0xB6
|
|
|
|
|
|
|
|
#define START_MARKER 0x000001
|
|
|
|
#define VISUAL_OBJECT_STARTCODE_MARKER ((START_MARKER << 8) + VISUAL_OBJECT_STARTCODE)
|
2009-09-07 14:20:23 +00:00
|
|
|
#define USER_DATA_STARTCODE_MARKER ((START_MARKER << 8) + USER_DATA_STARTCODE)
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const guint8 *data;
|
|
|
|
/* byte offset */
|
|
|
|
gsize offset;
|
|
|
|
/* bit offset */
|
|
|
|
gsize b_offset;
|
|
|
|
|
|
|
|
/* size in bytes */
|
|
|
|
gsize size;
|
|
|
|
} bitstream_t;
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
get_bits (bitstream_t * b, int num, guint32 * bits)
|
|
|
|
{
|
|
|
|
*bits = 0;
|
|
|
|
|
|
|
|
if (b->offset + ((b->b_offset + num) / 8) > b->size)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (b->b_offset + num <= 8) {
|
|
|
|
*bits = b->data[b->offset];
|
|
|
|
*bits = (*bits >> (8 - num - b->b_offset)) & (((1 << num)) - 1);
|
|
|
|
|
|
|
|
b->offset += (b->b_offset + num) / 8;
|
|
|
|
b->b_offset = (b->b_offset + num) % 8;
|
|
|
|
return TRUE;
|
|
|
|
} else {
|
|
|
|
/* going over the edge.. */
|
|
|
|
int next;
|
|
|
|
|
|
|
|
next = (8 - b->b_offset);
|
|
|
|
do {
|
|
|
|
guint32 t;
|
|
|
|
|
|
|
|
if (!get_bits (b, next, &t))
|
|
|
|
return FALSE;
|
|
|
|
*bits <<= next;
|
|
|
|
*bits |= t;
|
|
|
|
num -= next;
|
|
|
|
next = MIN (8, num);
|
|
|
|
} while (num > 0);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GET_BITS(b, num, bits) G_STMT_START { \
|
|
|
|
if (!get_bits(b, num, bits)) \
|
|
|
|
goto failed; \
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
#define MARKER_BIT(b) G_STMT_START { \
|
|
|
|
guint32 i; \
|
|
|
|
GET_BITS(b, 1, &i); \
|
|
|
|
if (i != 0x1) \
|
|
|
|
goto failed; \
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
static inline gboolean
|
|
|
|
next_start_code (bitstream_t * b)
|
|
|
|
{
|
|
|
|
guint32 bits;
|
|
|
|
|
|
|
|
GET_BITS (b, 1, &bits);
|
|
|
|
if (bits != 0)
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
while (b->b_offset != 0) {
|
|
|
|
GET_BITS (b, 1, &bits);
|
|
|
|
if (bits != 0x1)
|
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
failed:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint aspect_ratio_table[6][2] = { {-1, -1}, {1, 1}, {12, 11},
|
|
|
|
{10, 11}, {16, 11}, {40, 33}
|
|
|
|
};
|
|
|
|
|
2010-04-20 13:37:03 +00:00
|
|
|
static void
|
|
|
|
gst_mpeg4vparse_set_config (GstMpeg4VParse * parse, const guint8 * data,
|
|
|
|
gsize size)
|
|
|
|
{
|
|
|
|
/* limit possible caps noise */
|
|
|
|
if (parse->config && size == GST_BUFFER_SIZE (parse->config) &&
|
|
|
|
memcmp (GST_BUFFER_DATA (parse->config), data, size) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (parse->config != NULL)
|
|
|
|
gst_buffer_unref (parse->config);
|
|
|
|
|
|
|
|
parse->config = gst_buffer_new_and_alloc (size);
|
|
|
|
memcpy (GST_BUFFER_DATA (parse->config), data, size);
|
|
|
|
}
|
|
|
|
|
2010-01-16 21:17:08 +00:00
|
|
|
/* Handle parsing a video object */
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
static gboolean
|
2009-02-26 14:40:26 +00:00
|
|
|
gst_mpeg4vparse_handle_vo (GstMpeg4VParse * parse, const guint8 * data,
|
2010-04-20 13:37:03 +00:00
|
|
|
gsize size, gboolean set_codec_data)
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
{
|
|
|
|
guint32 bits;
|
2009-02-26 14:40:26 +00:00
|
|
|
bitstream_t bs = { data, 0, 0, size };
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
guint16 time_increment_resolution = 0;
|
|
|
|
guint16 fixed_time_increment = 0;
|
|
|
|
gint aspect_ratio_width = -1, aspect_ratio_height = -1;
|
|
|
|
gint height = -1, width = -1;
|
2008-06-02 07:37:31 +00:00
|
|
|
|
2010-04-20 13:37:03 +00:00
|
|
|
if (set_codec_data)
|
|
|
|
gst_mpeg4vparse_set_config (parse, data, size);
|
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
/* expecting a video object startcode */
|
|
|
|
GET_BITS (&bs, 32, &bits);
|
2008-06-02 07:37:31 +00:00
|
|
|
if (bits > 0x11F)
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
goto failed;
|
|
|
|
|
|
|
|
/* expecting a video object layer startcode */
|
|
|
|
GET_BITS (&bs, 32, &bits);
|
2008-06-02 07:37:31 +00:00
|
|
|
if (bits < 0x120 || bits > 0x12F)
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
goto failed;
|
|
|
|
|
|
|
|
/* ignore random accessible vol and video object type indication */
|
|
|
|
GET_BITS (&bs, 9, &bits);
|
|
|
|
|
|
|
|
GET_BITS (&bs, 1, &bits);
|
|
|
|
if (bits) {
|
|
|
|
/* skip video object layer verid and priority */
|
|
|
|
GET_BITS (&bs, 7, &bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* aspect ratio info */
|
|
|
|
GET_BITS (&bs, 4, &bits);
|
|
|
|
if (bits == 0)
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
/* check if aspect ratio info is extended par */
|
2009-09-07 17:08:08 +00:00
|
|
|
if (bits == 0xf) {
|
|
|
|
GET_BITS (&bs, 8, &bits);
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
aspect_ratio_width = bits;
|
2009-09-07 17:08:08 +00:00
|
|
|
GET_BITS (&bs, 8, &bits);
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
aspect_ratio_height = bits;
|
|
|
|
} else if (bits < 0x6) {
|
|
|
|
aspect_ratio_width = aspect_ratio_table[bits][0];
|
|
|
|
aspect_ratio_height = aspect_ratio_table[bits][1];
|
|
|
|
}
|
|
|
|
|
|
|
|
GET_BITS (&bs, 1, &bits);
|
|
|
|
if (bits) {
|
|
|
|
/* vol control parameters, skip chroma and low delay */
|
|
|
|
GET_BITS (&bs, 3, &bits);
|
|
|
|
GET_BITS (&bs, 1, &bits);
|
|
|
|
if (bits) {
|
|
|
|
/* skip vbv_parameters */
|
|
|
|
GET_BITS (&bs, 79, &bits);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* layer shape */
|
|
|
|
GET_BITS (&bs, 2, &bits);
|
|
|
|
/* only support rectangular */
|
|
|
|
if (bits != 0)
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
MARKER_BIT (&bs);
|
|
|
|
GET_BITS (&bs, 16, &bits);
|
|
|
|
time_increment_resolution = bits;
|
|
|
|
MARKER_BIT (&bs);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (parse, "time increment resolution %d",
|
|
|
|
time_increment_resolution);
|
|
|
|
|
|
|
|
GET_BITS (&bs, 1, &bits);
|
|
|
|
if (bits) {
|
|
|
|
/* fixed time increment */
|
|
|
|
int n;
|
|
|
|
|
2010-01-16 21:17:08 +00:00
|
|
|
/* Length of the time increment is the minimal number of bits needed to
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
* represent time_increment_resolution */
|
|
|
|
for (n = 0; (time_increment_resolution >> n) != 0; n++);
|
|
|
|
GET_BITS (&bs, n, &bits);
|
|
|
|
|
|
|
|
fixed_time_increment = bits;
|
|
|
|
} else {
|
2010-01-15 20:34:02 +00:00
|
|
|
/* When fixed_vop_rate is not set we can't guess any framerate */
|
|
|
|
fixed_time_increment = 0;
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
}
|
|
|
|
GST_DEBUG_OBJECT (parse, "fixed time increment %d", fixed_time_increment);
|
|
|
|
|
|
|
|
/* assuming rectangular shape */
|
|
|
|
MARKER_BIT (&bs);
|
|
|
|
GET_BITS (&bs, 13, &bits);
|
|
|
|
width = bits;
|
|
|
|
MARKER_BIT (&bs);
|
|
|
|
GET_BITS (&bs, 13, &bits);
|
|
|
|
height = bits;
|
|
|
|
MARKER_BIT (&bs);
|
|
|
|
|
2009-02-26 14:40:26 +00:00
|
|
|
/* ok we know there is enough data in the stream to decode it and we can start
|
|
|
|
* pushing the data */
|
|
|
|
parse->have_config = TRUE;
|
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
out:
|
|
|
|
return gst_mpeg4vparse_set_new_caps (parse, time_increment_resolution,
|
|
|
|
fixed_time_increment, aspect_ratio_width, aspect_ratio_height,
|
|
|
|
width, height);
|
|
|
|
|
2009-02-26 14:40:26 +00:00
|
|
|
/* ERRORS */
|
|
|
|
failed:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (parse, "Failed to parse config data");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-07 14:20:23 +00:00
|
|
|
static inline gboolean
|
|
|
|
skip_user_data (bitstream_t * bs, guint32 * bits)
|
|
|
|
{
|
|
|
|
while (*bits == USER_DATA_STARTCODE_MARKER) {
|
|
|
|
guint32 b;
|
|
|
|
|
|
|
|
do {
|
|
|
|
GET_BITS (bs, 8, &b);
|
|
|
|
*bits = (*bits << 8) | b;
|
|
|
|
} while ((*bits >> 8) != START_MARKER);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
failed:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-01-16 21:17:08 +00:00
|
|
|
/* Handle parsing a visual object sequence.
|
|
|
|
Returns whether we successfully set the caps downstream if needed */
|
2009-02-26 14:40:26 +00:00
|
|
|
static gboolean
|
|
|
|
gst_mpeg4vparse_handle_vos (GstMpeg4VParse * parse, const guint8 * data,
|
|
|
|
gsize size)
|
|
|
|
{
|
|
|
|
/* Skip the startcode */
|
|
|
|
guint32 bits;
|
|
|
|
|
|
|
|
guint8 profile;
|
|
|
|
gboolean equal;
|
|
|
|
bitstream_t bs = { data, 0, 0, size };
|
|
|
|
|
2010-01-06 19:20:06 +00:00
|
|
|
if (size < 5)
|
|
|
|
goto failed;
|
|
|
|
|
2009-02-26 14:40:26 +00:00
|
|
|
/* Parse the config from the VOS frame */
|
|
|
|
bs.offset = 5;
|
|
|
|
|
|
|
|
profile = data[4];
|
|
|
|
|
|
|
|
/* invalid profile, yikes */
|
2010-01-16 21:17:08 +00:00
|
|
|
if (profile == 0) {
|
|
|
|
GST_WARNING_OBJECT (parse, "Invalid profile in VOS");
|
2009-02-26 14:40:26 +00:00
|
|
|
return FALSE;
|
2010-01-16 21:17:08 +00:00
|
|
|
}
|
2009-02-26 14:40:26 +00:00
|
|
|
|
|
|
|
equal = FALSE;
|
2010-01-16 21:17:08 +00:00
|
|
|
if (G_LIKELY (parse->config && size == GST_BUFFER_SIZE (parse->config) &&
|
2009-02-26 14:40:26 +00:00
|
|
|
memcmp (GST_BUFFER_DATA (parse->config), data, size) == 0))
|
|
|
|
equal = TRUE;
|
|
|
|
|
|
|
|
if (G_LIKELY (parse->profile == profile && equal)) {
|
|
|
|
/* We know this profile and config data, so we can just keep the same caps
|
|
|
|
*/
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Even if we fail to parse, then some other element might succeed, so always
|
|
|
|
* put the VOS in the config */
|
|
|
|
parse->profile = profile;
|
2010-04-20 13:37:03 +00:00
|
|
|
gst_mpeg4vparse_set_config (parse, data, size);
|
2009-02-26 14:40:26 +00:00
|
|
|
|
|
|
|
parse->have_config = TRUE;
|
|
|
|
|
|
|
|
/* Expect Visual Object startcode */
|
|
|
|
GET_BITS (&bs, 32, &bits);
|
|
|
|
|
2009-09-07 14:20:23 +00:00
|
|
|
/* but skip optional user data */
|
|
|
|
if (!skip_user_data (&bs, &bits))
|
|
|
|
goto failed;
|
|
|
|
|
2009-02-26 14:40:26 +00:00
|
|
|
if (bits != VISUAL_OBJECT_STARTCODE_MARKER)
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
GET_BITS (&bs, 1, &bits);
|
|
|
|
if (bits == 0x1) {
|
|
|
|
/* Skip visual_object_verid and priority */
|
|
|
|
GET_BITS (&bs, 7, &bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
GET_BITS (&bs, 4, &bits);
|
|
|
|
/* Only support video ID */
|
|
|
|
if (bits != 0x1)
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
/* video signal type */
|
|
|
|
GET_BITS (&bs, 1, &bits);
|
|
|
|
|
|
|
|
if (bits == 0x1) {
|
|
|
|
/* video signal type, ignore format and range */
|
|
|
|
GET_BITS (&bs, 4, &bits);
|
|
|
|
|
|
|
|
GET_BITS (&bs, 1, &bits);
|
|
|
|
if (bits == 0x1) {
|
|
|
|
/* ignore color description */
|
|
|
|
GET_BITS (&bs, 24, &bits);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!next_start_code (&bs))
|
|
|
|
goto failed;
|
|
|
|
|
2009-09-07 14:20:23 +00:00
|
|
|
/* skip optional user data */
|
|
|
|
GET_BITS (&bs, 32, &bits);
|
|
|
|
if (!skip_user_data (&bs, &bits))
|
|
|
|
goto failed;
|
|
|
|
/* rewind to start code */
|
|
|
|
bs.offset -= 4;
|
|
|
|
|
2009-02-26 14:40:26 +00:00
|
|
|
data = &bs.data[bs.offset];
|
|
|
|
size -= bs.offset;
|
|
|
|
|
2010-04-20 13:37:03 +00:00
|
|
|
return gst_mpeg4vparse_handle_vo (parse, data, size, FALSE);
|
2009-02-26 14:40:26 +00:00
|
|
|
|
|
|
|
out:
|
|
|
|
return gst_mpeg4vparse_set_new_caps (parse, 0, 0, -1, -1, -1, -1);
|
|
|
|
|
|
|
|
/* ERRORS */
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
failed:
|
2009-02-26 14:40:26 +00:00
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (parse, "Failed to parse config data");
|
|
|
|
goto out;
|
|
|
|
}
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_mpeg4vparse_push (GstMpeg4VParse * parse, gsize size)
|
|
|
|
{
|
2009-02-26 14:40:26 +00:00
|
|
|
if (G_UNLIKELY (!parse->have_config && parse->drop)) {
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
GST_LOG_OBJECT (parse, "Dropping %d bytes", parse->offset);
|
|
|
|
gst_adapter_flush (parse->adapter, size);
|
|
|
|
} else {
|
|
|
|
GstBuffer *out_buf;
|
|
|
|
|
|
|
|
out_buf = gst_adapter_take_buffer (parse->adapter, parse->offset);
|
|
|
|
|
2010-06-15 09:20:21 +00:00
|
|
|
if (G_LIKELY (out_buf)) {
|
2010-12-23 22:01:00 +00:00
|
|
|
out_buf = gst_buffer_make_metadata_writable (out_buf);
|
|
|
|
GST_BUFFER_TIMESTAMP (out_buf) = parse->timestamp;
|
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
/* Set GST_BUFFER_FLAG_DELTA_UNIT if it's not an intra frame */
|
|
|
|
if (!parse->intra_frame) {
|
|
|
|
GST_BUFFER_FLAG_SET (out_buf, GST_BUFFER_FLAG_DELTA_UNIT);
|
2010-06-15 09:16:34 +00:00
|
|
|
} else if (parse->interval > 0 && parse->config) {
|
|
|
|
GstClockTime timestamp = GST_BUFFER_TIMESTAMP (out_buf);
|
|
|
|
guint64 diff;
|
|
|
|
|
|
|
|
/* init */
|
2010-06-15 09:20:21 +00:00
|
|
|
if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (parse->last_report))) {
|
2010-06-15 09:16:34 +00:00
|
|
|
parse->last_report = timestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* insert on intra frames */
|
2010-06-15 09:20:21 +00:00
|
|
|
if (G_LIKELY (timestamp > parse->last_report))
|
2010-06-15 09:16:34 +00:00
|
|
|
diff = timestamp - parse->last_report;
|
|
|
|
else
|
|
|
|
diff = 0;
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (parse,
|
|
|
|
"now %" GST_TIME_FORMAT ", last VOP-I %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (timestamp), GST_TIME_ARGS (parse->last_report));
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (parse,
|
|
|
|
"interval since last config %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (diff));
|
|
|
|
|
2010-06-15 09:20:21 +00:00
|
|
|
if (G_UNLIKELY (GST_TIME_AS_SECONDS (diff) >= parse->interval)) {
|
2010-06-15 09:16:34 +00:00
|
|
|
/* we need to send config now first */
|
|
|
|
GstBuffer *superbuf;
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (parse, "inserting config in stream");
|
|
|
|
|
|
|
|
/* insert header */
|
|
|
|
superbuf = gst_buffer_merge (parse->config, out_buf);
|
|
|
|
gst_buffer_unref (out_buf);
|
2010-12-23 22:01:00 +00:00
|
|
|
|
|
|
|
out_buf = gst_buffer_make_metadata_writable (superbuf);
|
|
|
|
GST_BUFFER_TIMESTAMP (out_buf) = timestamp;
|
2010-06-15 09:16:34 +00:00
|
|
|
|
2010-06-15 09:20:21 +00:00
|
|
|
if (G_UNLIKELY (timestamp != -1)) {
|
2010-06-15 09:16:34 +00:00
|
|
|
parse->last_report = timestamp;
|
|
|
|
}
|
|
|
|
}
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
}
|
|
|
|
gst_buffer_set_caps (out_buf, GST_PAD_CAPS (parse->srcpad));
|
|
|
|
gst_pad_push (parse->srcpad, out_buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restart now that we flushed data */
|
|
|
|
parse->offset = 0;
|
2008-05-22 14:03:05 +00:00
|
|
|
parse->state = PARSE_NEED_START;
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
parse->intra_frame = FALSE;
|
|
|
|
}
|
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Improved version not damaging headers using a simple state machine.
Original commit message from CVS:
2007-10-27 Julien MOUTTE <julien@moutte.net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_align),
(gst_mpeg4vparse_drain), (gst_mpeg4vparse_chain),
(gst_mpeg4vparse_sink_setcaps), (gst_mpeg4vparse_sink_event),
(gst_mpeg4vparse_cleanup), (gst_mpeg4vparse_change_state),
(gst_mpeg4vparse_dispose), (gst_mpeg4vparse_base_init),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init),
(plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Improved version not
damaging headers using a simple state machine.
2007-10-27 08:20:59 +00:00
|
|
|
static GstFlowReturn
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
gst_mpeg4vparse_drain (GstMpeg4VParse * parse, GstBuffer * last_buffer)
|
gst/mpeg4videoparse/mpeg4videoparse.*: Improved version not damaging headers using a simple state machine.
Original commit message from CVS:
2007-10-27 Julien MOUTTE <julien@moutte.net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_align),
(gst_mpeg4vparse_drain), (gst_mpeg4vparse_chain),
(gst_mpeg4vparse_sink_setcaps), (gst_mpeg4vparse_sink_event),
(gst_mpeg4vparse_cleanup), (gst_mpeg4vparse_change_state),
(gst_mpeg4vparse_dispose), (gst_mpeg4vparse_base_init),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init),
(plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Improved version not
damaging headers using a simple state machine.
2007-10-27 08:20:59 +00:00
|
|
|
{
|
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
|
|
|
const guint8 *data = NULL;
|
|
|
|
guint available = 0;
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
|
|
|
|
available = gst_adapter_available (parse->adapter);
|
2008-05-22 14:03:05 +00:00
|
|
|
/* We do a quick check here to avoid the _peek() below. */
|
|
|
|
if (G_UNLIKELY (available < 5)) {
|
|
|
|
GST_DEBUG_OBJECT (parse, "we need more data, %d < 5", available);
|
|
|
|
goto beach;
|
|
|
|
}
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
data = gst_adapter_peek (parse->adapter, available);
|
gst/mpeg4videoparse/mpeg4videoparse.*: Improved version not damaging headers using a simple state machine.
Original commit message from CVS:
2007-10-27 Julien MOUTTE <julien@moutte.net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_align),
(gst_mpeg4vparse_drain), (gst_mpeg4vparse_chain),
(gst_mpeg4vparse_sink_setcaps), (gst_mpeg4vparse_sink_event),
(gst_mpeg4vparse_cleanup), (gst_mpeg4vparse_change_state),
(gst_mpeg4vparse_dispose), (gst_mpeg4vparse_base_init),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init),
(plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Improved version not
damaging headers using a simple state machine.
2007-10-27 08:20:59 +00:00
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
/* Need at least 5 more bytes, 4 for the startcode, 1 to optionally determine
|
|
|
|
* the VOP frame type */
|
2008-05-22 14:03:05 +00:00
|
|
|
while (available >= 5 && parse->offset < available - 5) {
|
gst/mpeg4videoparse/mpeg4videoparse.*: Improved version not damaging headers using a simple state machine.
Original commit message from CVS:
2007-10-27 Julien MOUTTE <julien@moutte.net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_align),
(gst_mpeg4vparse_drain), (gst_mpeg4vparse_chain),
(gst_mpeg4vparse_sink_setcaps), (gst_mpeg4vparse_sink_event),
(gst_mpeg4vparse_cleanup), (gst_mpeg4vparse_change_state),
(gst_mpeg4vparse_dispose), (gst_mpeg4vparse_base_init),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init),
(plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Improved version not
damaging headers using a simple state machine.
2007-10-27 08:20:59 +00:00
|
|
|
if (data[parse->offset] == 0 && data[parse->offset + 1] == 0 &&
|
|
|
|
data[parse->offset + 2] == 1) {
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Improved version not damaging headers using a simple state machine.
Original commit message from CVS:
2007-10-27 Julien MOUTTE <julien@moutte.net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_align),
(gst_mpeg4vparse_drain), (gst_mpeg4vparse_chain),
(gst_mpeg4vparse_sink_setcaps), (gst_mpeg4vparse_sink_event),
(gst_mpeg4vparse_cleanup), (gst_mpeg4vparse_change_state),
(gst_mpeg4vparse_dispose), (gst_mpeg4vparse_base_init),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init),
(plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Improved version not
damaging headers using a simple state machine.
2007-10-27 08:20:59 +00:00
|
|
|
switch (parse->state) {
|
2008-05-22 14:03:05 +00:00
|
|
|
case PARSE_NEED_START:
|
2009-02-26 14:40:26 +00:00
|
|
|
{
|
|
|
|
gboolean found = FALSE;
|
|
|
|
guint8 code;
|
|
|
|
|
|
|
|
code = data[parse->offset + 3];
|
|
|
|
|
|
|
|
switch (code) {
|
2008-05-22 14:03:05 +00:00
|
|
|
case VOP_STARTCODE:
|
|
|
|
case VOS_STARTCODE:
|
|
|
|
case GOP_STARTCODE:
|
2009-02-26 14:40:26 +00:00
|
|
|
found = TRUE;
|
2008-05-22 14:03:05 +00:00
|
|
|
break;
|
|
|
|
default:
|
2009-02-27 19:36:58 +00:00
|
|
|
if (code <= 0x1f)
|
2009-02-26 14:40:26 +00:00
|
|
|
found = TRUE;
|
|
|
|
break;
|
2008-05-22 14:03:05 +00:00
|
|
|
}
|
2009-02-26 14:40:26 +00:00
|
|
|
if (found) {
|
|
|
|
/* valid starts of a frame */
|
|
|
|
parse->state = PARSE_START_FOUND;
|
|
|
|
if (parse->offset > 0) {
|
|
|
|
GST_LOG_OBJECT (parse, "Flushing %u bytes", parse->offset);
|
|
|
|
gst_adapter_flush (parse->adapter, parse->offset);
|
|
|
|
parse->offset = 0;
|
|
|
|
available = gst_adapter_available (parse->adapter);
|
|
|
|
data = gst_adapter_peek (parse->adapter, available);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
parse->offset += 4;
|
2008-05-22 14:03:05 +00:00
|
|
|
break;
|
2009-02-26 14:40:26 +00:00
|
|
|
}
|
gst/mpeg4videoparse/mpeg4videoparse.*: Improved version not damaging headers using a simple state machine.
Original commit message from CVS:
2007-10-27 Julien MOUTTE <julien@moutte.net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_align),
(gst_mpeg4vparse_drain), (gst_mpeg4vparse_chain),
(gst_mpeg4vparse_sink_setcaps), (gst_mpeg4vparse_sink_event),
(gst_mpeg4vparse_cleanup), (gst_mpeg4vparse_change_state),
(gst_mpeg4vparse_dispose), (gst_mpeg4vparse_base_init),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init),
(plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Improved version not
damaging headers using a simple state machine.
2007-10-27 08:20:59 +00:00
|
|
|
case PARSE_START_FOUND:
|
2009-02-26 14:40:26 +00:00
|
|
|
{
|
|
|
|
guint8 code;
|
|
|
|
|
|
|
|
code = data[parse->offset + 3];
|
|
|
|
|
|
|
|
switch (code) {
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
case VOP_STARTCODE:
|
|
|
|
GST_LOG_OBJECT (parse, "found VOP start marker at %u",
|
|
|
|
parse->offset);
|
|
|
|
parse->intra_frame = ((data[parse->offset + 4] >> 6 & 0x3) == 0);
|
|
|
|
/* Ensure that the timestamp of the outgoing buffer is the same
|
|
|
|
* as the one the VOP header is found in */
|
|
|
|
parse->timestamp = GST_BUFFER_TIMESTAMP (last_buffer);
|
|
|
|
parse->state = PARSE_VOP_FOUND;
|
|
|
|
break;
|
|
|
|
case VOS_STARTCODE:
|
|
|
|
GST_LOG_OBJECT (parse, "found VOS start marker at %u",
|
|
|
|
parse->offset);
|
|
|
|
parse->vos_offset = parse->offset;
|
|
|
|
parse->state = PARSE_VOS_FOUND;
|
|
|
|
break;
|
2009-02-26 14:40:26 +00:00
|
|
|
default:
|
2009-02-27 19:36:58 +00:00
|
|
|
if (code <= 0x1f) {
|
2009-02-26 14:40:26 +00:00
|
|
|
GST_LOG_OBJECT (parse, "found VO start marker at %u",
|
|
|
|
parse->offset);
|
|
|
|
parse->vos_offset = parse->offset;
|
|
|
|
parse->state = PARSE_VO_FOUND;
|
|
|
|
}
|
|
|
|
break;
|
gst/mpeg4videoparse/mpeg4videoparse.*: Improved version not damaging headers using a simple state machine.
Original commit message from CVS:
2007-10-27 Julien MOUTTE <julien@moutte.net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_align),
(gst_mpeg4vparse_drain), (gst_mpeg4vparse_chain),
(gst_mpeg4vparse_sink_setcaps), (gst_mpeg4vparse_sink_event),
(gst_mpeg4vparse_cleanup), (gst_mpeg4vparse_change_state),
(gst_mpeg4vparse_dispose), (gst_mpeg4vparse_base_init),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init),
(plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Improved version not
damaging headers using a simple state machine.
2007-10-27 08:20:59 +00:00
|
|
|
}
|
|
|
|
/* Jump over it */
|
|
|
|
parse->offset += 4;
|
|
|
|
break;
|
2009-02-26 14:40:26 +00:00
|
|
|
}
|
|
|
|
case PARSE_VO_FOUND:
|
|
|
|
switch (data[parse->offset + 3]) {
|
|
|
|
case GOP_STARTCODE:
|
|
|
|
case VOP_STARTCODE:
|
|
|
|
/* end of VOS found, interpret the config data and restart the
|
|
|
|
* search for the VOP */
|
|
|
|
gst_mpeg4vparse_handle_vo (parse, data + parse->vos_offset,
|
2010-04-20 13:37:03 +00:00
|
|
|
parse->offset - parse->vos_offset, TRUE);
|
2009-02-26 14:40:26 +00:00
|
|
|
parse->state = PARSE_START_FOUND;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
parse->offset += 4;
|
|
|
|
}
|
|
|
|
break;
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
case PARSE_VOS_FOUND:
|
|
|
|
switch (data[parse->offset + 3]) {
|
|
|
|
case GOP_STARTCODE:
|
|
|
|
case VOP_STARTCODE:
|
|
|
|
/* end of VOS found, interpret the config data and restart the
|
|
|
|
* search for the VOP */
|
|
|
|
gst_mpeg4vparse_handle_vos (parse, data + parse->vos_offset,
|
|
|
|
parse->offset - parse->vos_offset);
|
|
|
|
parse->state = PARSE_START_FOUND;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
parse->offset += 4;
|
|
|
|
}
|
|
|
|
break;
|
gst/mpeg4videoparse/mpeg4videoparse.*: Improved version not damaging headers using a simple state machine.
Original commit message from CVS:
2007-10-27 Julien MOUTTE <julien@moutte.net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_align),
(gst_mpeg4vparse_drain), (gst_mpeg4vparse_chain),
(gst_mpeg4vparse_sink_setcaps), (gst_mpeg4vparse_sink_event),
(gst_mpeg4vparse_cleanup), (gst_mpeg4vparse_change_state),
(gst_mpeg4vparse_dispose), (gst_mpeg4vparse_base_init),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init),
(plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Improved version not
damaging headers using a simple state machine.
2007-10-27 08:20:59 +00:00
|
|
|
case PARSE_VOP_FOUND:
|
|
|
|
{ /* We were in a VOP already, any start code marks the end of it */
|
|
|
|
GST_LOG_OBJECT (parse, "found VOP end marker at %u", parse->offset);
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
|
|
|
|
gst_mpeg4vparse_push (parse, parse->offset);
|
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Improved version not damaging headers using a simple state machine.
Original commit message from CVS:
2007-10-27 Julien MOUTTE <julien@moutte.net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_align),
(gst_mpeg4vparse_drain), (gst_mpeg4vparse_chain),
(gst_mpeg4vparse_sink_setcaps), (gst_mpeg4vparse_sink_event),
(gst_mpeg4vparse_cleanup), (gst_mpeg4vparse_change_state),
(gst_mpeg4vparse_dispose), (gst_mpeg4vparse_base_init),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init),
(plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Improved version not
damaging headers using a simple state machine.
2007-10-27 08:20:59 +00:00
|
|
|
available = gst_adapter_available (parse->adapter);
|
|
|
|
data = gst_adapter_peek (parse->adapter, available);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
GST_WARNING_OBJECT (parse, "unexpected parse state (%d)",
|
|
|
|
parse->state);
|
|
|
|
ret = GST_FLOW_UNEXPECTED;
|
|
|
|
goto beach;
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
}
|
gst/mpeg4videoparse/mpeg4videoparse.*: Improved version not damaging headers using a simple state machine.
Original commit message from CVS:
2007-10-27 Julien MOUTTE <julien@moutte.net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_align),
(gst_mpeg4vparse_drain), (gst_mpeg4vparse_chain),
(gst_mpeg4vparse_sink_setcaps), (gst_mpeg4vparse_sink_event),
(gst_mpeg4vparse_cleanup), (gst_mpeg4vparse_change_state),
(gst_mpeg4vparse_dispose), (gst_mpeg4vparse_base_init),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init),
(plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Improved version not
damaging headers using a simple state machine.
2007-10-27 08:20:59 +00:00
|
|
|
} else { /* Continue searching */
|
|
|
|
parse->offset++;
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
beach:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_mpeg4vparse_chain (GstPad * pad, GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
GstMpeg4VParse *parse = GST_MPEG4VIDEOPARSE (gst_pad_get_parent (pad));
|
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (parse, "received buffer of %u bytes with ts %"
|
|
|
|
GST_TIME_FORMAT " and offset %" G_GINT64_FORMAT, GST_BUFFER_SIZE (buffer),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
|
|
|
|
GST_BUFFER_OFFSET (buffer));
|
|
|
|
|
|
|
|
gst_adapter_push (parse->adapter, buffer);
|
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Improved version not damaging headers using a simple state machine.
Original commit message from CVS:
2007-10-27 Julien MOUTTE <julien@moutte.net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_align),
(gst_mpeg4vparse_drain), (gst_mpeg4vparse_chain),
(gst_mpeg4vparse_sink_setcaps), (gst_mpeg4vparse_sink_event),
(gst_mpeg4vparse_cleanup), (gst_mpeg4vparse_change_state),
(gst_mpeg4vparse_dispose), (gst_mpeg4vparse_base_init),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init),
(plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Improved version not
damaging headers using a simple state machine.
2007-10-27 08:20:59 +00:00
|
|
|
/* Drain the accumulated blocks frame per frame */
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
ret = gst_mpeg4vparse_drain (parse, buffer);
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
|
|
|
|
gst_object_unref (parse);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_mpeg4vparse_sink_setcaps (GstPad * pad, GstCaps * caps)
|
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
GstMpeg4VParse *parse = GST_MPEG4VIDEOPARSE (gst_pad_get_parent (pad));
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
GstStructure *s;
|
|
|
|
const GValue *value;
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (parse, "setcaps called with %" GST_PTR_FORMAT, caps);
|
2010-11-18 17:59:51 +00:00
|
|
|
parse->sink_caps = gst_caps_ref (caps);
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
if ((value = gst_structure_get_value (s, "codec_data")) != NULL
|
|
|
|
&& G_VALUE_HOLDS (value, GST_TYPE_BUFFER)) {
|
|
|
|
GstBuffer *buf = gst_value_get_buffer (value);
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
|
2010-01-16 21:17:08 +00:00
|
|
|
/* Set the config from this codec_data immediately so that in the worst
|
|
|
|
case, we don't just discard it.
|
|
|
|
Note that in most cases, this will be freed and overwritten when we
|
|
|
|
manage to parse the codec_data. */
|
|
|
|
if (!parse->config) {
|
|
|
|
parse->config = gst_buffer_copy (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_BUFFER_SIZE (buf) < 4) {
|
|
|
|
GST_WARNING_OBJECT (parse, "codec_data too short, ignoring");
|
|
|
|
goto failed_parse;
|
|
|
|
} else {
|
|
|
|
const guint8 *data = GST_BUFFER_DATA (buf);
|
|
|
|
|
2010-12-07 14:20:29 +00:00
|
|
|
res = FALSE;
|
2010-01-16 21:17:08 +00:00
|
|
|
if (data[0] == 0 && data[1] == 0 && data[2] == 1) {
|
|
|
|
if (data[3] == VOS_STARTCODE) {
|
|
|
|
/* Usually the codec data will be a visual object sequence, containing
|
|
|
|
a visual object, with a video object/video object layer. */
|
|
|
|
res = gst_mpeg4vparse_handle_vos (parse, data, GST_BUFFER_SIZE (buf));
|
2010-03-10 16:26:27 +00:00
|
|
|
} else if (data[3] <= VIDEO_OBJECT_STARTCODE_MAX) {
|
|
|
|
/* VIDEO_OBJECT_STARTCODE_MIN is zero, and data is unsigned, so we
|
|
|
|
don't need to check min (and in fact that causes a compile err */
|
2010-01-16 21:17:08 +00:00
|
|
|
/* Sometimes, instead, it'll just have the video object/video object
|
|
|
|
layer data. We can parse that too, though it'll give us slightly
|
|
|
|
less information. */
|
2010-04-20 13:37:03 +00:00
|
|
|
res = gst_mpeg4vparse_handle_vo (parse, data, GST_BUFFER_SIZE (buf),
|
|
|
|
FALSE);
|
2010-01-16 21:17:08 +00:00
|
|
|
}
|
2010-12-07 14:20:29 +00:00
|
|
|
if (!res)
|
|
|
|
goto failed_parse;
|
2010-01-16 21:17:08 +00:00
|
|
|
} else {
|
|
|
|
GST_WARNING_OBJECT (parse,
|
|
|
|
"codec_data does not begin with start code, invalid");
|
|
|
|
goto failed_parse;
|
|
|
|
}
|
|
|
|
}
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
} else {
|
2010-01-16 21:17:08 +00:00
|
|
|
/* No codec data; treat the same a failed codec data */
|
|
|
|
goto failed_parse;
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
}
|
|
|
|
|
2010-01-16 21:17:08 +00:00
|
|
|
done:
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
gst_object_unref (parse);
|
|
|
|
return res;
|
2010-01-16 21:17:08 +00:00
|
|
|
|
|
|
|
failed_parse:
|
|
|
|
/* No codec data, or obviously-invalid, so set minimal new caps.
|
|
|
|
VOS parsing later will (hopefully) fill in the other fields */
|
|
|
|
res = gst_mpeg4vparse_set_new_caps (parse, 0, 0, 0, 0, 0, 0);
|
|
|
|
goto done;
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_mpeg4vparse_sink_event (GstPad * pad, GstEvent * event)
|
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
GstMpeg4VParse *parse = GST_MPEG4VIDEOPARSE (gst_pad_get_parent (pad));
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (parse, "handling event type %s",
|
|
|
|
GST_EVENT_TYPE_NAME (event));
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2010-06-15 09:16:47 +00:00
|
|
|
case GST_EVENT_FLUSH_STOP:
|
|
|
|
parse->last_report = GST_CLOCK_TIME_NONE;
|
|
|
|
gst_adapter_clear (parse->adapter);
|
|
|
|
parse->state = PARSE_NEED_START;
|
|
|
|
parse->offset = 0;
|
|
|
|
break;
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
case GST_EVENT_EOS:
|
2010-11-18 08:09:23 +00:00
|
|
|
if (parse->pending_segment != NULL) {
|
|
|
|
/* Send pending newsegment before EOS */
|
|
|
|
gst_pad_push_event (parse->srcpad, parse->pending_segment);
|
|
|
|
parse->pending_segment = NULL;
|
|
|
|
}
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
if (parse->state == PARSE_VOP_FOUND) {
|
|
|
|
/* If we've found the start of the VOP assume what's left in the
|
|
|
|
* adapter is the complete VOP. This might cause us to send an
|
|
|
|
* incomplete VOP out, but prevents the last video frame from
|
|
|
|
* potentially being dropped */
|
|
|
|
gst_mpeg4vparse_push (parse, gst_adapter_available (parse->adapter));
|
|
|
|
}
|
|
|
|
/* fallthrough */
|
2010-11-18 08:09:23 +00:00
|
|
|
case GST_EVENT_FLUSH_START:
|
|
|
|
res = gst_pad_event_default (pad, event);
|
|
|
|
break;
|
|
|
|
case GST_EVENT_NEWSEGMENT:
|
|
|
|
gst_event_replace (&parse->pending_segment, event);
|
|
|
|
gst_event_unref (event);
|
|
|
|
res = TRUE;
|
|
|
|
break;
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
default:
|
2010-11-18 08:09:23 +00:00
|
|
|
if (G_UNLIKELY (!parse->have_src_caps || parse->pending_segment)) {
|
|
|
|
/* We don't yet have enough data to set caps on the srcpad, so collect
|
|
|
|
* non-critical events till we do */
|
|
|
|
parse->pending_events = g_list_append (parse->pending_events, event);
|
|
|
|
res = TRUE;
|
|
|
|
} else
|
|
|
|
res = gst_pad_event_default (pad, event);
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_object_unref (parse);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
static gboolean
|
|
|
|
gst_mpeg4vparse_src_query (GstPad * pad, GstQuery * query)
|
|
|
|
{
|
|
|
|
GstMpeg4VParse *parse = GST_MPEG4VIDEOPARSE (gst_pad_get_parent (pad));
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_LATENCY:
|
|
|
|
{
|
|
|
|
/* We need to send the query upstream and add the returned latency to our
|
|
|
|
* own */
|
|
|
|
GstClockTime min_latency, max_latency;
|
2008-06-02 07:37:31 +00:00
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
gboolean us_live;
|
2008-06-02 07:37:31 +00:00
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
GstClockTime our_latency;
|
|
|
|
|
|
|
|
if ((res = gst_pad_peer_query (parse->sinkpad, query))) {
|
|
|
|
gst_query_parse_latency (query, &us_live, &min_latency, &max_latency);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (parse, "Peer latency: min %"
|
|
|
|
GST_TIME_FORMAT " max %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (min_latency), GST_TIME_ARGS (max_latency));
|
|
|
|
|
|
|
|
/* our latency is 1 frame, find the frame duration */
|
|
|
|
our_latency = parse->frame_duration;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (parse, "Our latency: %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (our_latency));
|
|
|
|
|
|
|
|
/* we add some latency */
|
|
|
|
min_latency += our_latency;
|
|
|
|
if (max_latency != -1)
|
|
|
|
max_latency += our_latency;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (parse, "Calculated total latency : min %"
|
|
|
|
GST_TIME_FORMAT " max %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (min_latency), GST_TIME_ARGS (max_latency));
|
|
|
|
|
|
|
|
gst_query_set_latency (query, us_live, min_latency, max_latency);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
res = gst_pad_peer_query (parse->sinkpad, query);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gst_object_unref (parse);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
static void
|
|
|
|
gst_mpeg4vparse_cleanup (GstMpeg4VParse * parse)
|
|
|
|
{
|
2010-11-18 17:59:51 +00:00
|
|
|
if (parse->sink_caps) {
|
|
|
|
gst_caps_unref (parse->sink_caps);
|
|
|
|
parse->sink_caps = NULL;
|
|
|
|
}
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
if (parse->adapter) {
|
|
|
|
gst_adapter_clear (parse->adapter);
|
|
|
|
}
|
2009-05-05 14:54:39 +00:00
|
|
|
if (parse->config != NULL) {
|
|
|
|
gst_buffer_unref (parse->config);
|
|
|
|
parse->config = NULL;
|
|
|
|
}
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
|
2010-11-18 08:09:23 +00:00
|
|
|
if (parse->pending_segment)
|
|
|
|
gst_event_unref (parse->pending_segment);
|
|
|
|
parse->pending_segment = NULL;
|
|
|
|
|
|
|
|
g_list_foreach (parse->pending_events, (GFunc) gst_event_unref, NULL);
|
|
|
|
g_list_free (parse->pending_events);
|
|
|
|
parse->pending_events = NULL;
|
|
|
|
|
|
|
|
parse->have_src_caps = FALSE;
|
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Improved version not damaging headers using a simple state machine.
Original commit message from CVS:
2007-10-27 Julien MOUTTE <julien@moutte.net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_align),
(gst_mpeg4vparse_drain), (gst_mpeg4vparse_chain),
(gst_mpeg4vparse_sink_setcaps), (gst_mpeg4vparse_sink_event),
(gst_mpeg4vparse_cleanup), (gst_mpeg4vparse_change_state),
(gst_mpeg4vparse_dispose), (gst_mpeg4vparse_base_init),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init),
(plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Improved version not
damaging headers using a simple state machine.
2007-10-27 08:20:59 +00:00
|
|
|
parse->state = PARSE_NEED_START;
|
2009-02-26 14:40:26 +00:00
|
|
|
parse->have_config = FALSE;
|
gst/mpeg4videoparse/mpeg4videoparse.*: Improved version not damaging headers using a simple state machine.
Original commit message from CVS:
2007-10-27 Julien MOUTTE <julien@moutte.net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_align),
(gst_mpeg4vparse_drain), (gst_mpeg4vparse_chain),
(gst_mpeg4vparse_sink_setcaps), (gst_mpeg4vparse_sink_event),
(gst_mpeg4vparse_cleanup), (gst_mpeg4vparse_change_state),
(gst_mpeg4vparse_dispose), (gst_mpeg4vparse_base_init),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init),
(plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Improved version not
damaging headers using a simple state machine.
2007-10-27 08:20:59 +00:00
|
|
|
parse->offset = 0;
|
2010-06-15 09:16:34 +00:00
|
|
|
parse->last_report = GST_CLOCK_TIME_NONE;
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_mpeg4vparse_change_state (GstElement * element, GstStateChange transition)
|
|
|
|
{
|
|
|
|
GstMpeg4VParse *parse = GST_MPEG4VIDEOPARSE (element);
|
2008-06-02 07:37:31 +00:00
|
|
|
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
GstStateChangeReturn ret;
|
|
|
|
|
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
|
|
gst_mpeg4vparse_cleanup (parse);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-12-07 14:44:00 +00:00
|
|
|
gst_mpeg4vparse_finalize (GObject * object)
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
{
|
|
|
|
GstMpeg4VParse *parse = GST_MPEG4VIDEOPARSE (object);
|
|
|
|
|
2010-12-07 14:44:00 +00:00
|
|
|
gst_mpeg4vparse_cleanup (parse);
|
|
|
|
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
if (parse->adapter) {
|
|
|
|
g_object_unref (parse->adapter);
|
|
|
|
parse->adapter = NULL;
|
|
|
|
}
|
2010-11-18 08:09:23 +00:00
|
|
|
|
2010-12-07 14:44:00 +00:00
|
|
|
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_mpeg4vparse_base_init (gpointer klass)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&src_template));
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&sink_template));
|
|
|
|
|
2010-03-18 16:30:26 +00:00
|
|
|
gst_element_class_set_details_simple (element_class,
|
|
|
|
"MPEG 4 video elementary stream parser", "Codec/Parser/Video",
|
|
|
|
"Parses MPEG-4 Part 2 elementary video streams",
|
|
|
|
"Julien Moutte <julien@fluendo.com>");
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
}
|
|
|
|
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
static void
|
|
|
|
gst_mpeg4vparse_set_property (GObject * object, guint property_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstMpeg4VParse *parse = GST_MPEG4VIDEOPARSE (object);
|
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_DROP:
|
|
|
|
parse->drop = g_value_get_boolean (value);
|
|
|
|
break;
|
2010-06-15 09:16:34 +00:00
|
|
|
case PROP_CONFIG_INTERVAL:
|
|
|
|
parse->interval = g_value_get_uint (value);
|
|
|
|
break;
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_mpeg4vparse_get_property (GObject * object, guint property_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstMpeg4VParse *parse = GST_MPEG4VIDEOPARSE (object);
|
|
|
|
|
|
|
|
switch (property_id) {
|
|
|
|
case PROP_DROP:
|
|
|
|
g_value_set_boolean (value, parse->drop);
|
|
|
|
break;
|
2010-06-15 09:16:34 +00:00
|
|
|
case PROP_CONFIG_INTERVAL:
|
|
|
|
g_value_set_uint (value, parse->interval);
|
|
|
|
break;
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
static void
|
|
|
|
gst_mpeg4vparse_class_init (GstMpeg4VParseClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
|
|
|
gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
2010-12-07 14:44:00 +00:00
|
|
|
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_mpeg4vparse_finalize);
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = gst_mpeg4vparse_set_property;
|
|
|
|
gobject_class->get_property = gst_mpeg4vparse_get_property;
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_DROP,
|
|
|
|
g_param_spec_boolean ("drop", "drop",
|
|
|
|
"Drop data untill valid configuration data is received either "
|
|
|
|
"in the stream or through caps", DEFAULT_PROP_DROP,
|
2010-10-19 10:43:14 +00:00
|
|
|
G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
|
2010-06-15 09:16:34 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_CONFIG_INTERVAL,
|
|
|
|
g_param_spec_uint ("config-interval",
|
|
|
|
"Configuration Send Interval",
|
|
|
|
"Send Configuration Insertion Interval in seconds (configuration headers "
|
|
|
|
"will be multiplexed in the data stream when detected.) (0 = disabled)",
|
|
|
|
0, 3600, DEFAULT_CONFIG_INTERVAL,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
|
|
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
gstelement_class->change_state =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg4vparse_change_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_mpeg4vparse_init (GstMpeg4VParse * parse, GstMpeg4VParseClass * g_class)
|
|
|
|
{
|
|
|
|
parse->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
|
|
|
|
gst_pad_set_chain_function (parse->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg4vparse_chain));
|
|
|
|
gst_pad_set_event_function (parse->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg4vparse_sink_event));
|
|
|
|
gst_pad_set_setcaps_function (parse->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg4vparse_sink_setcaps));
|
|
|
|
gst_element_add_pad (GST_ELEMENT (parse), parse->sinkpad);
|
|
|
|
|
|
|
|
parse->srcpad = gst_pad_new_from_static_template (&src_template, "src");
|
gst/mpeg4videoparse/mpeg4videoparse.*: Parse the config data (either outbound or in the stream) to set width/height, ...
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_set_new_caps), (gst_mpeg4vparse_align),
(get_bits), (next_start_code), (gst_mpeg4vparse_handle_vos),
(gst_mpeg4vparse_push), (gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_src_query),
(gst_mpeg4vparse_set_property), (gst_mpeg4vparse_get_property),
(gst_mpeg4vparse_class_init), (gst_mpeg4vparse_init):
* gst/mpeg4videoparse/mpeg4videoparse.h:
Parse the config data (either outbound or in the stream) to set
width/height, apect ration, framerate in the caps if applicable.
Mark frames as GST_BUFFER_FLAG_DELTA_UNIT when they are not
intra frames
Set the timestamps of outgoing buffers to the buffer in
which the VOP header was found.
Drop incoming data untill configuration is found (by default,
configurable using a property).
Report a 1 frame latency. Fixes #532723.
2008-05-13 17:21:07 +00:00
|
|
|
gst_pad_set_query_function (parse->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mpeg4vparse_src_query));
|
2008-05-14 20:57:31 +00:00
|
|
|
gst_pad_use_fixed_caps (parse->srcpad);
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (parse), parse->srcpad);
|
|
|
|
|
|
|
|
parse->adapter = gst_adapter_new ();
|
|
|
|
|
2010-06-15 09:16:34 +00:00
|
|
|
parse->interval = DEFAULT_CONFIG_INTERVAL;
|
|
|
|
parse->last_report = GST_CLOCK_TIME_NONE;
|
|
|
|
|
Add a simple MPEG4 ES parser.
Original commit message from CVS:
2007-10-26 Julien MOUTTE <julien@moutte.net>
* configure.ac:
* gst/mpeg4videoparse/Makefile.am:
* gst/mpeg4videoparse/mpeg4videoparse.c:
(gst_mpeg4vparse_drain),
(gst_mpeg4vparse_chain), (gst_mpeg4vparse_sink_setcaps),
(gst_mpeg4vparse_sink_event), (gst_mpeg4vparse_cleanup),
(gst_mpeg4vparse_change_state), (gst_mpeg4vparse_dispose),
(gst_mpeg4vparse_base_init), (gst_mpeg4vparse_class_init),
(gst_mpeg4vparse_init), (plugin_init):
* gst/mpeg4videoparse/mpeg4videoparse.h: Add a simple MPEG4 ES
parser.
2007-10-26 16:08:04 +00:00
|
|
|
gst_mpeg4vparse_cleanup (parse);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
plugin_init (GstPlugin * plugin)
|
|
|
|
{
|
|
|
|
GST_DEBUG_CATEGORY_INIT (mpeg4v_parse_debug, "mpeg4videoparse", 0,
|
|
|
|
"MPEG-4 video parser");
|
|
|
|
|
|
|
|
if (!gst_element_register (plugin, "mpeg4videoparse", GST_RANK_SECONDARY,
|
|
|
|
gst_mpeg4vparse_get_type ()))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"mpeg4videoparse",
|
|
|
|
"MPEG-4 video parser",
|
|
|
|
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|