diff --git a/livesupport/modules/gstreamerElements/include/LiveSupport/GstreamerElements/autoplug.h b/livesupport/modules/gstreamerElements/include/LiveSupport/GstreamerElements/autoplug.h index d185711c7..0ea892f25 100644 --- a/livesupport/modules/gstreamerElements/include/LiveSupport/GstreamerElements/autoplug.h +++ b/livesupport/modules/gstreamerElements/include/LiveSupport/GstreamerElements/autoplug.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/include/LiveSupport/GstreamerElements/autoplug.h,v $ ------------------------------------------------------------------------------*/ @@ -34,7 +34,7 @@ * Functions for autoplugging gstreamer elements based on their MIME types. * * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ #ifdef __cplusplus @@ -65,13 +65,16 @@ extern "C" { * * @param source the source to autoplug. * @param name the name of the new element. + * @param caps the capabilities expected from the returned element, + * on its src pad. * @return a gstreamer element already linked to source, that produces * the audio provided by source in audio/x-raw-int or * audio/x-raw-float format, as needed. */ GstElement * -ls_gst_autoplug_plug_source(GstElement * source, - const gchar * name); +ls_gst_autoplug_plug_source(GstElement * source, + const gchar * name, + const GstCaps * caps); #ifdef __cplusplus diff --git a/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx b/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx index cefe46d4c..400fe9852 100644 --- a/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx +++ b/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -116,12 +116,21 @@ AutoplugTest :: playFile(const char * audioFile) GstElement * source; GstElement * decoder; GstElement * sink; + GstCaps * caps; GstFormat format; gint64 timePlayed; /* initialize GStreamer */ gst_init(0, 0); + caps = gst_caps_new_simple("audio/x-raw-int", + "width", G_TYPE_INT, 16, + "depth", G_TYPE_INT, 16, + "endiannes", G_TYPE_INT, G_BYTE_ORDER, + "channels", G_TYPE_INT, 2, + "rate", G_TYPE_INT, 44100, + NULL); + /* create elements */ pipeline = gst_pipeline_new("audio-player"); source = gst_element_factory_make("filesrc", "source"); @@ -129,7 +138,7 @@ AutoplugTest :: playFile(const char * audioFile) g_object_set(G_OBJECT(source), "location", audioFile, NULL); - decoder = ls_gst_autoplug_plug_source(source, "decoder"); + decoder = ls_gst_autoplug_plug_source(source, "decoder", caps); if (!decoder) { gst_object_unref(GST_OBJECT(sink)); @@ -139,7 +148,7 @@ AutoplugTest :: playFile(const char * audioFile) return 0LL; } - gst_element_link(decoder, sink); + gst_element_link_filtered(decoder, sink, caps); gst_bin_add_many(GST_BIN(pipeline), source, decoder, sink, NULL); gst_element_set_state(source, GST_STATE_PAUSED); @@ -147,7 +156,6 @@ AutoplugTest :: playFile(const char * audioFile) gst_element_set_state(sink, GST_STATE_PAUSED); gst_element_set_state(pipeline, GST_STATE_PLAYING); - // iterate until playTo is reached while (gst_bin_iterate(GST_BIN(pipeline))); /* FIXME: query the decoder, as for some reason, the sink will return diff --git a/livesupport/modules/gstreamerElements/src/SeekPackTest.cxx b/livesupport/modules/gstreamerElements/src/SeekPackTest.cxx index 70fd8820e..e0b598e83 100644 --- a/livesupport/modules/gstreamerElements/src/SeekPackTest.cxx +++ b/livesupport/modules/gstreamerElements/src/SeekPackTest.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/SeekPackTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -113,6 +113,7 @@ SeekPackTest :: playFile(const char * audioFile, GstElement * pipeline; GstElement * source; LivesupportSeekPack * seekPack; + GstCaps * caps; GstElement * sink; GstFormat format; gint64 timePlayed; @@ -120,6 +121,14 @@ SeekPackTest :: playFile(const char * audioFile, /* initialize GStreamer */ gst_init(0, 0); + caps = gst_caps_new_simple("audio/x-raw-int", + "width", G_TYPE_INT, 16, + "depth", G_TYPE_INT, 16, + "endiannes", G_TYPE_INT, G_BYTE_ORDER, + "channels", G_TYPE_INT, 2, + "rate", G_TYPE_INT, 44100, + NULL); + /* create elements */ pipeline = gst_pipeline_new("audio-player"); source = gst_element_factory_make("filesrc", "filesource"); @@ -131,6 +140,7 @@ SeekPackTest :: playFile(const char * audioFile, livesupport_seek_pack_init(seekPack, source, + caps, silenceDuration, playFrom, playTo); diff --git a/livesupport/modules/gstreamerElements/src/SeekTest.cxx b/livesupport/modules/gstreamerElements/src/SeekTest.cxx index b8d13ddb3..4b34ef1e0 100644 --- a/livesupport/modules/gstreamerElements/src/SeekTest.cxx +++ b/livesupport/modules/gstreamerElements/src/SeekTest.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/SeekTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -105,6 +105,7 @@ SeekTest :: playFile(const char * audioFile, GstElement * decoder; GstElement * sink; GstSeekType seekType; + GstCaps * caps; GstFormat format; gint64 timePlayed; gint64 timeAfterSeek; @@ -113,6 +114,14 @@ SeekTest :: playFile(const char * audioFile, /* initialize GStreamer */ gst_init(0, 0); + caps = gst_caps_new_simple("audio/x-raw-int", + "width", G_TYPE_INT, 16, + "depth", G_TYPE_INT, 16, + "endiannes", G_TYPE_INT, G_BYTE_ORDER, + "channels", G_TYPE_INT, 2, + "rate", G_TYPE_INT, 44100, + NULL); + /* create elements */ seekType = (GstSeekType) (GST_FORMAT_TIME | GST_SEEK_METHOD_SET | @@ -124,7 +133,7 @@ SeekTest :: playFile(const char * audioFile, g_object_set(G_OBJECT(source), "location", audioFile, NULL); - decoder = ls_gst_autoplug_plug_source(source, "decoder"); + decoder = ls_gst_autoplug_plug_source(source, "decoder", caps); if (!decoder) { gst_object_unref(GST_OBJECT(sink)); diff --git a/livesupport/modules/gstreamerElements/src/SwitcherTest.cxx b/livesupport/modules/gstreamerElements/src/SwitcherTest.cxx index ac9279cce..f9e7d1054 100644 --- a/livesupport/modules/gstreamerElements/src/SwitcherTest.cxx +++ b/livesupport/modules/gstreamerElements/src/SwitcherTest.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/SwitcherTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -112,6 +112,7 @@ SwitcherTest :: playFiles(const char ** audioFiles, GstElement * pipeline; GstElement * switcher; GstElement * sink; + GstCaps * caps; unsigned int i; GstFormat format; gint64 timePlayed; @@ -119,6 +120,14 @@ SwitcherTest :: playFiles(const char ** audioFiles, /* initialize GStreamer */ gst_init(0, 0); + caps = gst_caps_new_simple("audio/x-raw-int", + "width", G_TYPE_INT, 16, + "depth", G_TYPE_INT, 16, + "endiannes", G_TYPE_INT, G_BYTE_ORDER, + "channels", G_TYPE_INT, 2, + "rate", G_TYPE_INT, 44100, + NULL); + /* create elements */ pipeline = gst_pipeline_new("audio-player"); switcher = gst_element_factory_make("switcher", "switcher"); @@ -136,7 +145,7 @@ SwitcherTest :: playFiles(const char ** audioFiles, g_object_set(G_OBJECT(source), "location", audioFiles[i], NULL); g_snprintf(str, 256, "decoder_%d", i); - decoder = ls_gst_autoplug_plug_source(source, str); + decoder = ls_gst_autoplug_plug_source(source, str, caps); CPPUNIT_ASSERT(decoder); ret = gst_element_link(decoder, switcher); diff --git a/livesupport/modules/gstreamerElements/src/autoplug.c b/livesupport/modules/gstreamerElements/src/autoplug.c index 6f2e208ce..ab07eab0e 100644 --- a/livesupport/modules/gstreamerElements/src/autoplug.c +++ b/livesupport/modules/gstreamerElements/src/autoplug.c @@ -27,7 +27,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/autoplug.c,v $ ------------------------------------------------------------------------------*/ @@ -47,18 +47,20 @@ typedef struct _Typefind Typefind; * Data structure to hold information related to typefindinf. */ struct _Typefind { - GList * factories; + GList * factories; - GstElement * pipeline; - GstElement * bin; - GstElement * source; - GstElement * typefind; - GstElement * audiosink; - GstElement * sink; + GstElement * pipeline; + GstElement * bin; + GstElement * source; + GstElement * typefind; + GstElement * audiosink; + GstElement * sink; - gulong typefindSignal; + const GstCaps * caps; - gboolean done; + gulong typefindSignal; + + gboolean done; }; @@ -104,10 +106,13 @@ autoplug_typefound_handler(GstElement * typefind, * @param typefind the Typefind structure to init. * @param name the name of the topmost bin element, that will * be returned at the end of autoplugging. + * @param caps the capabilities expected from the returned element, + * on its src pad. */ static void -autoplug_init(Typefind * typefind, - const gchar * name); +autoplug_init(Typefind * typefind, + const gchar * name, + const GstCaps * caps); /** * De-initialize a typefind object. @@ -250,8 +255,9 @@ autoplug_compare_ranks(GstPluginFeature * feature1, * Initialize a Typefind object, like the factories that we care about. *----------------------------------------------------------------------------*/ static void -autoplug_init(Typefind * typefind, - const gchar * name) +autoplug_init(Typefind * typefind, + const gchar * name, + const GstCaps * caps) { /* first filter out the interesting element factories */ typefind->factories = gst_registry_pool_feature_filter( @@ -268,6 +274,8 @@ autoplug_init(Typefind * typefind, typefind->audiosink = gst_element_factory_make("audioconvert", "audiosink"); typefind->sink = gst_element_factory_make("fakesink", "fakesink"); + typefind->caps = caps; + gst_element_add_ghost_pad(typefind->bin, gst_element_get_pad(typefind->typefind, "sink"), "sink"); @@ -364,7 +372,15 @@ autoplug_close_link(Typefind * typefind, /* add the element to the pipeline and set correct state */ gst_bin_add(GST_BIN(typefind->bin), sinkelement); pad = gst_element_get_pad(sinkelement, padname); - gst_pad_link(srcpad, pad); + + if (g_strrstr(gst_object_get_name(GST_OBJECT(sinkelement)), "audiosink")) { + if (!gst_pad_link_filtered(srcpad, pad, typefind->caps)) { + gst_pad_link(srcpad, pad); + } + } else { + gst_pad_link(srcpad, pad); + } + /* FIXME: this is a nasty workaround for lack of time * the minimalaudiosmil will try to read the input immediately * from it sink pad as its set to PLAYING state, @@ -442,7 +458,7 @@ autoplug_try_to_plug(Typefind * typefind, /* don't plug if we're already plugged */ if (GST_PAD_IS_LINKED(gst_element_get_pad(typefind->audiosink, "sink"))) { GST_DEBUG("Omitting link for pad %s:%s because we're already linked", - gst_object_get_name (parent), gst_pad_get_name (pad)); + gst_object_get_name(parent), gst_pad_get_name(pad)); return; } @@ -451,7 +467,7 @@ autoplug_try_to_plug(Typefind * typefind, if (g_strrstr(mime, "video")) { GST_DEBUG("Omitting link for pad %s:%s because " "mimetype %s is non-audio\n", - gst_object_get_name (parent), gst_pad_get_name (pad), mime); + gst_object_get_name(parent), gst_pad_get_name(pad), mime); return; } @@ -468,16 +484,17 @@ autoplug_try_to_plug(Typefind * typefind, gst_element_add_ghost_pad(typefind->bin, gst_element_get_pad(typefind->audiosink, "src"), "src"); - gst_element_link(typefind->bin, typefind->sink); + gst_element_link_filtered(typefind->bin, typefind->sink, + typefind->caps); gst_bin_add(GST_BIN(typefind->pipeline), typefind->sink); gst_bin_sync_children_state(GST_BIN(typefind->pipeline)); - gst_caps_free (audiocaps); - gst_caps_free (res); + gst_caps_free(audiocaps); + gst_caps_free(res); return; } - gst_caps_free (audiocaps); - gst_caps_free (res); + gst_caps_free(audiocaps); + gst_caps_free(res); /* try to plug from our list */ for (item = typefind->factories; item != NULL; item = item->next) { @@ -659,8 +676,9 @@ autoplug_remove_typefind_elements(Typefind * typefind, * Filter the features that we're interested in. *----------------------------------------------------------------------------*/ GstElement * -ls_gst_autoplug_plug_source(GstElement * source, - const gchar * name) +ls_gst_autoplug_plug_source(GstElement * source, + const gchar * name, + const GstCaps * caps) { Typefind typefind; GstElement * bin; @@ -670,7 +688,7 @@ ls_gst_autoplug_plug_source(GstElement * source, g_object_ref(source); typefind.source = source; - autoplug_init(&typefind, name); + autoplug_init(&typefind, name, caps); gst_element_set_state(typefind.audiosink, GST_STATE_PAUSED); gst_element_set_state(typefind.sink, GST_STATE_PAUSED); diff --git a/livesupport/modules/gstreamerElements/src/minimal-audio-smil.c b/livesupport/modules/gstreamerElements/src/minimal-audio-smil.c index 1313fa8ce..1b67b9da6 100644 --- a/livesupport/modules/gstreamerElements/src/minimal-audio-smil.c +++ b/livesupport/modules/gstreamerElements/src/minimal-audio-smil.c @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/minimal-audio-smil.c,v $ ------------------------------------------------------------------------------*/ @@ -114,7 +114,7 @@ GST_PLUGIN_DEFINE(GST_VERSION_MAJOR, "minimalaudiosmil", "Minimal Audio-only SMIL", plugin_init, - "$Revision: 1.5 $", + "$Revision: 1.6 $", "GPL", "LiveSupport", "http://livesupport.campware.org/") @@ -654,6 +654,7 @@ handle_par_element(LivesupportMinimalAudioSmil * smil, for (index = 0, node = par->children; node; node = node->next, ++index) { if (node->type == XML_ELEMENT_NODE) { GstElement * element = 0; + GstCaps * caps; if (!strcmp(node->name, "audio")) { element = handle_audio_element(smil, diff --git a/livesupport/modules/gstreamerElements/src/partial-play.c b/livesupport/modules/gstreamerElements/src/partial-play.c index dd45c8505..ea2a51f3c 100644 --- a/livesupport/modules/gstreamerElements/src/partial-play.c +++ b/livesupport/modules/gstreamerElements/src/partial-play.c @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/partial-play.c,v $ ------------------------------------------------------------------------------*/ @@ -86,7 +86,7 @@ GST_PLUGIN_DEFINE ( "partialplay", "Partial play", plugin_init, - "$Revision: 1.4 $", + "$Revision: 1.5 $", "GPL", "LiveSupport", "http://livesupport.campware.org/" @@ -241,6 +241,9 @@ livesupport_partial_play_change_state(GstElement * element) case GST_STATE_PAUSED_TO_PLAYING: if (!pplay->seekPackInited) { + GstPad * srcPad; + const GstCaps * caps; + pplay->seekPackInited = TRUE; if (pplay->source) { g_object_unref(pplay->source); @@ -251,8 +254,12 @@ livesupport_partial_play_change_state(GstElement * element) "location", pplay->location, NULL); + srcPad = gst_element_get_pad((GstElement *) pplay, "src"); + caps = gst_pad_get_caps(srcPad); + livesupport_seek_pack_init(pplay->seekPack, pplay->source, + caps, pplay->silenceDuration, pplay->playFrom, pplay->playTo); diff --git a/livesupport/modules/gstreamerElements/src/play.c b/livesupport/modules/gstreamerElements/src/play.c index 6f8fe1073..4e6eda23a 100644 --- a/livesupport/modules/gstreamerElements/src/play.c +++ b/livesupport/modules/gstreamerElements/src/play.c @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/play.c,v $ ------------------------------------------------------------------------------*/ @@ -71,12 +71,21 @@ main(int argc, GstElement * source; GstElement * decoder; GstElement * sink; + GstCaps * caps; GstFormat format; gint64 timePlayed; /* initialize GStreamer */ gst_init(&argc, &argv); + caps = gst_caps_new_simple("audio/x-raw-int", + "width", G_TYPE_INT, 16, + "depth", G_TYPE_INT, 16, + "endiannes", G_TYPE_INT, G_BYTE_ORDER, + "channels", G_TYPE_INT, 2, + "rate", G_TYPE_INT, 44100, + NULL); + if (argc != 2) { g_print("Usage: %s