summaryrefslogtreecommitdiffstats
path: root/gst/rtp/gstrtpmpadepay.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2007-01-09 12:23:48 +0000
committerWim Taymans <wim.taymans@gmail.com>2007-01-09 12:23:48 +0000
commit42b8b3a37f5ab9cda3dc63b362d4f59ec0b8109a (patch)
tree58d30cb635777c1b409c7e765fc235e774627410 /gst/rtp/gstrtpmpadepay.c
parentfd185066571a02bb59228df7df9b4f717f81a6fd (diff)
gst/rtp/: Added RFC 2250 MPEG Video Depayloader.
Original commit message from CVS: * gst/rtp/Makefile.am: * gst/rtp/gstrtp.c: (plugin_init): * gst/rtp/gstrtpmpvdepay.c: (gst_rtp_mpv_depay_base_init), (gst_rtp_mpv_depay_class_init), (gst_rtp_mpv_depay_init), (gst_rtp_mpv_depay_setcaps), (gst_rtp_mpv_depay_process), (gst_rtp_mpv_depay_set_property), (gst_rtp_mpv_depay_get_property), (gst_rtp_mpv_depay_change_state), (gst_rtp_mpv_depay_plugin_init): * gst/rtp/gstrtpmpvdepay.h: Added RFC 2250 MPEG Video Depayloader. * gst/rtp/gstrtpL16depay.h: * gst/rtp/gstrtph263pdepay.c: (gst_rtp_h263p_depay_setcaps), (gst_rtp_h263p_depay_process): Fix Header file. Small cleanups. * gst/rtp/gstrtpmp4gdepay.c: (gst_rtp_mp4g_depay_class_init), (gst_rtp_mp4g_depay_init), (gst_rtp_mp4g_depay_finalize), (gst_rtp_mp4g_depay_process), (gst_rtp_mp4g_depay_change_state): * gst/rtp/gstrtpmp4vdepay.c: (gst_rtp_mp4v_depay_class_init), (gst_rtp_mp4v_depay_init), (gst_rtp_mp4v_depay_finalize), (gst_rtp_mp4v_depay_setcaps), (gst_rtp_mp4v_depay_process), (gst_rtp_mp4v_depay_change_state): Remove usused code. Remove Adapter from state Change. Added debug. * gst/rtp/gstrtpmpadepay.c: (gst_rtp_mpa_depay_base_init), (gst_rtp_mpa_depay_class_init), (gst_rtp_mpa_depay_init), (gst_rtp_mpa_depay_setcaps), (gst_rtp_mpa_depay_process): * gst/rtp/gstrtpmpadepay.h: Subclass base depayloader. Added debug. Support static payload type assignment as well. * gst/rtp/gstrtpmpapay.c: Fix caps.
Diffstat (limited to 'gst/rtp/gstrtpmpadepay.c')
-rw-r--r--gst/rtp/gstrtpmpadepay.c127
1 files changed, 59 insertions, 68 deletions
diff --git a/gst/rtp/gstrtpmpadepay.c b/gst/rtp/gstrtpmpadepay.c
index bce5e005..0fb9409b 100644
--- a/gst/rtp/gstrtpmpadepay.c
+++ b/gst/rtp/gstrtpmpadepay.c
@@ -26,6 +26,9 @@
#include <string.h>
#include "gstrtpmpadepay.h"
+GST_DEBUG_CATEGORY_STATIC (rtpmpadepay_debug);
+#define GST_CAT_DEFAULT (rtpmpadepay_debug)
+
/* elementfactory information */
static const GstElementDetails gst_rtp_mpadepay_details =
GST_ELEMENT_DETAILS ("RTP packet depayloader",
@@ -43,7 +46,6 @@ enum
enum
{
ARG_0,
- ARG_FREQUENCY
};
static GstStaticPadTemplate gst_rtp_mpa_depay_src_template =
@@ -54,20 +56,25 @@ GST_STATIC_PAD_TEMPLATE ("src",
);
static GstStaticPadTemplate gst_rtp_mpa_depay_sink_template =
-GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-rtp, "
"media = (string) \"audio\", "
- "clock-rate = (int) 90000, " "encoding-name = (string) \"MPA\"")
+ "clock-rate = (int) 90000, " "encoding-name = (string) \"MPA\";"
+ "application/x-rtp, "
+ "media = (string) \"audio\", "
+ "payload = (int) " GST_RTP_PAYLOAD_MPA_STRING ", "
+ "clock-rate = (int) 90000")
);
+GST_BOILERPLATE (GstRtpMPADepay, gst_rtp_mpa_depay, GstBaseRTPDepayload,
+ GST_TYPE_BASE_RTP_DEPAYLOAD);
-static void gst_rtp_mpa_depay_class_init (GstRtpMPADepayClass * klass);
-static void gst_rtp_mpa_depay_base_init (GstRtpMPADepayClass * klass);
-static void gst_rtp_mpa_depay_init (GstRtpMPADepay * rtpmpadepay);
-
-static GstFlowReturn gst_rtp_mpa_depay_chain (GstPad * pad, GstBuffer * buffer);
+static gboolean gst_rtp_mpa_depay_setcaps (GstBaseRTPDepayload * depayload,
+ GstCaps * caps);
+static GstBuffer *gst_rtp_mpa_depay_process (GstBaseRTPDepayload * depayload,
+ GstBuffer * buf);
static void gst_rtp_mpa_depay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
@@ -77,35 +84,8 @@ static void gst_rtp_mpa_depay_get_property (GObject * object, guint prop_id,
static GstStateChangeReturn gst_rtp_mpa_depay_change_state (GstElement *
element, GstStateChange transition);
-static GstElementClass *parent_class = NULL;
-
-static GType
-gst_rtp_mpa_depay_get_type (void)
-{
- static GType rtpmpadepay_type = 0;
-
- if (!rtpmpadepay_type) {
- static const GTypeInfo rtpmpadepay_info = {
- sizeof (GstRtpMPADepayClass),
- (GBaseInitFunc) gst_rtp_mpa_depay_base_init,
- NULL,
- (GClassInitFunc) gst_rtp_mpa_depay_class_init,
- NULL,
- NULL,
- sizeof (GstRtpMPADepay),
- 0,
- (GInstanceInitFunc) gst_rtp_mpa_depay_init,
- };
-
- rtpmpadepay_type =
- g_type_register_static (GST_TYPE_ELEMENT, "GstRtpMPADepay",
- &rtpmpadepay_info, 0);
- }
- return rtpmpadepay_type;
-}
-
static void
-gst_rtp_mpa_depay_base_init (GstRtpMPADepayClass * klass)
+gst_rtp_mpa_depay_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@@ -122,9 +102,11 @@ gst_rtp_mpa_depay_class_init (GstRtpMPADepayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
+ GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
+ gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
parent_class = g_type_class_peek_parent (klass);
@@ -132,39 +114,48 @@ gst_rtp_mpa_depay_class_init (GstRtpMPADepayClass * klass)
gobject_class->get_property = gst_rtp_mpa_depay_get_property;
gstelement_class->change_state = gst_rtp_mpa_depay_change_state;
+
+ gstbasertpdepayload_class->set_caps = gst_rtp_mpa_depay_setcaps;
+ gstbasertpdepayload_class->process = gst_rtp_mpa_depay_process;
+
+ GST_DEBUG_CATEGORY_INIT (rtpmpadepay_debug, "rtpmpadepay", 0,
+ "MPEG Audio RTP Depayloader");
}
static void
-gst_rtp_mpa_depay_init (GstRtpMPADepay * rtpmpadepay)
+gst_rtp_mpa_depay_init (GstRtpMPADepay * rtpmpadepay,
+ GstRtpMPADepayClass * klass)
{
- rtpmpadepay->srcpad =
- gst_pad_new_from_static_template (&gst_rtp_mpa_depay_src_template, "src");
- gst_element_add_pad (GST_ELEMENT (rtpmpadepay), rtpmpadepay->srcpad);
-
- rtpmpadepay->sinkpad =
- gst_pad_new_from_static_template (&gst_rtp_mpa_depay_sink_template,
- "sink");
- gst_pad_set_chain_function (rtpmpadepay->sinkpad, gst_rtp_mpa_depay_chain);
- gst_element_add_pad (GST_ELEMENT (rtpmpadepay), rtpmpadepay->sinkpad);
}
-static GstFlowReturn
-gst_rtp_mpa_depay_chain (GstPad * pad, GstBuffer * buf)
+static gboolean
+gst_rtp_mpa_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+{
+ GstStructure *structure;
+ GstRtpMPADepay *rtpmpadepay;
+ gint clock_rate = 90000; /* default */
+
+ rtpmpadepay = GST_RTP_MPA_DEPAY (depayload);
+
+ structure = gst_caps_get_structure (caps, 0);
+
+ gst_structure_get_int (structure, "clock-rate", &clock_rate);
+ depayload->clock_rate = clock_rate;
+
+ return TRUE;
+}
+
+static GstBuffer *
+gst_rtp_mpa_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
{
GstRtpMPADepay *rtpmpadepay;
GstBuffer *outbuf;
- guint8 pt;
- GstFlowReturn ret;
- rtpmpadepay = GST_RTP_MPA_DEPAY (GST_OBJECT_PARENT (pad));
+ rtpmpadepay = GST_RTP_MPA_DEPAY (depayload);
if (!gst_rtp_buffer_validate (buf))
goto bad_packet;
- if ((pt = gst_rtp_buffer_get_payload_type (buf)) != GST_RTP_PAYLOAD_MPA)
- goto bad_payload;
-
-
{
gint payload_len;
guint8 *payload;
@@ -202,32 +193,32 @@ gst_rtp_mpa_depay_chain (GstPad * pad, GstBuffer * buf)
"gst_rtp_mpa_depay_chain: pushing buffer of size %d",
GST_BUFFER_SIZE (outbuf));
- gst_buffer_unref (buf);
-
/* FIXME, we can push half mpeg frames when they are split over multiple
* RTP packets */
- ret = gst_pad_push (rtpmpadepay->srcpad, outbuf);
+ return outbuf;
}
- return ret;
+ return NULL;
bad_packet:
{
- GST_DEBUG_OBJECT (rtpmpadepay, "Packet did not validate");
- gst_buffer_unref (buf);
- return GST_FLOW_ERROR;
+ GST_ELEMENT_WARNING (rtpmpadepay, STREAM, DECODE,
+ ("Packet did not validate."), (NULL));
+ return NULL;
}
+#if 0
bad_payload:
{
- GST_DEBUG_OBJECT (rtpmpadepay, "Unexpected payload type %u", pt);
- gst_buffer_unref (buf);
- return GST_FLOW_ERROR;
+ GST_ELEMENT_WARNING (rtpmpadepay, STREAM, DECODE,
+ ("Unexpected payload type."), (NULL));
+ return NULL;
}
+#endif
empty_packet:
{
- GST_DEBUG_OBJECT (rtpmpadepay, "Empty payload");
- gst_buffer_unref (buf);
- return GST_FLOW_OK;
+ GST_ELEMENT_WARNING (rtpmpadepay, STREAM, DECODE,
+ ("Empty Payload."), (NULL));
+ return NULL;
}
}