summaryrefslogtreecommitdiffstats
path: root/gst/rtp/gstrtpilbcpay.c
diff options
context:
space:
mode:
authorOlivier Crete <tester@tester.ca>2008-05-02 12:24:55 +0000
committerWim Taymans <wim.taymans@gmail.com>2008-05-02 12:24:55 +0000
commit6dc062fbdbc1d33c799214d235c116a7381d8df0 (patch)
tree3ede3b643d5e68005a9491b0551af86f13cf56cd /gst/rtp/gstrtpilbcpay.c
parent39eb91d6f4ccbc16062b2dfdd6082e0622e4e37e (diff)
gst/rtp/gstrtpilbcpay.c: Add negotiation for the ILBC mode. See #465146.
Original commit message from CVS: Patch by: Olivier Crete <tester at tester dot ca> * gst/rtp/gstrtpilbcpay.c: (gst_rtpilbcpay_class_init), (gst_rtpilbcpay_sink_setcaps), (gst_rtpilbcpay_sink_getcaps): Add negotiation for the ILBC mode. See #465146.
Diffstat (limited to 'gst/rtp/gstrtpilbcpay.c')
-rw-r--r--gst/rtp/gstrtpilbcpay.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/gst/rtp/gstrtpilbcpay.c b/gst/rtp/gstrtpilbcpay.c
index 5d226d68..3ac00f52 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)
{