Yate
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
ClientSound Class Reference

A sound file. More...

#include <yatecbase.h>

Inheritance diagram for ClientSound:
String GenObject

List of all members.

Public Member Functions

 ClientSound (const char *name, const char *file, const char *device=0)
virtual ~ClientSound ()
virtual void destruct ()
bool native () const
bool started () const
const Stringdevice () const
void device (const char *dev)
const Stringfile () const
void file (const char *filename, bool stereo)
void setRepeat (unsigned int count)
bool stereo () const
bool start (bool force=true)
void stop ()
void setChannel (const String &chan, bool ok)
bool attachSource (ClientChannel *chan)

Static Public Member Functions

static bool build (const String &id, const char *file, const char *device=0, unsigned int repeat=0, bool resetExisting=true, bool stereo=false)
static bool started (const String &name)
static bool start (const String &name, bool force=true)
static void stop (const String &name)
static ClientSoundfind (const String &token, bool byName=true)

Static Public Attributes

static ObjList s_sounds
static Mutex s_soundsMutex
static String s_calltoPrefix

Protected Member Functions

virtual bool doStart ()
virtual void doStop ()

Protected Attributes

bool m_native
String m_file
String m_device
unsigned int m_repeat
bool m_started
bool m_stereo
String m_channel

Detailed Description

A sound file.

This class holds a sound file along with an output device used to play it


Constructor & Destructor Documentation

ClientSound ( const char *  name,
const char *  file,
const char *  device = 0 
) [inline]

Constructor

Parameters:
nameThe name of this object
fileThe file to play (should contain the whole path and the file name)
deviceOptional device used to play the file. Set to 0 to use the default one
virtual ~ClientSound ( ) [inline, virtual]

Destructor. Stop playing the file


Member Function Documentation

bool attachSource ( ClientChannel chan)

Attach this sound to a channel

Parameters:
chanThe channel to attach to
Returns:
True on success
static bool build ( const String id,
const char *  file,
const char *  device = 0,
unsigned int  repeat = 0,
bool  resetExisting = true,
bool  stereo = false 
) [static]

Build a client sound

Parameters:
idThe name of the object
fileThe file to play (should contain the whole path and the file name)
deviceOptional device used to play the file. Set to 0 to use the default one
repeatThe number of times to play the sound, 0 to repeat until explicitely stopped
resetExistingTrue to reset the file of an already created sound
stereoTrue if the sound file contains 2 channel audio
Returns:
True on success, false if the sound already exists
virtual void destruct ( ) [inline, virtual]

Stop playing. Release memory

Reimplemented from GenObject.

References TelEngine::destruct().

const String& device ( ) const [inline]

Get the device used to play this sound

Returns:
The device used to play sound
void device ( const char *  dev) [inline]

Set the device used to play this sound

Parameters:
devThe device used to play sound
const String& file ( ) const [inline]

Get the file played by this sound

Returns:
The file played by this sound
void file ( const char *  filename,
bool  stereo 
) [inline]

Set the file played by this sound. The new file will not be used until the next time the sound is started

Parameters:
filenameThe new file played by this sound
stereoTrue if the file contains 2 channel audio
static ClientSound* find ( const String token,
bool  byName = true 
) [static]

Find a sound object

Parameters:
tokenThe token used to match the sound
byNameTrue to match the sound's name, false to match its file
Returns:
ClientSound pointer or 0 if not found
bool native ( ) const [inline]

Check if this sound is a system dependent one

Returns:
True if the sound is played using a system dependent method, false if played using a yate module (like wavefile)
void setChannel ( const String chan,
bool  ok 
)

Set/reset channel on sound start/stop

Parameters:
chanThe channel id
okOperation: true to start, false to stop
void setRepeat ( unsigned int  count) [inline]

Set the repeat counter.

Parameters:
countThe number of times to play the sound, 0 to repeat until explicitely stopped
bool start ( bool  force = true)

Start playing the file

Parameters:
forceTrue to start playing the file even if already started
Returns:
True on success
static bool start ( const String name,
bool  force = true 
) [static]

Start playing a given sound

Parameters:
nameThe name of the sound to play
forceTrue to start playing the file even if already started
Returns:
True on success
bool started ( ) const [inline]

Check if this sound is started

Returns:
True if this sound is started
static bool started ( const String name) [static]

Check if a sound is started

Parameters:
nameThe name of the sound to check
Returns:
True if the given sound is started
bool stereo ( ) const [inline]

Check if this sound's file contains 2 channel audio

Returns:
True if the sound file contains 2 channel audio
void stop ( )

Stop playing the file

static void stop ( const String name) [static]

Stop playing a given sound

Parameters:
nameThe name of the sound to stop

Member Data Documentation

The prefix to be added to the file when an utility channel is started or a sound is played in a regular client channel

ObjList s_sounds [static]

The list of sounds

Mutex s_soundsMutex [static]

Mutex used to lock the sounds list operations


The documentation for this class was generated from the following file: