mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
alaw/mulaw: Implement _getcaps function for alaw/mulaw decoders
Fixes bug #572358.
This commit is contained in:
parent
b3a90202c1
commit
bfcf84a3eb
2 changed files with 108 additions and 0 deletions
|
@ -145,6 +145,57 @@ gst_alaw_dec_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstCaps *
|
||||||
|
gst_alaw_dec_getcaps (GstPad * pad)
|
||||||
|
{
|
||||||
|
GstALawDec *alawdec;
|
||||||
|
GstPad *otherpad;
|
||||||
|
GstCaps *base_caps, *othercaps;
|
||||||
|
|
||||||
|
alawdec = GST_ALAW_DEC (GST_PAD_PARENT (pad));
|
||||||
|
|
||||||
|
base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
||||||
|
|
||||||
|
if (pad == alawdec->srcpad) {
|
||||||
|
otherpad = alawdec->sinkpad;
|
||||||
|
} else {
|
||||||
|
otherpad = alawdec->srcpad;
|
||||||
|
}
|
||||||
|
othercaps = gst_pad_peer_get_caps (otherpad);
|
||||||
|
if (othercaps) {
|
||||||
|
GstStructure *structure;
|
||||||
|
const GValue *orate, *ochans;
|
||||||
|
const GValue *rate, *chans;
|
||||||
|
GValue irate = { 0 };
|
||||||
|
GValue ichans = { 0 };
|
||||||
|
|
||||||
|
if (gst_caps_is_empty (othercaps) || gst_caps_is_any (othercaps))
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
structure = gst_caps_get_structure (othercaps, 0);
|
||||||
|
orate = gst_structure_get_value (structure, "rate");
|
||||||
|
ochans = gst_structure_get_value (structure, "channels");
|
||||||
|
|
||||||
|
structure = gst_caps_get_structure (base_caps, 0);
|
||||||
|
rate = gst_structure_get_value (structure, "rate");
|
||||||
|
chans = gst_structure_get_value (structure, "channels");
|
||||||
|
|
||||||
|
if (orate) {
|
||||||
|
gst_value_intersect (&irate, orate, rate);
|
||||||
|
gst_structure_set_value (structure, "rate", &irate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ochans) {
|
||||||
|
gst_value_intersect (&ichans, ochans, chans);
|
||||||
|
gst_structure_set_value (structure, "channels", &ichans);
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
gst_caps_unref (othercaps);
|
||||||
|
}
|
||||||
|
return base_caps;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_alaw_dec_base_init (gpointer klass)
|
gst_alaw_dec_base_init (gpointer klass)
|
||||||
{
|
{
|
||||||
|
@ -177,6 +228,8 @@ gst_alaw_dec_init (GstALawDec * alawdec, GstALawDecClass * klass)
|
||||||
gst_pad_new_from_static_template (&alaw_dec_sink_factory, "sink");
|
gst_pad_new_from_static_template (&alaw_dec_sink_factory, "sink");
|
||||||
gst_pad_set_setcaps_function (alawdec->sinkpad,
|
gst_pad_set_setcaps_function (alawdec->sinkpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_alaw_dec_sink_setcaps));
|
GST_DEBUG_FUNCPTR (gst_alaw_dec_sink_setcaps));
|
||||||
|
gst_pad_set_getcaps_function (alawdec->sinkpad,
|
||||||
|
GST_DEBUG_FUNCPTR (gst_alaw_dec_getcaps));
|
||||||
gst_pad_set_chain_function (alawdec->sinkpad,
|
gst_pad_set_chain_function (alawdec->sinkpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_alaw_dec_chain));
|
GST_DEBUG_FUNCPTR (gst_alaw_dec_chain));
|
||||||
gst_element_add_pad (GST_ELEMENT (alawdec), alawdec->sinkpad);
|
gst_element_add_pad (GST_ELEMENT (alawdec), alawdec->sinkpad);
|
||||||
|
@ -184,6 +237,8 @@ gst_alaw_dec_init (GstALawDec * alawdec, GstALawDecClass * klass)
|
||||||
alawdec->srcpad =
|
alawdec->srcpad =
|
||||||
gst_pad_new_from_static_template (&alaw_dec_src_factory, "src");
|
gst_pad_new_from_static_template (&alaw_dec_src_factory, "src");
|
||||||
gst_pad_use_fixed_caps (alawdec->srcpad);
|
gst_pad_use_fixed_caps (alawdec->srcpad);
|
||||||
|
gst_pad_set_getcaps_function (alawdec->srcpad,
|
||||||
|
GST_DEBUG_FUNCPTR (gst_alaw_dec_getcaps));
|
||||||
gst_element_add_pad (GST_ELEMENT (alawdec), alawdec->srcpad);
|
gst_element_add_pad (GST_ELEMENT (alawdec), alawdec->srcpad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,57 @@ mulawdec_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstCaps *
|
||||||
|
mulawdec_getcaps (GstPad * pad)
|
||||||
|
{
|
||||||
|
GstMuLawDec *mulawdec;
|
||||||
|
GstPad *otherpad;
|
||||||
|
GstCaps *base_caps, *othercaps;
|
||||||
|
|
||||||
|
mulawdec = GST_MULAWDEC (GST_PAD_PARENT (pad));
|
||||||
|
|
||||||
|
base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
||||||
|
|
||||||
|
if (pad == mulawdec->srcpad) {
|
||||||
|
otherpad = mulawdec->sinkpad;
|
||||||
|
} else {
|
||||||
|
otherpad = mulawdec->srcpad;
|
||||||
|
}
|
||||||
|
othercaps = gst_pad_peer_get_caps (otherpad);
|
||||||
|
if (othercaps) {
|
||||||
|
GstStructure *structure;
|
||||||
|
const GValue *orate, *ochans;
|
||||||
|
const GValue *rate, *chans;
|
||||||
|
GValue irate = { 0 };
|
||||||
|
GValue ichans = { 0 };
|
||||||
|
|
||||||
|
if (gst_caps_is_empty (othercaps) || gst_caps_is_any (othercaps))
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
structure = gst_caps_get_structure (othercaps, 0);
|
||||||
|
orate = gst_structure_get_value (structure, "rate");
|
||||||
|
ochans = gst_structure_get_value (structure, "channels");
|
||||||
|
|
||||||
|
structure = gst_caps_get_structure (base_caps, 0);
|
||||||
|
rate = gst_structure_get_value (structure, "rate");
|
||||||
|
chans = gst_structure_get_value (structure, "channels");
|
||||||
|
|
||||||
|
if (orate) {
|
||||||
|
gst_value_intersect (&irate, orate, rate);
|
||||||
|
gst_structure_set_value (structure, "rate", &irate);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ochans) {
|
||||||
|
gst_value_intersect (&ichans, ochans, chans);
|
||||||
|
gst_structure_set_value (structure, "channels", &ichans);
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
gst_caps_unref (othercaps);
|
||||||
|
}
|
||||||
|
return base_caps;
|
||||||
|
}
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gst_mulawdec_get_type (void)
|
gst_mulawdec_get_type (void)
|
||||||
{
|
{
|
||||||
|
@ -146,12 +197,14 @@ gst_mulawdec_init (GstMuLawDec * mulawdec)
|
||||||
mulawdec->sinkpad =
|
mulawdec->sinkpad =
|
||||||
gst_pad_new_from_static_template (&mulaw_dec_sink_factory, "sink");
|
gst_pad_new_from_static_template (&mulaw_dec_sink_factory, "sink");
|
||||||
gst_pad_set_setcaps_function (mulawdec->sinkpad, mulawdec_sink_setcaps);
|
gst_pad_set_setcaps_function (mulawdec->sinkpad, mulawdec_sink_setcaps);
|
||||||
|
gst_pad_set_getcaps_function (mulawdec->sinkpad, mulawdec_getcaps);
|
||||||
gst_pad_set_chain_function (mulawdec->sinkpad, gst_mulawdec_chain);
|
gst_pad_set_chain_function (mulawdec->sinkpad, gst_mulawdec_chain);
|
||||||
gst_element_add_pad (GST_ELEMENT (mulawdec), mulawdec->sinkpad);
|
gst_element_add_pad (GST_ELEMENT (mulawdec), mulawdec->sinkpad);
|
||||||
|
|
||||||
mulawdec->srcpad =
|
mulawdec->srcpad =
|
||||||
gst_pad_new_from_static_template (&mulaw_dec_src_factory, "src");
|
gst_pad_new_from_static_template (&mulaw_dec_src_factory, "src");
|
||||||
gst_pad_use_fixed_caps (mulawdec->srcpad);
|
gst_pad_use_fixed_caps (mulawdec->srcpad);
|
||||||
|
gst_pad_set_getcaps_function (mulawdec->srcpad, mulawdec_getcaps);
|
||||||
gst_element_add_pad (GST_ELEMENT (mulawdec), mulawdec->srcpad);
|
gst_element_add_pad (GST_ELEMENT (mulawdec), mulawdec->srcpad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue