NetStream_as ActionScript class. More...
#include <NetStream_as.h>
Public Types | |
enum | PauseMode { pauseModeToggle = -1, pauseModePause = 0, pauseModeUnPause = 1 } |
Public Member Functions | |
NetStream_as (as_object *owner) | |
Contruct a NetStream object. | |
~NetStream_as () | |
PlayHead::PlaybackStatus | playbackState () const |
int | videoHeight () const |
Get the real height of the video in pixels if the decoder exists. | |
int | videoWidth () const |
Get the real width of the video in pixels if the decoder exists. | |
void | close () |
void | setAudioController (DisplayObject *controller) |
Make audio controlled by given DisplayObject. | |
void | pause (PauseMode mode) |
Pauses/starts the playback of the media played by the current instance. | |
void | play (const std::string &source) |
Starts the playback of the media. | |
void | seek (boost::uint32_t pos) |
Seek in the media played by the current instance. | |
boost::int32_t | time () |
Tells where the playhead currently is. | |
void | update () |
double | getCurrentFPS () |
Returns the current framerate in frames per second. | |
void | setNetCon (NetConnection_as *nc) |
Sets the NetConnection needed to access external files. | |
bool | isConnected () const |
Return true if the NetStream has an associated NetConnection. | |
void | setBufferTime (boost::uint32_t time) |
boost::uint32_t | bufferTime () |
long | bytesLoaded () |
Returns the number of bytes of the media file that have been buffered. | |
long | bytesTotal () |
Returns the total number of bytes (size) of the media file. | |
long | bufferLength () |
bool | newFrameReady () |
Tells us if there is a new video frame ready. | |
std::auto_ptr< GnashImage > | get_video () |
Returns the video frame closest to current cursor. See time(). | |
void | setInvalidatedVideo (DisplayObject *ch) |
Register the DisplayObject to invalidate on video updates. | |
virtual void | markReachableResources () const |
Mark any reachable resources other than the owner. | |
Static Public Member Functions | |
static unsigned int | audio_streamer (void *udata, boost::int16_t *samples, unsigned int nSamples, bool &eof) |
Callback used by sound_handler to get audio data. | |
Protected Types | |
enum | StatusCode { invalidStatus, bufferEmpty, bufferFull, bufferFlush, playStart, playStop, seekNotify, streamNotFound, invalidTime } |
Status codes used for notifications. More... | |
Protected Member Functions | |
void | setStatus (StatusCode code) |
Set stream status. | |
void | processStatusNotifications () |
Call any onStatus event handler passing it any queued status change, see _statusQueue. | |
void | stopAdvanceTimer () |
Unplug the advance timer callback. | |
void | startAdvanceTimer () |
Register the advance timer callback. | |
Protected Attributes | |
NetConnection_as * | _netCon |
boost::scoped_ptr< CharacterProxy > | _audioController |
boost::uint32_t | m_bufferTime |
volatile bool | m_newFrameReady |
boost::mutex | image_mutex |
std::auto_ptr< GnashImage > | m_imageframe |
std::string | url |
std::auto_ptr< media::MediaParser > | m_parser |
boost::intrusive_ptr< as_function > | _statusHandler |
long | inputPos |
DisplayObject * | _invalidatedVideoCharacter |
The DisplayObject to invalidate on video updates. |
NetStream_as ActionScript class.
This class is responsible for handlign external media files. Provides interfaces for playback control.
enum gnash::NetStream_as::StatusCode [protected] |
Status codes used for notifications.
gnash::NetStream_as::NetStream_as | ( | as_object * | owner | ) |
Contruct a NetStream object.
The default size needed to begin playback (m_bufferTime) of media is 100 milliseconds.
gnash::NetStream_as::~NetStream_as | ( | ) |
References close().
static unsigned int gnash::NetStream_as::audio_streamer | ( | void * | udata, | |
boost::int16_t * | samples, | |||
unsigned int | nSamples, | |||
bool & | eof | |||
) | [static] |
Callback used by sound_handler to get audio data.
This is a sound_handler::aux_streamer_ptr type.
It might be invoked by a separate thread (neither main, nor decoder thread).
long gnash::NetStream_as::bufferLength | ( | ) |
boost::uint32_t gnash::NetStream_as::bufferTime | ( | ) | [inline] |
Returns what the buffer time has been set to. (100 milliseconds is default)
References m_bufferTime.
long gnash::NetStream_as::bytesLoaded | ( | ) |
Returns the number of bytes of the media file that have been buffered.
References m_parser.
long gnash::NetStream_as::bytesTotal | ( | ) |
Returns the total number of bytes (size) of the media file.
References m_parser.
void gnash::NetStream_as::close | ( | void | ) |
Closes the video session and frees all ressources used for decoding except the FLV-parser (this might not be correct).
References gnash::BufferedAudioStreamer::cleanAudioQueue(), gnash::BufferedAudioStreamer::detachAuxStreamer(), m_imageframe, m_parser, and stopAdvanceTimer().
Referenced by play(), and ~NetStream_as().
std::auto_ptr< GnashImage > gnash::NetStream_as::get_video | ( | ) |
Returns the video frame closest to current cursor. See time().
References image_mutex, and m_imageframe.
double gnash::NetStream_as::getCurrentFPS | ( | ) | [inline] |
Returns the current framerate in frames per second.
bool gnash::NetStream_as::isConnected | ( | ) | const [inline] |
Return true if the NetStream has an associated NetConnection.
References _netCon.
void gnash::NetStream_as::markReachableResources | ( | ) | const [virtual] |
Mark any reachable resources other than the owner.
Override this function if the subclass holds references to GC resources other than the owner.
Reimplemented from gnash::ActiveRelay.
References _audioController, _invalidatedVideoCharacter, _netCon, _statusHandler, gnash::GcResource::setReachable(), and gnash::ActiveRelay::setReachable().
bool gnash::NetStream_as::newFrameReady | ( | ) |
Tells us if there is a new video frame ready.
References m_newFrameReady.
void gnash::NetStream_as::pause | ( | PauseMode | mode | ) |
Pauses/starts the playback of the media played by the current instance.
mode | Defines what mode to put the instance in. |
References gnash::PlayHead::getState(), pauseModePause, pauseModeToggle, and pauseModeUnPause.
void gnash::NetStream_as::play | ( | const std::string & | source | ) |
Starts the playback of the media.
source | Defines what file to play |
References _, _netCon, gnash::BufferedAudioStreamer::attachAuxStreamer(), close(), gnash::NetConnection_as::getStream(), IF_VERBOSE_ASCODING_ERRORS, gnash::NetConnection_as::isConnected(), and url.
PlayHead::PlaybackStatus gnash::NetStream_as::playbackState | ( | ) | const [inline] |
References gnash::PlayHead::getState().
void gnash::NetStream_as::processStatusNotifications | ( | ) | [protected] |
Call any onStatus event handler passing it any queued status change, see _statusQueue.
Will NOT lock the statusMutex itself, rather it will iteratively call the popNextPendingStatusNotification() private method, which will take care of locking it. This is to make sure onStatus handler won't call methods possibly trying to obtain the lock again (play, pause, ...)
References invalidStatus, gnash::key::o, gnash::ActiveRelay::owner(), and gnash::NSV::PROP_ON_STATUS.
Referenced by update().
void gnash::NetStream_as::seek | ( | boost::uint32_t | pos | ) |
Seek in the media played by the current instance.
pos | Defines in seconds where to seek to |
References gnash::BufferedAudioStreamer::cleanAudioQueue(), invalidTime, m_parser, gnash::PlayHead::seekTo(), and setStatus().
void gnash::NetStream_as::setAudioController | ( | DisplayObject * | controller | ) |
Make audio controlled by given DisplayObject.
References _audioController.
void gnash::NetStream_as::setBufferTime | ( | boost::uint32_t | time | ) |
Specifies the number of milliseconds to buffer before starting to display the stream.
time | The time in milliseconds that should be buffered. |
References m_bufferTime, and m_parser.
void gnash::NetStream_as::setInvalidatedVideo | ( | DisplayObject * | ch | ) | [inline] |
Register the DisplayObject to invalidate on video updates.
References _invalidatedVideoCharacter.
void gnash::NetStream_as::setNetCon | ( | NetConnection_as * | nc | ) | [inline] |
Sets the NetConnection needed to access external files.
nc | The NetConnection object to use for network access |
References _netCon.
void gnash::NetStream_as::setStatus | ( | StatusCode | code | ) | [protected] |
Set stream status.
Valid statuses are:
Status level:
Error level:
This method locks the statusMutex during operations
void gnash::NetStream_as::startAdvanceTimer | ( | ) | [protected] |
Register the advance timer callback.
References gnash::movie_root::addAdvanceCallback(), gnash::getRoot(), and gnash::ActiveRelay::owner().
void gnash::NetStream_as::stopAdvanceTimer | ( | ) | [protected] |
Unplug the advance timer callback.
References gnash::getRoot(), gnash::ActiveRelay::owner(), and gnash::movie_root::removeAdvanceCallback().
Referenced by close().
boost::int32_t gnash::NetStream_as::time | ( | ) |
Tells where the playhead currently is.
References gnash::PlayHead::getPosition().
void gnash::NetStream_as::update | ( | ) | [virtual] |
Called at the SWF heart-beat. Used to process queued status messages and (re)start after a buffering pause. In NetStreamFfmpeg it is also used to find the next video frame to be shown, though this might change.
Implements gnash::ActiveRelay.
References gnash::BufferedAudioStreamer::_audioQueue, gnash::BufferedAudioStreamer::_audioQueueMutex, gnash::PlayHead::advanceIfConsumed(), bufferEmpty, bufferFull, bufferLength(), gnash::PlayHead::getPosition(), gnash::PlayHead::getState(), gnash::key::i, m_bufferTime, m_imageframe, m_parser, gnash::ActiveRelay::owner(), processStatusNotifications(), gnash::PlayHead::seekTo(), and setStatus().
int gnash::NetStream_as::videoHeight | ( | ) | const |
Get the real height of the video in pixels if the decoder exists.
Referenced by gnash::Video::display().
int gnash::NetStream_as::videoWidth | ( | ) | const |
Get the real width of the video in pixels if the decoder exists.
boost::scoped_ptr<CharacterProxy> gnash::NetStream_as::_audioController [protected] |
Referenced by markReachableResources(), and setAudioController().
The DisplayObject to invalidate on video updates.
Referenced by markReachableResources(), and setInvalidatedVideo().
NetConnection_as* gnash::NetStream_as::_netCon [protected] |
Referenced by isConnected(), markReachableResources(), play(), and setNetCon().
boost::intrusive_ptr<as_function> gnash::NetStream_as::_statusHandler [protected] |
Referenced by markReachableResources().
boost::mutex gnash::NetStream_as::image_mutex [protected] |
Referenced by get_video().
long gnash::NetStream_as::inputPos [protected] |
boost::uint32_t gnash::NetStream_as::m_bufferTime [protected] |
Referenced by bufferTime(), setBufferTime(), and update().
std::auto_ptr<GnashImage> gnash::NetStream_as::m_imageframe [protected] |
Referenced by close(), get_video(), and update().
volatile bool gnash::NetStream_as::m_newFrameReady [protected] |
Referenced by newFrameReady().
std::auto_ptr<media::MediaParser> gnash::NetStream_as::m_parser [protected] |
Referenced by bufferLength(), bytesLoaded(), bytesTotal(), close(), seek(), setBufferTime(), and update().
std::string gnash::NetStream_as::url [protected] |
Referenced by play().