From 83b20a84378a9d224474c626d183f532dcc25fab Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Thu, 21 Feb 2002 14:04:02 +0000 Subject: [PATCH] on sink connect, check if the current pad is compatible with the given caps cleaned up debug output change pad templa... Original commit message from CVS: * on sink connect, check if the current pad is compatible with the given caps * cleaned up debug output * change pad template to only accept allowed sample rates if these changes are considered ok by others then the same should be applied to other encoding plugins (notably the compatibility check) --- ext/lame/gstlame.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/ext/lame/gstlame.c b/ext/lame/gstlame.c index 89e10906b2..673cd6f888 100644 --- a/ext/lame/gstlame.c +++ b/ext/lame/gstlame.c @@ -58,7 +58,14 @@ GST_PADTEMPLATE_FACTORY (gst_lame_sink_factory, "signed", GST_PROPS_BOOLEAN (TRUE), "width", GST_PROPS_INT (16), "depth", GST_PROPS_INT (16), - "rate", GST_PROPS_INT_RANGE (8000, 48000), + "rate", GST_PROPS_LIST ( + GST_PROPS_INT (16000), + GST_PROPS_INT (22050), + GST_PROPS_INT (24000), + GST_PROPS_INT (32000), + GST_PROPS_INT (44100), + GST_PROPS_INT (48000) + ), "channels", GST_PROPS_INT_RANGE (1, 2) ) ) @@ -339,7 +346,24 @@ gst_lame_sinkconnect (GstPad *pad, GstCaps *caps) lame = GST_LAME (gst_pad_get_parent (pad)); if (!GST_CAPS_IS_FIXED (caps)) + { + GST_DEBUG (GST_CAT_CAPS, "caps on lame pad %s:%s not fixed, delayed\n", + GST_DEBUG_PAD_NAME (pad)); return GST_PAD_CONNECT_DELAYED; + } + /* + GST_INFO (GST_CAT_CAPS, "dumping supplied caps %p\n", caps); + gst_caps_debug (caps); + GST_INFO (GST_CAT_CAPS, "dumping caps of own pad %s:%s\n", GST_DEBUG_PAD_NAME (pad)); + */ + gst_caps_debug (gst_pad_get_caps (pad)); + /* check if the supplied caps of the peer element are compatible with our own use gst_pad_get_caps because if caps aren't set yet we need the template */ + if (!gst_caps_check_compatibility (caps, gst_pad_get_caps (pad))) + { + GST_DEBUG (GST_CAT_CAPS, "peer caps (%p) not compatible with caps of pad %s:%s!\n", + caps, GST_DEBUG_PAD_NAME (pad)); + return GST_PAD_CONNECT_REFUSED; + } lame->samplerate = gst_caps_get_int (caps, "rate"); lame->num_channels = gst_caps_get_int (caps, "channels"); @@ -377,7 +401,7 @@ gst_lame_init (GstLame *lame) GST_FLAG_SET (lame, GST_ELEMENT_EVENT_AWARE); - GST_DEBUG (0, "setting up lame encoder\n"); + GST_DEBUG (GST_CAT_PLUGIN_INFO, "setting up lame encoder\n"); lame->lgf = lame_init (); lame->samplerate = 44100; @@ -416,7 +440,7 @@ gst_lame_init (GstLame *lame) lame->no_short_blocks = lame_get_no_short_blocks (lame->lgf); lame->emphasis = lame_get_emphasis (lame->lgf); - GST_DEBUG (0, "done initializing lame element\n"); + GST_DEBUG (GST_CAT_PLUGIN_INFO, "done initializing lame element\n"); } @@ -657,7 +681,7 @@ gst_lame_chain (GstPad *pad, GstBuffer *buf) lame = GST_LAME (gst_pad_get_parent (pad)); - GST_DEBUG (0, "entered\n"); + GST_DEBUG (GST_CAT_PLUGIN_INFO, "entered chain\n"); if (!lame->initialized) { gst_element_error (GST_ELEMENT (lame), "encoder not initialized (input is not audio?)"); @@ -705,7 +729,7 @@ gst_lame_chain (GstPad *pad, GstBuffer *buf) mp3_data, mp3_buffer_size); } - GST_DEBUG (0, "encoded %d bytes of audio to %d bytes of mp3\n", GST_BUFFER_SIZE (buf), mp3_size); + GST_DEBUG (GST_CAT_PLUGIN_INFO, "encoded %d bytes of audio to %d bytes of mp3\n", GST_BUFFER_SIZE (buf), mp3_size); gst_buffer_unref (buf); } @@ -780,6 +804,7 @@ gst_lame_setup (GstLame *lame) } else { lame->initialized = TRUE; + GST_INFO (GST_CAT_PLUGIN_INFO, "lame encoder initialized"); } GST_DEBUG_LEAVE ("");