2010-05-13 20:38:03 +00:00
|
|
|
/* GStreamer H.263 Parser
|
|
|
|
* Copyright (C) <2010> Arun Raghavan <arun.raghavan@collabora.co.uk>
|
|
|
|
* Copyright (C) <2010> Edward Hervey <edward.hervey@collabora.co.uk>
|
|
|
|
* Copyright (C) <2010> Collabora Multimedia
|
|
|
|
* Copyright (C) <2010> Nokia Corporation
|
|
|
|
*
|
|
|
|
* Some bits C-c,C-v'ed and s/4/3 from h264parse:
|
|
|
|
* (C) 2005 Michal Benes <michal.benes@itonis.tv>
|
|
|
|
* (C) 2008 Wim Taymans <wim.taymans@gmail.com>
|
|
|
|
* (C) 2009 Mark Nauwelaerts <mnauw users sf net>
|
|
|
|
*
|
|
|
|
* 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
|
2012-11-03 20:38:00 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2010-05-13 20:38:03 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gst/base/gstbytereader.h>
|
|
|
|
#include "gsth263parse.h"
|
|
|
|
|
2012-02-13 17:44:01 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2010-05-13 20:38:03 +00:00
|
|
|
GST_DEBUG_CATEGORY (h263_parse_debug);
|
2011-01-06 11:34:12 +00:00
|
|
|
#define GST_CAT_DEFAULT h263_parse_debug
|
2010-05-13 20:38:03 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate srctemplate =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("video/x-h263, variant = (string) itu, "
|
2011-09-07 09:27:56 +00:00
|
|
|
"parsed = (boolean) true, framerate=(fraction)[0/1,MAX]")
|
2010-05-13 20:38:03 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate sinktemplate =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2011-09-07 09:22:07 +00:00
|
|
|
GST_STATIC_CAPS ("video/x-h263, variant = (string) itu")
|
2010-05-13 20:38:03 +00:00
|
|
|
);
|
|
|
|
|
2012-02-15 12:39:29 +00:00
|
|
|
#define parent_class gst_h263_parse_parent_class
|
2011-11-24 11:01:48 +00:00
|
|
|
G_DEFINE_TYPE (GstH263Parse, gst_h263_parse, GST_TYPE_BASE_PARSE);
|
2010-05-13 20:38:03 +00:00
|
|
|
|
|
|
|
static gboolean gst_h263_parse_start (GstBaseParse * parse);
|
|
|
|
static gboolean gst_h263_parse_stop (GstBaseParse * parse);
|
|
|
|
static gboolean gst_h263_parse_sink_event (GstBaseParse * parse,
|
|
|
|
GstEvent * event);
|
2012-02-13 17:44:01 +00:00
|
|
|
static GstFlowReturn gst_h263_parse_handle_frame (GstBaseParse * parse,
|
|
|
|
GstBaseParseFrame * frame, gint * skipsize);
|
2011-11-25 11:48:58 +00:00
|
|
|
static GstCaps *gst_h263_parse_get_sink_caps (GstBaseParse * parse,
|
|
|
|
GstCaps * filter);
|
2010-05-13 20:38:03 +00:00
|
|
|
|
|
|
|
static void
|
2011-11-24 11:01:48 +00:00
|
|
|
gst_h263_parse_class_init (GstH263ParseClass * klass)
|
2010-05-13 20:38:03 +00:00
|
|
|
{
|
2011-11-24 11:01:48 +00:00
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
GstBaseParseClass *parse_class = GST_BASE_PARSE_CLASS (klass);
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (h263_parse_debug, "h263parse", 0, "h263 parser");
|
2010-05-13 20:38:03 +00:00
|
|
|
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&srctemplate));
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&sinktemplate));
|
2012-10-17 16:34:26 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class, "H.263 parser",
|
2010-05-13 20:38:03 +00:00
|
|
|
"Codec/Parser/Video",
|
|
|
|
"Parses H.263 streams",
|
|
|
|
"Arun Raghavan <arun.raghavan@collabora.co.uk>,"
|
|
|
|
"Edward Hervey <edward.hervey@collabora.co.uk>");
|
|
|
|
|
|
|
|
/* Override BaseParse vfuncs */
|
|
|
|
parse_class->start = GST_DEBUG_FUNCPTR (gst_h263_parse_start);
|
|
|
|
parse_class->stop = GST_DEBUG_FUNCPTR (gst_h263_parse_stop);
|
2012-03-30 10:02:16 +00:00
|
|
|
parse_class->sink_event = GST_DEBUG_FUNCPTR (gst_h263_parse_sink_event);
|
2012-02-13 17:44:01 +00:00
|
|
|
parse_class->handle_frame = GST_DEBUG_FUNCPTR (gst_h263_parse_handle_frame);
|
2011-11-24 09:09:59 +00:00
|
|
|
parse_class->get_sink_caps = GST_DEBUG_FUNCPTR (gst_h263_parse_get_sink_caps);
|
2010-05-13 20:38:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-24 11:01:48 +00:00
|
|
|
gst_h263_parse_init (GstH263Parse * h263parse)
|
2010-05-13 20:38:03 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_h263_parse_start (GstBaseParse * parse)
|
|
|
|
{
|
2011-01-06 11:34:12 +00:00
|
|
|
GstH263Parse *h263parse = GST_H263_PARSE (parse);
|
2010-05-13 20:38:03 +00:00
|
|
|
|
2011-09-19 12:54:11 +00:00
|
|
|
GST_DEBUG_OBJECT (h263parse, "start");
|
2010-05-13 20:38:03 +00:00
|
|
|
|
|
|
|
h263parse->bitrate = 0;
|
|
|
|
h263parse->profile = -1;
|
|
|
|
h263parse->level = -1;
|
|
|
|
|
|
|
|
h263parse->state = PARSING;
|
|
|
|
|
2011-05-17 20:42:45 +00:00
|
|
|
gst_base_parse_set_min_frame_size (parse, 4);
|
2010-05-13 20:38:03 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_h263_parse_stop (GstBaseParse * parse)
|
|
|
|
{
|
2011-09-19 12:54:11 +00:00
|
|
|
GST_DEBUG_OBJECT (parse, "stop");
|
2010-05-13 20:38:03 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_h263_parse_sink_event (GstBaseParse * parse, GstEvent * event)
|
|
|
|
{
|
|
|
|
GstH263Parse *h263parse;
|
|
|
|
|
2011-01-06 11:34:12 +00:00
|
|
|
h263parse = GST_H263_PARSE (parse);
|
2010-05-13 20:38:03 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_TAG:
|
|
|
|
{
|
|
|
|
GstTagList *taglist;
|
|
|
|
|
|
|
|
gst_event_parse_tag (event, &taglist);
|
|
|
|
|
|
|
|
if (gst_tag_list_get_uint (taglist, GST_TAG_BITRATE, &h263parse->bitrate))
|
2011-09-19 12:54:11 +00:00
|
|
|
GST_DEBUG_OBJECT (h263parse, "got bitrate tag: %u", h263parse->bitrate);
|
2010-05-13 20:38:03 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-03-30 10:02:16 +00:00
|
|
|
return GST_BASE_PARSE_CLASS (parent_class)->sink_event (parse, event);
|
2010-05-13 20:38:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static guint
|
|
|
|
find_psc (GstBuffer * buffer, guint skip)
|
|
|
|
{
|
2012-01-25 15:20:41 +00:00
|
|
|
GstMapInfo map;
|
2010-05-13 20:38:03 +00:00
|
|
|
GstByteReader br;
|
|
|
|
guint psc_pos = -1, psc;
|
|
|
|
|
2012-01-25 15:20:41 +00:00
|
|
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
|
|
|
gst_byte_reader_init (&br, map.data, map.size);
|
2010-05-13 20:38:03 +00:00
|
|
|
|
|
|
|
if (!gst_byte_reader_set_pos (&br, skip))
|
|
|
|
goto out;
|
|
|
|
|
2012-03-10 22:10:52 +00:00
|
|
|
if (gst_byte_reader_peek_uint24_be (&br, &psc) == FALSE)
|
|
|
|
goto out;
|
2010-05-13 20:38:03 +00:00
|
|
|
|
|
|
|
/* Scan for the picture start code (22 bits - 0x0020) */
|
|
|
|
while ((gst_byte_reader_get_remaining (&br) >= 3)) {
|
|
|
|
if (gst_byte_reader_peek_uint24_be (&br, &psc) &&
|
|
|
|
((psc & 0xffffc0) == 0x000080)) {
|
|
|
|
psc_pos = gst_byte_reader_get_pos (&br);
|
|
|
|
break;
|
2012-03-10 22:10:52 +00:00
|
|
|
} else if (gst_byte_reader_skip (&br, 1) == FALSE)
|
|
|
|
break;
|
2010-05-13 20:38:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2012-01-25 15:20:41 +00:00
|
|
|
gst_buffer_unmap (buffer, &map);
|
2010-05-13 20:38:03 +00:00
|
|
|
return psc_pos;
|
|
|
|
}
|
|
|
|
|
2011-01-06 11:29:34 +00:00
|
|
|
static void
|
2011-03-03 00:57:09 +00:00
|
|
|
gst_h263_parse_set_src_caps (GstH263Parse * h263parse,
|
|
|
|
const H263Params * params)
|
2011-01-06 11:29:34 +00:00
|
|
|
{
|
2013-07-15 21:57:06 +00:00
|
|
|
GstStructure *st = NULL;
|
2011-01-06 11:29:34 +00:00
|
|
|
GstCaps *caps, *sink_caps;
|
2013-07-15 21:57:06 +00:00
|
|
|
gint fr_num, fr_denom, par_num, par_denom;
|
2011-01-06 11:29:34 +00:00
|
|
|
|
|
|
|
g_assert (h263parse->state == PASSTHROUGH || h263parse->state == GOT_HEADER);
|
|
|
|
|
2011-11-24 11:01:48 +00:00
|
|
|
caps = gst_pad_get_current_caps (GST_BASE_PARSE_SINK_PAD (h263parse));
|
2011-01-06 11:29:34 +00:00
|
|
|
if (caps) {
|
2011-11-24 11:01:48 +00:00
|
|
|
caps = gst_caps_make_writable (caps);
|
2011-01-06 11:29:34 +00:00
|
|
|
} else {
|
|
|
|
caps = gst_caps_new_simple ("video/x-h263",
|
|
|
|
"variant", G_TYPE_STRING, "itu", NULL);
|
|
|
|
}
|
|
|
|
gst_caps_set_simple (caps, "parsed", G_TYPE_BOOLEAN, TRUE, NULL);
|
|
|
|
|
2011-11-24 11:01:48 +00:00
|
|
|
sink_caps = gst_pad_get_current_caps (GST_BASE_PARSE_SINK_PAD (h263parse));
|
2011-01-06 11:29:34 +00:00
|
|
|
if (sink_caps && (st = gst_caps_get_structure (sink_caps, 0)) &&
|
|
|
|
gst_structure_get_fraction (st, "framerate", &fr_num, &fr_denom)) {
|
|
|
|
/* Got it in caps - nothing more to do */
|
2011-09-19 12:54:11 +00:00
|
|
|
GST_DEBUG_OBJECT (h263parse, "sink caps override framerate from headers");
|
2011-01-06 11:29:34 +00:00
|
|
|
} else {
|
|
|
|
/* Caps didn't have the framerate - get it from params */
|
|
|
|
gst_h263_parse_get_framerate (params, &fr_num, &fr_denom);
|
|
|
|
}
|
|
|
|
gst_caps_set_simple (caps, "framerate", GST_TYPE_FRACTION, fr_num, fr_denom,
|
|
|
|
NULL);
|
|
|
|
|
2011-05-24 19:50:52 +00:00
|
|
|
if (params->width && params->height)
|
|
|
|
gst_caps_set_simple (caps, "width", G_TYPE_INT, params->width,
|
|
|
|
"height", G_TYPE_INT, params->height, NULL);
|
|
|
|
|
2013-07-15 21:57:06 +00:00
|
|
|
if (st != NULL
|
|
|
|
&& gst_structure_get_fraction (st, "pixel-aspect-ratio", &par_num,
|
|
|
|
&par_denom)) {
|
|
|
|
/* Got it in caps - nothing more to do */
|
|
|
|
GST_DEBUG_OBJECT (h263parse, "sink caps override PAR");
|
|
|
|
} else {
|
|
|
|
/* Caps didn't have the framerate - get it from params */
|
|
|
|
gst_h263_parse_get_par (params, &par_num, &par_denom);
|
|
|
|
}
|
|
|
|
gst_caps_set_simple (caps, "pixel-aspect-ratio", GST_TYPE_FRACTION,
|
|
|
|
par_num, par_denom, NULL);
|
|
|
|
|
2011-01-06 11:29:34 +00:00
|
|
|
if (h263parse->state == GOT_HEADER) {
|
|
|
|
gst_caps_set_simple (caps,
|
|
|
|
"annex-d", G_TYPE_BOOLEAN, (params->features & H263_OPTION_UMV_MODE),
|
|
|
|
"annex-e", G_TYPE_BOOLEAN, (params->features & H263_OPTION_SAC_MODE),
|
|
|
|
"annex-f", G_TYPE_BOOLEAN, (params->features & H263_OPTION_AP_MODE),
|
|
|
|
"annex-g", G_TYPE_BOOLEAN, (params->features & H263_OPTION_PB_MODE),
|
|
|
|
"annex-i", G_TYPE_BOOLEAN, (params->features & H263_OPTION_AIC_MODE),
|
|
|
|
"annex-j", G_TYPE_BOOLEAN, (params->features & H263_OPTION_DF_MODE),
|
|
|
|
"annex-k", G_TYPE_BOOLEAN, (params->features & H263_OPTION_SS_MODE),
|
|
|
|
"annex-m", G_TYPE_BOOLEAN, (params->type == PICTURE_IMPROVED_PB),
|
|
|
|
"annex-n", G_TYPE_BOOLEAN, (params->features & H263_OPTION_RPS_MODE),
|
|
|
|
"annex-q", G_TYPE_BOOLEAN, (params->features & H263_OPTION_RRU_MODE),
|
|
|
|
"annex-r", G_TYPE_BOOLEAN, (params->features & H263_OPTION_ISD_MODE),
|
|
|
|
"annex-s", G_TYPE_BOOLEAN, (params->features & H263_OPTION_AIV_MODE),
|
|
|
|
"annex-t", G_TYPE_BOOLEAN, (params->features & H263_OPTION_MQ_MODE),
|
|
|
|
"annex-u", G_TYPE_BOOLEAN, (params->features & H263_OPTION_ERPS_MODE),
|
|
|
|
"annex-v", G_TYPE_BOOLEAN, (params->features & H263_OPTION_DPS_MODE),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
h263parse->profile = gst_h263_parse_get_profile (params);
|
2012-01-22 19:11:21 +00:00
|
|
|
if (h263parse->profile != -1) {
|
|
|
|
gchar *profile_str;
|
|
|
|
|
|
|
|
profile_str = g_strdup_printf ("%u", h263parse->profile);
|
|
|
|
gst_caps_set_simple (caps, "profile", G_TYPE_STRING, profile_str, NULL);
|
|
|
|
g_free (profile_str);
|
|
|
|
}
|
2011-01-06 11:29:34 +00:00
|
|
|
|
|
|
|
h263parse->level = gst_h263_parse_get_level (params, h263parse->profile,
|
|
|
|
h263parse->bitrate, fr_num, fr_denom);
|
2012-01-22 19:11:21 +00:00
|
|
|
if (h263parse->level != -1) {
|
|
|
|
gchar *level_str;
|
|
|
|
|
|
|
|
level_str = g_strdup_printf ("%u", h263parse->level);
|
|
|
|
gst_caps_set_simple (caps, "level", G_TYPE_STRING, level_str, NULL);
|
|
|
|
g_free (level_str);
|
|
|
|
}
|
2011-01-06 11:29:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (GST_BASE_PARSE (h263parse)), caps);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
}
|
|
|
|
|
2012-02-13 17:44:01 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_h263_parse_handle_frame (GstBaseParse * parse,
|
|
|
|
GstBaseParseFrame * frame, gint * skipsize)
|
2010-05-13 20:38:03 +00:00
|
|
|
{
|
|
|
|
GstH263Parse *h263parse;
|
2011-01-27 17:03:50 +00:00
|
|
|
GstBuffer *buffer;
|
2010-12-10 15:26:27 +00:00
|
|
|
guint psc_pos, next_psc_pos;
|
2011-11-24 11:01:48 +00:00
|
|
|
gsize size;
|
2012-02-13 17:44:01 +00:00
|
|
|
H263Params params = { 0, };
|
|
|
|
GstFlowReturn res = GST_FLOW_OK;
|
2010-05-13 20:38:03 +00:00
|
|
|
|
2011-01-06 11:34:12 +00:00
|
|
|
h263parse = GST_H263_PARSE (parse);
|
2011-01-27 17:03:50 +00:00
|
|
|
buffer = frame->buffer;
|
2011-11-24 11:01:48 +00:00
|
|
|
size = gst_buffer_get_size (buffer);
|
2011-01-06 11:34:12 +00:00
|
|
|
|
2012-02-13 17:44:01 +00:00
|
|
|
if (size < 3) {
|
|
|
|
*skipsize = 1;
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
2010-05-13 20:38:03 +00:00
|
|
|
|
2010-12-10 15:26:27 +00:00
|
|
|
psc_pos = find_psc (buffer, 0);
|
2010-05-13 20:38:03 +00:00
|
|
|
|
|
|
|
if (psc_pos == -1) {
|
|
|
|
/* PSC not found, need more data */
|
2011-11-24 11:01:48 +00:00
|
|
|
if (size > 3)
|
|
|
|
psc_pos = size - 3;
|
2010-12-10 15:26:27 +00:00
|
|
|
else
|
|
|
|
psc_pos = 0;
|
2010-05-13 20:38:03 +00:00
|
|
|
goto more;
|
|
|
|
}
|
|
|
|
|
2012-02-13 17:44:01 +00:00
|
|
|
/* need to skip */
|
|
|
|
if (psc_pos > 0)
|
|
|
|
goto more;
|
|
|
|
|
2010-12-10 15:26:27 +00:00
|
|
|
/* Found the start of the frame, now try to find the end */
|
|
|
|
next_psc_pos = psc_pos + 3;
|
|
|
|
next_psc_pos = find_psc (buffer, next_psc_pos);
|
2010-05-13 20:38:03 +00:00
|
|
|
|
2010-12-10 15:26:27 +00:00
|
|
|
if (next_psc_pos == -1) {
|
2011-04-02 17:30:22 +00:00
|
|
|
if (GST_BASE_PARSE_DRAINING (parse))
|
2010-12-10 15:26:27 +00:00
|
|
|
/* FLUSH/EOS, it's okay if we can't find the next frame */
|
2011-11-24 11:01:48 +00:00
|
|
|
next_psc_pos = size;
|
2010-12-10 15:26:27 +00:00
|
|
|
else
|
|
|
|
goto more;
|
2010-05-13 20:38:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* We should now have a complete frame */
|
|
|
|
|
|
|
|
/* If this is the first frame, parse and set srcpad caps */
|
|
|
|
if (h263parse->state == PARSING) {
|
2011-01-06 11:29:34 +00:00
|
|
|
res = gst_h263_parse_get_params (¶ms, buffer, FALSE, &h263parse->state);
|
2010-05-13 20:38:03 +00:00
|
|
|
if (res != GST_FLOW_OK || h263parse->state != GOT_HEADER) {
|
|
|
|
GST_WARNING ("Couldn't parse header - setting passthrough mode");
|
2011-04-02 17:30:22 +00:00
|
|
|
gst_base_parse_set_passthrough (parse, TRUE);
|
2010-05-13 20:38:03 +00:00
|
|
|
} else {
|
|
|
|
/* Set srcpad caps since we now have sufficient information to do so */
|
2011-03-03 00:57:09 +00:00
|
|
|
gst_h263_parse_set_src_caps (h263parse, ¶ms);
|
2011-04-02 17:30:22 +00:00
|
|
|
gst_base_parse_set_passthrough (parse, FALSE);
|
2010-05-13 20:38:03 +00:00
|
|
|
}
|
2012-02-13 17:44:01 +00:00
|
|
|
memset (¶ms, 0, sizeof (params));
|
2010-05-13 20:38:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX: After getting a keyframe, should we adjust min_frame_size to
|
|
|
|
* something smaller so we don't end up collecting too many non-keyframes? */
|
|
|
|
|
2012-02-13 17:44:01 +00:00
|
|
|
GST_DEBUG_OBJECT (h263parse, "found a frame of size %u at pos %u",
|
|
|
|
next_psc_pos, psc_pos);
|
2010-05-13 20:38:03 +00:00
|
|
|
|
2011-01-06 11:29:34 +00:00
|
|
|
res = gst_h263_parse_get_params (¶ms, buffer, TRUE, &h263parse->state);
|
2010-05-13 20:38:03 +00:00
|
|
|
if (res != GST_FLOW_OK)
|
2012-02-13 17:44:01 +00:00
|
|
|
goto more;
|
2010-05-13 20:38:03 +00:00
|
|
|
|
|
|
|
if (h263parse->state == PASSTHROUGH || h263parse->state == PARSING) {
|
|
|
|
/* There's a feature we don't support, or we didn't have enough data to
|
|
|
|
* parse the header, which should not be possible. Either way, go into
|
|
|
|
* passthrough mode and let downstream handle it if it can. */
|
|
|
|
GST_WARNING ("Couldn't parse header - setting passthrough mode");
|
2011-04-02 17:30:22 +00:00
|
|
|
gst_base_parse_set_passthrough (parse, TRUE);
|
2012-02-13 17:44:01 +00:00
|
|
|
goto more;
|
2010-05-13 20:38:03 +00:00
|
|
|
}
|
|
|
|
|
2011-03-03 00:57:09 +00:00
|
|
|
if (gst_h263_parse_is_delta_unit (¶ms))
|
2010-05-13 20:38:03 +00:00
|
|
|
GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
|
|
|
|
else
|
|
|
|
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
|
|
|
|
|
2012-02-13 17:44:01 +00:00
|
|
|
return gst_base_parse_finish_frame (parse, frame, next_psc_pos);
|
|
|
|
|
|
|
|
more:
|
|
|
|
*skipsize = psc_pos;
|
2011-03-03 00:57:09 +00:00
|
|
|
|
2010-05-13 20:38:03 +00:00
|
|
|
return res;
|
|
|
|
}
|
2011-11-24 09:09:59 +00:00
|
|
|
|
|
|
|
static GstCaps *
|
2011-11-25 11:48:58 +00:00
|
|
|
gst_h263_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
|
2011-11-24 09:09:59 +00:00
|
|
|
{
|
2012-06-05 07:30:00 +00:00
|
|
|
GstCaps *peercaps, *templ;
|
2011-11-24 09:09:59 +00:00
|
|
|
GstCaps *res;
|
|
|
|
|
2012-06-05 07:30:00 +00:00
|
|
|
templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse));
|
2012-12-17 14:04:44 +00:00
|
|
|
peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), filter);
|
2012-06-05 07:30:00 +00:00
|
|
|
|
2011-11-24 09:09:59 +00:00
|
|
|
if (peercaps) {
|
|
|
|
guint i, n;
|
|
|
|
|
|
|
|
/* Remove parsed field */
|
|
|
|
peercaps = gst_caps_make_writable (peercaps);
|
|
|
|
n = gst_caps_get_size (peercaps);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
GstStructure *s = gst_caps_get_structure (peercaps, i);
|
|
|
|
gst_structure_remove_field (s, "parsed");
|
|
|
|
}
|
|
|
|
|
2012-06-05 07:30:00 +00:00
|
|
|
res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
|
2011-11-24 09:09:59 +00:00
|
|
|
gst_caps_unref (peercaps);
|
2012-12-17 14:16:48 +00:00
|
|
|
res = gst_caps_make_writable (res);
|
2012-06-05 07:30:00 +00:00
|
|
|
|
|
|
|
/* Append the template caps because we still want to accept
|
|
|
|
* caps without any fields in the case upstream does not
|
|
|
|
* know anything.
|
|
|
|
*/
|
|
|
|
gst_caps_append (res, templ);
|
2011-11-24 09:09:59 +00:00
|
|
|
} else {
|
2012-06-05 07:30:00 +00:00
|
|
|
res = templ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filter) {
|
|
|
|
GstCaps *intersection;
|
|
|
|
|
|
|
|
intersection =
|
|
|
|
gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST);
|
|
|
|
gst_caps_unref (res);
|
|
|
|
res = intersection;
|
2011-11-24 09:09:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|