From 77ea437507a4db3e1b6630958cfafba941a55597 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Fri, 30 Dec 2011 11:41:17 +0100 Subject: Merge remote-tracking branch 'origin/master' into 0.11-premerge Conflicts: docs/libs/Makefile.am ext/kate/gstkatetiger.c ext/opus/gstopusdec.c ext/xvid/gstxvidenc.c gst-libs/gst/basecamerabinsrc/Makefile.am gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.c gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.h gst-libs/gst/video/gstbasevideocodec.c gst-libs/gst/video/gstbasevideocodec.h gst-libs/gst/video/gstbasevideodecoder.c gst-libs/gst/video/gstbasevideoencoder.c gst/asfmux/gstasfmux.c gst/audiovisualizers/gstwavescope.c gst/camerabin2/gstcamerabin2.c gst/debugutils/gstcompare.c gst/frei0r/gstfrei0rmixer.c gst/mpegpsmux/mpegpsmux.c gst/mpegtsmux/mpegtsmux.c gst/mxf/mxfmux.c gst/videomeasure/gstvideomeasure_ssim.c gst/videoparsers/gsth264parse.c gst/videoparsers/gstmpeg4videoparse.c --- gst/rtp/gstrtpopusdepay.c | 43 ++++++++++++-------------- gst/rtp/gstrtpopusdepay.h | 6 ++-- gst/rtp/gstrtpopuspay.c | 79 +++++++++++++++++++++++------------------------ gst/rtp/gstrtpopuspay.h | 6 ++-- 4 files changed, 64 insertions(+), 70 deletions(-) diff --git a/gst/rtp/gstrtpopusdepay.c b/gst/rtp/gstrtpopusdepay.c index 0f1869ed5..f8effbb6c 100644 --- a/gst/rtp/gstrtpopusdepay.c +++ b/gst/rtp/gstrtpopusdepay.c @@ -31,8 +31,6 @@ GST_DEBUG_CATEGORY_STATIC (rtpopusdepay_debug); #define GST_CAT_DEFAULT (rtpopusdepay_debug) - - static GstStaticPadTemplate gst_rtp_opus_depay_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, @@ -51,18 +49,22 @@ GST_STATIC_PAD_TEMPLATE ("src", GST_STATIC_CAPS ("audio/x-opus") ); -static GstBuffer *gst_rtp_opus_depay_process (GstBaseRTPDepayload * depayload, +static GstBuffer *gst_rtp_opus_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf); -static gboolean gst_rtp_opus_depay_setcaps (GstBaseRTPDepayload * depayload, +static gboolean gst_rtp_opus_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps); -GST_BOILERPLATE (GstRTPOpusDepay, gst_rtp_opus_depay, GstBaseRTPDepayload, - GST_TYPE_BASE_RTP_DEPAYLOAD); +G_DEFINE_TYPE (GstRTPOpusDepay, gst_rtp_opus_depay, + GST_TYPE_RTP_BASE_DEPAYLOAD); static void -gst_rtp_opus_depay_base_init (gpointer klass) +gst_rtp_opus_depay_class_init (GstRTPOpusDepayClass * klass) { - GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + GstRTPBaseDepayloadClass *gstbasertpdepayload_class; + GstElementClass *element_class; + + element_class = GST_ELEMENT_CLASS (klass); + gstbasertpdepayload_class = (GstRTPBaseDepayloadClass *) klass; gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_rtp_opus_depay_src_template)); @@ -72,14 +74,6 @@ gst_rtp_opus_depay_base_init (gpointer klass) "RTP Opus packet depayloader", "Codec/Depayloader/Network/RTP", "Extracts Opus audio from RTP packets", "Danilo Cesar Lemes de Paula "); -} - -static void -gst_rtp_opus_depay_class_init (GstRTPOpusDepayClass * klass) -{ - GstBaseRTPDepayloadClass *gstbasertpdepayload_class; - - gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass; gstbasertpdepayload_class->process = gst_rtp_opus_depay_process; gstbasertpdepayload_class->set_caps = gst_rtp_opus_depay_setcaps; @@ -89,20 +83,19 @@ gst_rtp_opus_depay_class_init (GstRTPOpusDepayClass * klass) } static void -gst_rtp_opus_depay_init (GstRTPOpusDepay * rtpopusdepay, - GstRTPOpusDepayClass * klass) +gst_rtp_opus_depay_init (GstRTPOpusDepay * rtpopusdepay) { } static gboolean -gst_rtp_opus_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps) +gst_rtp_opus_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps) { GstCaps *srccaps; gboolean ret; - srccaps = gst_caps_new_simple ("audio/x-opus", NULL); - ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps); + srccaps = gst_caps_new_empty_simple ("audio/x-opus"); + ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps); GST_DEBUG_OBJECT (depayload, "set caps on source: %" GST_PTR_FORMAT " (ret=%d)", srccaps, ret); @@ -114,10 +107,14 @@ gst_rtp_opus_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps) } static GstBuffer * -gst_rtp_opus_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) +gst_rtp_opus_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf) { GstBuffer *outbuf; - outbuf = gst_rtp_buffer_get_payload_buffer (buf); + GstRTPBuffer rtpbuf = { NULL, }; + + gst_rtp_buffer_map (buf, GST_MAP_READ, &rtpbuf); + outbuf = gst_rtp_buffer_get_payload_buffer (&rtpbuf); + gst_rtp_buffer_unmap (&rtpbuf); return outbuf; } diff --git a/gst/rtp/gstrtpopusdepay.h b/gst/rtp/gstrtpopusdepay.h index ba217e0e8..968ae52ae 100644 --- a/gst/rtp/gstrtpopusdepay.h +++ b/gst/rtp/gstrtpopusdepay.h @@ -23,7 +23,7 @@ #define __GST_RTP_OPUS_DEPAY_H__ #include -#include +#include G_BEGIN_DECLS typedef struct _GstRTPOpusDepay GstRTPOpusDepay; typedef struct _GstRTPOpusDepayClass GstRTPOpusDepayClass; @@ -42,13 +42,13 @@ typedef struct _GstRTPOpusDepayClass GstRTPOpusDepayClass; struct _GstRTPOpusDepay { - GstBaseRTPDepayload depayload; + GstRTPBaseDepayload depayload; }; struct _GstRTPOpusDepayClass { - GstBaseRTPDepayloadClass parent_class; + GstRTPBaseDepayloadClass parent_class; }; GType gst_rtp_opus_depay_get_type (void); diff --git a/gst/rtp/gstrtpopuspay.c b/gst/rtp/gstrtpopuspay.c index cdd7ee00c..5003c739f 100644 --- a/gst/rtp/gstrtpopuspay.c +++ b/gst/rtp/gstrtpopuspay.c @@ -51,18 +51,24 @@ GST_STATIC_PAD_TEMPLATE ("src", "encoding-name = (string) \"X-GST-OPUS-DRAFT-SPITTKA-00\"") ); -static gboolean gst_rtp_opus_pay_setcaps (GstBaseRTPPayload * payload, +static gboolean gst_rtp_opus_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps); -static GstFlowReturn gst_rtp_opus_pay_handle_buffer (GstBaseRTPPayload * +static GstFlowReturn gst_rtp_opus_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer); -GST_BOILERPLATE (GstRtpOPUSPay, gst_rtp_opus_pay, GstBaseRTPPayload, - GST_TYPE_BASE_RTP_PAYLOAD); +G_DEFINE_TYPE (GstRtpOPUSPay, gst_rtp_opus_pay, GST_TYPE_RTP_BASE_PAYLOAD); static void -gst_rtp_opus_pay_base_init (gpointer klass) +gst_rtp_opus_pay_class_init (GstRtpOPUSPayClass * klass) { - GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + GstRTPBasePayloadClass *gstbasertppayload_class; + GstElementClass *element_class; + + gstbasertppayload_class = (GstRTPBasePayloadClass *) klass; + element_class = GST_ELEMENT_CLASS (klass); + + gstbasertppayload_class->set_caps = gst_rtp_opus_pay_setcaps; + gstbasertppayload_class->handle_buffer = gst_rtp_opus_pay_handle_buffer; gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_rtp_opus_pay_src_template)); @@ -74,39 +80,28 @@ gst_rtp_opus_pay_base_init (gpointer klass) "Codec/Payloader/Network/RTP", "Puts Opus audio in RTP packets", "Danilo Cesar Lemes de Paula "); -} - -static void -gst_rtp_opus_pay_class_init (GstRtpOPUSPayClass * klass) -{ - GstBaseRTPPayloadClass *gstbasertppayload_class; - - gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass; - - gstbasertppayload_class->set_caps = gst_rtp_opus_pay_setcaps; - gstbasertppayload_class->handle_buffer = gst_rtp_opus_pay_handle_buffer; GST_DEBUG_CATEGORY_INIT (rtpopuspay_debug, "rtpopuspay", 0, "Opus RTP Payloader"); } static void -gst_rtp_opus_pay_init (GstRtpOPUSPay * rtpopuspay, GstRtpOPUSPayClass * klass) +gst_rtp_opus_pay_init (GstRtpOPUSPay * rtpopuspay) { } static gboolean -gst_rtp_opus_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps) +gst_rtp_opus_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) { gboolean res; gchar *capsstr; capsstr = gst_caps_to_string (caps); - gst_basertppayload_set_options (payload, "audio", FALSE, + gst_rtp_base_payload_set_options (payload, "audio", FALSE, "X-GST-OPUS-DRAFT-SPITTKA-00", 48000); res = - gst_basertppayload_set_outcaps (payload, "caps", G_TYPE_STRING, capsstr, + gst_rtp_base_payload_set_outcaps (payload, "caps", G_TYPE_STRING, capsstr, NULL); g_free (capsstr); @@ -114,27 +109,29 @@ gst_rtp_opus_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps) } static GstFlowReturn -gst_rtp_opus_pay_handle_buffer (GstBaseRTPPayload * basepayload, +gst_rtp_opus_pay_handle_buffer (GstRTPBasePayload * basepayload, GstBuffer * buffer) { + GstRTPBuffer rtpbuf = { NULL, }; GstBuffer *outbuf; - GstClockTime timestamp; - - guint size; - guint8 *data; - guint8 *payload; - - size = GST_BUFFER_SIZE (buffer); - data = GST_BUFFER_DATA (buffer); - timestamp = GST_BUFFER_TIMESTAMP (buffer); - - outbuf = gst_rtp_buffer_new_allocate (size, 0, 0); - payload = gst_rtp_buffer_get_payload (outbuf); - - memcpy (payload, data, size); - - gst_rtp_buffer_set_marker (outbuf, FALSE); - GST_BUFFER_TIMESTAMP (outbuf) = timestamp; - - return gst_basertppayload_push (basepayload, outbuf); + gsize size; + gpointer *data; + + /* Copy data and timestamp to a new output buffer + * FIXME : Don't we have a convenience function for this ? */ + data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); + outbuf = gst_rtp_buffer_new_copy_data (data, size); + GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer); + + /* Unmap and free input buffer */ + gst_buffer_unmap (buffer, data, size); + gst_buffer_unref (buffer); + + /* Remove marker from RTP buffer */ + gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtpbuf); + gst_rtp_buffer_set_marker (&rtpbuf, FALSE); + gst_rtp_buffer_unmap (&rtpbuf); + + /* Push out */ + return gst_rtp_base_payload_push (basepayload, outbuf); } diff --git a/gst/rtp/gstrtpopuspay.h b/gst/rtp/gstrtpopuspay.h index 23abd0dab..81160fe2a 100644 --- a/gst/rtp/gstrtpopuspay.h +++ b/gst/rtp/gstrtpopuspay.h @@ -23,7 +23,7 @@ #define __GST_RTP_OPUS_PAY_H__ #include -#include +#include G_BEGIN_DECLS @@ -43,12 +43,12 @@ typedef struct _GstRtpOPUSPayClass GstRtpOPUSPayClass; struct _GstRtpOPUSPay { - GstBaseRTPPayload payload; + GstRTPBasePayload payload; }; struct _GstRtpOPUSPayClass { - GstBaseRTPPayloadClass parent_class; + GstRTPBasePayloadClass parent_class; }; GType gst_rtp_opus_pay_get_type (void); -- cgit v1.2.1