From 6dc062fbdbc1d33c799214d235c116a7381d8df0 Mon Sep 17 00:00:00 2001 From: Olivier Crete Date: Fri, 2 May 2008 12:24:55 +0000 Subject: [PATCH] gst/rtp/gstrtpilbcpay.c: Add negotiation for the ILBC mode. See #465146. Original commit message from CVS: Patch by: Olivier Crete * gst/rtp/gstrtpilbcpay.c: (gst_rtpilbcpay_class_init), (gst_rtpilbcpay_sink_setcaps), (gst_rtpilbcpay_sink_getcaps): Add negotiation for the ILBC mode. See #465146. --- ChangeLog | 8 ++++++++ gst/rtp/gstrtpilbcpay.c | 44 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6138e5a64a..c2587272a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-05-02 Wim Taymans + + Patch by: Olivier Crete + + * gst/rtp/gstrtpilbcpay.c: (gst_rtpilbcpay_class_init), + (gst_rtpilbcpay_sink_setcaps), (gst_rtpilbcpay_sink_getcaps): + Add negotiation for the ILBC mode. See #465146. + 2008-05-02 Stefan Kost * ext/soup/gstsouphttpsrc.c: diff --git a/gst/rtp/gstrtpilbcpay.c b/gst/rtp/gstrtpilbcpay.c index 5d226d68f8..3ac00f52be 100644 --- a/gst/rtp/gstrtpilbcpay.c +++ b/gst/rtp/gstrtpilbcpay.c @@ -54,7 +54,10 @@ GST_STATIC_PAD_TEMPLATE ("src", "mode = (string) { \"20\", \"30\" }") ); -static gboolean gst_rtpilbcpay_setcaps (GstBaseRTPPayload * payload, + +static GstCaps *gst_rtpilbcpay_sink_getcaps (GstBaseRTPPayload * payload, + GstPad * pad); +static gboolean gst_rtpilbcpay_sink_setcaps (GstBaseRTPPayload * payload, GstCaps * caps); GST_BOILERPLATE (GstRTPILBCPay, gst_rtpilbcpay, GstBaseRTPAudioPayload, @@ -85,7 +88,8 @@ gst_rtpilbcpay_class_init (GstRTPILBCPayClass * klass) parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_PAYLOAD); - gstbasertppayload_class->set_caps = gst_rtpilbcpay_setcaps; + gstbasertppayload_class->set_caps = gst_rtpilbcpay_sink_setcaps; + gstbasertppayload_class->get_caps = gst_rtpilbcpay_sink_getcaps; GST_DEBUG_CATEGORY_INIT (rtpilbcpay_debug, "rtpilbcpay", 0, "iLBC audio RTP payloader"); @@ -111,7 +115,7 @@ gst_rtpilbcpay_init (GstRTPILBCPay * rtpilbcpay, GstRTPILBCPayClass * klass) } static gboolean -gst_rtpilbcpay_setcaps (GstBaseRTPPayload * basertppayload, GstCaps * caps) +gst_rtpilbcpay_sink_setcaps (GstBaseRTPPayload * basertppayload, GstCaps * caps) { GstRTPILBCPay *rtpilbcpay; GstBaseRTPAudioPayload *basertpaudiopayload; @@ -173,6 +177,40 @@ mode_changed: } } +/* we return the padtemplate caps with the mode field fixated to a value if we + * can */ +static GstCaps * +gst_rtpilbcpay_sink_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad) +{ + GstCaps *otherpadcaps; + GstCaps *caps; + + otherpadcaps = gst_pad_get_allowed_caps (rtppayload->srcpad); + caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); + + if (otherpadcaps) { + if (!gst_caps_is_empty (otherpadcaps)) { + GstStructure *structure; + const gchar *mode_str; + gint mode; + + structure = gst_caps_get_structure (otherpadcaps, 0); + + /* parse mode, if we can */ + mode_str = gst_structure_get_string (structure, "mode"); + if (mode_str) { + mode = strtol (mode_str, NULL, 10); + if (mode == 20 || mode == 30) { + structure = gst_caps_get_structure (caps, 0); + gst_structure_set (structure, "mode", G_TYPE_INT, mode, NULL); + } + } + } + gst_caps_unref (otherpadcaps); + } + return caps; +} + gboolean gst_rtp_ilbc_pay_plugin_init (GstPlugin * plugin) {