/* GStreamer
- * Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
+ * Copyright (C) <2005> Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
#include <gst/rtp/gstrtpbuffer.h>
#include "gstrtph263pdepay.h"
-/* elementfactory information */
-static const GstElementDetails gst_rtp_h263pdepay_details =
-GST_ELEMENT_DETAILS ("RTP packet depayloader",
- "Codec/Depayloader/Network",
- "Extracts H263/+/++ video from RTP packets (RFC 4629)",
- "Wim Taymans <wim@fluendo.com>");
-
static GstStaticPadTemplate gst_rtp_h263p_depay_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_STATIC_CAPS ("application/x-rtp, "
"media = (string) \"video\", "
"payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
- "clock-rate = (int) 90000, " "encoding-name = (string) \"H263-1998\"; "
+ "clock-rate = (int) [1, MAX], "
+ "encoding-name = (string) \"H263-1998\"; "
/* optional params */
/* NOTE all optional SDP params must be strings in the caps */
/*
"application/x-rtp, "
"media = (string) \"video\", "
"payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
- "clock-rate = (int) 90000, " "encoding-name = (string) \"H263-2000\" "
+ "clock-rate = (int) [1, MAX], "
+ "encoding-name = (string) \"H263-2000\" "
/* optional params */
/* NOTE all optional SDP params must be strings in the caps */
/*
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rtp_h263p_depay_src_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rtp_h263p_depay_sink_template));
+ gst_element_class_add_static_pad_template (element_class,
+ &gst_rtp_h263p_depay_src_template);
+ gst_element_class_add_static_pad_template (element_class,
+ &gst_rtp_h263p_depay_sink_template);
- gst_element_class_set_details (element_class, &gst_rtp_h263pdepay_details);
+ gst_element_class_set_details_simple (element_class, "RTP H263 depayloader",
+ "Codec/Depayloader/Network/RTP",
+ "Extracts H263/+/++ video from RTP packets (RFC 4629)",
+ "Wim Taymans <wim.taymans@gmail.com>");
}
static void
gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
- parent_class = g_type_class_peek_parent (klass);
-
gstbasertpdepayload_class->process = gst_rtp_h263p_depay_process;
gstbasertpdepayload_class->set_caps = gst_rtp_h263p_depay_setcaps;
{
GstCaps *srccaps = NULL;
GstStructure *structure = gst_caps_get_structure (caps, 0);
- gint clock_rate = 90000; /* default */
+ gint clock_rate;
const gchar *encoding_name = NULL;
+ gboolean res;
- gst_structure_get_int (structure, "clock-rate", &clock_rate);
+ if (!gst_structure_get_int (structure, "clock-rate", &clock_rate))
+ clock_rate = 90000; /* default */
filter->clock_rate = clock_rate;
encoding_name = gst_structure_get_string (structure, "encoding-name");
F = gst_structure_get_string (structure, "f");
if (F)
- if (g_strcasecmp (F, "1") == 0)
+ if (g_ascii_strcasecmp (F, "1") == 0)
is_h263p = TRUE;
I = gst_structure_get_string (structure, "i");
if (I)
- if (g_strcasecmp (I, "1") == 0)
+ if (g_ascii_strcasecmp (I, "1") == 0)
is_h263p = TRUE;
J = gst_structure_get_string (structure, "j");
if (J)
- if (g_strcasecmp (J, "1") == 0)
+ if (g_ascii_strcasecmp (J, "1") == 0)
is_h263p = TRUE;
T = gst_structure_get_string (structure, "t");
if (T)
- if (g_strcasecmp (T, "1") == 0)
+ if (g_ascii_strcasecmp (T, "1") == 0)
is_h263p = TRUE;
K = gst_structure_get_string (structure, "k");
if (K)
if (!srccaps)
goto no_caps;
- gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (filter), srccaps);
+ res = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (filter), srccaps);
gst_caps_unref (srccaps);
- return TRUE;
+ return res;
/* ERRORS */
no_encoding_name:
static GstBuffer *
gst_rtp_h263p_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
{
-
GstRtpH263PDepay *rtph263pdepay;
GstBuffer *outbuf;
rtph263pdepay = GST_RTP_H263P_DEPAY (depayload);
- if (!gst_rtp_buffer_validate (buf))
- goto bad_packet;
-
/* flush remaining data on discont */
if (GST_BUFFER_IS_DISCONT (buf)) {
+ GST_LOG_OBJECT (depayload, "DISCONT, flushing adapter");
gst_adapter_clear (rtph263pdepay->adapter);
rtph263pdepay->wait_start = TRUE;
}
gint payload_len;
guint8 *payload;
gboolean P, V, M;
- guint32 timestamp;
guint header_len;
guint8 PLEN, PEBIT;
header_len = 2;
if (payload_len < header_len)
- goto bad_packet;
+ goto too_small;
M = gst_rtp_buffer_get_marker (buf);
PLEN = ((payload[0] & 0x1) << 5) | (payload[1] >> 3);
PEBIT = payload[1] & 0x7;
+ GST_LOG_OBJECT (depayload, "P %d, V %d, PLEN %d, PEBIT %d", P, V, PLEN,
+ PEBIT);
+
if (V) {
header_len++;
}
}
if ((!P && payload_len < header_len) || (P && payload_len < header_len - 2))
- goto bad_packet;
+ goto too_small;
if (P) {
+ /* FIXME, have to make the packet writable hear. Better to reset these
+ * bytes when we copy the packet below */
rtph263pdepay->wait_start = FALSE;
header_len -= 2;
payload[header_len] = 0;
if (rtph263pdepay->wait_start)
goto waiting_start;
+ if (payload_len < header_len)
+ goto too_small;
+
/* FIXME do not ignore the VRC header (See RFC 2429 section 4.2) */
/* FIXME actually use the RTP picture header when it is lost in the network */
/* for now strip off header */
payload += header_len;
payload_len -= header_len;
- timestamp = gst_rtp_buffer_get_timestamp (buf);
-
if (M) {
/* frame is completed: append to previous, push it out */
guint len, padlen;
guint avail;
+ GST_LOG_OBJECT (depayload, "Frame complete");
+
avail = gst_adapter_available (rtph263pdepay->adapter);
len = avail + payload_len;
/* frame not completed: store in adapter */
outbuf = gst_buffer_new_and_alloc (payload_len);
+ GST_LOG_OBJECT (depayload, "Frame incomplete, storing %d", payload_len);
+
memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
gst_adapter_push (rtph263pdepay->adapter, outbuf);
}
return NULL;
-bad_packet:
+too_small:
{
GST_ELEMENT_WARNING (rtph263pdepay, STREAM, DECODE,
- ("Packet did not validate"), (NULL));
+ ("Packet payload was too small"), (NULL));
return NULL;
}
waiting_start:
gst_rtp_h263p_depay_plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "rtph263pdepay",
- GST_RANK_MARGINAL, GST_TYPE_RTP_H263P_DEPAY);
+ GST_RANK_SECONDARY, GST_TYPE_RTP_H263P_DEPAY);
}