Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes

gnash::NetStream_as Class Reference

NetStream_as ActionScript class. More...

#include <NetStream_as.h>

Inheritance diagram for gnash::NetStream_as:
Inheritance graph
[legend]
Collaboration diagram for gnash::NetStream_as:
Collaboration graph
[legend]

List of all members.

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< image::GnashImageget_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< image::GnashImagem_imageframe
std::string url
std::auto_ptr< media::MediaParserm_parser
boost::intrusive_ptr< as_function_statusHandler
long inputPos
DisplayObject_invalidatedVideoCharacter
 The DisplayObject to invalidate on video updates.

Detailed Description

NetStream_as ActionScript class.

This class is responsible for handlign external media files. Provides interfaces for playback control.


Member Enumeration Documentation

Enumerator:
pauseModeToggle 
pauseModePause 
pauseModeUnPause 

Status codes used for notifications.

Enumerator:
invalidStatus 
bufferEmpty 

NetStream.Buffer.Empty (level: status).

bufferFull 

NetStream.Buffer.Full (level: status).

bufferFlush 

NetStream.Buffer.Flush (level: status).

playStart 

NetStream.Play.Start (level: status).

playStop 

NetStream.Play.Stop (level: status).

seekNotify 

NetStream.Seek.Notify (level: status).

streamNotFound 

NetStream.Play.StreamNotFound (level: error).

invalidTime 

NetStream.Seek.InvalidTime (level: error).


Constructor & Destructor Documentation

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().


Member Function Documentation

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 (  ) 

Returns the number of millisecond of the media file that is buffered and yet to be played

Returns:
Returns the number of millisecond of the media file that is buffered and yet to be played

References m_parser.

Referenced by update().

boost::uint32_t gnash::NetStream_as::bufferTime (  )  [inline]

Returns what the buffer time has been set to. (100 milliseconds is default)

Returns:
The size of the buffer in milliseconds.

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.

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< image::GnashImage > gnash::NetStream_as::get_video (  ) 

Returns the video frame closest to current cursor. See time().

Returns:
a image containing the video frame, a NULL auto_ptr if none were ready

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.

Returns:
true if a frame is ready, false if not

References m_newFrameReady.

void gnash::NetStream_as::pause ( PauseMode  mode  ) 

Pauses/starts the playback of the media played by the current instance.

Parameters:
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.

Parameters:
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]
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.

Parameters:
pos Defines in seconds where to seek to
Todo:
take milliseconds !!

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.

Parameters:
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.

Parameters:
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:

  • NetStream.Buffer.Empty
  • NetStream.Buffer.Full
  • NetStream.Buffer.Flush
  • NetStream.Play.Start
  • NetStream.Play.Stop
  • NetStream.Seek.Notify

Error level:

  • NetStream.Play.StreamNotFound
  • NetStream.Seek.InvalidTime

This method locks the statusMutex during operations

Referenced by seek(), and update().

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.

Returns:
The time in milliseconds of the current playhead position

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.

Returns:
the height of the video in pixels or 0 if no decoder exists. The width returned from the decoder may also vary, and will be 0 until it knows the width.

Referenced by gnash::Video::display().

int gnash::NetStream_as::videoWidth (  )  const

Get the real width of the video in pixels if the decoder exists.

Returns:
the width of the video in pixels or 0 if no decoder exists. The width returned from the decoder may also vary, and will be 0 until it knows the width.

Member Data Documentation

boost::scoped_ptr<CharacterProxy> gnash::NetStream_as::_audioController [protected]

The DisplayObject to invalidate on video updates.

Referenced by markReachableResources(), and setInvalidatedVideo().

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().

boost::uint32_t gnash::NetStream_as::m_bufferTime [protected]

Referenced by bufferTime(), setBufferTime(), and update().

Referenced by close(), get_video(), and update().

volatile bool gnash::NetStream_as::m_newFrameReady [protected]

Referenced by newFrameReady().

std::string gnash::NetStream_as::url [protected]

Referenced by play().


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