Gnash  0.8.10
Public Member Functions
gnash::SWFMovieDefinition Class Reference

Immutable definition of a SWF movie's contents. More...

#include <SWFMovieDefinition.h>

Inheritance diagram for gnash::SWFMovieDefinition:
gnash::movie_definition gnash::SWF::DefinitionTag gnash::SWF::ControlTag gnash::ref_counted

List of all members.

Public Member Functions

 SWFMovieDefinition (const RunResources &runResources)
 Construct a SWF movie.
 ~SWFMovieDefinition ()
size_t get_frame_count () const
 Return total number of frames advertised for the SWFMovie.
float get_frame_rate () const
 Return frame rate advertised for the SWFMovie.
const SWFRectget_frame_size () const
 Return dimensions of the SWFMovie.
size_t get_width_pixels () const
 Frame width in pixels.
size_t get_height_pixels () const
 Frame height in pixels.
void setAS3 ()
 Call this to inform callers that tags should be executed using AVM2.
bool isAS3 () const
 Check whether tags should be executed using AVM2.
virtual int get_version () const
 Return the advertised version for the SWFMovie.
virtual size_t get_loading_frame () const
 Get the number of fully loaded frames.
size_t get_bytes_loaded () const
 Get number of bytes loaded from input stream.
size_t get_bytes_total () const
 Get total number of bytes as parsed from the SWF header.
virtual void importResources (boost::intrusive_ptr< movie_definition > source, const Imports &imports)
 Import resources.
virtual void addDisplayObject (boost::uint16_t id, SWF::DefinitionTag *c)
SWF::DefinitionTaggetDefinitionTag (boost::uint16_t id) const
 Return a DisplayObject from the dictionary.
bool get_labeled_frame (const std::string &label, size_t &frame_number) const
 Get 0-based index of the frame with given label.
void add_font (int font_id, boost::intrusive_ptr< Font > f)
 Add a font DisplayObject with given ID to the CharacterDictionary.
Fontget_font (int font_id) const
 Return the font with given DisplayObject id.
Fontget_font (const std::string &name, bool bold, bool italic) const
 Find a font from the movie (not shared) lib.
CachedBitmapgetBitmap (int DisplayObject_id) const
 Get a bitmap from the bitmap dictionary.
void addBitmap (int DisplayObject_id, boost::intrusive_ptr< CachedBitmap > im)
 Add a bitmap DisplayObject in the dictionary, with the specified DisplayObject id.
sound_sampleget_sound_sample (int DisplayObject_id) const
 Get the sound sample with given ID.
virtual void add_sound_sample (int DisplayObject_id, sound_sample *sam)
 Add a sound sample DisplayObject in the dictionary, with the specified DisplayObject id.
virtual void set_loading_sound_stream_id (int id)
 Set the currently being loaded sound stream.
int get_loading_sound_stream_id () const
 Get the currently being loaded sound stream, if any.
void addControlTag (boost::intrusive_ptr< SWF::ControlTag > tag)
 Add an ControlTag to this movie_definition's playlist.
void add_frame_name (const std::string &name)
 Labels the frame currently being loaded with the given name.
void set_jpeg_loader (std::auto_ptr< image::JpegInput > j_in)
image::JpegInputget_jpeg_loader () const
 Get the jpeg input loader, to load a DefineBits image (one without table info).
virtual const PlayListgetPlaylist (size_t frame_number) const
 Return the list of execute tags for given frame number.
bool readHeader (std::auto_ptr< IOChannel > in, const std::string &url)
 Read the header of the SWF file.
bool completeLoad ()
 Complete load of the SWF file.
bool ensure_frame_loaded (size_t framenum) const
 Ensure that frame number 'framenum' (1-based offset) has been loaded (load on demand).
void read_all_swf ()
 Read and parse all the SWF stream (blocking until load is finished)
MoviecreateMovie (Global_as &gl, DisplayObject *parent=0)
 Create an instance of this movie.
virtual DisplayObjectcreateDisplayObject (Global_as &, DisplayObject *) const
 Create a DisplayObject with the given parent.
virtual const std::string & get_url () const
 Return the URL of the SWF stream this definition has been read from.
boost::uint16_t exportID (const std::string &symbol) const
 Get the id that corresponds to a symbol.
void registerExport (const std::string &symbol, boost::uint16_t id)
 Register a symbol to refer to a character id.

Detailed Description

Immutable definition of a SWF movie's contents.

It cannot be played directly, and does not hold current state; for that you need to call createMovie() to get a movie instance


Constructor & Destructor Documentation

gnash::SWFMovieDefinition::SWFMovieDefinition ( const RunResources runResources)

Construct a SWF movie.

Parameters:
runResourcesA RunResources containing information used for parsing.
gnash::SWFMovieDefinition::~SWFMovieDefinition ( )

Member Function Documentation

void gnash::SWFMovieDefinition::add_font ( int  ,
boost::intrusive_ptr< Font  
) [virtual]

Add a font DisplayObject with given ID to the CharacterDictionary.

This method is here to be called by DEFINEFONT tags loaders. The default implementation does nothing.

Reimplemented from gnash::movie_definition.

References assert.

Referenced by importResources().

void gnash::SWFMovieDefinition::add_frame_name ( const std::string &  ) [virtual]

Labels the frame currently being loaded with the given name.

A copy of the name string is made and kept in this object. In case of multiple frames with the same name, the last added will be the one referenced by that name.

The default implementation is a no-op.

Reimplemented from gnash::movie_definition.

void gnash::SWFMovieDefinition::add_sound_sample ( int  ,
sound_sample  
) [virtual]

Add a sound sample DisplayObject in the dictionary, with the specified DisplayObject id.

The default implementation is a no-op

Reimplemented from gnash::movie_definition.

References assert, IF_VERBOSE_PARSE, _, and gnash::sound_sample::m_sound_handler_id.

void gnash::SWFMovieDefinition::addBitmap ( int  ,
boost::intrusive_ptr< CachedBitmap  
) [virtual]

Add a bitmap DisplayObject in the dictionary, with the specified DisplayObject id.

The default implementation is a no-op (deletes the image data).

Reimplemented from gnash::movie_definition.

References assert.

void gnash::SWFMovieDefinition::addControlTag ( boost::intrusive_ptr< SWF::ControlTag ) [inline, virtual]

Add an ControlTag to this movie_definition's playlist.

The default implementation is a no-op.

Parameters:
tagThe tag to add in the list of executable tags for the frame currently being loaded. Ownership is transferred to the SWFMovieDefinition.

Reimplemented from gnash::movie_definition.

References assert.

Referenced by addDisplayObject().

void gnash::SWFMovieDefinition::addDisplayObject ( boost::uint16_t  id,
SWF::DefinitionTag c 
) [virtual]
bool gnash::SWFMovieDefinition::completeLoad ( ) [virtual]

Complete load of the SWF file.

This function completes parsing of the SWF stream engaging a separate thread. Make sure you called readHeader before this!

Returns:
false if the loading thread could not be started.

Reimplemented from gnash::movie_definition.

References assert, gnash::SWFMovieLoader::started(), gnash::SWFMovieLoader::start(), _, ensure_frame_loaded(), and read_all_swf().

virtual DisplayObject* gnash::SWFMovieDefinition::createDisplayObject ( Global_as gl,
DisplayObject parent 
) const [inline, virtual]

Create a DisplayObject with the given parent.

This function will determine the correct prototype and associated object using the passed global.

Parameters:
glThe global object used to set prototype and associated object. Calling this function creates a new DisplayObject from the DefinitionTag and adds it as a child of the specified parent DisplayObject.

Implements gnash::SWF::DefinitionTag.

Movie * gnash::SWFMovieDefinition::createMovie ( Global_as gl,
DisplayObject parent = 0 
) [virtual]

Create an instance of this movie.

TOCHECK: Make sure you called completeLoad() before this function is invoked (calling read() will do that for you).

TOCHECK: The _root reference of the newly created movie_root will be set to a newly created Movie.

Reimplemented from gnash::movie_definition.

References gnash::key::o, gnash::getObjectWithPrototype(), and gnash::NSV::CLASS_MOVIE_CLIP.

bool gnash::SWFMovieDefinition::ensure_frame_loaded ( size_t  framenum) const [virtual]

Ensure that frame number 'framenum' (1-based offset) has been loaded (load on demand).

Reimplemented from gnash::movie_definition.

Referenced by completeLoad().

boost::uint16_t gnash::SWFMovieDefinition::exportID ( const std::string &  symbol) const [virtual]

Get the id that corresponds to a symbol.

This function is thread-safe.

Parameters:
symbolThe symbol to lookup in the table.
Returns:
The id corresponding to the passed symbol. 0 is not a valid id and signifies that the symbol was not (yet) exported.

Reimplemented from gnash::movie_definition.

size_t gnash::SWFMovieDefinition::get_bytes_loaded ( ) const [inline, virtual]

Get number of bytes loaded from input stream.

NOTE: this method locks _bytes_loaded_mutex

Implements gnash::movie_definition.

size_t gnash::SWFMovieDefinition::get_bytes_total ( ) const [inline, virtual]

Get total number of bytes as parsed from the SWF header.

Implements gnash::movie_definition.

Font * gnash::SWFMovieDefinition::get_font ( int  ) const [virtual]

Return the font with given DisplayObject id.

Returns:
NULL if the given id doesn't correspond to any registered font (default).
See also:
add_font

Reimplemented from gnash::movie_definition.

References gnash::key::f, and assert.

Font * gnash::SWFMovieDefinition::get_font ( const std::string &  ,
bool  ,
bool   
) const [virtual]

Find a font from the movie (not shared) lib.

Reimplemented from gnash::movie_definition.

References gnash::key::f, and gnash::Font::matches().

size_t gnash::SWFMovieDefinition::get_frame_count ( ) const [inline, virtual]

Return total number of frames advertised for the SWFMovie.

Implements gnash::movie_definition.

float gnash::SWFMovieDefinition::get_frame_rate ( ) const [inline, virtual]

Return frame rate advertised for the SWFMovie.

Implements gnash::movie_definition.

const SWFRect& gnash::SWFMovieDefinition::get_frame_size ( ) const [inline, virtual]

Return dimensions of the SWFMovie.

Implements gnash::movie_definition.

size_t gnash::SWFMovieDefinition::get_height_pixels ( ) const [inline, virtual]

Frame height in pixels.

The frame size is in twips and may be rounded up.

Implements gnash::movie_definition.

References gnash::twipsToPixels(), and gnash::SWFRect::height().

image::JpegInput* gnash::SWFMovieDefinition::get_jpeg_loader ( ) const [inline, virtual]

Get the jpeg input loader, to load a DefineBits image (one without table info).

This method should probably not be there but in some higher-level class, like a Parser class..

The default implementation returns NULL

NOTE: ownership of the returned object is NOT transferred

Reimplemented from gnash::movie_definition.

bool gnash::SWFMovieDefinition::get_labeled_frame ( const std::string &  ,
size_t &   
) const [virtual]

Get 0-based index of the frame with given label.

The default implementation is to always return false, as if NO frame with given label was found.

Parameters:
labelLabel of the frame we're looking for.
frame_numberWhere to write frame number to (if a match is found). A 0-based index will be written there.
Returns:
true if a frame with that label was found, false otherwise

Reimplemented from gnash::movie_definition.

size_t gnash::SWFMovieDefinition::get_loading_frame ( ) const [virtual]

Get the number of fully loaded frames.

The number returned is also the index of the frame currently being loaded/parsed, except when parsing finishes, in which case it an index to on-past-last frame.

NOTE: this method locks _frames_loaded_mutex

Implements gnash::movie_definition.

Referenced by read_all_swf().

int gnash::SWFMovieDefinition::get_loading_sound_stream_id ( ) const [inline, virtual]

Get the currently being loaded sound stream, if any.

See also:
set_loading_sound_stream_id

The default implementation returns -1

Returns:
-1 if no sound stream is being currently loading

Reimplemented from gnash::movie_definition.

sound_sample * gnash::SWFMovieDefinition::get_sound_sample ( int  ) const [virtual]

Get the sound sample with given ID.

Returns:
NULL if the given DisplayObject ID isn't found in the dictionary or it is not a sound sample.

The default implementation always returns NULL

Reimplemented from gnash::movie_definition.

virtual const std::string& gnash::SWFMovieDefinition::get_url ( ) const [inline, virtual]

Return the URL of the SWF stream this definition has been read from.

Implements gnash::movie_definition.

Referenced by registerExport(), and importResources().

virtual int gnash::SWFMovieDefinition::get_version ( ) const [inline, virtual]

Return the advertised version for the SWFMovie.

This is stored and used in AS interpretation for some version-based behaviour.

Implements gnash::movie_definition.

size_t gnash::SWFMovieDefinition::get_width_pixels ( ) const [inline, virtual]

Frame width in pixels.

The frame size is in twips and may be rounded up.

Implements gnash::movie_definition.

References gnash::twipsToPixels(), and gnash::SWFRect::width().

CachedBitmap * gnash::SWFMovieDefinition::getBitmap ( int  ) const [virtual]

Get a bitmap from the bitmap dictionary.

Note that only top-level movies (those belonging to a single SWF stream) have a bitmap dictionary, thus our SWFMovieDefinition. The other derived class, sprite_definition will seek for DisplayObjects in its base SWFMovieDefinition.

Returns:
0 if no DisplayObject with the given ID is found, or if the corresponding DisplayObject is not a bitmap.

The default implementation returns 0.

Reimplemented from gnash::movie_definition.

SWF::DefinitionTag * gnash::SWFMovieDefinition::getDefinitionTag ( boost::uint16_t  id) const [virtual]

Return a DisplayObject from the dictionary.

Reimplemented from gnash::movie_definition.

References gnash::CharacterDictionary::getDisplayObject().

virtual const PlayList* gnash::SWFMovieDefinition::getPlaylist ( size_t  ) const [inline, virtual]

Return the list of execute tags for given frame number.

Parameters:
frame_numberFrame number, 0-based (ie: first frame is 0)
Returns:
NULL if no execute tags are defined for the given frame number (the default implementation) or a pointer to the vector of them (PlayList)

Reimplemented from gnash::movie_definition.

References assert.

void gnash::SWFMovieDefinition::importResources ( boost::intrusive_ptr< movie_definition ,
const Imports  
) [virtual]

Import resources.

Parameters:
sourceMovie containing the resources being imported
importsResources to import, each with the id to use in our dictionary

Reimplemented from gnash::movie_definition.

References gnash::key::i, gnash::key::e, get_url(), gnash::gnashSleep(), addDisplayObject(), registerExport(), gnash::key::f, add_font(), and _.

bool gnash::SWFMovieDefinition::isAS3 ( ) const [inline, virtual]

Check whether tags should be executed using AVM2.

Reimplemented from gnash::movie_definition.

void gnash::SWFMovieDefinition::read_all_swf ( )

Read and parse all the SWF stream (blocking until load is finished)

This function uses a private TagLoadersTable to interpret specific tag types. Currently the TagLoadersTable in use is the TagLoadersTable singleton.

References assert, gnash::SWFMovieLoader::isSelfThread(), gnash::SWFMovieLoader::started(), startPos, gnash::key::e, _, get_loading_frame(), and IF_VERBOSE_MALFORMED_SWF.

Referenced by completeLoad().

bool gnash::SWFMovieDefinition::readHeader ( std::auto_ptr< IOChannel in,
const std::string &  url 
)

Read the header of the SWF file.

This function only reads the header of the SWF stream and assigns the movie an URL. Call completeLoad() to fire up the loader thread.

Parameters:
inthe IOChannel from which to read SWF
urlthe url associated with the input
Returns:
false if SWF header could not be parsed

References assert, url, _, IF_VERBOSE_PARSE, gnash::zlib_adapter::make_inflater(), gnash::readRect(), gnash::SWFRect::is_null(), and IF_VERBOSE_MALFORMED_SWF.

void gnash::SWFMovieDefinition::registerExport ( const std::string &  symbol,
boost::uint16_t  id 
) [virtual]

Register a symbol to refer to a character id.

This function is thread safe.

Parameters:
idThe id of the character to map to the symbol. NB: this must never be 0!
symbolThe symbol to map to the id.

Reimplemented from gnash::movie_definition.

References assert, get_url(), and gnash::SWF::DefinitionTag::id().

Referenced by importResources().

void gnash::SWFMovieDefinition::set_jpeg_loader ( std::auto_ptr< image::JpegInput j_in) [virtual]

Set an input object for later loading DefineBits images (JPEG images without the table info).

There should be only one JPEGTABLES tag in an SWF (see: http://www.m2osw.com/en/swf_alexref.html#tag_jpegtables) Discard any subsequent attempts to set the jpeg loader to avoid crashing on very malformed SWFs. (No conclusive tests for pp behaviour, though one version also crashes out on the malformed SWF that triggers this assert in Gnash).

Reimplemented from gnash::movie_definition.

References _.

virtual void gnash::SWFMovieDefinition::set_loading_sound_stream_id ( int  ) [inline, virtual]

Set the currently being loaded sound stream.

The default implementation is a no-op

Reimplemented from gnash::movie_definition.

References gnash::SWF::DefinitionTag::id().

void gnash::SWFMovieDefinition::setAS3 ( ) [inline, virtual]

Call this to inform callers that tags should be executed using AVM2.

Reimplemented from gnash::movie_definition.


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