Gnash
0.8.10
|
Immutable definition of a SWF movie's contents. More...
#include <SWFMovieDefinition.h>
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 SWFRect & | get_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::DefinitionTag * | getDefinitionTag (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. | |
Font * | get_font (int font_id) const |
Return the font with given DisplayObject id. | |
Font * | get_font (const std::string &name, bool bold, bool italic) const |
Find a font from the movie (not shared) lib. | |
CachedBitmap * | getBitmap (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_sample * | get_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::JpegInput * | get_jpeg_loader () const |
Get the jpeg input loader, to load a DefineBits image (one without table info). | |
virtual const PlayList * | getPlaylist (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) | |
Movie * | createMovie (Global_as &gl, DisplayObject *parent=0) |
Create an instance of this movie. | |
virtual DisplayObject * | createDisplayObject (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. |
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
gnash::SWFMovieDefinition::SWFMovieDefinition | ( | const RunResources & | runResources | ) |
Construct a SWF movie.
runResources | A RunResources containing information used for parsing. |
gnash::SWFMovieDefinition::~SWFMovieDefinition | ( | ) |
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.
tag | The 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] |
References assert, gnash::CharacterDictionary::addDisplayObject(), and addControlTag().
Referenced by importResources().
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!
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.
gl | The 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.
symbol | The symbol to lookup in the table. |
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.
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.
label | Label of the frame we're looking for. |
frame_number | Where to write frame number to (if a match is found). A 0-based index will be written there. |
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.
The default implementation returns -1
Reimplemented from gnash::movie_definition.
sound_sample * gnash::SWFMovieDefinition::get_sound_sample | ( | int | ) | const [virtual] |
Get the sound sample with given ID.
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.
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.
frame_number | Frame number, 0-based (ie: first frame is 0) |
Reimplemented from gnash::movie_definition.
References assert.
void gnash::SWFMovieDefinition::importResources | ( | boost::intrusive_ptr< movie_definition > | , |
const Imports & | |||
) | [virtual] |
Import resources.
source | Movie containing the resources being imported |
imports | Resources 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.
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.
id | The id of the character to map to the symbol. NB: this must never be 0! |
symbol | The 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.