added gstreamer support for playlistExecutor, scheduler and gLiveSupport
This commit is contained in:
parent
56dc591a02
commit
87b2840b53
13 changed files with 206 additions and 452 deletions
|
@ -20,8 +20,8 @@
|
|||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#
|
||||
# Author : $Author: fgerlits $
|
||||
# Version : $Revision: 1.14 $
|
||||
# Author : $Author: maroy $
|
||||
# Version : $Revision: 1.15 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -49,6 +49,9 @@ LIB_DIR = ${BASE_DIR}/lib
|
|||
SRC_DIR = ${BASE_DIR}/src
|
||||
TMP_DIR = ${BASE_DIR}/tmp
|
||||
|
||||
REAL_BASE_DIR=$(shell cd ${BASE_DIR}; pwd)
|
||||
|
||||
|
||||
USR_DIR = ${BASE_DIR}/../../usr
|
||||
USR_INCLUDE_DIR = ${USR_DIR}/include
|
||||
USR_LIB_DIR = ${USR_DIR}/lib
|
||||
|
@ -72,6 +75,13 @@ CORE_LIB_DIR = ${CORE_DIR}/lib
|
|||
CORE_LIB = livesupport_core
|
||||
CORE_LIB_FILE = ${CORE_LIB_DIR}/lib${CORE_LIB}.a
|
||||
|
||||
GSTREAMER_ELEMENTS_DIR = ${MODULES_DIR}/gstreamerElements
|
||||
GSTREAMER_ELEMENTS_INCLUDE_DIR = ${GSTREAMER_ELEMENTS_DIR}/include
|
||||
GSTREAMER_ELEMENTS_LIB_DIR = ${GSTREAMER_ELEMENTS_DIR}/lib
|
||||
GSTREAMER_ELEMENTS_LIB = livesupport_gstreamerelements
|
||||
GSTREAMER_ELEMENTS_LIB_FILE = ${GSTREAMER_ELEMENTS_LIB_DIR}/lib${GSTREAMER_ELEMENTS_LIB}.a
|
||||
GST_REAL_LIB_DIR=${REAL_BASE_DIR}/modules/gstreamerElements/lib
|
||||
|
||||
VPATH = ${SRC_DIR}
|
||||
|
||||
LIBXMLPP_CFLAGS=@LIBXMLPP_CFLAGS@
|
||||
|
@ -80,8 +90,8 @@ LIBXMLPP_LIBS=@LIBXMLPP_LIBS@
|
|||
# TODO: move ICU flag determination to configure script
|
||||
ICU_LIBS=`${USR_DIR}/bin/icu-config --ldflags --ldflags-toolutil --ldflags-icuio`
|
||||
|
||||
#GSTREAMER_CFLAGS=@GSTREAMER_CFLAGS@
|
||||
#GSTREAMER_LIBS=@GSTREAMER_LIBS@
|
||||
GSTREAMER_CFLAGS=@GSTREAMER_CFLAGS@
|
||||
GSTREAMER_LIBS=@GSTREAMER_LIBS@
|
||||
|
||||
TAGLIB_LIBS =`${USR_DIR}/bin/taglib-config --libs`
|
||||
|
||||
|
@ -97,6 +107,7 @@ TWOTEST_RUNNER = ${TMP_DIR}/twoTestRunner
|
|||
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
|
||||
|
||||
export LD_LIBRARY_PATH:=${LD_LIBRARY_PATH}:${USR_LIB_DIR}
|
||||
export GST_PLUGIN_PATH=${GST_REAL_LIB_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -111,6 +122,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
|
|||
-I${USR_INCLUDE_DIR} \
|
||||
-I${BOOST_INCLUDE_DIR} \
|
||||
-I${HELIX_INCLUDE_DIR} \
|
||||
-I${GSTREAMER_ELEMENTS_INCLUDE_DIR} \
|
||||
-I${CORE_INCLUDE_DIR} \
|
||||
-I${INCLUDE_DIR} -I${TMP_DIR}
|
||||
LDFLAGS = @LDFLAGS@ -pthread \
|
||||
|
@ -120,6 +132,7 @@ LDFLAGS = @LDFLAGS@ -pthread \
|
|||
${TAGLIB_LIBS} \
|
||||
-L${USR_LIB_DIR} \
|
||||
-L${CORE_LIB_DIR} \
|
||||
-L${GSTREAMER_ELEMENTS_LIB_DIR} \
|
||||
-L${HELIX_LIB_DIR} \
|
||||
-L${LIB_DIR}
|
||||
|
||||
|
@ -134,14 +147,15 @@ PLAYLIST_EXECUTOR_LIB_OBJS = ${TMP_DIR}/HelixPlayer.o \
|
|||
${TMP_DIR}/ClientContext.o \
|
||||
${TMP_DIR}/ErrorSink.o \
|
||||
${TMP_DIR}/HelixIIDs.o \
|
||||
${TMP_DIR}/AudioPlayerFactory.o
|
||||
# ${TMP_DIR}/GstreamerPlayer.o
|
||||
${TMP_DIR}/AudioPlayerFactory.o \
|
||||
${TMP_DIR}/GstreamerPlayer.o
|
||||
TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \
|
||||
${TMP_DIR}/HelixPlayerTest.o \
|
||||
${TMP_DIR}/AudioPlayerFactoryTest.o
|
||||
# ${TMP_DIR}/AudioPlayerFactoryGstreamerTest.o
|
||||
# ${TMP_DIR}/GstreamerPlayerTest.o
|
||||
${TMP_DIR}/AudioPlayerFactoryTest.o \
|
||||
${TMP_DIR}/AudioPlayerFactoryGstreamerTest.o \
|
||||
${TMP_DIR}/GstreamerPlayerTest.o
|
||||
TEST_RUNNER_LIBS = -l${PLAYLIST_EXECUTOR_LIB} -l${CORE_LIB} \
|
||||
-l${GSTREAMER_ELEMENTS_LIB} \
|
||||
${HELIX_LIBS} ${TAGLIB_LIBS} \
|
||||
-lcppunit -ldl -lm -lxmlrpc++
|
||||
|
||||
|
@ -196,15 +210,20 @@ ${TMP_DIR}:
|
|||
${DOXYGEN_DIR}:
|
||||
${MKDIR} ${DOXYGEN_DIR}
|
||||
|
||||
${TEST_RUNNER}: ${CORE_LIB_FILE} ${TEST_RUNNER_OBJS} ${PLAYLIST_EXECUTOR_LIB_FILE}
|
||||
${TEST_RUNNER}: ${CORE_LIB_FILE} ${GSTREAMER_ELEMENTS_LIB_FILE} \
|
||||
${TEST_RUNNER_OBJS} ${PLAYLIST_EXECUTOR_LIB_FILE}
|
||||
${CXX} ${LDFLAGS} -o $@ ${TEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS}
|
||||
|
||||
${TWOTEST_RUNNER}: ${CORE_LIB_FILE} ${TWOTEST_RUNNER_OBJS} ${PLAYLIST_EXECUTOR_LIB_FILE}
|
||||
${TWOTEST_RUNNER}: ${CORE_LIB_FILE} ${GSTREAMER_ELEMENTS_LIB_FILE} \
|
||||
${TWOTEST_RUNNER_OBJS} ${PLAYLIST_EXECUTOR_LIB_FILE}
|
||||
${CXX} ${LDFLAGS} -o $@ ${TWOTEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS}
|
||||
|
||||
${CORE_LIB_FILE}:
|
||||
${MAKE} -C ${CORE_DIR}
|
||||
|
||||
${GSTREAMER_ELEMENTS_LIB_FILE}:
|
||||
${MAKE} -C ${GSTREAMER_ELEMENTS_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Pattern rules
|
||||
|
|
|
@ -21,7 +21,7 @@ dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
dnl
|
||||
dnl
|
||||
dnl Author : $Author: maroy $
|
||||
dnl Version : $Revision: 1.7 $
|
||||
dnl Version : $Revision: 1.8 $
|
||||
dnl Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/etc/configure.ac,v $
|
||||
dnl-----------------------------------------------------------------------------
|
||||
|
||||
|
@ -35,7 +35,7 @@ dnl-----------------------------------------------------------------------------
|
|||
AC_INIT(PlaylistExecutor, 1.0, bugs@campware.org)
|
||||
AC_PREREQ(2.59)
|
||||
AC_COPYRIGHT([Copyright (c) 2004 Media Development Loan Fund under the GNU GPL])
|
||||
AC_REVISION($Revision: 1.7 $)
|
||||
AC_REVISION($Revision: 1.8 $)
|
||||
|
||||
AC_CONFIG_SRCDIR(../src/HelixPlayer.cxx)
|
||||
|
||||
|
@ -48,9 +48,9 @@ PKG_CHECK_MODULES(LIBXMLPP,[libxml++-2.6 >= 2.6.0])
|
|||
AC_SUBST(LIBXMLPP_CFLAGS)
|
||||
AC_SUBST(LIBXMLPP_LIBS)
|
||||
|
||||
dnl PKG_CHECK_MODULES(GSTREAMER,[gstreamer-0.8 >= 0.8])
|
||||
dnl AC_SUBST(GSTREAMER_CFLAGS)
|
||||
dnl AC_SUBST(GSTREAMER_LIBS)
|
||||
PKG_CHECK_MODULES(GSTREAMER,[gstreamer-0.8 >= 0.8])
|
||||
AC_SUBST(GSTREAMER_CFLAGS)
|
||||
AC_SUBST(GSTREAMER_LIBS)
|
||||
|
||||
dnl-----------------------------------------------------------------------------
|
||||
dnl enable compilaton for code coverage data
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.5 $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/AudioPlayerFactory.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerFactory.h"
|
||||
#include "HelixPlayer.h"
|
||||
//#include "GstreamerPlayer.h"
|
||||
#include "GstreamerPlayer.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
@ -106,7 +106,7 @@ AudioPlayerFactory :: configure(const xmlpp::Element & element)
|
|||
|
||||
return;
|
||||
}
|
||||
/*
|
||||
|
||||
nodes = element.get_children(GstreamerPlayer::getConfigElementName());
|
||||
if (nodes.size() >= 1) {
|
||||
const xmlpp::Element * configElement =
|
||||
|
@ -117,7 +117,7 @@ AudioPlayerFactory :: configure(const xmlpp::Element & element)
|
|||
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
throw std::invalid_argument("no audio player factories to configure");
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/GstreamerPlayer.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -34,6 +34,7 @@
|
|||
#endif
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "LiveSupport/GstreamerElements/autoplug.h"
|
||||
#include "GstreamerPlayer.h"
|
||||
|
||||
|
||||
|
@ -56,11 +57,6 @@ const std::string GstreamerPlayer::configElementNameStr = "gstreamerPlayer";
|
|||
*/
|
||||
static const std::string audioDeviceName = "audioDevice";
|
||||
|
||||
/**
|
||||
* The factories considered when creating the pipeline
|
||||
*/
|
||||
GList * GstreamerPlayer::factories = 0;
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
@ -103,7 +99,6 @@ GstreamerPlayer :: initialize(void) throw (std::exception)
|
|||
if (!gst_init_check(0, 0)) {
|
||||
throw std::runtime_error("couldn't initialize the gstreamer library");
|
||||
}
|
||||
initFactories();
|
||||
|
||||
// initialize the pipeline
|
||||
pipeline = gst_thread_new("audio-player");
|
||||
|
@ -111,88 +106,18 @@ GstreamerPlayer :: initialize(void) throw (std::exception)
|
|||
gst_object_ref(GST_OBJECT(pipeline));
|
||||
gst_object_sink(GST_OBJECT(pipeline));
|
||||
|
||||
filesrc = gst_element_factory_make("filesrc", "file-source");
|
||||
typefinder = gst_element_factory_make("typefind", "typefind");
|
||||
gst_element_link(filesrc, typefinder);
|
||||
gst_bin_add_many(GST_BIN(pipeline), filesrc, typefinder, NULL);
|
||||
|
||||
g_signal_connect(pipeline, "error", G_CALLBACK(errorHandler), this);
|
||||
g_signal_connect(pipeline, "state-change", G_CALLBACK(stateChange), this);
|
||||
g_signal_connect(typefinder, "have-type", G_CALLBACK(typeFound), this);
|
||||
|
||||
audiosink = gst_element_factory_make("alsasink", "audiosink");
|
||||
setAudioDevice(audioDevice);
|
||||
gst_bin_add(GST_BIN(pipeline), audiosink);
|
||||
|
||||
// set up other variables
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Initialize the list of factories
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: initFactories(void) throw ()
|
||||
{
|
||||
if (factories) {
|
||||
return;
|
||||
}
|
||||
|
||||
factories = gst_registry_pool_feature_filter(
|
||||
(GstPluginFeatureFilter) featureFilter, FALSE, NULL);
|
||||
// sort the factories according to their ranks
|
||||
factories = g_list_sort(factories, (GCompareFunc) compareRanks);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Filter plugins so that only demixers, decoders and parsers are considered
|
||||
*----------------------------------------------------------------------------*/
|
||||
gboolean
|
||||
GstreamerPlayer :: featureFilter(GstPluginFeature * feature,
|
||||
gpointer data)
|
||||
throw ()
|
||||
{
|
||||
const gchar * klass;
|
||||
guint rank;
|
||||
|
||||
// we only care about element factories
|
||||
if (!GST_IS_ELEMENT_FACTORY(feature)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// only parsers, demuxers and decoders
|
||||
klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature));
|
||||
if (g_strrstr(klass, "Demux") == NULL &&
|
||||
g_strrstr(klass, "Decoder") == NULL &&
|
||||
g_strrstr(klass, "Parse") == NULL) {
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// only select elements with autoplugging rank
|
||||
rank = gst_plugin_feature_get_rank(feature);
|
||||
if (rank < GST_RANK_MARGINAL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Compare two plugins according to their ranks
|
||||
*----------------------------------------------------------------------------*/
|
||||
gint
|
||||
GstreamerPlayer :: compareRanks(GstPluginFeature * feature1,
|
||||
GstPluginFeature * feature2)
|
||||
throw ()
|
||||
{
|
||||
return gst_plugin_feature_get_rank(feature1)
|
||||
- gst_plugin_feature_get_rank(feature2);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Handler for gstreamer errors.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -209,202 +134,6 @@ GstreamerPlayer :: errorHandler(GstElement * pipeline,
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Handler for the event when a matching type has been found
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: typeFound(GstElement * typefinder,
|
||||
guint probability,
|
||||
GstCaps * caps,
|
||||
gpointer self)
|
||||
throw ()
|
||||
{
|
||||
// actually plug now
|
||||
GstreamerPlayer * player = (GstreamerPlayer*) self;
|
||||
try {
|
||||
player->tryToPlug(gst_element_get_pad(typefinder, "src"), caps);
|
||||
} catch (std::logic_error &e) {
|
||||
// TODO: handle error
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Try to plug a matching element to the specified pad
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: tryToPlug(GstPad * pad,
|
||||
const GstCaps * caps)
|
||||
throw (std::logic_error)
|
||||
{
|
||||
GstObject * parent = GST_OBJECT(gst_pad_get_parent(pad));
|
||||
const gchar * mime;
|
||||
const GList * item;
|
||||
GstCaps * res;
|
||||
GstCaps * audiocaps;
|
||||
|
||||
// don't plug if we're already plugged
|
||||
if (GST_PAD_IS_LINKED(gst_element_get_pad(audiosink, "sink"))) {
|
||||
throw std::logic_error(std::string("Omitting link for pad ")
|
||||
+ gst_object_get_name(parent) + ":"
|
||||
+ gst_pad_get_name(pad)
|
||||
+ " because we're alreadey linked");
|
||||
}
|
||||
|
||||
// only plug audio
|
||||
mime = gst_structure_get_name(gst_caps_get_structure(caps, 0));
|
||||
if (!g_strrstr (mime, "audio")) {
|
||||
throw std::logic_error(std::string("Omitting link for pad ")
|
||||
+ gst_object_get_name(parent) + ":"
|
||||
+ gst_pad_get_name(pad)
|
||||
+ " because mimetype "
|
||||
+ mime
|
||||
+ " is non-audio");
|
||||
}
|
||||
|
||||
// can it link to the audiopad?
|
||||
audiocaps = gst_pad_get_caps(gst_element_get_pad(audiosink, "sink"));
|
||||
res = gst_caps_intersect(caps, audiocaps);
|
||||
if (res && !gst_caps_is_empty(res)) {
|
||||
closeLink(pad, audiosink, "sink", NULL);
|
||||
gst_caps_free(audiocaps);
|
||||
gst_caps_free(res);
|
||||
return;
|
||||
}
|
||||
gst_caps_free(audiocaps);
|
||||
gst_caps_free(res);
|
||||
|
||||
// try to plug from our list
|
||||
for (item = factories; item != NULL; item = item->next) {
|
||||
GstElementFactory * factory = GST_ELEMENT_FACTORY(item->data);
|
||||
const GList * pads;
|
||||
|
||||
for (pads = gst_element_factory_get_pad_templates (factory);
|
||||
pads != NULL;
|
||||
pads = pads->next) {
|
||||
|
||||
GstPadTemplate * templ = GST_PAD_TEMPLATE(pads->data);
|
||||
|
||||
// find the sink template - need an always pad
|
||||
if (templ->direction != GST_PAD_SINK ||
|
||||
templ->presence != GST_PAD_ALWAYS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// can it link?
|
||||
res = gst_caps_intersect(caps, templ->caps);
|
||||
if (res && !gst_caps_is_empty(res)) {
|
||||
GstElement *element;
|
||||
|
||||
// close link and return
|
||||
gst_caps_free(res);
|
||||
element = gst_element_factory_create(factory, NULL);
|
||||
closeLink(pad,
|
||||
element,
|
||||
templ->name_template,
|
||||
gst_element_factory_get_pad_templates(factory));
|
||||
|
||||
const gchar *klass =
|
||||
gst_element_factory_get_klass(GST_ELEMENT_FACTORY(factory));
|
||||
if (g_strrstr(klass, "Decoder")) {
|
||||
// if a decoder element, store it
|
||||
decoder = element;
|
||||
decoderSrc = gst_element_get_pad(decoder, "src");
|
||||
}
|
||||
return;
|
||||
}
|
||||
gst_caps_free(res);
|
||||
|
||||
// we only check one sink template per factory, so move on to the
|
||||
// next factory now
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
throw std::logic_error(std::string("No compatible pad found to decode ")
|
||||
+ mime
|
||||
+ " on "
|
||||
+ gst_object_get_name (parent) + ":"
|
||||
+ gst_pad_get_name (pad));
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Close the element links
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: closeLink(GstPad * srcpad,
|
||||
GstElement * sinkelement,
|
||||
const gchar * padname,
|
||||
const GList * templlist)
|
||||
throw ()
|
||||
{
|
||||
gboolean has_dynamic_pads = FALSE;
|
||||
|
||||
// add the element to the pipeline and set correct state
|
||||
gst_element_set_state(sinkelement, GST_STATE_PAUSED);
|
||||
gst_bin_add(GST_BIN(pipeline), sinkelement);
|
||||
gst_pad_link(srcpad, gst_element_get_pad(sinkelement, padname));
|
||||
gst_bin_sync_children_state(GST_BIN(pipeline));
|
||||
|
||||
// if we have static source pads, link those. If we have dynamic
|
||||
// source pads, listen for new-pad signals on the element
|
||||
for ( ; templlist != NULL; templlist = templlist->next) {
|
||||
GstPadTemplate *templ = GST_PAD_TEMPLATE(templlist->data);
|
||||
|
||||
// only sourcepads, no request pads
|
||||
if (templ->direction != GST_PAD_SRC ||
|
||||
templ->presence == GST_PAD_REQUEST) {
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (templ->presence) {
|
||||
case GST_PAD_ALWAYS: {
|
||||
GstPad *pad = gst_element_get_pad(sinkelement,
|
||||
templ->name_template);
|
||||
GstCaps *caps = gst_pad_get_caps(pad);
|
||||
|
||||
// link
|
||||
tryToPlug(pad, caps);
|
||||
gst_caps_free(caps);
|
||||
break;
|
||||
}
|
||||
|
||||
case GST_PAD_SOMETIMES:
|
||||
has_dynamic_pads = TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// listen for newly created pads if this element supports that
|
||||
if (has_dynamic_pads) {
|
||||
g_signal_connect(sinkelement, "new-pad", G_CALLBACK(newPad), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Event handler for when a new dynamic pad is created
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayer :: newPad(GstElement * element,
|
||||
GstPad * pad,
|
||||
gpointer self)
|
||||
throw ()
|
||||
{
|
||||
GstreamerPlayer * player = (GstreamerPlayer*) self;
|
||||
GstCaps * caps = gst_pad_get_caps(pad);
|
||||
|
||||
player->tryToPlug(pad, caps);
|
||||
gst_caps_free(caps);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Event handler for when the state of the pipeline changes
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -503,6 +232,10 @@ GstreamerPlayer :: open(const std::string fileUrl)
|
|||
{
|
||||
std::string filePath;
|
||||
|
||||
if (isOpened()) {
|
||||
close();
|
||||
}
|
||||
|
||||
if (fileUrl.find("file:") == 0) {
|
||||
filePath = fileUrl.substr(5, fileUrl.size());
|
||||
} else if (fileUrl.find("file://") == 0) {
|
||||
|
@ -511,7 +244,23 @@ GstreamerPlayer :: open(const std::string fileUrl)
|
|||
throw std::invalid_argument("badly formed URL or unsupported protocol");
|
||||
}
|
||||
|
||||
g_object_ref(G_OBJECT(audiosink));
|
||||
gst_bin_remove(GST_BIN(pipeline), audiosink);
|
||||
|
||||
filesrc = gst_element_factory_make("filesrc", "file-source");
|
||||
g_object_set(G_OBJECT(filesrc), "location", filePath.c_str(), NULL);
|
||||
|
||||
decoder = ls_gst_autoplug_plug_source(filesrc, "decoder");
|
||||
|
||||
if (!decoder) {
|
||||
throw std::invalid_argument(std::string("can't open URL ") + fileUrl);
|
||||
}
|
||||
|
||||
gst_element_link(decoder, audiosink);
|
||||
gst_bin_add_many(GST_BIN(pipeline), filesrc, decoder, audiosink, NULL);
|
||||
|
||||
gst_element_set_state(pipeline, GST_STATE_PAUSED);
|
||||
gst_bin_sync_children_state(GST_BIN(pipeline));
|
||||
}
|
||||
|
||||
|
||||
|
@ -521,11 +270,7 @@ GstreamerPlayer :: open(const std::string fileUrl)
|
|||
bool
|
||||
GstreamerPlayer :: isOpened(void) throw ()
|
||||
{
|
||||
gchar * str;
|
||||
|
||||
g_object_get(G_OBJECT(filesrc), "location", &str, NULL);
|
||||
|
||||
return str != 0;
|
||||
return decoder != 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -539,8 +284,8 @@ GstreamerPlayer :: getPlaylength(void) throw ()
|
|||
gint64 ns;
|
||||
GstFormat format = GST_FORMAT_TIME;
|
||||
|
||||
if (decoderSrc
|
||||
&& gst_pad_query(decoderSrc, GST_QUERY_TOTAL, &format, &ns)
|
||||
if (decoder
|
||||
&& gst_element_query(decoder, GST_QUERY_TOTAL, &format, &ns)
|
||||
&& format == GST_FORMAT_TIME) {
|
||||
|
||||
// use microsec, as nanosec() is not found by the compiler (?)
|
||||
|
@ -617,6 +362,12 @@ GstreamerPlayer :: close(void) throw ()
|
|||
}
|
||||
|
||||
gst_element_set_state(pipeline, GST_STATE_NULL);
|
||||
gst_element_unlink(filesrc, decoder);
|
||||
gst_element_unlink(decoder, audiosink);
|
||||
gst_bin_remove(GST_BIN(pipeline), decoder);
|
||||
gst_bin_remove(GST_BIN(pipeline), filesrc);
|
||||
filesrc = 0;
|
||||
decoder = 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.3 $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/GstreamerPlayer.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -42,7 +42,7 @@
|
|||
|
||||
#include <list>
|
||||
|
||||
//#include <gst/gst.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "LiveSupport/Core/Configurable.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
|
||||
|
@ -86,7 +86,7 @@ using namespace LiveSupport::Core;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.3 $
|
||||
* @version $Revision: 1.4 $
|
||||
*/
|
||||
class GstreamerPlayer : virtual public Configurable,
|
||||
virtual public AudioPlayerInterface
|
||||
|
@ -107,32 +107,16 @@ class GstreamerPlayer : virtual public Configurable,
|
|||
*/
|
||||
GstElement * filesrc;
|
||||
|
||||
/**
|
||||
* The typefinder element.
|
||||
*/
|
||||
GstElement * typefinder;
|
||||
|
||||
/**
|
||||
* The decoder element.
|
||||
*/
|
||||
GstElement * decoder;
|
||||
|
||||
/**
|
||||
* The source pad of the decoder element.
|
||||
* This pad can be used to navigate in a time-based manner.
|
||||
*/
|
||||
GstPad * decoderSrc;
|
||||
|
||||
/**
|
||||
* The audio sink
|
||||
*/
|
||||
GstElement * audiosink;
|
||||
|
||||
/**
|
||||
* The list of factories considered when creating the pipeline.
|
||||
*/
|
||||
static GList * factories;
|
||||
|
||||
/**
|
||||
* The URL to play.
|
||||
*/
|
||||
|
@ -162,40 +146,6 @@ class GstreamerPlayer : virtual public Configurable,
|
|||
*/
|
||||
ListenerVector listeners;
|
||||
|
||||
/**
|
||||
* Initialize the list of factories that we're interested in
|
||||
* when creating the pipeline.
|
||||
*/
|
||||
static void
|
||||
initFactories(void) throw ();
|
||||
|
||||
/**
|
||||
* Filter plugins so that only factories for demuxers, decoders
|
||||
* and parsers are considered.
|
||||
*
|
||||
* @param feature the features of the plugin to check
|
||||
* @param data not used
|
||||
* @return true of the supplied feature is a factory for a demuxer,
|
||||
* decoder or parser, false otherwise
|
||||
*/
|
||||
static gboolean
|
||||
featureFilter(GstPluginFeature * feature,
|
||||
gpointer data)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Compare the plugin features according to their rank.
|
||||
*
|
||||
* @param feature1 one of the features to compare
|
||||
* @param feature2 the second feature to compare
|
||||
* @return 0 of the ranks are equal, <0 if feature1 is ranked lower,
|
||||
* >0 if feature1 is ranked higher
|
||||
*/
|
||||
static gint
|
||||
compareRanks(GstPluginFeature * feature1,
|
||||
GstPluginFeature * feature2)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Handler to recieve errors from gstreamer.
|
||||
*
|
||||
|
@ -212,34 +162,6 @@ class GstreamerPlayer : virtual public Configurable,
|
|||
gchar * debug,
|
||||
gpointer self) throw ();
|
||||
|
||||
/**
|
||||
* Even handler for when a matching type was found by typefineder.
|
||||
*
|
||||
* @param typefinder the typefineder that found the match
|
||||
* @param probability the probability of the match
|
||||
* @param caps the capabilities of the found match
|
||||
* @param self pointer to the associated GstreamPlayer object.
|
||||
*/
|
||||
static void
|
||||
typeFound(GstElement * typefinder,
|
||||
guint probability,
|
||||
GstCaps * caps,
|
||||
gpointer self) throw ();
|
||||
|
||||
/**
|
||||
* Event handler for when a new dynamic pad is found. Plug the found
|
||||
* pad by calling tryToPlug().
|
||||
*
|
||||
* @param element the element where the new pad came up.
|
||||
* @param pad the new pad
|
||||
* @param self reference to the associated GstreamerPlayer object
|
||||
*/
|
||||
static void
|
||||
newPad(GstElement * element,
|
||||
GstPad * pad,
|
||||
gpointer self)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Event handler for the state change event on the pipeline.
|
||||
* Use this to catch events like playing has ended.
|
||||
|
@ -256,33 +178,6 @@ class GstreamerPlayer : virtual public Configurable,
|
|||
gpointer self)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Try to plug a matching element to the specified pad
|
||||
*
|
||||
* @param pad the pad to plug to
|
||||
* @param caps find a matching element to these capabilities
|
||||
* @exception std::logic_error if couldn't plug
|
||||
*/
|
||||
void
|
||||
tryToPlug(GstPad * pad,
|
||||
const GstCaps * caps)
|
||||
throw (std::logic_error);
|
||||
|
||||
/**
|
||||
* Close the link between a source pad and a sink element
|
||||
*
|
||||
* @param srcpad the source pad to link up
|
||||
* @param sinkelement link srcpad to this element
|
||||
* @param padname use this pad from sinkelement to link to
|
||||
* @param templlist use pads from these templates
|
||||
*/
|
||||
void
|
||||
closeLink(GstPad * srcpad,
|
||||
GstElement * sinkelement,
|
||||
const gchar * padname,
|
||||
const GList * templlist)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Send the onStop event to all attached listeners.
|
||||
*/
|
||||
|
@ -307,9 +202,7 @@ class GstreamerPlayer : virtual public Configurable,
|
|||
{
|
||||
pipeline = 0;
|
||||
filesrc = 0;
|
||||
typefinder = 0;
|
||||
decoder = 0;
|
||||
decoderSrc = 0;
|
||||
audiosink = 0;
|
||||
initialized = false;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/GstreamerPlayerTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -153,6 +153,35 @@ GstreamerPlayerTest :: simplePlayTest(void)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Play a simple SMIL file
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GstreamerPlayerTest :: smilTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||
|
||||
player->initialize();
|
||||
try {
|
||||
player->open("file:var/simpleSmil.smil");
|
||||
} catch (std::invalid_argument &e) {
|
||||
CPPUNIT_FAIL(e.what());
|
||||
}
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
while (player->isPlaying()) {
|
||||
TimeConversion::sleep(sleepT);
|
||||
}
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
player->close();
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check for error conditions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -274,7 +303,9 @@ GstreamerPlayerTest :: eventListenerTest(void)
|
|||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||
player->start();
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||
while (player->isPlaying()) {
|
||||
|
@ -284,6 +315,7 @@ GstreamerPlayerTest :: eventListenerTest(void)
|
|||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT(listener1->stopFlag);
|
||||
listener1->stopFlag = false;
|
||||
player->close();
|
||||
|
||||
// try with two listeners
|
||||
Ptr<TestEventListener>::Ref listener2(new TestEventListener());
|
||||
|
@ -297,7 +329,9 @@ GstreamerPlayerTest :: eventListenerTest(void)
|
|||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||
player->start();
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||
|
@ -311,6 +345,7 @@ GstreamerPlayerTest :: eventListenerTest(void)
|
|||
CPPUNIT_ASSERT(listener2->stopFlag);
|
||||
listener1->stopFlag = false;
|
||||
listener2->stopFlag = false;
|
||||
player->close();
|
||||
|
||||
// try with only the second listener
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
|
@ -322,7 +357,9 @@ GstreamerPlayerTest :: eventListenerTest(void)
|
|||
);
|
||||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||
player->start();
|
||||
CPPUNIT_ASSERT_NO_THROW(
|
||||
player->start();
|
||||
);
|
||||
CPPUNIT_ASSERT(player->isPlaying());
|
||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||
while (player->isPlaying()) {
|
||||
|
@ -332,8 +369,8 @@ GstreamerPlayerTest :: eventListenerTest(void)
|
|||
CPPUNIT_ASSERT(!player->isPlaying());
|
||||
CPPUNIT_ASSERT(listener2->stopFlag);
|
||||
listener2->stopFlag = false;
|
||||
|
||||
player->close();
|
||||
|
||||
player->deInitialize();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/GstreamerPlayerTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -58,7 +58,7 @@ namespace PlaylistExecutor {
|
|||
* Unit test for the GstreamerPlayer class.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
* @see GstreamerPlayer
|
||||
*/
|
||||
class GstreamerPlayerTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -66,6 +66,7 @@ class GstreamerPlayerTest : public CPPUNIT_NS::TestFixture
|
|||
CPPUNIT_TEST_SUITE(GstreamerPlayerTest);
|
||||
CPPUNIT_TEST(firstTest);
|
||||
CPPUNIT_TEST(simplePlayTest);
|
||||
CPPUNIT_TEST(smilTest);
|
||||
CPPUNIT_TEST(checkErrorConditions);
|
||||
CPPUNIT_TEST(eventListenerAttachTest);
|
||||
CPPUNIT_TEST(eventListenerTest);
|
||||
|
@ -97,6 +98,14 @@ class GstreamerPlayerTest : public CPPUNIT_NS::TestFixture
|
|||
void
|
||||
simplePlayTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Play a simple SMIL file.
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
smilTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Check for error conditions.
|
||||
*
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<smil xmlns = "http://www.w3.org/2001/SMIL20/Language"
|
||||
xmlns:rn = "http://features.real.com/2001/SMIL20/Extensions">
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<smil xmlns = "http://www.w3.org/2001/SMIL20/Language">
|
||||
<body>
|
||||
<audio src="file:var/test-short.mp3"/>
|
||||
<par>
|
||||
<audio src="file:var/test-short.mp3"/>
|
||||
</par>
|
||||
</body>
|
||||
</smil>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue