made the autoplug test work properly with SMIL files
This commit is contained in:
parent
9aebbbb938
commit
d4557842f6
8 changed files with 109 additions and 58 deletions
|
@ -23,11 +23,11 @@
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: maroy $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.1 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/Attic/autoplug.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/include/LiveSupport/GstreamerElements/autoplug.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
#ifndef Audioplug_h
|
#ifndef LiveSupport_GstreamerElements_Autoplug_h
|
||||||
#define Audioplug_h
|
#define LiveSupport_GstreamerElements_Autoplug_h
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
|
@ -64,17 +64,19 @@ extern "C" {
|
||||||
* source, and produces raw audio on its src pad as it output.
|
* source, and produces raw audio on its src pad as it output.
|
||||||
*
|
*
|
||||||
* @param source the source to autoplug.
|
* @param source the source to autoplug.
|
||||||
|
* @param name the name of the new element.
|
||||||
* @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 *
|
||||||
autoplug_plug_source(GstElement * source);
|
ls_gst_autoplug_plug_source(GstElement * source,
|
||||||
|
const gchar * name);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* Audioplug_h */
|
#endif /* LiveSupport_GstreamerElements_Autoplug_h */
|
||||||
|
|
|
@ -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/AutoplugTest.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/AutoplugTest.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
#include "autoplug.h"
|
#include "LiveSupport/GstreamerElements/autoplug.h"
|
||||||
#include "AutoplugTest.h"
|
#include "AutoplugTest.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,7 +119,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 = autoplug_plug_source(source);
|
decoder = ls_gst_autoplug_plug_source(source, "decoder");
|
||||||
|
|
||||||
if (!decoder) {
|
if (!decoder) {
|
||||||
gst_object_unref(GST_OBJECT(sink));
|
gst_object_unref(GST_OBJECT(sink));
|
||||||
|
@ -132,11 +132,10 @@ AutoplugTest :: playFile(const char * audioFile)
|
||||||
gst_element_link(decoder, sink);
|
gst_element_link(decoder, sink);
|
||||||
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_PLAYING);
|
||||||
gst_element_set_state(decoder, GST_STATE_PAUSED);
|
gst_element_set_state(decoder, GST_STATE_PAUSED);
|
||||||
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);
|
||||||
gst_bin_sync_children_state(GST_BIN(pipeline));
|
|
||||||
|
|
||||||
// iterate until playTo is reached
|
// iterate until playTo is reached
|
||||||
while (gst_bin_iterate(GST_BIN(pipeline)));
|
while (gst_bin_iterate(GST_BIN(pipeline)));
|
||||||
|
|
|
@ -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/src/SeekPackTest.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/SeekPackTest.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -177,13 +177,15 @@ SeekPackTest :: firstTest(void)
|
||||||
throw (CPPUNIT_NS::Exception)
|
throw (CPPUNIT_NS::Exception)
|
||||||
{
|
{
|
||||||
gint64 timePlayed;
|
gint64 timePlayed;
|
||||||
|
char str[256];
|
||||||
|
|
||||||
timePlayed = playFile(testFile,
|
timePlayed = playFile(testFile,
|
||||||
2LL * GST_SECOND,
|
2LL * GST_SECOND,
|
||||||
1LL * GST_SECOND,
|
1LL * GST_SECOND,
|
||||||
3LL * GST_SECOND);
|
3LL * GST_SECOND);
|
||||||
CPPUNIT_ASSERT(timePlayed > 3.9 * GST_SECOND);
|
g_snprintf(str, 256, "time played: %" G_GINT64_FORMAT, timePlayed);
|
||||||
CPPUNIT_ASSERT(timePlayed < 4.1 * GST_SECOND);
|
CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 3.9 * GST_SECOND);
|
||||||
|
CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 4.1 * GST_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,13 +197,15 @@ SeekPackTest :: noSilenceTest(void)
|
||||||
throw (CPPUNIT_NS::Exception)
|
throw (CPPUNIT_NS::Exception)
|
||||||
{
|
{
|
||||||
gint64 timePlayed;
|
gint64 timePlayed;
|
||||||
|
char str[256];
|
||||||
|
|
||||||
timePlayed = playFile(testFile,
|
timePlayed = playFile(testFile,
|
||||||
0LL * GST_SECOND,
|
0LL * GST_SECOND,
|
||||||
1LL * GST_SECOND,
|
1LL * GST_SECOND,
|
||||||
3LL * GST_SECOND);
|
3LL * GST_SECOND);
|
||||||
CPPUNIT_ASSERT(timePlayed > 1.9 * GST_SECOND);
|
g_snprintf(str, 256, "time played: %" G_GINT64_FORMAT, timePlayed);
|
||||||
CPPUNIT_ASSERT(timePlayed < 2.1 * GST_SECOND);
|
CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 1.9 * GST_SECOND);
|
||||||
|
CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 2.1 * GST_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -213,12 +217,14 @@ SeekPackTest :: openEndedTest(void)
|
||||||
throw (CPPUNIT_NS::Exception)
|
throw (CPPUNIT_NS::Exception)
|
||||||
{
|
{
|
||||||
gint64 timePlayed;
|
gint64 timePlayed;
|
||||||
|
char str[256];
|
||||||
|
|
||||||
timePlayed = playFile(testFile,
|
timePlayed = playFile(testFile,
|
||||||
2LL * GST_SECOND,
|
2LL * GST_SECOND,
|
||||||
1LL * GST_SECOND,
|
1LL * GST_SECOND,
|
||||||
-1LL);
|
-1LL);
|
||||||
CPPUNIT_ASSERT(timePlayed > 5.9 * GST_SECOND);
|
g_snprintf(str, 256, "time played: %" G_GINT64_FORMAT, timePlayed);
|
||||||
CPPUNIT_ASSERT(timePlayed < 6.1 * GST_SECOND);
|
CPPUNIT_ASSERT_MESSAGE(str, timePlayed > 5.9 * GST_SECOND);
|
||||||
|
CPPUNIT_ASSERT_MESSAGE(str, timePlayed < 6.1 * GST_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,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/autoplug.c,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/autoplug.c,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
#include "autoplug.h"
|
#include "LiveSupport/GstreamerElements/autoplug.h"
|
||||||
|
|
||||||
|
|
||||||
/* =================================================== local data structures */
|
/* =================================================== local data structures */
|
||||||
|
@ -102,9 +102,12 @@ autoplug_typefound_handler(GstElement * typefind,
|
||||||
* Initialize a typefind object.
|
* Initialize a typefind object.
|
||||||
*
|
*
|
||||||
* @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
|
||||||
|
* be returned at the end of autoplugging.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
autoplug_init(Typefind * typefind);
|
autoplug_init(Typefind * typefind,
|
||||||
|
const gchar * name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* De-initialize a typefind object.
|
* De-initialize a typefind object.
|
||||||
|
@ -247,7 +250,8 @@ 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)
|
||||||
{
|
{
|
||||||
/* 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(
|
||||||
|
@ -259,7 +263,7 @@ autoplug_init(Typefind * typefind)
|
||||||
(GCompareFunc) autoplug_compare_ranks);
|
(GCompareFunc) autoplug_compare_ranks);
|
||||||
|
|
||||||
typefind->pipeline = gst_pipeline_new("pipeline");
|
typefind->pipeline = gst_pipeline_new("pipeline");
|
||||||
typefind->bin = gst_bin_new("bin");
|
typefind->bin = gst_bin_new(name);
|
||||||
typefind->typefind = gst_element_factory_make("typefind", "tf");
|
typefind->typefind = gst_element_factory_make("typefind", "tf");
|
||||||
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");
|
||||||
|
@ -297,6 +301,7 @@ autoplug_deinit(Typefind * typefind)
|
||||||
{
|
{
|
||||||
g_list_free(typefind->factories);
|
g_list_free(typefind->factories);
|
||||||
|
|
||||||
|
gst_element_set_state(typefind->pipeline, GST_STATE_NULL);
|
||||||
if (typefind->typefind) {
|
if (typefind->typefind) {
|
||||||
g_signal_handler_disconnect(typefind->typefind,
|
g_signal_handler_disconnect(typefind->typefind,
|
||||||
typefind->typefindSignal);
|
typefind->typefindSignal);
|
||||||
|
@ -654,7 +659,8 @@ autoplug_remove_typefind_elements(Typefind * typefind,
|
||||||
* Filter the features that we're interested in.
|
* Filter the features that we're interested in.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
GstElement *
|
GstElement *
|
||||||
autoplug_plug_source(GstElement * source)
|
ls_gst_autoplug_plug_source(GstElement * source,
|
||||||
|
const gchar * name)
|
||||||
{
|
{
|
||||||
Typefind typefind;
|
Typefind typefind;
|
||||||
GstElement * bin;
|
GstElement * bin;
|
||||||
|
@ -664,7 +670,7 @@ autoplug_plug_source(GstElement * source)
|
||||||
g_object_ref(source);
|
g_object_ref(source);
|
||||||
|
|
||||||
typefind.source = source;
|
typefind.source = source;
|
||||||
autoplug_init(&typefind);
|
autoplug_init(&typefind, name);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -679,19 +685,23 @@ autoplug_plug_source(GstElement * source)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* remove the source element from the pipeline */
|
||||||
|
gst_bin_remove(GST_BIN(typefind.pipeline), typefind.source);
|
||||||
|
gst_element_unlink(typefind.source, typefind.bin);
|
||||||
|
|
||||||
/* remove the sink element */
|
/* remove the sink element */
|
||||||
gst_element_unlink(typefind.bin, typefind.sink);
|
gst_element_unlink(typefind.bin, typefind.sink);
|
||||||
gst_bin_remove(GST_BIN(typefind.pipeline), typefind.sink);
|
gst_bin_remove(GST_BIN(typefind.pipeline), typefind.sink);
|
||||||
typefind.sink = NULL;
|
typefind.sink = NULL;
|
||||||
|
|
||||||
/* remove the typefind elements, and re-link with the source */
|
|
||||||
autoplug_remove_typefind_elements(&typefind, GST_BIN(typefind.bin));
|
|
||||||
gst_element_link(typefind.source, typefind.bin);
|
|
||||||
|
|
||||||
/* destory the pipeline, but keep source and bin */
|
/* destory the pipeline, but keep source and bin */
|
||||||
g_object_ref(typefind.bin);
|
g_object_ref(typefind.bin);
|
||||||
gst_bin_remove(GST_BIN(typefind.pipeline), typefind.bin);
|
gst_bin_remove(GST_BIN(typefind.pipeline), typefind.bin);
|
||||||
|
|
||||||
|
/* remove the typefind elements, and re-link with the source */
|
||||||
|
autoplug_remove_typefind_elements(&typefind, GST_BIN(typefind.bin));
|
||||||
|
gst_element_link(typefind.source, typefind.bin);
|
||||||
|
|
||||||
bin = typefind.bin;
|
bin = typefind.bin;
|
||||||
|
|
||||||
autoplug_deinit(&typefind);
|
autoplug_deinit(&typefind);
|
||||||
|
|
|
@ -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/minimal-audio-smil.c,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/minimal-audio-smil.c,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -110,7 +110,7 @@ GST_PLUGIN_DEFINE(GST_VERSION_MAJOR,
|
||||||
"minimalaudiosmil",
|
"minimalaudiosmil",
|
||||||
"Minimal Audio-only SMIL",
|
"Minimal Audio-only SMIL",
|
||||||
plugin_init,
|
plugin_init,
|
||||||
"$Revision: 1.2 $",
|
"$Revision: 1.3 $",
|
||||||
"GPL",
|
"GPL",
|
||||||
"LiveSupport",
|
"LiveSupport",
|
||||||
"http://livesupport.campware.org/")
|
"http://livesupport.campware.org/")
|
||||||
|
@ -248,10 +248,13 @@ read_stream_into_memory(LivesupportMinimalAudioSmil * smil,
|
||||||
g_object_get(G_OBJECT(smil->oneshotReader), "length", &length, NULL);
|
g_object_get(G_OBJECT(smil->oneshotReader), "length", &length, NULL);
|
||||||
g_object_get(G_OBJECT(smil->oneshotReader), "contents", &buffer, NULL);
|
g_object_get(G_OBJECT(smil->oneshotReader), "contents", &buffer, NULL);
|
||||||
|
|
||||||
gst_element_set_state(smil->oneshotReader, oldState);
|
if (!length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
*outbuffer = buffer;
|
*outbuffer = g_malloc(length);
|
||||||
*outlength = length;
|
*outlength = length;
|
||||||
|
memcpy(*outbuffer, buffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -431,7 +434,7 @@ handle_par_element(LivesupportMinimalAudioSmil * smil,
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Process the sink input as a SMIL file.
|
* Process the sink input as a SMIL file.
|
||||||
*----------------------------------------------------------------------------*/
|
e*----------------------------------------------------------------------------*/
|
||||||
static gboolean
|
static gboolean
|
||||||
process_smil_file(LivesupportMinimalAudioSmil * smil)
|
process_smil_file(LivesupportMinimalAudioSmil * smil)
|
||||||
{
|
{
|
||||||
|
@ -440,6 +443,12 @@ process_smil_file(LivesupportMinimalAudioSmil * smil)
|
||||||
xmlDocPtr document;
|
xmlDocPtr document;
|
||||||
xmlNode * node;
|
xmlNode * node;
|
||||||
|
|
||||||
|
if (smil->fileProcessed) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
smil->fileProcessed = TRUE;
|
||||||
|
|
||||||
if (!GST_PAD_IS_LINKED(smil->sinkpad)) {
|
if (!GST_PAD_IS_LINKED(smil->sinkpad)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -447,12 +456,14 @@ process_smil_file(LivesupportMinimalAudioSmil * smil)
|
||||||
/* read the source document into memory */
|
/* read the source document into memory */
|
||||||
read_stream_into_memory(smil, &buffer, &length);
|
read_stream_into_memory(smil, &buffer, &length);
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
|
smil->fileProcessed = FALSE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse the XML files */
|
/* parse the XML files */
|
||||||
document = xmlReadMemory((const char *) buffer,
|
document = xmlReadMemory((const char *) buffer,
|
||||||
length, "noname.xml", NULL, 0);
|
length, "noname.xml", NULL, 0);
|
||||||
|
g_free(buffer);
|
||||||
if (!document
|
if (!document
|
||||||
|| !(node = get_body_element(document))) {
|
|| !(node = get_body_element(document))) {
|
||||||
GST_ELEMENT_ERROR(GST_ELEMENT(smil),
|
GST_ELEMENT_ERROR(GST_ELEMENT(smil),
|
||||||
|
@ -515,16 +526,12 @@ livesupport_minimal_audio_smil_change_state(GstElement * element)
|
||||||
case GST_STATE_PAUSED_TO_PLAYING:
|
case GST_STATE_PAUSED_TO_PLAYING:
|
||||||
gst_element_set_state(GST_ELEMENT(smil->bin), GST_STATE_PLAYING);
|
gst_element_set_state(GST_ELEMENT(smil->bin), GST_STATE_PLAYING);
|
||||||
|
|
||||||
if (!smil->fileProcessed) {
|
if (!process_smil_file(smil)) {
|
||||||
/* set to true, in case of multiple change events */
|
GST_ELEMENT_ERROR(GST_ELEMENT(smil),
|
||||||
smil->fileProcessed = TRUE;
|
STREAM,
|
||||||
if (!(smil->fileProcessed = process_smil_file(smil))) {
|
WRONG_TYPE,
|
||||||
GST_ELEMENT_ERROR(GST_ELEMENT(smil),
|
("unable to process SMIL file"),
|
||||||
STREAM,
|
(NULL));
|
||||||
WRONG_TYPE,
|
|
||||||
("unable to process SMIL file"),
|
|
||||||
(NULL));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -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/oneshot-reader.c,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/oneshot-reader.c,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -93,7 +93,7 @@ GST_PLUGIN_DEFINE(GST_VERSION_MAJOR,
|
||||||
"oneshotreaderplugin",
|
"oneshotreaderplugin",
|
||||||
"A reader that reads all of the input on one go",
|
"A reader that reads all of the input on one go",
|
||||||
plugin_init,
|
plugin_init,
|
||||||
"$Revision: 1.2 $",
|
"$Revision: 1.3 $",
|
||||||
"GPL",
|
"GPL",
|
||||||
"LiveSupport",
|
"LiveSupport",
|
||||||
"http://livesupport.campware.org/")
|
"http://livesupport.campware.org/")
|
||||||
|
@ -218,6 +218,7 @@ read_stream_into_memory(LivesupportOneShotReader * reader,
|
||||||
guint32 length;
|
guint32 length;
|
||||||
guint32 read;
|
guint32 read;
|
||||||
guint8 * buffer;
|
guint8 * buffer;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
*outbuffer = 0;
|
*outbuffer = 0;
|
||||||
*outlength = 0;
|
*outlength = 0;
|
||||||
|
@ -231,6 +232,9 @@ read_stream_into_memory(LivesupportOneShotReader * reader,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* seek to the beginning, to make sure... */
|
||||||
|
gst_bytestream_seek(reader->bytestream, 0LL, GST_SEEK_METHOD_SET);
|
||||||
|
|
||||||
length = (guint32) gst_bytestream_length(reader->bytestream);
|
length = (guint32) gst_bytestream_length(reader->bytestream);
|
||||||
buffer = g_malloc(length + 1);
|
buffer = g_malloc(length + 1);
|
||||||
read = 0;
|
read = 0;
|
||||||
|
@ -268,6 +272,9 @@ read_stream_into_memory(LivesupportOneShotReader * reader,
|
||||||
/* flush the bytestream, as we've read all from it anyway */
|
/* flush the bytestream, as we've read all from it anyway */
|
||||||
gst_bytestream_flush_fast(reader->bytestream, length);
|
gst_bytestream_flush_fast(reader->bytestream, length);
|
||||||
|
|
||||||
|
/* re-seek to the beginning, to make sure it can be set to PLAYING again */
|
||||||
|
gst_bytestream_seek(reader->bytestream, 0LL, GST_SEEK_METHOD_SET);
|
||||||
|
|
||||||
/* put a 0 character at the end of the buffer */
|
/* put a 0 character at the end of the buffer */
|
||||||
buffer[length] = '\0';
|
buffer[length] = '\0';
|
||||||
|
|
||||||
|
@ -380,9 +387,11 @@ livesupport_one_shot_reader_dispose(GObject * object)
|
||||||
|
|
||||||
if (reader->bytestream) {
|
if (reader->bytestream) {
|
||||||
gst_bytestream_destroy(reader->bytestream);
|
gst_bytestream_destroy(reader->bytestream);
|
||||||
|
reader->bytestream = 0;
|
||||||
}
|
}
|
||||||
if (reader->contents) {
|
if (reader->contents) {
|
||||||
g_free(reader->contents);
|
g_free(reader->contents);
|
||||||
|
reader->contents = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_OBJECT_CLASS(parent_class)->dispose(object);
|
G_OBJECT_CLASS(parent_class)->dispose(object);
|
||||||
|
|
|
@ -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/seek-pack.c,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/gstreamerElements/src/seek-pack.c,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -42,6 +42,7 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#include "LiveSupport/GstreamerElements/autoplug.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "seek.h"
|
#include "seek.h"
|
||||||
#include "seek-pack.h"
|
#include "seek-pack.h"
|
||||||
|
@ -112,6 +113,8 @@ livesupport_seek_pack_new(const gchar * uniqueName)
|
||||||
gchar * str = g_malloc(len);
|
gchar * str = g_malloc(len);
|
||||||
LivesupportSeekPack * seekPack = g_malloc(sizeof(LivesupportSeekPack));
|
LivesupportSeekPack * seekPack = g_malloc(sizeof(LivesupportSeekPack));
|
||||||
|
|
||||||
|
seekPack->name = g_strdup(uniqueName);
|
||||||
|
|
||||||
g_snprintf(str, len, "%s_seekPackSilence", uniqueName);
|
g_snprintf(str, len, "%s_seekPackSilence", uniqueName);
|
||||||
seekPack->silence = gst_element_factory_make("silence", str);
|
seekPack->silence = gst_element_factory_make("silence", str);
|
||||||
g_snprintf(str, len, "%s_seekPackAudioConvert", uniqueName);
|
g_snprintf(str, len, "%s_seekPackAudioConvert", uniqueName);
|
||||||
|
@ -121,8 +124,8 @@ livesupport_seek_pack_new(const gchar * uniqueName)
|
||||||
/* TODO: typefind, and create Ogg Vorbis parser/decoder */
|
/* TODO: typefind, and create Ogg Vorbis parser/decoder */
|
||||||
seekPack->parser = NULL;
|
seekPack->parser = NULL;
|
||||||
|
|
||||||
g_snprintf(str, len, "%s_seekPackDecoder", uniqueName);
|
/* generate decoder later, by autoplugging */
|
||||||
seekPack->decoder = gst_element_factory_make("mad", str);
|
seekPack->decoder = 0;
|
||||||
g_snprintf(str, len, "%s_seekPackSwitcher", uniqueName);
|
g_snprintf(str, len, "%s_seekPackSwitcher", uniqueName);
|
||||||
seekPack->switcher = gst_element_factory_make("switcher", str);
|
seekPack->switcher = gst_element_factory_make("switcher", str);
|
||||||
g_snprintf(str, len, "%s_seekPackBin", uniqueName);
|
g_snprintf(str, len, "%s_seekPackBin", uniqueName);
|
||||||
|
@ -172,8 +175,10 @@ livesupport_seek_pack_init(LivesupportSeekPack * seekPack,
|
||||||
gint64 startTime,
|
gint64 startTime,
|
||||||
gint64 endTime)
|
gint64 endTime)
|
||||||
{
|
{
|
||||||
GValue gvalue = { 0 };
|
GValue gvalue = { 0 };
|
||||||
gchar str[256];
|
gchar str[256];
|
||||||
|
unsigned int len = strlen(seekPack->name) + 64;
|
||||||
|
gchar * name = g_malloc(len);
|
||||||
|
|
||||||
seekPack->source = source;
|
seekPack->source = source;
|
||||||
|
|
||||||
|
@ -196,6 +201,11 @@ livesupport_seek_pack_init(LivesupportSeekPack * seekPack,
|
||||||
g_value_set_string(&gvalue, str);
|
g_value_set_string(&gvalue, str);
|
||||||
gst_element_set_property(seekPack->switcher, "source-config", &gvalue);
|
gst_element_set_property(seekPack->switcher, "source-config", &gvalue);
|
||||||
|
|
||||||
|
g_snprintf(name, len, "%s_seekPackDecoder", seekPack->name);
|
||||||
|
seekPack->decoder = ls_gst_autoplug_plug_source(seekPack->source,
|
||||||
|
name);
|
||||||
|
g_free(name);
|
||||||
|
|
||||||
gst_element_link(seekPack->source, seekPack->decoder);
|
gst_element_link(seekPack->source, seekPack->decoder);
|
||||||
livesupport_seek_pack_seek(seekPack);
|
livesupport_seek_pack_seek(seekPack);
|
||||||
gst_element_link(seekPack->decoder, seekPack->switcher);
|
gst_element_link(seekPack->decoder, seekPack->switcher);
|
||||||
|
@ -215,6 +225,7 @@ livesupport_seek_pack_destroy(LivesupportSeekPack * seekPack)
|
||||||
{
|
{
|
||||||
gst_element_set_state(seekPack->bin, GST_STATE_NULL);
|
gst_element_set_state(seekPack->bin, GST_STATE_NULL);
|
||||||
g_object_unref(seekPack->bin);
|
g_object_unref(seekPack->bin);
|
||||||
|
g_free(seekPack->name);
|
||||||
g_free(seekPack);
|
g_free(seekPack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,9 +275,15 @@ livesupport_seek_pack_set_state(LivesupportSeekPack * seekPack,
|
||||||
{
|
{
|
||||||
/* FIXME: resetting the source from PLAYING state would make it lose
|
/* FIXME: resetting the source from PLAYING state would make it lose
|
||||||
* it's seek position */
|
* it's seek position */
|
||||||
gst_element_set_state(seekPack->audioconvert, state);
|
if (seekPack->audioconvert) {
|
||||||
gst_element_set_state(seekPack->decoder, state);
|
gst_element_set_state(seekPack->audioconvert, state);
|
||||||
gst_element_set_state(seekPack->switcher, state);
|
}
|
||||||
|
if (seekPack->decoder) {
|
||||||
|
gst_element_set_state(seekPack->decoder, state);
|
||||||
|
}
|
||||||
|
if (seekPack->switcher) {
|
||||||
|
gst_element_set_state(seekPack->switcher, state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,8 +316,8 @@ livesupport_seek_pack_seek(LivesupportSeekPack * seekPack)
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
GST_DEBUG("setting seek pipeline to PLAYING state");
|
GST_DEBUG("setting seek pipeline to PLAYING state");
|
||||||
gst_element_set_state(seekPack->decoder, GST_STATE_READY);
|
gst_element_set_state(seekPack->decoder, GST_STATE_PAUSED);
|
||||||
gst_element_set_state(fakesink, GST_STATE_READY);
|
gst_element_set_state(fakesink, GST_STATE_PAUSED);
|
||||||
gst_element_set_state(pipeline, GST_STATE_PLAYING);
|
gst_element_set_state(pipeline, GST_STATE_PLAYING);
|
||||||
|
|
||||||
GST_DEBUG("starting to iterate...");
|
GST_DEBUG("starting to iterate...");
|
||||||
|
@ -313,7 +330,6 @@ livesupport_seek_pack_seek(LivesupportSeekPack * seekPack)
|
||||||
ret = livesupport_seek(seekPack->decoder, seekType, seekPack->startTime);
|
ret = livesupport_seek(seekPack->decoder, seekType, seekPack->startTime);
|
||||||
GST_DEBUG("seek result: %d", ret);
|
GST_DEBUG("seek result: %d", ret);
|
||||||
|
|
||||||
|
|
||||||
gst_bin_remove_many(GST_BIN(pipeline),
|
gst_bin_remove_many(GST_BIN(pipeline),
|
||||||
seekPack->source,
|
seekPack->source,
|
||||||
seekPack->decoder,
|
seekPack->decoder,
|
||||||
|
|
|
@ -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/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.3 $
|
* @version $Revision: 1.4 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -64,6 +64,8 @@ typedef struct _LivesupportSeekPack LivesupportSeekPack;
|
||||||
* A SeekPack structure.
|
* A SeekPack structure.
|
||||||
*/
|
*/
|
||||||
struct _LivesupportSeekPack {
|
struct _LivesupportSeekPack {
|
||||||
|
gchar * name;
|
||||||
|
|
||||||
GstElement * silence;
|
GstElement * silence;
|
||||||
GstElement * audioconvert;
|
GstElement * audioconvert;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue