#include <string.h>
#include "gstrtpg729depay.h"
+GST_DEBUG_CATEGORY_STATIC (rtpg729depay_debug);
+#define GST_CAT_DEFAULT (rtpg729depay_debug)
+
+
/* references:
*
* RFC 3551 (4.5.6)
*/
-/* elementfactory information */
-static const GstElementDetails gst_rtp_g729depay_details =
-GST_ELEMENT_DETAILS ("RTP G.729 depayloader",
- "Codec/Depayloader/Network",
- "Extracts G.729 audio from RTP packets (RFC 3551)",
- "Laurent Glayal <spglegle@yahoo.fr>");
-
enum
{
/* FILL ME */
GST_STATIC_CAPS ("audio/G729, " "channels = (int) 1," "rate = (int) 8000")
);
-static gboolean gst_rtp_g729_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_g729_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
-static GstBuffer *gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_g729_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-GST_BOILERPLATE (GstRtpG729Depay, gst_rtp_g729_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_g729_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG729Depay, gst_rtp_g729_depay,
+ GST_TYPE_RTP_BASE_DEPAYLOAD);
static void
-gst_rtp_g729_depay_base_init (gpointer klass)
+gst_rtp_g729_depay_class_init (GstRtpG729DepayClass * klass)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rtp_g729_depay_src_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rtp_g729_depay_sink_template));
-
- gst_element_class_set_details (element_class, &gst_rtp_g729depay_details);
-}
+ GST_DEBUG_CATEGORY_INIT (rtpg729depay_debug, "rtpg729depay", 0,
+ "G.729 RTP Depayloader");
-static void
-gst_rtp_g729_depay_class_init (GstRtpG729DepayClass * klass)
-{
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_g729_depay_src_template));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_g729_depay_sink_template));
- parent_class = g_type_class_peek_parent (klass);
+ gst_element_class_set_details_simple (gstelement_class,
+ "RTP G.729 depayloader", "Codec/Depayloader/Network/RTP",
+ "Extracts G.729 audio from RTP packets (RFC 3551)",
+ "Laurent Glayal <spglegle@yahoo.fr>");
- gstbasertpdepayload_class->process = gst_rtp_g729_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_g729_depay_setcaps;
+ gstrtpbasedepayload_class->process = gst_rtp_g729_depay_process;
+ gstrtpbasedepayload_class->set_caps = gst_rtp_g729_depay_setcaps;
}
static void
-gst_rtp_g729_depay_init (GstRtpG729Depay * rtpg729depay,
- GstRtpG729DepayClass * klass)
+gst_rtp_g729_depay_init (GstRtpG729Depay * rtpg729depay)
{
- GstBaseRTPDepayload *depayload;
+ GstRTPBaseDepayload *depayload;
- depayload = GST_BASE_RTP_DEPAYLOAD (rtpg729depay);
+ depayload = GST_RTP_BASE_DEPAYLOAD (rtpg729depay);
- gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
+ gst_pad_use_fixed_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload));
}
static gboolean
-gst_rtp_g729_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_g729_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstCaps *srccaps;
srccaps = gst_caps_new_simple ("audio/G729",
"channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, clock_rate, NULL);
- ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
return ret;
/* ERRORS */
wrong_channels:
{
- GST_DEBUG_OBJECT (rtpg729depay, "expected 1 channel, got %d",
- rtpg729depay->channels);
+ GST_DEBUG_OBJECT (rtpg729depay, "expected 1 channel, got %d", channels);
return FALSE;
}
wrong_clock_rate:
}
}
-
static GstBuffer *
-gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_g729_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpG729Depay *rtpg729depay;
GstBuffer *outbuf = NULL;
gint payload_len;
gboolean marker;
+ GstRTPBuffer rtp = { NULL };
rtpg729depay = GST_RTP_G729_DEPAY (depayload);
- payload_len = gst_rtp_buffer_get_payload_len (buf);
+ gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+ payload_len = gst_rtp_buffer_get_payload_len (&rtp);
/* At least 2 bytes (CNG from G729 Annex B) */
if (payload_len < 2) {
goto bad_packet;
}
- GST_DEBUG_OBJECT (rtpg729depay, "payload len %d", payload_len);
+ GST_LOG_OBJECT (rtpg729depay, "payload len %d", payload_len);
if ((payload_len % 10) == 2) {
- GST_DEBUG_OBJECT (rtpg729depay, "G729 payload contains CNG frame");
+ GST_LOG_OBJECT (rtpg729depay, "G729 payload contains CNG frame");
}
- outbuf = gst_rtp_buffer_get_payload_buffer (buf);
- marker = gst_rtp_buffer_get_marker (buf);
+ outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+ marker = gst_rtp_buffer_get_marker (&rtp);
+
+ gst_rtp_buffer_unmap (&rtp);
if (marker) {
/* marker bit starts talkspurt */
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
}
- GST_DEBUG ("gst_rtp_g729_depay_chain: pushing buffer of size %d",
- GST_BUFFER_SIZE (outbuf));
+ GST_LOG_OBJECT (depayload, "pushing buffer of size %" G_GSIZE_FORMAT,
+ gst_buffer_get_size (outbuf));
return outbuf;
gst_rtp_g729_depay_plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "rtpg729depay",
- GST_RANK_MARGINAL, GST_TYPE_RTP_G729_DEPAY);
+ GST_RANK_SECONDARY, GST_TYPE_RTP_G729_DEPAY);
}