Public Member Functions | Protected Member Functions | Protected Attributes

wosh::bundles::PlayerGStreamerBundle Class Reference
[WOSH Bundles]

Audio player implementation based on GStreamer library, for POSIX systems. More...

#include <H:/WOSH/win32_vc2010/src/bundles/PlayerGStreamer/PlayerGStreamerBundle.h>

List of all members.

Public Member Functions

 PlayerGStreamerBundle (const std::string &name="", const std::string &device_name="default")
 Empty constructor, init bundle and vars, Properties and Methods. May Assign device name.
virtual ~PlayerGStreamerBundle ()
 Empty destructor, may (synch) stop bundle and internal threads when still running.
void busMessage (const Message &message, const Bus *source)
 Method raised by the Bus when it processes a new message. Implementations will probably analyze the message and perform actions.
PlayerAudio Interface - Playback
WRESULT play (const std::string &file_url, int volume=-1, bool override=false)
 Play a resource.
WRESULT play (unsigned int index)
WRESULT play ()
 Play the current media.
WRESULT pause ()
 Pause the current media, keeping track of position. Continue calling play()
WRESULT stop ()
 Stop the current media.
WRESULT first ()
 Play the first element in the playlist.
WRESULT next ()
 Play the next element in the playlist.
WRESULT prev ()
 Play the previous element in the playlist.
WRESULT last ()
 Play the last element in the playlist.
WRESULT enqueue (const std::string &file_url)
WRESULT remove (unsigned int index)
WRESULT clear ()
 Clear the playlist. Won't necessary stop current playback.
PlayerAudio Interface - Setters
WRESULT setVolume (int newVolume)
 Set the volume of device.
WRESULT setVolumeOffset (int volume_span)
WRESULT setMute (bool on)
WRESULT setRepeat (short on)
WRESULT setRandom (short on)
WRESULT setCrossfade (int seconds)
WRESULT setPosition (float position_rate)
WRESULT setPositionOffset (float position_rate_offset)
WRESULT setPositionMs (int64 position_ms)
PlayerAudio Interface - Getters
bool isPlaying () const
long getPlayListIndex () const
long getPlayListLength () const
int getVolume () const
bool isMuted () const
int getCrossfade () const
short getRepeat () const
short getRandom () const
float getPosition () const
std::string getPositionStr () const
int64 getPositionMs () const
int64 getLengthMs () const
std::string getLengthStr () const
Player Events
void changed_PlayState (int state, PlayerAudio *source)
void changed_Volume (int volume, bool muted, PlayerAudio *source)
void changed_PlayOptions (int crossfade, short repeat, short random, PlayerAudio *source)
void changed_PlayItem (const wosh::entertainment::MediaTrack *track, PlayerAudio *source)
void changed_PlayList (const wosh::entertainment::MediaList *list, PlayerAudio *source)
IPropertiesProviderListener interface
bool updatingProperty (bool &do_update, const Variant &value_proposed, Property &property_current, const PropertiesProvider *source)
Thread Events
void thread_event (Thread::THREAD_STATE thread_event, Thread *thread_source)

Protected Member Functions

void raiseEvent (MessageContent *fact)
 Raise a standard Device event (fact): Create Message and inject in BusDevices ("_Bus_Devices")

Protected Attributes

BusConnector BusDevices
 register myself & work as Device too
PlayerGStreamerplayerWorker
 real implementation
wosh::rmi::skeletons::PlayerAudio skeleton
 skeleton for PlayerAudio

Detailed Description

Audio player implementation based on GStreamer library, for POSIX systems.

Most important setting of the bundle is DeviceOutput property, default output name is "default", but you may define your own virtual outputs to support multiple audio cards or low-level settings (sample rate, buffer size, ..).

PlayerGStreamerBundle is designed to support multiple instances at same time, this is very useful when you have multiple sound cards (they will work even at same time).

In other words: I can play a different song (and different volume) on each output channel, having a multi-zone audio system; moreover I can also define a set of virtual outputs as multiplexer (play same track on more channels) and even play a song on all outputs at same time. This is enabled by a custom configuration of the ALSA layer and multiple instance of the bundle (properly configured).

What is GStreamer?
"GStreamer is a library for constructing graphs of media-handling components. The applications it supports range from simple Ogg/Vorbis playback, audio/video streaming to complex audio (mixing) and video (non-linear editing) processing. Applications can take advantage of advances in codec and filter technology transparently. Developers can add new codecs and filters by writing a simple plugin with a clean, generic interface."
See also:
http://gstreamer.freedesktop.org

The bundle and its bindings have been tested using ALSA layer. However it is possible to switch alsasink with another audio rendering layer (such as ossink).

See also:
http://www.alsa-project.org
Requirements and Installation
PlayerGStreamerBundle is available for POSIX platforms only (as Linux), you need to install the gstreamer library.

Tested with:

On Debian based systems (such as Ubuntu), you may install requirements executing:

alex@linbox:/home/alex# sudo apt-get install gstreamer0.10-alsa
alex@linbox:/home/alex# sudo apt-get install gstreamer0.10-plugins-base
alex@linbox:/home/alex# sudo apt-get install gstreamer0.10-plugins-good
alex@linbox:/home/alex# sudo apt-get install libgstreamer0.10-dev
alex@linbox:/home/alex# sudo updatedb

You must accept all related dependencies.

G++/Linker settings are configured by pkgconfig tool, so it should be easy to build.

alex@linbox:/home/alex# gst-inspect fakesrc
alex@linbox:/home/alex# gst-inspect alsasink

This should print out a bunch of information about this particular element. If this tells you that there is "no such element or plugin", you haven't installed GStreamer correctly.

Next test is to play the sine tone by running (make sure volume is turned up, but not too loud):

alex@linbox:/home/alex# gst-launch audiotestsrc ! audioconvert ! audioresample ! alsasink

Once the system is ready and the library have been tested, you may include the PlayerGStreamerBundle in the build, editing /src/bundles/devices/devices.pri. See Configuration for more information about bundle setup.

Using PlayerGStreamer
You may test the bundle playing an audio file:
root@wosh1:Bundles/PlayerHouse# enqueue "PATH-TO-FOLDER-or-FILENAME"
root@wosh1:Bundles/PlayerHouse# volume 6
root@wosh1:Bundles/PlayerHouse# first
(Advanced) ALSA Hacking
[..] DOLBY TO MULTICHANNEL AUDIO

I think ALSA is awesome, after some tests and research I was able to have my integrated (N+1) dolby sound card to act as N independent sound cards, and also to create virtual outputs (multiplexing). All you need to do is create your own asoundrc configuration file. My own asoundrc is provided as sample. The file should be placed in the home folder (such as /home/root) of the user (running WOSH).

Todo:
[..] DEVICEOUTPUT, PLAYLIST and VOLUME, ALSA STUFF
See also:
wosh::interfaces::entertainment::PlayerAudio
wosh::bundles:PlayerPhononBundle
Version:
0.8.399
Id:
PlayerGStreamerBundle.h 3775 2011-01-01 16:38:17Z alex
Author:
Alessandro Polo
Date:
Released on 2009-06-04

Definition at line 152 of file PlayerGStreamerBundle.h.


Constructor & Destructor Documentation

wosh::bundles::PlayerGStreamerBundle::PlayerGStreamerBundle ( const std::string &  name = "",
const std::string &  device_name = "default" 
)

Empty constructor, init bundle and vars, Properties and Methods. May Assign device name.

Parameters:
name[in] optional name of the bundle
device_name[in] output device name, 'default' is the default output for gstreamer
See also:
setDeviceOutput()

Definition at line 62 of file PlayerGStreamerBundle.cpp.

References _METHOD_Retrieve, and wosh::LOG_DEBUG.

wosh::bundles::PlayerGStreamerBundle::~PlayerGStreamerBundle (  ) [virtual]

Empty destructor, may (synch) stop bundle and internal threads when still running.

Definition at line 106 of file PlayerGStreamerBundle.cpp.

References wosh::LOG_VERBOSE, and wosh::LOG_WARNING.


Member Function Documentation

void wosh::bundles::PlayerGStreamerBundle::busMessage ( const Message message,
const Bus source 
) [virtual]

Method raised by the Bus when it processes a new message. Implementations will probably analyze the message and perform actions.

Parameters:
[in]messagethe incoming message
[in]sourcethe source Bus of the incoming message
Warning:
The current thread is own and managed by the caller Bus. Heavy, dangerous or time expensive operations should be executed asynchronously and not inline!

Reimplemented from wosh::BundleGeneric.

Definition at line 177 of file PlayerGStreamerBundle.cpp.

References BusCore.

WRESULT wosh::bundles::PlayerGStreamerBundle::clear (  ) [virtual]

Clear the playlist. Won't necessary stop current playback.

Returns:
WRET_OK if playlist has been cleared. Check custom implementation error codes.

Implements wosh::interfaces::entertainment::PlayerAudio.

Definition at line 313 of file PlayerGStreamerBundle.cpp.

WRESULT wosh::bundles::PlayerGStreamerBundle::first (  ) [virtual]

Play the first element in the playlist.

Returns:
WRET_ERR_ILLEGAL_USE when playlist is empty/invalid; WRET_OK when playback is starting

Implements wosh::interfaces::entertainment::PlayerAudio.

Definition at line 314 of file PlayerGStreamerBundle.cpp.

WRESULT wosh::bundles::PlayerGStreamerBundle::last (  ) [virtual]

Play the last element in the playlist.

Returns:
WRET_ERR_ILLEGAL_USE when playlist is empty/invalid; WRET_OK when playback is starting

Implements wosh::interfaces::entertainment::PlayerAudio.

Definition at line 317 of file PlayerGStreamerBundle.cpp.

WRESULT wosh::bundles::PlayerGStreamerBundle::next (  ) [virtual]

Play the next element in the playlist.

Returns:
WRET_ERR_ILLEGAL_USE when playlist is empty/invalid; WRET_ERR_PARAM when out of index; WRET_OK when playback is starting

Implements wosh::interfaces::entertainment::PlayerAudio.

Definition at line 315 of file PlayerGStreamerBundle.cpp.

WRESULT wosh::bundles::PlayerGStreamerBundle::pause (  ) [virtual]

Pause the current media, keeping track of position. Continue calling play()

Returns:
See also:
play()

Implements wosh::interfaces::entertainment::PlayerAudio.

Definition at line 311 of file PlayerGStreamerBundle.cpp.

WRESULT wosh::bundles::PlayerGStreamerBundle::play ( const std::string &  file_url,
int  volume = -1,
bool  override_current = false 
) [virtual]

Play a resource.

Parameters:
file_url[in] the URI of the resource to be played. Multiple protocols are supported:

Implements wosh::interfaces::entertainment::PlayerAudio.

Definition at line 334 of file PlayerGStreamerBundle.cpp.

WRESULT wosh::bundles::PlayerGStreamerBundle::play (  ) [virtual]

Play the current media.

Returns:

Implements wosh::interfaces::entertainment::PlayerAudio.

Definition at line 310 of file PlayerGStreamerBundle.cpp.

WRESULT wosh::bundles::PlayerGStreamerBundle::prev (  ) [virtual]

Play the previous element in the playlist.

Returns:
WRET_ERR_ILLEGAL_USE when playlist is empty/invalid; WRET_ERR_PARAM when out of index; WRET_OK when playback is starting

Implements wosh::interfaces::entertainment::PlayerAudio.

Definition at line 316 of file PlayerGStreamerBundle.cpp.

void wosh::bundles::PlayerGStreamerBundle::raiseEvent ( MessageContent fact ) [protected]

Raise a standard Device event (fact): Create Message and inject in BusDevices ("_Bus_Devices")

Parameters:
fact[in] the fact (instance) to include in (event) Message, instance will be deleted by Bus

Definition at line 185 of file PlayerGStreamerBundle.cpp.

References wosh::Message::setDestinationBroadcast().

WRESULT wosh::bundles::PlayerGStreamerBundle::setVolume ( int  newVolume ) [virtual]

Set the volume of device.

Parameters:
[in]newVolumethe volume level expressed in range [0; 100]
Returns:

Implements wosh::interfaces::entertainment::PlayerAudio.

Definition at line 340 of file PlayerGStreamerBundle.cpp.

WRESULT wosh::bundles::PlayerGStreamerBundle::stop (  ) [virtual]

Stop the current media.

Returns:

Implements wosh::interfaces::entertainment::PlayerAudio.

Definition at line 312 of file PlayerGStreamerBundle.cpp.


Member Data Documentation

register myself & work as Device too

Definition at line 281 of file PlayerGStreamerBundle.h.

real implementation

Definition at line 282 of file PlayerGStreamerBundle.h.

skeleton for PlayerAudio

Definition at line 285 of file PlayerGStreamerBundle.h.


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

Generated on Tue Feb 8 2011 09:33:36 for WOSH system 0.8.888 [wolf] by Alessandro Polo, using DoxyGen 1.7.2 hosted by WOSH Framework