mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
add link function. fixes @148986
Original commit message from CVS: add link function. fixes @148986
This commit is contained in:
parent
93d6475a67
commit
1f00cce2f7
1 changed files with 46 additions and 0 deletions
|
@ -346,6 +346,51 @@ gst_lame_class_init (GstLameClass * klass)
|
|||
gstelement_class->change_state = gst_lame_change_state;
|
||||
}
|
||||
|
||||
static GstPadLinkReturn
|
||||
gst_lame_src_link (GstPad * pad, const GstCaps * caps)
|
||||
{
|
||||
GstLame *lame;
|
||||
gint out_samplerate;
|
||||
GstStructure *structure;
|
||||
GstCaps *othercaps, *channelcaps;
|
||||
GstPadLinkReturn result;
|
||||
|
||||
lame = GST_LAME (gst_pad_get_parent (pad));
|
||||
structure = gst_caps_get_structure (caps, 0);
|
||||
|
||||
if (!gst_structure_get_int (structure, "rate", &out_samplerate) ||
|
||||
!gst_structure_get_int (structure, "channels", &lame->num_channels))
|
||||
g_return_val_if_reached (GST_PAD_LINK_REFUSED);
|
||||
|
||||
if (lame_set_out_samplerate (lame->lgf, out_samplerate) != 0)
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
|
||||
/* we don't do channel conversion */
|
||||
channelcaps = gst_caps_new_simple ("audio/x-raw-int", "chnnels", G_TYPE_INT,
|
||||
lame->num_channels, NULL);
|
||||
othercaps = gst_caps_intersect (gst_pad_get_pad_template_caps (lame->sinkpad),
|
||||
channelcaps);
|
||||
gst_caps_free (channelcaps);
|
||||
|
||||
result = gst_pad_try_set_caps_nonfixed (lame->sinkpad, othercaps);
|
||||
|
||||
if (GST_PAD_LINK_FAILED (result))
|
||||
return result;
|
||||
|
||||
caps = gst_pad_get_negotiated_caps (lame->sinkpad);
|
||||
structure = gst_caps_get_structure (caps, 0);
|
||||
if (!gst_structure_get_int (structure, "rate", &lame->samplerate))
|
||||
g_return_val_if_reached (GST_PAD_LINK_REFUSED);
|
||||
|
||||
if (!gst_lame_setup (lame)) {
|
||||
GST_ELEMENT_ERROR (lame, CORE, NEGOTIATION, (NULL),
|
||||
("could not initialize encoder (wrong parameters?)"));
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GstPadLinkReturn
|
||||
gst_lame_sink_link (GstPad * pad, const GstCaps * caps)
|
||||
{
|
||||
|
@ -394,6 +439,7 @@ gst_lame_init (GstLame * lame)
|
|||
gst_pad_new_from_template (gst_static_pad_template_get
|
||||
(&gst_lame_src_template), "src");
|
||||
gst_element_add_pad (GST_ELEMENT (lame), lame->srcpad);
|
||||
gst_pad_set_link_function (lame->srcpad, gst_lame_src_link);
|
||||
|
||||
GST_FLAG_SET (lame, GST_ELEMENT_EVENT_AWARE);
|
||||
|
||||
|
|
Loading…
Reference in a new issue