diff options
Diffstat (limited to 'gst/rtp')
-rw-r--r-- | gst/rtp/gstrtpL16depay.c | 68 | ||||
-rw-r--r-- | gst/rtp/gstrtpL16enc.c | 65 | ||||
-rw-r--r-- | gst/rtp/gstrtpL16parse.c | 68 | ||||
-rw-r--r-- | gst/rtp/gstrtpL16pay.c | 65 | ||||
-rw-r--r-- | gst/rtp/gstrtpgsmdepay.c | 51 | ||||
-rw-r--r-- | gst/rtp/gstrtpgsmenc.c | 59 | ||||
-rw-r--r-- | gst/rtp/gstrtpgsmparse.c | 51 | ||||
-rw-r--r-- | gst/rtp/gstrtpgsmpay.c | 59 |
8 files changed, 248 insertions, 238 deletions
diff --git a/gst/rtp/gstrtpL16depay.c b/gst/rtp/gstrtpL16depay.c index 3a18e295..16d128c6 100644 --- a/gst/rtp/gstrtpL16depay.c +++ b/gst/rtp/gstrtpL16depay.c @@ -41,29 +41,27 @@ enum ARG_PAYLOAD_TYPE, }; -GST_PAD_TEMPLATE_FACTORY (src_factory, - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "audio_raw", - "audio/x-raw-int", - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_BOOLEAN (TRUE), - "width", GST_PROPS_INT (16), - "depth", GST_PROPS_INT (16), - "rate", GST_PROPS_INT_RANGE (1000, 48000), - "channels", GST_PROPS_INT_RANGE (1, 2)) -) - -GST_PAD_TEMPLATE_FACTORY (sink_factory, - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "rtp", - "application/x-rtp", - NULL) +static GstStaticPadTemplate gst_rtpL16parse_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( "audio/x-raw-int, " + "endianness = (int) BYTE_ORDER, " + "signed = (boolean) true, " + "width = (int) 16, " + "depth = (int) 16, " + "rate = (int) [ 1000, 48000 ], " + "channels = (int) [ 1, 2 ]" + ) +); + +static GstStaticPadTemplate gst_rtpL16parse_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/x-rtp") ); static void gst_rtpL16parse_class_init (GstRtpL16ParseClass * klass); @@ -108,9 +106,9 @@ gst_rtpL16parse_base_init (GstRtpL16ParseClass * klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (src_factory)); + gst_static_pad_template_get (&gst_rtpL16parse_src_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (sink_factory)); + gst_static_pad_template_get (&gst_rtpL16parse_sink_template)); gst_element_class_set_details (element_class, &gst_rtp_L16parse_details); } @@ -141,8 +139,10 @@ gst_rtpL16parse_class_init (GstRtpL16ParseClass * klass) static void gst_rtpL16parse_init (GstRtpL16Parse * rtpL16parse) { - rtpL16parse->srcpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (src_factory), "src"); - rtpL16parse->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (sink_factory), "sink"); + rtpL16parse->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_rtpL16parse_src_template), "src"); + rtpL16parse->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_rtpL16parse_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (rtpL16parse), rtpL16parse->srcpad); gst_element_add_pad (GST_ELEMENT (rtpL16parse), rtpL16parse->sinkpad); gst_pad_set_chain_function (rtpL16parse->sinkpad, gst_rtpL16parse_chain); @@ -172,15 +172,11 @@ gst_rtpL16_caps_nego (GstRtpL16Parse *rtpL16parse) { GstCaps *caps; - caps = GST_CAPS_NEW ( - "audio_raw", - "audio/x-raw-int", - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_BOOLEAN (TRUE), - "width", GST_PROPS_INT (16), - "depth", GST_PROPS_INT (16), - "rate", GST_PROPS_INT (rtpL16parse->frequency), - "channels", GST_PROPS_INT (rtpL16parse->channels)); + caps = gst_caps_copy(gst_static_caps_get (&gst_rtpL16parse_src_template.static_caps)); + + gst_caps_set_simple (caps, + "rate", G_TYPE_INT, rtpL16parse->frequency, + "channel", G_TYPE_INT, rtpL16parse->channels, NULL); gst_pad_try_set_caps (rtpL16parse->srcpad, caps); } diff --git a/gst/rtp/gstrtpL16enc.c b/gst/rtp/gstrtpL16enc.c index 610ef051..45d6a95a 100644 --- a/gst/rtp/gstrtpL16enc.c +++ b/gst/rtp/gstrtpL16enc.c @@ -44,30 +44,27 @@ enum ARG_0, }; -GST_PAD_TEMPLATE_FACTORY (sink_factory, - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "audio_raw", - "audio/x-raw-int", - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_BOOLEAN (TRUE), - "width", GST_PROPS_INT (16), - "depth", GST_PROPS_INT (16), - "rate", GST_PROPS_INT_RANGE (1000, 48000), - "channels", GST_PROPS_INT_RANGE (1, 2) - ) +static GstStaticPadTemplate gst_rtpL16enc_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( "audio/x-raw-int, " + "endianness = (int) BYTE_ORDER, " + "signed = (boolean) true, " + "width = (int) 16, " + "depth = (int) 16, " + "rate = (int) [ 1000, 48000 ], " + "channels = (int) [ 1, 2 ]" + ) ); -GST_PAD_TEMPLATE_FACTORY (src_factory, - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "rtp", - "application/x-rtp", - NULL) +static GstStaticPadTemplate gst_rtpL16enc_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/x-rtp") ); static void gst_rtpL16enc_class_init (GstRtpL16EncClass * klass); @@ -78,7 +75,7 @@ static void gst_rtpL16enc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_rtpL16enc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static GstPadLinkReturn gst_rtpL16enc_sinkconnect (GstPad * pad, GstCaps * caps); +static GstPadLinkReturn gst_rtpL16enc_sinkconnect (GstPad * pad, const GstCaps * caps); static GstElementStateReturn gst_rtpL16enc_change_state (GstElement * element); static GstElementClass *parent_class = NULL; @@ -111,9 +108,9 @@ gst_rtpL16enc_base_init (GstRtpL16EncClass * klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (sink_factory)); + gst_static_pad_template_get (&gst_rtpL16enc_sink_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (src_factory)); + gst_static_pad_template_get (&gst_rtpL16enc_src_template)); gst_element_class_set_details (element_class, &gst_rtpL16enc_details); } @@ -137,8 +134,10 @@ gst_rtpL16enc_class_init (GstRtpL16EncClass * klass) static void gst_rtpL16enc_init (GstRtpL16Enc * rtpL16enc) { - rtpL16enc->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (sink_factory), "sink"); - rtpL16enc->srcpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (src_factory), "src"); + rtpL16enc->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_rtpL16enc_sink_template), "sink"); + rtpL16enc->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_rtpL16enc_src_template), "src"); gst_element_add_pad (GST_ELEMENT (rtpL16enc), rtpL16enc->sinkpad); gst_element_add_pad (GST_ELEMENT (rtpL16enc), rtpL16enc->srcpad); gst_pad_set_chain_function (rtpL16enc->sinkpad, gst_rtpL16enc_chain); @@ -155,14 +154,20 @@ gst_rtpL16enc_init (GstRtpL16Enc * rtpL16enc) } static GstPadLinkReturn -gst_rtpL16enc_sinkconnect (GstPad * pad, GstCaps * caps) +gst_rtpL16enc_sinkconnect (GstPad * pad, const GstCaps * caps) { GstRtpL16Enc *rtpL16enc; + GstStructure *structure; + gboolean ret; rtpL16enc = GST_RTP_L16_ENC (gst_pad_get_parent (pad)); - gst_caps_get_int (caps, "rate", &rtpL16enc->frequency); - gst_caps_get_int (caps, "channels", &rtpL16enc->channels); + structure = gst_caps_get_structure (caps, 0); + + ret = gst_structure_get_int (structure, "rate", &rtpL16enc->frequency); + ret &= gst_structure_get_int (structure, "channels", &rtpL16enc->channels); + + if (!ret) return GST_PAD_LINK_REFUSED; /* Pre-calculate what we can */ rtpL16enc->time_interval = GST_SECOND / (2 * rtpL16enc->channels * rtpL16enc->frequency); diff --git a/gst/rtp/gstrtpL16parse.c b/gst/rtp/gstrtpL16parse.c index 3a18e295..16d128c6 100644 --- a/gst/rtp/gstrtpL16parse.c +++ b/gst/rtp/gstrtpL16parse.c @@ -41,29 +41,27 @@ enum ARG_PAYLOAD_TYPE, }; -GST_PAD_TEMPLATE_FACTORY (src_factory, - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "audio_raw", - "audio/x-raw-int", - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_BOOLEAN (TRUE), - "width", GST_PROPS_INT (16), - "depth", GST_PROPS_INT (16), - "rate", GST_PROPS_INT_RANGE (1000, 48000), - "channels", GST_PROPS_INT_RANGE (1, 2)) -) - -GST_PAD_TEMPLATE_FACTORY (sink_factory, - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "rtp", - "application/x-rtp", - NULL) +static GstStaticPadTemplate gst_rtpL16parse_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( "audio/x-raw-int, " + "endianness = (int) BYTE_ORDER, " + "signed = (boolean) true, " + "width = (int) 16, " + "depth = (int) 16, " + "rate = (int) [ 1000, 48000 ], " + "channels = (int) [ 1, 2 ]" + ) +); + +static GstStaticPadTemplate gst_rtpL16parse_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/x-rtp") ); static void gst_rtpL16parse_class_init (GstRtpL16ParseClass * klass); @@ -108,9 +106,9 @@ gst_rtpL16parse_base_init (GstRtpL16ParseClass * klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (src_factory)); + gst_static_pad_template_get (&gst_rtpL16parse_src_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (sink_factory)); + gst_static_pad_template_get (&gst_rtpL16parse_sink_template)); gst_element_class_set_details (element_class, &gst_rtp_L16parse_details); } @@ -141,8 +139,10 @@ gst_rtpL16parse_class_init (GstRtpL16ParseClass * klass) static void gst_rtpL16parse_init (GstRtpL16Parse * rtpL16parse) { - rtpL16parse->srcpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (src_factory), "src"); - rtpL16parse->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (sink_factory), "sink"); + rtpL16parse->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_rtpL16parse_src_template), "src"); + rtpL16parse->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_rtpL16parse_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (rtpL16parse), rtpL16parse->srcpad); gst_element_add_pad (GST_ELEMENT (rtpL16parse), rtpL16parse->sinkpad); gst_pad_set_chain_function (rtpL16parse->sinkpad, gst_rtpL16parse_chain); @@ -172,15 +172,11 @@ gst_rtpL16_caps_nego (GstRtpL16Parse *rtpL16parse) { GstCaps *caps; - caps = GST_CAPS_NEW ( - "audio_raw", - "audio/x-raw-int", - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_BOOLEAN (TRUE), - "width", GST_PROPS_INT (16), - "depth", GST_PROPS_INT (16), - "rate", GST_PROPS_INT (rtpL16parse->frequency), - "channels", GST_PROPS_INT (rtpL16parse->channels)); + caps = gst_caps_copy(gst_static_caps_get (&gst_rtpL16parse_src_template.static_caps)); + + gst_caps_set_simple (caps, + "rate", G_TYPE_INT, rtpL16parse->frequency, + "channel", G_TYPE_INT, rtpL16parse->channels, NULL); gst_pad_try_set_caps (rtpL16parse->srcpad, caps); } diff --git a/gst/rtp/gstrtpL16pay.c b/gst/rtp/gstrtpL16pay.c index 610ef051..45d6a95a 100644 --- a/gst/rtp/gstrtpL16pay.c +++ b/gst/rtp/gstrtpL16pay.c @@ -44,30 +44,27 @@ enum ARG_0, }; -GST_PAD_TEMPLATE_FACTORY (sink_factory, - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "audio_raw", - "audio/x-raw-int", - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_BOOLEAN (TRUE), - "width", GST_PROPS_INT (16), - "depth", GST_PROPS_INT (16), - "rate", GST_PROPS_INT_RANGE (1000, 48000), - "channels", GST_PROPS_INT_RANGE (1, 2) - ) +static GstStaticPadTemplate gst_rtpL16enc_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( "audio/x-raw-int, " + "endianness = (int) BYTE_ORDER, " + "signed = (boolean) true, " + "width = (int) 16, " + "depth = (int) 16, " + "rate = (int) [ 1000, 48000 ], " + "channels = (int) [ 1, 2 ]" + ) ); -GST_PAD_TEMPLATE_FACTORY (src_factory, - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "rtp", - "application/x-rtp", - NULL) +static GstStaticPadTemplate gst_rtpL16enc_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/x-rtp") ); static void gst_rtpL16enc_class_init (GstRtpL16EncClass * klass); @@ -78,7 +75,7 @@ static void gst_rtpL16enc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_rtpL16enc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static GstPadLinkReturn gst_rtpL16enc_sinkconnect (GstPad * pad, GstCaps * caps); +static GstPadLinkReturn gst_rtpL16enc_sinkconnect (GstPad * pad, const GstCaps * caps); static GstElementStateReturn gst_rtpL16enc_change_state (GstElement * element); static GstElementClass *parent_class = NULL; @@ -111,9 +108,9 @@ gst_rtpL16enc_base_init (GstRtpL16EncClass * klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (sink_factory)); + gst_static_pad_template_get (&gst_rtpL16enc_sink_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (src_factory)); + gst_static_pad_template_get (&gst_rtpL16enc_src_template)); gst_element_class_set_details (element_class, &gst_rtpL16enc_details); } @@ -137,8 +134,10 @@ gst_rtpL16enc_class_init (GstRtpL16EncClass * klass) static void gst_rtpL16enc_init (GstRtpL16Enc * rtpL16enc) { - rtpL16enc->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (sink_factory), "sink"); - rtpL16enc->srcpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (src_factory), "src"); + rtpL16enc->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_rtpL16enc_sink_template), "sink"); + rtpL16enc->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_rtpL16enc_src_template), "src"); gst_element_add_pad (GST_ELEMENT (rtpL16enc), rtpL16enc->sinkpad); gst_element_add_pad (GST_ELEMENT (rtpL16enc), rtpL16enc->srcpad); gst_pad_set_chain_function (rtpL16enc->sinkpad, gst_rtpL16enc_chain); @@ -155,14 +154,20 @@ gst_rtpL16enc_init (GstRtpL16Enc * rtpL16enc) } static GstPadLinkReturn -gst_rtpL16enc_sinkconnect (GstPad * pad, GstCaps * caps) +gst_rtpL16enc_sinkconnect (GstPad * pad, const GstCaps * caps) { GstRtpL16Enc *rtpL16enc; + GstStructure *structure; + gboolean ret; rtpL16enc = GST_RTP_L16_ENC (gst_pad_get_parent (pad)); - gst_caps_get_int (caps, "rate", &rtpL16enc->frequency); - gst_caps_get_int (caps, "channels", &rtpL16enc->channels); + structure = gst_caps_get_structure (caps, 0); + + ret = gst_structure_get_int (structure, "rate", &rtpL16enc->frequency); + ret &= gst_structure_get_int (structure, "channels", &rtpL16enc->channels); + + if (!ret) return GST_PAD_LINK_REFUSED; /* Pre-calculate what we can */ rtpL16enc->time_interval = GST_SECOND / (2 * rtpL16enc->channels * rtpL16enc->frequency); diff --git a/gst/rtp/gstrtpgsmdepay.c b/gst/rtp/gstrtpgsmdepay.c index edc027b1..8f1b301a 100644 --- a/gst/rtp/gstrtpgsmdepay.c +++ b/gst/rtp/gstrtpgsmdepay.c @@ -41,26 +41,25 @@ enum ARG_FREQUENCY }; -GST_PAD_TEMPLATE_FACTORY (src_factory, - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "gsm_gsm", - "audio/x-gsm", - "rate", GST_PROPS_INT_RANGE (1000, 48000)) -) - -GST_PAD_TEMPLATE_FACTORY (sink_factory, - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "rtp", - "application/x-rtp", - NULL) +static GstStaticPadTemplate gst_rtpgsmparse_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( "audio/x-gsm, " + "rate = (int) [ 1000, 48000 ]" + ) ); +static GstStaticPadTemplate gst_rtpgsmparse_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/x-rtp") +); + + static void gst_rtpgsmparse_class_init (GstRtpGSMParseClass * klass); static void gst_rtpgsmparse_base_init (GstRtpGSMParseClass * klass); static void gst_rtpgsmparse_init (GstRtpGSMParse * rtpgsmparse); @@ -103,9 +102,9 @@ gst_rtpgsmparse_base_init (GstRtpGSMParseClass * klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (src_factory)); + gst_static_pad_template_get(&gst_rtpgsmparse_src_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (sink_factory)); + gst_static_pad_template_get(&gst_rtpgsmparse_sink_template)); gst_element_class_set_details (element_class, &gst_rtp_gsmparse_details); } @@ -133,8 +132,10 @@ gst_rtpgsmparse_class_init (GstRtpGSMParseClass * klass) static void gst_rtpgsmparse_init (GstRtpGSMParse * rtpgsmparse) { - rtpgsmparse->srcpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (src_factory), "src"); - rtpgsmparse->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (sink_factory), "sink"); + rtpgsmparse->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get(&gst_rtpgsmparse_src_template), "src"); + rtpgsmparse->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get(&gst_rtpgsmparse_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (rtpgsmparse), rtpgsmparse->srcpad); gst_element_add_pad (GST_ELEMENT (rtpgsmparse), rtpgsmparse->sinkpad); gst_pad_set_chain_function (rtpgsmparse->sinkpad, gst_rtpgsmparse_chain); @@ -161,10 +162,8 @@ gst_rtpgsm_caps_nego (GstRtpGSMParse *rtpgsmparse) { GstCaps *caps; - caps = GST_CAPS_NEW ( - "gsm_gsm", - "audio/x-gsm", - "rate", GST_PROPS_INT (rtpgsmparse->frequency)); + caps = gst_caps_new_simple ("audio/x-gsm", + "rate", G_TYPE_INT, rtpgsmparse->frequency); gst_pad_try_set_caps (rtpgsmparse->srcpad, caps); } diff --git a/gst/rtp/gstrtpgsmenc.c b/gst/rtp/gstrtpgsmenc.c index c32e32f8..495e4367 100644 --- a/gst/rtp/gstrtpgsmenc.c +++ b/gst/rtp/gstrtpgsmenc.c @@ -45,26 +45,24 @@ enum ARG_0, }; -GST_PAD_TEMPLATE_FACTORY (sink_factory, - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "gsm_gsm", - "audio/x-gsm", - "rate", GST_PROPS_INT_RANGE (1000, 48000) - ) -) - -GST_PAD_TEMPLATE_FACTORY (src_factory, - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "rtp", - "application/x-rtp", - NULL) -) +static GstStaticPadTemplate gst_rtpgsmenc_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( "audio/x-gsm, " + "rate = (int) [ 1000, 48000 ]" + ) +); + +static GstStaticPadTemplate gst_rtpgsmenc_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/x-rtp") +); + static void gst_rtpgsmenc_class_init (GstRtpGSMEncClass * klass); static void gst_rtpgsmenc_base_init (GstRtpGSMEncClass * klass); @@ -74,7 +72,7 @@ static void gst_rtpgsmenc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_rtpgsmenc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static GstPadLinkReturn gst_rtpgsmenc_sinkconnect (GstPad * pad, GstCaps * caps); +static GstPadLinkReturn gst_rtpgsmenc_sinkconnect (GstPad * pad, const GstCaps * caps); static GstElementStateReturn gst_rtpgsmenc_change_state (GstElement * element); static GstElementClass *parent_class = NULL; @@ -107,9 +105,9 @@ gst_rtpgsmenc_base_init (GstRtpGSMEncClass * klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (sink_factory)); + gst_static_pad_template_get (&gst_rtpgsmenc_sink_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (src_factory)); + gst_static_pad_template_get (&gst_rtpgsmenc_src_template)); gst_element_class_set_details (element_class, &gst_rtpgsmenc_details); } @@ -133,8 +131,10 @@ gst_rtpgsmenc_class_init (GstRtpGSMEncClass * klass) static void gst_rtpgsmenc_init (GstRtpGSMEnc * rtpgsmenc) { - rtpgsmenc->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (sink_factory), "sink"); - rtpgsmenc->srcpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (src_factory), "src"); + rtpgsmenc->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_rtpgsmenc_sink_template), "sink"); + rtpgsmenc->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_rtpgsmenc_sink_template), "src"); gst_element_add_pad (GST_ELEMENT (rtpgsmenc), rtpgsmenc->sinkpad); gst_element_add_pad (GST_ELEMENT (rtpgsmenc), rtpgsmenc->srcpad); gst_pad_set_chain_function (rtpgsmenc->sinkpad, gst_rtpgsmenc_chain); @@ -150,13 +150,18 @@ gst_rtpgsmenc_init (GstRtpGSMEnc * rtpgsmenc) } static GstPadLinkReturn -gst_rtpgsmenc_sinkconnect (GstPad * pad, GstCaps * caps) +gst_rtpgsmenc_sinkconnect (GstPad * pad, const GstCaps * caps) { GstRtpGSMEnc *rtpgsmenc; + GstStructure *structure; + gboolean ret; rtpgsmenc = GST_RTP_GSM_ENC (gst_pad_get_parent (pad)); - gst_caps_get_int (caps, "rate", &rtpgsmenc->frequency); + structure = gst_caps_get_structure (caps, 0); + + ret = gst_structure_get_int (structure, "rate", &rtpgsmenc->frequency); + if (!ret) return GST_PAD_LINK_REFUSED; /* Pre-calculate what we can */ rtpgsmenc->time_interval = GST_SECOND / (2 * rtpgsmenc->frequency); diff --git a/gst/rtp/gstrtpgsmparse.c b/gst/rtp/gstrtpgsmparse.c index edc027b1..8f1b301a 100644 --- a/gst/rtp/gstrtpgsmparse.c +++ b/gst/rtp/gstrtpgsmparse.c @@ -41,26 +41,25 @@ enum ARG_FREQUENCY }; -GST_PAD_TEMPLATE_FACTORY (src_factory, - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "gsm_gsm", - "audio/x-gsm", - "rate", GST_PROPS_INT_RANGE (1000, 48000)) -) - -GST_PAD_TEMPLATE_FACTORY (sink_factory, - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "rtp", - "application/x-rtp", - NULL) +static GstStaticPadTemplate gst_rtpgsmparse_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( "audio/x-gsm, " + "rate = (int) [ 1000, 48000 ]" + ) ); +static GstStaticPadTemplate gst_rtpgsmparse_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/x-rtp") +); + + static void gst_rtpgsmparse_class_init (GstRtpGSMParseClass * klass); static void gst_rtpgsmparse_base_init (GstRtpGSMParseClass * klass); static void gst_rtpgsmparse_init (GstRtpGSMParse * rtpgsmparse); @@ -103,9 +102,9 @@ gst_rtpgsmparse_base_init (GstRtpGSMParseClass * klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (src_factory)); + gst_static_pad_template_get(&gst_rtpgsmparse_src_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (sink_factory)); + gst_static_pad_template_get(&gst_rtpgsmparse_sink_template)); gst_element_class_set_details (element_class, &gst_rtp_gsmparse_details); } @@ -133,8 +132,10 @@ gst_rtpgsmparse_class_init (GstRtpGSMParseClass * klass) static void gst_rtpgsmparse_init (GstRtpGSMParse * rtpgsmparse) { - rtpgsmparse->srcpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (src_factory), "src"); - rtpgsmparse->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (sink_factory), "sink"); + rtpgsmparse->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get(&gst_rtpgsmparse_src_template), "src"); + rtpgsmparse->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get(&gst_rtpgsmparse_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (rtpgsmparse), rtpgsmparse->srcpad); gst_element_add_pad (GST_ELEMENT (rtpgsmparse), rtpgsmparse->sinkpad); gst_pad_set_chain_function (rtpgsmparse->sinkpad, gst_rtpgsmparse_chain); @@ -161,10 +162,8 @@ gst_rtpgsm_caps_nego (GstRtpGSMParse *rtpgsmparse) { GstCaps *caps; - caps = GST_CAPS_NEW ( - "gsm_gsm", - "audio/x-gsm", - "rate", GST_PROPS_INT (rtpgsmparse->frequency)); + caps = gst_caps_new_simple ("audio/x-gsm", + "rate", G_TYPE_INT, rtpgsmparse->frequency); gst_pad_try_set_caps (rtpgsmparse->srcpad, caps); } diff --git a/gst/rtp/gstrtpgsmpay.c b/gst/rtp/gstrtpgsmpay.c index c32e32f8..495e4367 100644 --- a/gst/rtp/gstrtpgsmpay.c +++ b/gst/rtp/gstrtpgsmpay.c @@ -45,26 +45,24 @@ enum ARG_0, }; -GST_PAD_TEMPLATE_FACTORY (sink_factory, - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "gsm_gsm", - "audio/x-gsm", - "rate", GST_PROPS_INT_RANGE (1000, 48000) - ) -) - -GST_PAD_TEMPLATE_FACTORY (src_factory, - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "rtp", - "application/x-rtp", - NULL) -) +static GstStaticPadTemplate gst_rtpgsmenc_sink_template = +GST_STATIC_PAD_TEMPLATE ( + "sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ( "audio/x-gsm, " + "rate = (int) [ 1000, 48000 ]" + ) +); + +static GstStaticPadTemplate gst_rtpgsmenc_src_template = +GST_STATIC_PAD_TEMPLATE ( + "src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("application/x-rtp") +); + static void gst_rtpgsmenc_class_init (GstRtpGSMEncClass * klass); static void gst_rtpgsmenc_base_init (GstRtpGSMEncClass * klass); @@ -74,7 +72,7 @@ static void gst_rtpgsmenc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_rtpgsmenc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static GstPadLinkReturn gst_rtpgsmenc_sinkconnect (GstPad * pad, GstCaps * caps); +static GstPadLinkReturn gst_rtpgsmenc_sinkconnect (GstPad * pad, const GstCaps * caps); static GstElementStateReturn gst_rtpgsmenc_change_state (GstElement * element); static GstElementClass *parent_class = NULL; @@ -107,9 +105,9 @@ gst_rtpgsmenc_base_init (GstRtpGSMEncClass * klass) GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (sink_factory)); + gst_static_pad_template_get (&gst_rtpgsmenc_sink_template)); gst_element_class_add_pad_template (element_class, - GST_PAD_TEMPLATE_GET (src_factory)); + gst_static_pad_template_get (&gst_rtpgsmenc_src_template)); gst_element_class_set_details (element_class, &gst_rtpgsmenc_details); } @@ -133,8 +131,10 @@ gst_rtpgsmenc_class_init (GstRtpGSMEncClass * klass) static void gst_rtpgsmenc_init (GstRtpGSMEnc * rtpgsmenc) { - rtpgsmenc->sinkpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (sink_factory), "sink"); - rtpgsmenc->srcpad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (src_factory), "src"); + rtpgsmenc->sinkpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_rtpgsmenc_sink_template), "sink"); + rtpgsmenc->srcpad = gst_pad_new_from_template ( + gst_static_pad_template_get (&gst_rtpgsmenc_sink_template), "src"); gst_element_add_pad (GST_ELEMENT (rtpgsmenc), rtpgsmenc->sinkpad); gst_element_add_pad (GST_ELEMENT (rtpgsmenc), rtpgsmenc->srcpad); gst_pad_set_chain_function (rtpgsmenc->sinkpad, gst_rtpgsmenc_chain); @@ -150,13 +150,18 @@ gst_rtpgsmenc_init (GstRtpGSMEnc * rtpgsmenc) } static GstPadLinkReturn -gst_rtpgsmenc_sinkconnect (GstPad * pad, GstCaps * caps) +gst_rtpgsmenc_sinkconnect (GstPad * pad, const GstCaps * caps) { GstRtpGSMEnc *rtpgsmenc; + GstStructure *structure; + gboolean ret; rtpgsmenc = GST_RTP_GSM_ENC (gst_pad_get_parent (pad)); - gst_caps_get_int (caps, "rate", &rtpgsmenc->frequency); + structure = gst_caps_get_structure (caps, 0); + + ret = gst_structure_get_int (structure, "rate", &rtpgsmenc->frequency); + if (!ret) return GST_PAD_LINK_REFUSED; /* Pre-calculate what we can */ rtpgsmenc->time_interval = GST_SECOND / (2 * rtpgsmenc->frequency); |