added getPlaylength() function to AudioPlayerInterface
renamed playThis() to open(), and added close() function
This commit is contained in:
parent
6eb6926c8b
commit
9566112cfd
|
@ -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/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerInterface.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerInterface.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -43,11 +43,17 @@
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
|
|
||||||
|
#include "LiveSupport/Core/Ptr.h"
|
||||||
|
|
||||||
|
|
||||||
namespace LiveSupport {
|
namespace LiveSupport {
|
||||||
namespace PlaylistExecutor {
|
namespace PlaylistExecutor {
|
||||||
|
|
||||||
using namespace LiveSupport;
|
using namespace boost;
|
||||||
|
|
||||||
|
using namespace LiveSupport::Core;
|
||||||
|
|
||||||
/* ================================================================ constants */
|
/* ================================================================ constants */
|
||||||
|
|
||||||
|
@ -61,7 +67,7 @@ using namespace LiveSupport;
|
||||||
* A generic interface for playing audio files.
|
* A generic interface for playing audio files.
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: maroy $
|
||||||
* @version $Revision: 1.3 $
|
* @version $Revision: 1.4 $
|
||||||
*/
|
*/
|
||||||
class AudioPlayerInterface
|
class AudioPlayerInterface
|
||||||
{
|
{
|
||||||
|
@ -95,16 +101,36 @@ class AudioPlayerInterface
|
||||||
* will be accessed automatically.
|
* will be accessed automatically.
|
||||||
* Note: this call will <b>not</b> start playing! You will
|
* Note: this call will <b>not</b> start playing! You will
|
||||||
* have to call the start() function to begin playing.
|
* have to call the start() function to begin playing.
|
||||||
|
* Always close any opened resources with a call to close().
|
||||||
*
|
*
|
||||||
* @param fileUrl a URL to a file
|
* @param fileUrl a URL to a file
|
||||||
* @exception std::invalid_argument if the supplied fileUrl
|
* @exception std::invalid_argument if the supplied fileUrl
|
||||||
* seems to be invalid.
|
* seems to be invalid.
|
||||||
|
* @see #close
|
||||||
* @see #start
|
* @see #start
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
playThis(const std::string fileUrl) throw (std::invalid_argument)
|
open(const std::string fileUrl) throw (std::invalid_argument)
|
||||||
= 0;
|
= 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close an audio source that was opened.
|
||||||
|
*
|
||||||
|
* @see #open
|
||||||
|
*/
|
||||||
|
virtual void
|
||||||
|
close(void) throw () = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the length of the currently opened audio clip.
|
||||||
|
* This function waits as long as necessary to get the length.
|
||||||
|
*
|
||||||
|
* @return the length of the currently playing audio clip, or 0,
|
||||||
|
* if nothing is openned.
|
||||||
|
*/
|
||||||
|
virtual Ptr<posix_time::time_duration>::Ref
|
||||||
|
getPlaylength(void) throw () = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start playing.
|
* Start playing.
|
||||||
* This call will start playing the active playlist, which was
|
* This call will start playing the active playlist, which was
|
||||||
|
|
|
@ -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/playlistExecutor/src/Attic/AdviseSink.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/AdviseSink.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include <hxcom.h>
|
#include <hxcom.h>
|
||||||
|
|
||||||
|
#include "HelixPlayer.h"
|
||||||
#include "AdviseSink.h"
|
#include "AdviseSink.h"
|
||||||
|
|
||||||
using namespace LiveSupport::PlaylistExecutor;
|
using namespace LiveSupport::PlaylistExecutor;
|
||||||
|
@ -56,12 +57,15 @@ using namespace LiveSupport::PlaylistExecutor;
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Construct the advise sink
|
* Construct the advise sink
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
AdviseSink::AdviseSink(IUnknown * pUnknown) throw ()
|
AdviseSink::AdviseSink(IUnknown * pUnknown,
|
||||||
|
Ptr<HelixPlayer>::Ref helixPlayer) throw ()
|
||||||
: lRefCount(0)
|
: lRefCount(0)
|
||||||
, pUnknown(NULL)
|
, pUnknown(NULL)
|
||||||
, pRegistry(NULL)
|
, pRegistry(NULL)
|
||||||
, pScheduler(NULL)
|
, pScheduler(NULL)
|
||||||
{
|
{
|
||||||
|
this->helixPlayer = helixPlayer;
|
||||||
|
|
||||||
if (pUnknown) {
|
if (pUnknown) {
|
||||||
this->pUnknown = pUnknown;
|
this->pUnknown = pUnknown;
|
||||||
this->pUnknown->AddRef();
|
this->pUnknown->AddRef();
|
||||||
|
@ -168,6 +172,7 @@ STDMETHODIMP
|
||||||
AdviseSink::OnPosLength(UINT32 ulPosition,
|
AdviseSink::OnPosLength(UINT32 ulPosition,
|
||||||
UINT32 ulLength) throw ()
|
UINT32 ulLength) throw ()
|
||||||
{
|
{
|
||||||
|
helixPlayer->setPlaylength(ulLength);
|
||||||
return HXR_OK;
|
return HXR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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/playlistExecutor/src/Attic/AdviseSink.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/AdviseSink.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -46,11 +46,13 @@
|
||||||
#include <hxengin.h>
|
#include <hxengin.h>
|
||||||
#include <hxclsnk.h>
|
#include <hxclsnk.h>
|
||||||
|
|
||||||
|
#include "LiveSupport/Core/Ptr.h"
|
||||||
|
|
||||||
|
|
||||||
namespace LiveSupport {
|
namespace LiveSupport {
|
||||||
namespace PlaylistExecutor {
|
namespace PlaylistExecutor {
|
||||||
|
|
||||||
using namespace LiveSupport;
|
using namespace LiveSupport::Core;
|
||||||
|
|
||||||
|
|
||||||
/* ================================================================ constants */
|
/* ================================================================ constants */
|
||||||
|
@ -61,12 +63,15 @@ using namespace LiveSupport;
|
||||||
|
|
||||||
/* =============================================================== data types */
|
/* =============================================================== data types */
|
||||||
|
|
||||||
|
class HelixPlayer;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helix client advise sink, receiving notifications on the status
|
* A Helix client advise sink, receiving notifications on the status
|
||||||
* of the client playing.
|
* of the client playing.
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: maroy $
|
||||||
* @version $Revision: 1.1 $
|
* @version $Revision: 1.2 $
|
||||||
*/
|
*/
|
||||||
class AdviseSink : public IHXClientAdviseSink
|
class AdviseSink : public IHXClientAdviseSink
|
||||||
{
|
{
|
||||||
|
@ -100,15 +105,24 @@ class AdviseSink : public IHXClientAdviseSink
|
||||||
* The time playing os stopped.
|
* The time playing os stopped.
|
||||||
*/
|
*/
|
||||||
UINT32 ulStopTime;
|
UINT32 ulStopTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The HelixPlayer object this advise sink is associated with.
|
||||||
|
*/
|
||||||
|
Ptr<HelixPlayer>::Ref helixPlayer;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param pUknown the Helix object to initialize this sink with
|
||||||
|
* @param helixPlayer the HelixPlayer object this sink is
|
||||||
|
* associated with
|
||||||
*/
|
*/
|
||||||
AdviseSink(IUnknown * pUnknown) throw ();
|
AdviseSink(IUnknown * pUnknown,
|
||||||
|
Ptr<HelixPlayer>::Ref helixPlayer) throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
|
|
|
@ -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/playlistExecutor/src/Attic/ClientContext.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/ClientContext.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -42,6 +42,7 @@
|
||||||
#include "ErrorSink.h"
|
#include "ErrorSink.h"
|
||||||
#include "AuthenticationManager.h"
|
#include "AuthenticationManager.h"
|
||||||
#include "ClientContext.h"
|
#include "ClientContext.h"
|
||||||
|
#include "HelixPlayer.h"
|
||||||
|
|
||||||
using namespace LiveSupport::PlaylistExecutor;
|
using namespace LiveSupport::PlaylistExecutor;
|
||||||
|
|
||||||
|
@ -61,13 +62,14 @@ using namespace LiveSupport::PlaylistExecutor;
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Construct the Client Context
|
* Construct the Client Context
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
ClientContext::ClientContext() throw ()
|
ClientContext::ClientContext(Ptr<HelixPlayer>::Ref helixPlayer) throw ()
|
||||||
: lRefCount(0)
|
: lRefCount(0)
|
||||||
, pClientSink(NULL)
|
, pClientSink(NULL)
|
||||||
, pErrorSink(NULL)
|
, pErrorSink(NULL)
|
||||||
, pAuthMgr(NULL)
|
, pAuthMgr(NULL)
|
||||||
, pDefaultPrefs(NULL)
|
, pDefaultPrefs(NULL)
|
||||||
{
|
{
|
||||||
|
this->helixPlayer = helixPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,7 +92,7 @@ ClientContext::Init(IUnknown * pUnknown,
|
||||||
{
|
{
|
||||||
char* pszCipher = NULL;
|
char* pszCipher = NULL;
|
||||||
|
|
||||||
pClientSink = new AdviseSink(pUnknown);
|
pClientSink = new AdviseSink(pUnknown, helixPlayer);
|
||||||
pErrorSink = new ErrorSink(pUnknown);
|
pErrorSink = new ErrorSink(pUnknown);
|
||||||
pAuthMgr = new AuthenticationManager();
|
pAuthMgr = new AuthenticationManager();
|
||||||
|
|
||||||
|
|
|
@ -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/playlistExecutor/src/Attic/ClientContext.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/ClientContext.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -43,12 +43,13 @@
|
||||||
#include <hxprefs.h>
|
#include <hxprefs.h>
|
||||||
#include <ihxpckts.h>
|
#include <ihxpckts.h>
|
||||||
|
|
||||||
|
#include "LiveSupport/Core/Ptr.h"
|
||||||
#include "AdviseSink.h"
|
#include "AdviseSink.h"
|
||||||
|
|
||||||
namespace LiveSupport {
|
namespace LiveSupport {
|
||||||
namespace PlaylistExecutor {
|
namespace PlaylistExecutor {
|
||||||
|
|
||||||
using namespace LiveSupport;
|
using namespace LiveSupport::Core;
|
||||||
|
|
||||||
|
|
||||||
/* ================================================================ constants */
|
/* ================================================================ constants */
|
||||||
|
@ -60,12 +61,13 @@ using namespace LiveSupport;
|
||||||
/* =============================================================== data types */
|
/* =============================================================== data types */
|
||||||
|
|
||||||
class ExampleErrorMessages;
|
class ExampleErrorMessages;
|
||||||
|
class HelixPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helix client context.
|
* A Helix client context.
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: maroy $
|
||||||
* @version $Revision: 1.1 $
|
* @version $Revision: 1.2 $
|
||||||
*/
|
*/
|
||||||
class ClientContext : public IHXPreferences
|
class ClientContext : public IHXPreferences
|
||||||
{
|
{
|
||||||
|
@ -75,6 +77,11 @@ class ClientContext : public IHXPreferences
|
||||||
*/
|
*/
|
||||||
LONG32 lRefCount;
|
LONG32 lRefCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The HelixPlayer object this is the client context for,
|
||||||
|
*/
|
||||||
|
Ptr<HelixPlayer>::Ref helixPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The advise sink recieving event notifications.
|
* The advise sink recieving event notifications.
|
||||||
*/
|
*/
|
||||||
|
@ -105,8 +112,10 @@ class ClientContext : public IHXPreferences
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param helixPlayer the HelixPlayer this is a client context for.
|
||||||
*/
|
*/
|
||||||
ClientContext() throw ();
|
ClientContext(Ptr<HelixPlayer>::Ref helixPlayer) throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
|
|
|
@ -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/playlistExecutor/src/Attic/HelixPlayer.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/HelixPlayer.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -158,7 +158,7 @@ HelixPlayer :: initialize(void) throw (std::exception)
|
||||||
}
|
}
|
||||||
|
|
||||||
// create and attach the client context
|
// create and attach the client context
|
||||||
clientContext = new ClientContext();
|
clientContext = new ClientContext(shared_from_this());
|
||||||
clientContext->AddRef();
|
clientContext->AddRef();
|
||||||
|
|
||||||
IHXPreferences * preferences = 0;
|
IHXPreferences * preferences = 0;
|
||||||
|
@ -227,9 +227,10 @@ HelixPlayer :: deInitialize(void) throw ()
|
||||||
* Specify which file to play
|
* Specify which file to play
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
HelixPlayer :: playThis(const std::string fileUrl)
|
HelixPlayer :: open(const std::string fileUrl)
|
||||||
throw (std::invalid_argument)
|
throw (std::invalid_argument)
|
||||||
{
|
{
|
||||||
|
playlength = 0UL;
|
||||||
// the only way to check if this is a valid URL is to see if the
|
// the only way to check if this is a valid URL is to see if the
|
||||||
// source count increases for the player.
|
// source count increases for the player.
|
||||||
UINT16 sourceCount = player->GetSourceCount();
|
UINT16 sourceCount = player->GetSourceCount();
|
||||||
|
@ -242,6 +243,33 @@ HelixPlayer :: playThis(const std::string fileUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Get the length of the current audio clip.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<time_duration>::Ref
|
||||||
|
HelixPlayer :: getPlaylength(void) throw ()
|
||||||
|
{
|
||||||
|
Ptr<time_duration>::Ref length;
|
||||||
|
|
||||||
|
// only bother if there is something to check for.
|
||||||
|
if (player->GetSourceCount() > 0) {
|
||||||
|
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(100)));
|
||||||
|
|
||||||
|
// wait until the playlength is set to a sensible value
|
||||||
|
// by the advise sink. this may take a while
|
||||||
|
while (playlength == 0) {
|
||||||
|
TimeConversion::sleep(sleepT);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long secs = playlength / 1000UL;
|
||||||
|
unsigned long millisecs = playlength - (secs * 1000UL);
|
||||||
|
length.reset(new time_duration(seconds(secs) + millisec(millisecs)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Start playing
|
* Start playing
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -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/playlistExecutor/src/Attic/HelixPlayer.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/HelixPlayer.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -40,6 +40,7 @@
|
||||||
#include "configure.h"
|
#include "configure.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
|
|
||||||
#include <dllacces.h>
|
#include <dllacces.h>
|
||||||
#include <dllpath.h>
|
#include <dllpath.h>
|
||||||
|
@ -48,7 +49,6 @@
|
||||||
#include "LiveSupport/Core/Thread.h"
|
#include "LiveSupport/Core/Thread.h"
|
||||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
|
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
|
||||||
|
|
||||||
#include "AdviseSink.h"
|
|
||||||
#include "ErrorSink.h"
|
#include "ErrorSink.h"
|
||||||
#include "AuthenticationManager.h"
|
#include "AuthenticationManager.h"
|
||||||
#include "ClientContext.h"
|
#include "ClientContext.h"
|
||||||
|
@ -57,6 +57,8 @@
|
||||||
namespace LiveSupport {
|
namespace LiveSupport {
|
||||||
namespace PlaylistExecutor {
|
namespace PlaylistExecutor {
|
||||||
|
|
||||||
|
using namespace boost;
|
||||||
|
|
||||||
using namespace LiveSupport;
|
using namespace LiveSupport;
|
||||||
using namespace LiveSupport::Core;
|
using namespace LiveSupport::Core;
|
||||||
|
|
||||||
|
@ -89,10 +91,11 @@ using namespace LiveSupport::Core;
|
||||||
* </pre></code>
|
* </pre></code>
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: maroy $
|
||||||
* @version $Revision: 1.4 $
|
* @version $Revision: 1.5 $
|
||||||
*/
|
*/
|
||||||
class HelixPlayer : virtual public Configurable,
|
class HelixPlayer : virtual public Configurable,
|
||||||
virtual public AudioPlayerInterface
|
virtual public AudioPlayerInterface,
|
||||||
|
public boost::enable_shared_from_this<HelixPlayer>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
@ -140,6 +143,12 @@ class HelixPlayer : virtual public Configurable,
|
||||||
*/
|
*/
|
||||||
std::string url;
|
std::string url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The length of the currently playing audio clip,
|
||||||
|
* in milliseconds.
|
||||||
|
*/
|
||||||
|
unsigned long playlength;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag to indicate if this object has been initialized.
|
* Flag to indicate if this object has been initialized.
|
||||||
*/
|
*/
|
||||||
|
@ -168,6 +177,7 @@ class HelixPlayer : virtual public Configurable,
|
||||||
{
|
{
|
||||||
playing = false;
|
playing = false;
|
||||||
initialized = false;
|
initialized = false;
|
||||||
|
playlength = 0UL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,14 +236,32 @@ class HelixPlayer : virtual public Configurable,
|
||||||
* will be accessed automatically.
|
* will be accessed automatically.
|
||||||
* Note: this call will <b>not</b> start playing! You will
|
* Note: this call will <b>not</b> start playing! You will
|
||||||
* have to call the start() function to begin playing.
|
* have to call the start() function to begin playing.
|
||||||
|
* Always close any opened resources with a call to close().
|
||||||
*
|
*
|
||||||
* @param fileUrl a URL to a file
|
* @param fileUrl a URL to a file
|
||||||
* @exception std::invalid_argument if the supplied fileUrl
|
* @exception std::invalid_argument if the supplied fileUrl
|
||||||
* seems to be invalid.
|
* seems to be invalid.
|
||||||
|
* @see #close
|
||||||
* @see #start
|
* @see #start
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
playThis(const std::string fileUrl) throw (std::invalid_argument);
|
open(const std::string fileUrl) throw (std::invalid_argument);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close an audio source that was opened.
|
||||||
|
*
|
||||||
|
* @see #open
|
||||||
|
*/
|
||||||
|
virtual void
|
||||||
|
close(void) throw ()
|
||||||
|
{
|
||||||
|
if (isPlaying()) {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// nothing else to do here, the Helix Player object does not
|
||||||
|
// have a close() function...
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start playing.
|
* Start playing.
|
||||||
|
@ -266,6 +294,30 @@ class HelixPlayer : virtual public Configurable,
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
stop(void) throw (std::logic_error);
|
stop(void) throw (std::logic_error);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the length of the currenlty playing audio clip.
|
||||||
|
* This is called by AdviseSink only!
|
||||||
|
*
|
||||||
|
* @param playlength the length of the currently playing audio clip.
|
||||||
|
* in milliseconds
|
||||||
|
* @see AdviseSink#OnPosLength
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
setPlaylength(unsigned long playlength)
|
||||||
|
{
|
||||||
|
this->playlength = playlength;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the length of the currently opened audio clip.
|
||||||
|
* This function waits as long as necessary to get the length.
|
||||||
|
*
|
||||||
|
* @return the length of the currently playing audio clip, or 0,
|
||||||
|
* if nothing is openned.
|
||||||
|
*/
|
||||||
|
virtual Ptr<posix_time::time_duration>::Ref
|
||||||
|
getPlaylength(void) throw ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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/playlistExecutor/src/Attic/HelixPlayerTest.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/HelixPlayerTest.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -119,6 +119,26 @@ HelixPlayerTest :: firstTest(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Check the length of an audio file
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
HelixPlayerTest :: playlengthTest(void)
|
||||||
|
throw (CPPUNIT_NS::Exception)
|
||||||
|
{
|
||||||
|
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||||
|
|
||||||
|
helixPlayer->initialize();
|
||||||
|
helixPlayer->open("file:var/test.mp3");
|
||||||
|
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
||||||
|
Ptr<time_duration>::Ref playlength = helixPlayer->getPlaylength();
|
||||||
|
CPPUNIT_ASSERT(playlength->seconds() == 14);
|
||||||
|
CPPUNIT_ASSERT(playlength->fractional_seconds() == 785000);
|
||||||
|
helixPlayer->close();
|
||||||
|
helixPlayer->deInitialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Play something simple
|
* Play something simple
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -129,7 +149,7 @@ HelixPlayerTest :: simplePlayTest(void)
|
||||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||||
|
|
||||||
helixPlayer->initialize();
|
helixPlayer->initialize();
|
||||||
helixPlayer->playThis("file:var/test.mp3");
|
helixPlayer->open("file:var/test.mp3");
|
||||||
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
||||||
helixPlayer->start();
|
helixPlayer->start();
|
||||||
CPPUNIT_ASSERT(helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(helixPlayer->isPlaying());
|
||||||
|
@ -137,6 +157,7 @@ HelixPlayerTest :: simplePlayTest(void)
|
||||||
TimeConversion::sleep(sleepT);
|
TimeConversion::sleep(sleepT);
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
||||||
|
helixPlayer->close();
|
||||||
helixPlayer->deInitialize();
|
helixPlayer->deInitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +193,7 @@ HelixPlayerTest :: checkErrorConditions(void)
|
||||||
|
|
||||||
gotException = false;
|
gotException = false;
|
||||||
try {
|
try {
|
||||||
helixPlayer->playThis("totally/bad/URL");
|
helixPlayer->open("totally/bad/URL");
|
||||||
} catch (std::invalid_argument &e) {
|
} catch (std::invalid_argument &e) {
|
||||||
gotException = true;
|
gotException = true;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +222,7 @@ HelixPlayerTest :: smilTest(void)
|
||||||
|
|
||||||
helixPlayer->initialize();
|
helixPlayer->initialize();
|
||||||
|
|
||||||
helixPlayer->playThis("file:var/simpleSmil.smil");
|
helixPlayer->open("file:var/simpleSmil.smil");
|
||||||
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
||||||
helixPlayer->start();
|
helixPlayer->start();
|
||||||
CPPUNIT_ASSERT(helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(helixPlayer->isPlaying());
|
||||||
|
@ -209,6 +230,9 @@ HelixPlayerTest :: smilTest(void)
|
||||||
TimeConversion::sleep(sleepT);
|
TimeConversion::sleep(sleepT);
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
||||||
|
|
||||||
|
helixPlayer->close();
|
||||||
|
helixPlayer->deInitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -222,7 +246,7 @@ HelixPlayerTest :: playFile(const std::string & fileName)
|
||||||
{
|
{
|
||||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||||
|
|
||||||
helixPlayer->playThis(fileName.c_str());
|
helixPlayer->open(fileName.c_str());
|
||||||
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
||||||
helixPlayer->start();
|
helixPlayer->start();
|
||||||
CPPUNIT_ASSERT(helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(helixPlayer->isPlaying());
|
||||||
|
@ -230,6 +254,7 @@ HelixPlayerTest :: playFile(const std::string & fileName)
|
||||||
TimeConversion::sleep(sleepT);
|
TimeConversion::sleep(sleepT);
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
||||||
|
helixPlayer->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -307,7 +332,7 @@ HelixPlayerTest :: smilSoundAnimationTest(void)
|
||||||
/* TODO: there is a bug with sound level animation, it causes a segfault
|
/* TODO: there is a bug with sound level animation, it causes a segfault
|
||||||
see https://bugs.helixcommunity.org/show_bug.cgi?id=3310
|
see https://bugs.helixcommunity.org/show_bug.cgi?id=3310
|
||||||
*/
|
*/
|
||||||
helixPlayer->playThis("file:var/animateSound.smil");
|
helixPlayer->open("file:var/animateSound.smil");
|
||||||
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
||||||
helixPlayer->start();
|
helixPlayer->start();
|
||||||
CPPUNIT_ASSERT(helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(helixPlayer->isPlaying());
|
||||||
|
@ -315,6 +340,7 @@ HelixPlayerTest :: smilSoundAnimationTest(void)
|
||||||
TimeConversion::sleep(sleepT);
|
TimeConversion::sleep(sleepT);
|
||||||
}
|
}
|
||||||
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
||||||
|
helixPlayer->close();
|
||||||
|
|
||||||
helixPlayer->deInitialize();
|
helixPlayer->deInitialize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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/playlistExecutor/src/Attic/HelixPlayerTest.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/HelixPlayerTest.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -58,13 +58,14 @@ namespace PlaylistExecutor {
|
||||||
* Unit test for the HelixPlayer class.
|
* Unit test for the HelixPlayer class.
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: maroy $
|
||||||
* @version $Revision: 1.5 $
|
* @version $Revision: 1.6 $
|
||||||
* @see HelixPlayer
|
* @see HelixPlayer
|
||||||
*/
|
*/
|
||||||
class HelixPlayerTest : public CPPUNIT_NS::TestFixture
|
class HelixPlayerTest : public CPPUNIT_NS::TestFixture
|
||||||
{
|
{
|
||||||
CPPUNIT_TEST_SUITE(HelixPlayerTest);
|
CPPUNIT_TEST_SUITE(HelixPlayerTest);
|
||||||
CPPUNIT_TEST(firstTest);
|
CPPUNIT_TEST(firstTest);
|
||||||
|
CPPUNIT_TEST(playlengthTest);
|
||||||
CPPUNIT_TEST(simplePlayTest);
|
CPPUNIT_TEST(simplePlayTest);
|
||||||
CPPUNIT_TEST(checkErrorConditions);
|
CPPUNIT_TEST(checkErrorConditions);
|
||||||
CPPUNIT_TEST(smilTest);
|
CPPUNIT_TEST(smilTest);
|
||||||
|
@ -73,7 +74,7 @@ class HelixPlayerTest : public CPPUNIT_NS::TestFixture
|
||||||
CPPUNIT_TEST(smilParallelTest2);
|
CPPUNIT_TEST(smilParallelTest2);
|
||||||
CPPUNIT_TEST(smilParallelTest3);
|
CPPUNIT_TEST(smilParallelTest3);
|
||||||
CPPUNIT_TEST(smilParallelTest4);
|
CPPUNIT_TEST(smilParallelTest4);
|
||||||
// CPPUNIT_TEST(smilSoundAnimationTest);
|
CPPUNIT_TEST(smilSoundAnimationTest);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -104,6 +105,14 @@ class HelixPlayerTest : public CPPUNIT_NS::TestFixture
|
||||||
void
|
void
|
||||||
firstTest(void) throw (CPPUNIT_NS::Exception);
|
firstTest(void) throw (CPPUNIT_NS::Exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the length of an audio file
|
||||||
|
*
|
||||||
|
* @exception CPPUNIT_NS::Exception on test failures.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
playlengthTest(void) throw (CPPUNIT_NS::Exception);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Play something simple.
|
* Play something simple.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue