improved playlist opening times, see issue #1229

http://bugs.campware.org/view.php?id=1229
This commit is contained in:
maroy 2005-08-22 15:02:20 +00:00
parent da5b1f6e71
commit 6e1647ffe5
13 changed files with 146 additions and 53 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ 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 $ 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. * Functions for autoplugging gstreamer elements based on their MIME types.
* *
* @author $Author: maroy $ * @author $Author: maroy $
* @version $Revision: 1.1 $ * @version $Revision: 1.2 $
*/ */
#ifdef __cplusplus #ifdef __cplusplus
@ -65,13 +65,16 @@ extern "C" {
* *
* @param source the source to autoplug. * @param source the source to autoplug.
* @param name the name of the new element. * @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 * @return a gstreamer element already linked to source, that produces
* the audio provided by source in audio/x-raw-int or * the audio provided by source in audio/x-raw-int or
* audio/x-raw-float format, as needed. * audio/x-raw-float format, as needed.
*/ */
GstElement * GstElement *
ls_gst_autoplug_plug_source(GstElement * source, ls_gst_autoplug_plug_source(GstElement * source,
const gchar * name); const gchar * name,
const GstCaps * caps);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ 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 $ 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 * source;
GstElement * decoder; GstElement * decoder;
GstElement * sink; GstElement * sink;
GstCaps * caps;
GstFormat format; GstFormat format;
gint64 timePlayed; gint64 timePlayed;
/* initialize GStreamer */ /* initialize GStreamer */
gst_init(0, 0); 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 */ /* create elements */
pipeline = gst_pipeline_new("audio-player"); pipeline = gst_pipeline_new("audio-player");
source = gst_element_factory_make("filesrc", "source"); 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); 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) { if (!decoder) {
gst_object_unref(GST_OBJECT(sink)); gst_object_unref(GST_OBJECT(sink));
@ -139,7 +148,7 @@ AutoplugTest :: playFile(const char * audioFile)
return 0LL; 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_bin_add_many(GST_BIN(pipeline), source, decoder, sink, NULL);
gst_element_set_state(source, GST_STATE_PAUSED); 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(sink, GST_STATE_PAUSED);
gst_element_set_state(pipeline, GST_STATE_PLAYING); gst_element_set_state(pipeline, GST_STATE_PLAYING);
// iterate until playTo is reached
while (gst_bin_iterate(GST_BIN(pipeline))); while (gst_bin_iterate(GST_BIN(pipeline)));
/* FIXME: query the decoder, as for some reason, the sink will return /* FIXME: query the decoder, as for some reason, the sink will return

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ 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 $ 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 * pipeline;
GstElement * source; GstElement * source;
LivesupportSeekPack * seekPack; LivesupportSeekPack * seekPack;
GstCaps * caps;
GstElement * sink; GstElement * sink;
GstFormat format; GstFormat format;
gint64 timePlayed; gint64 timePlayed;
@ -120,6 +121,14 @@ SeekPackTest :: playFile(const char * audioFile,
/* initialize GStreamer */ /* initialize GStreamer */
gst_init(0, 0); 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 */ /* create elements */
pipeline = gst_pipeline_new("audio-player"); pipeline = gst_pipeline_new("audio-player");
source = gst_element_factory_make("filesrc", "filesource"); source = gst_element_factory_make("filesrc", "filesource");
@ -131,6 +140,7 @@ SeekPackTest :: playFile(const char * audioFile,
livesupport_seek_pack_init(seekPack, livesupport_seek_pack_init(seekPack,
source, source,
caps,
silenceDuration, silenceDuration,
playFrom, playFrom,
playTo); playTo);

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ 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 $ 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 * decoder;
GstElement * sink; GstElement * sink;
GstSeekType seekType; GstSeekType seekType;
GstCaps * caps;
GstFormat format; GstFormat format;
gint64 timePlayed; gint64 timePlayed;
gint64 timeAfterSeek; gint64 timeAfterSeek;
@ -113,6 +114,14 @@ SeekTest :: playFile(const char * audioFile,
/* initialize GStreamer */ /* initialize GStreamer */
gst_init(0, 0); 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 */ /* create elements */
seekType = (GstSeekType) (GST_FORMAT_TIME | seekType = (GstSeekType) (GST_FORMAT_TIME |
GST_SEEK_METHOD_SET | GST_SEEK_METHOD_SET |
@ -124,7 +133,7 @@ SeekTest :: playFile(const char * audioFile,
g_object_set(G_OBJECT(source), "location", audioFile, NULL); 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) { if (!decoder) {
gst_object_unref(GST_OBJECT(sink)); gst_object_unref(GST_OBJECT(sink));

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ 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 $ 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 * pipeline;
GstElement * switcher; GstElement * switcher;
GstElement * sink; GstElement * sink;
GstCaps * caps;
unsigned int i; unsigned int i;
GstFormat format; GstFormat format;
gint64 timePlayed; gint64 timePlayed;
@ -119,6 +120,14 @@ SwitcherTest :: playFiles(const char ** audioFiles,
/* initialize GStreamer */ /* initialize GStreamer */
gst_init(0, 0); 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 */ /* create elements */
pipeline = gst_pipeline_new("audio-player"); pipeline = gst_pipeline_new("audio-player");
switcher = gst_element_factory_make("switcher", "switcher"); 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_object_set(G_OBJECT(source), "location", audioFiles[i], NULL);
g_snprintf(str, 256, "decoder_%d", i); 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); CPPUNIT_ASSERT(decoder);
ret = gst_element_link(decoder, switcher); ret = gst_element_link(decoder, switcher);

View file

@ -27,7 +27,7 @@
Author : $Author: maroy $ 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 $ 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. * Data structure to hold information related to typefindinf.
*/ */
struct _Typefind { struct _Typefind {
GList * factories; GList * factories;
GstElement * pipeline; GstElement * pipeline;
GstElement * bin; GstElement * bin;
GstElement * source; GstElement * source;
GstElement * typefind; GstElement * typefind;
GstElement * audiosink; GstElement * audiosink;
GstElement * sink; 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 typefind the Typefind structure to init.
* @param name the name of the topmost bin element, that will * @param name the name of the topmost bin element, that will
* be returned at the end of autoplugging. * be returned at the end of autoplugging.
* @param caps the capabilities expected from the returned element,
* on its src pad.
*/ */
static void static void
autoplug_init(Typefind * typefind, autoplug_init(Typefind * typefind,
const gchar * name); const gchar * name,
const GstCaps * caps);
/** /**
* De-initialize a typefind object. * 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. * Initialize a Typefind object, like the factories that we care about.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static void static void
autoplug_init(Typefind * typefind, autoplug_init(Typefind * typefind,
const gchar * name) const gchar * name,
const GstCaps * caps)
{ {
/* first filter out the interesting element factories */ /* first filter out the interesting element factories */
typefind->factories = gst_registry_pool_feature_filter( typefind->factories = gst_registry_pool_feature_filter(
@ -268,6 +274,8 @@ autoplug_init(Typefind * typefind,
typefind->audiosink = gst_element_factory_make("audioconvert", "audiosink"); typefind->audiosink = gst_element_factory_make("audioconvert", "audiosink");
typefind->sink = gst_element_factory_make("fakesink", "fakesink"); typefind->sink = gst_element_factory_make("fakesink", "fakesink");
typefind->caps = caps;
gst_element_add_ghost_pad(typefind->bin, gst_element_add_ghost_pad(typefind->bin,
gst_element_get_pad(typefind->typefind, "sink"), gst_element_get_pad(typefind->typefind, "sink"),
"sink"); "sink");
@ -364,7 +372,15 @@ autoplug_close_link(Typefind * typefind,
/* add the element to the pipeline and set correct state */ /* add the element to the pipeline and set correct state */
gst_bin_add(GST_BIN(typefind->bin), sinkelement); gst_bin_add(GST_BIN(typefind->bin), sinkelement);
pad = gst_element_get_pad(sinkelement, padname); 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 /* FIXME: this is a nasty workaround for lack of time
* the minimalaudiosmil will try to read the input immediately * the minimalaudiosmil will try to read the input immediately
* from it sink pad as its set to PLAYING state, * 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 */ /* don't plug if we're already plugged */
if (GST_PAD_IS_LINKED(gst_element_get_pad(typefind->audiosink, "sink"))) { 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_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; return;
} }
@ -451,7 +467,7 @@ autoplug_try_to_plug(Typefind * typefind,
if (g_strrstr(mime, "video")) { if (g_strrstr(mime, "video")) {
GST_DEBUG("Omitting link for pad %s:%s because " GST_DEBUG("Omitting link for pad %s:%s because "
"mimetype %s is non-audio\n", "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; return;
} }
@ -468,16 +484,17 @@ autoplug_try_to_plug(Typefind * typefind,
gst_element_add_ghost_pad(typefind->bin, gst_element_add_ghost_pad(typefind->bin,
gst_element_get_pad(typefind->audiosink, "src"), gst_element_get_pad(typefind->audiosink, "src"),
"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_add(GST_BIN(typefind->pipeline), typefind->sink);
gst_bin_sync_children_state(GST_BIN(typefind->pipeline)); gst_bin_sync_children_state(GST_BIN(typefind->pipeline));
gst_caps_free (audiocaps); gst_caps_free(audiocaps);
gst_caps_free (res); gst_caps_free(res);
return; return;
} }
gst_caps_free (audiocaps); gst_caps_free(audiocaps);
gst_caps_free (res); gst_caps_free(res);
/* try to plug from our list */ /* try to plug from our list */
for (item = typefind->factories; item != NULL; item = item->next) { 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. * Filter the features that we're interested in.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
GstElement * GstElement *
ls_gst_autoplug_plug_source(GstElement * source, ls_gst_autoplug_plug_source(GstElement * source,
const gchar * name) const gchar * name,
const GstCaps * caps)
{ {
Typefind typefind; Typefind typefind;
GstElement * bin; GstElement * bin;
@ -670,7 +688,7 @@ ls_gst_autoplug_plug_source(GstElement * source,
g_object_ref(source); g_object_ref(source);
typefind.source = 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.audiosink, GST_STATE_PAUSED);
gst_element_set_state(typefind.sink, GST_STATE_PAUSED); gst_element_set_state(typefind.sink, GST_STATE_PAUSED);

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ 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 $ 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", "minimalaudiosmil",
"Minimal Audio-only SMIL", "Minimal Audio-only SMIL",
plugin_init, plugin_init,
"$Revision: 1.5 $", "$Revision: 1.6 $",
"GPL", "GPL",
"LiveSupport", "LiveSupport",
"http://livesupport.campware.org/") "http://livesupport.campware.org/")
@ -654,6 +654,7 @@ handle_par_element(LivesupportMinimalAudioSmil * smil,
for (index = 0, node = par->children; node; node = node->next, ++index) { for (index = 0, node = par->children; node; node = node->next, ++index) {
if (node->type == XML_ELEMENT_NODE) { if (node->type == XML_ELEMENT_NODE) {
GstElement * element = 0; GstElement * element = 0;
GstCaps * caps;
if (!strcmp(node->name, "audio")) { if (!strcmp(node->name, "audio")) {
element = handle_audio_element(smil, element = handle_audio_element(smil,

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/partial-play.c,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -86,7 +86,7 @@ GST_PLUGIN_DEFINE (
"partialplay", "partialplay",
"Partial play", "Partial play",
plugin_init, plugin_init,
"$Revision: 1.4 $", "$Revision: 1.5 $",
"GPL", "GPL",
"LiveSupport", "LiveSupport",
"http://livesupport.campware.org/" "http://livesupport.campware.org/"
@ -241,6 +241,9 @@ livesupport_partial_play_change_state(GstElement * element)
case GST_STATE_PAUSED_TO_PLAYING: case GST_STATE_PAUSED_TO_PLAYING:
if (!pplay->seekPackInited) { if (!pplay->seekPackInited) {
GstPad * srcPad;
const GstCaps * caps;
pplay->seekPackInited = TRUE; pplay->seekPackInited = TRUE;
if (pplay->source) { if (pplay->source) {
g_object_unref(pplay->source); g_object_unref(pplay->source);
@ -251,8 +254,12 @@ livesupport_partial_play_change_state(GstElement * element)
"location", "location",
pplay->location, pplay->location,
NULL); NULL);
srcPad = gst_element_get_pad((GstElement *) pplay, "src");
caps = gst_pad_get_caps(srcPad);
livesupport_seek_pack_init(pplay->seekPack, livesupport_seek_pack_init(pplay->seekPack,
pplay->source, pplay->source,
caps,
pplay->silenceDuration, pplay->silenceDuration,
pplay->playFrom, pplay->playFrom,
pplay->playTo); pplay->playTo);

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/play.c,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -71,12 +71,21 @@ main(int argc,
GstElement * source; GstElement * source;
GstElement * decoder; GstElement * decoder;
GstElement * sink; GstElement * sink;
GstCaps * caps;
GstFormat format; GstFormat format;
gint64 timePlayed; gint64 timePlayed;
/* initialize GStreamer */ /* initialize GStreamer */
gst_init(&argc, &argv); 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) { if (argc != 2) {
g_print("Usage: %s <audio filename>\n", argv[0]); g_print("Usage: %s <audio filename>\n", argv[0]);
return -1; return -1;
@ -89,7 +98,7 @@ main(int argc,
g_object_set(G_OBJECT(source), "location", argv[1], NULL); g_object_set(G_OBJECT(source), "location", argv[1], NULL);
decoder = ls_gst_autoplug_plug_source(source, "decoder"); decoder = ls_gst_autoplug_plug_source(source, "decoder", caps);
if (!decoder) { if (!decoder) {
gst_object_unref(GST_OBJECT(sink)); gst_object_unref(GST_OBJECT(sink));

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.8 $ Version : $Revision: 1.9 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/seek-pack.c,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/seek-pack.c,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -161,6 +161,7 @@ livesupport_seek_pack_new(const gchar * uniqueName)
void void
livesupport_seek_pack_init(LivesupportSeekPack * seekPack, livesupport_seek_pack_init(LivesupportSeekPack * seekPack,
GstElement * source, GstElement * source,
const GstCaps * caps,
gint64 silenceDuration, gint64 silenceDuration,
gint64 startTime, gint64 startTime,
gint64 endTime) gint64 endTime)
@ -193,7 +194,8 @@ livesupport_seek_pack_init(LivesupportSeekPack * seekPack,
g_snprintf(name, len, "%s_seekPackDecoder", seekPack->name); g_snprintf(name, len, "%s_seekPackDecoder", seekPack->name);
seekPack->decoder = ls_gst_autoplug_plug_source(seekPack->source, seekPack->decoder = ls_gst_autoplug_plug_source(seekPack->source,
name); name,
caps);
g_snprintf(name, len, "%s_seekPackDecoderConvert", seekPack->name); g_snprintf(name, len, "%s_seekPackDecoderConvert", seekPack->name);
seekPack->decoderConvert = gst_element_factory_make("audioconvert", name); seekPack->decoderConvert = gst_element_factory_make("audioconvert", name);
g_snprintf(name, len, "%s_seekPackDecoderScale", seekPack->name); g_snprintf(name, len, "%s_seekPackDecoderScale", seekPack->name);

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.6 $ Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/seek-pack.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/seek-pack.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -35,7 +35,7 @@
* some silence and then some specified part of the source. * some silence and then some specified part of the source.
* *
* @author $Author: maroy $ * @author $Author: maroy $
* @version $Revision: 1.6 $ * @version $Revision: 1.7 $
*/ */
#ifdef __cplusplus #ifdef __cplusplus
@ -108,6 +108,7 @@ livesupport_seek_pack_new(const gchar * uniqueName);
* *
* @param seekPack the SeekPack to initialize. * @param seekPack the SeekPack to initialize.
* @param source the source the SeekPack will play. * @param source the source the SeekPack will play.
* @param caps the desired capabilites on the src of the SeekPack
* @param silenceDuration the number of nanoseconds the SeekPack will * @param silenceDuration the number of nanoseconds the SeekPack will
* play only silence in the beginning. * play only silence in the beginning.
* @param startTime the offset at which source will start to play after * @param startTime the offset at which source will start to play after
@ -117,6 +118,7 @@ livesupport_seek_pack_new(const gchar * uniqueName);
void void
livesupport_seek_pack_init(LivesupportSeekPack * seekPack, livesupport_seek_pack_init(LivesupportSeekPack * seekPack,
GstElement * source, GstElement * source,
const GstCaps * caps,
gint64 silenceDuration, gint64 silenceDuration,
gint64 startTime, gint64 startTime,
gint64 endTime); gint64 endTime);

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.8 $ Version : $Revision: 1.9 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/GstreamerPlayer.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/GstreamerPlayer.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -108,6 +108,15 @@ GstreamerPlayer :: initialize(void) throw (std::exception)
g_signal_connect(pipeline, "error", G_CALLBACK(errorHandler), this); g_signal_connect(pipeline, "error", G_CALLBACK(errorHandler), this);
// TODO: read the caps from the config file
sinkCaps = 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);
setAudioDevice(audioDevice); setAudioDevice(audioDevice);
// set up other variables // set up other variables
@ -147,6 +156,7 @@ GstreamerPlayer :: deInitialize(void) throw ()
gst_object_unref(GST_OBJECT(audiosink)); gst_object_unref(GST_OBJECT(audiosink));
} }
gst_object_unref(GST_OBJECT(pipeline)); gst_object_unref(GST_OBJECT(pipeline));
gst_caps_free(sinkCaps);
audiosink = 0; audiosink = 0;
initialized = false; initialized = false;
@ -248,7 +258,7 @@ GstreamerPlayer :: open(const std::string fileUrl)
filesrc = gst_element_factory_make("filesrc", "file-source"); filesrc = gst_element_factory_make("filesrc", "file-source");
g_object_set(G_OBJECT(filesrc), "location", filePath.c_str(), NULL); g_object_set(G_OBJECT(filesrc), "location", filePath.c_str(), NULL);
decoder = ls_gst_autoplug_plug_source(filesrc, "decoder"); decoder = ls_gst_autoplug_plug_source(filesrc, "decoder", sinkCaps);
if (!decoder) { if (!decoder) {
throw std::invalid_argument(std::string("can't open URL ") + fileUrl); throw std::invalid_argument(std::string("can't open URL ") + fileUrl);
@ -472,7 +482,7 @@ GstreamerPlayer :: setAudioDevice(const std::string &deviceName)
if (relink) { if (relink) {
if (decoder) { if (decoder) {
gst_element_link(decoder, audiosink); gst_element_link_filtered(decoder, audiosink, sinkCaps);
} }
gst_bin_add(GST_BIN(pipeline), audiosink); gst_bin_add(GST_BIN(pipeline), audiosink);
} }

View file

@ -22,7 +22,7 @@
Author : $Author: maroy $ Author : $Author: maroy $
Version : $Revision: 1.7 $ Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/GstreamerPlayer.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/GstreamerPlayer.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -86,7 +86,7 @@ using namespace LiveSupport::Core;
* </code></pre> * </code></pre>
* *
* @author $Author: maroy $ * @author $Author: maroy $
* @version $Revision: 1.7 $ * @version $Revision: 1.8 $
*/ */
class GstreamerPlayer : virtual public Configurable, class GstreamerPlayer : virtual public Configurable,
virtual public AudioPlayerInterface virtual public AudioPlayerInterface
@ -112,6 +112,11 @@ class GstreamerPlayer : virtual public Configurable,
*/ */
GstElement * decoder; GstElement * decoder;
/**
* The desired capabilities of the audio sink.
*/
GstCaps * sinkCaps;
/** /**
* The audio sink * The audio sink
*/ */