Gnash
0.8.11dev
|
Immutable definition of a SWF movie's contents. More...
#include <SWFMovieDefinition.h>
Public Member Functions | |
SWFMovieDefinition (const RunResources &runResources) | |
Construct a SWF movie. More... | |
DSOTEXPORT | ~SWFMovieDefinition () |
size_t | get_frame_count () const |
Return total number of frames advertised for the SWFMovie. More... | |
float | get_frame_rate () const |
Return frame rate advertised for the SWFMovie. More... | |
const SWFRect & | get_frame_size () const |
Return dimensions of the SWFMovie. More... | |
size_t | get_width_pixels () const |
Frame width in pixels. More... | |
size_t | get_height_pixels () const |
Frame height in pixels. More... | |
void | setAS3 () |
Call this to inform callers that tags should be executed using AVM2. More... | |
bool | isAS3 () const |
Check whether tags should be executed using AVM2. More... | |
virtual int | get_version () const |
Return the advertised version for the SWFMovie. More... | |
virtual size_t | get_loading_frame () const |
Get the number of fully loaded frames. More... | |
size_t | get_bytes_loaded () const |
Get number of bytes loaded from input stream. More... | |
size_t | get_bytes_total () const |
Get total number of bytes as parsed from the SWF header. More... | |
virtual DSOTEXPORT void | importResources (boost::intrusive_ptr< movie_definition > source, const Imports &imports) |
Import resources. More... | |
virtual void | addDisplayObject (std::uint16_t id, SWF::DefinitionTag *c) |
DSOTEXPORT SWF::DefinitionTag * | getDefinitionTag (std::uint16_t id) const |
Return a DisplayObject from the dictionary. More... | |
DSOTEXPORT bool | get_labeled_frame (const std::string &label, size_t &frame_number) const |
Get 0-based index of the frame with given label. More... | |
DSOTEXPORT void | add_font (int font_id, boost::intrusive_ptr< Font > f) |
Add a font DisplayObject with given ID to the CharacterDictionary. More... | |
DSOTEXPORT Font * | get_font (int font_id) const |
Return the font with given DisplayObject id. More... | |
Font * | get_font (const std::string &name, bool bold, bool italic) const |
Find a font from the movie (not shared) lib. More... | |
DSOTEXPORT CachedBitmap * | getBitmap (int DisplayObject_id) const |
Get a bitmap from the bitmap dictionary. More... | |
void | addBitmap (int DisplayObject_id, boost::intrusive_ptr< CachedBitmap > im) |
Add a bitmap DisplayObject in the dictionary, with the specified DisplayObject id. More... | |
sound_sample * | get_sound_sample (int DisplayObject_id) const |
Get the sound sample with given ID. More... | |
virtual void | add_sound_sample (int DisplayObject_id, sound_sample *sam) |
Add a sound sample DisplayObject in the dictionary, with the specified DisplayObject id. More... | |
virtual void | set_loading_sound_stream_id (int id) |
Set the currently being loaded sound stream. More... | |
int | get_loading_sound_stream_id () const |
Get the currently being loaded sound stream, if any. More... | |
void | addControlTag (boost::intrusive_ptr< SWF::ControlTag > tag) |
Add an ControlTag to this movie_definition's playlist. More... | |
DSOTEXPORT void | add_frame_name (const std::string &name) |
Labels the frame currently being loaded with the given name. More... | |
DSOTEXPORT void | set_jpeg_loader (std::unique_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). More... | |
virtual const PlayList * | getPlaylist (size_t frame_number) const |
Return the list of execute tags for given frame number. More... | |
bool | readHeader (std::unique_ptr< IOChannel > in, const std::string &url) |
Read the header of the SWF file. More... | |
bool | completeLoad () |
Complete load of the SWF file. More... | |
bool | ensure_frame_loaded (size_t framenum) const |
Ensure that frame number 'framenum' (1-based offset) has been loaded (load on demand). More... | |
void | read_all_swf () |
Read and parse all the SWF stream (blocking until load is finished) More... | |
Movie * | createMovie (Global_as &gl, DisplayObject *parent=nullptr) |
Create an instance of this movie. More... | |
virtual DisplayObject * | createDisplayObject (Global_as &, DisplayObject *) const |
Create a DisplayObject with the given parent. More... | |
virtual const std::string & | get_url () const |
Return the URL of the SWF stream this definition has been read from. More... | |
std::uint16_t | exportID (const std::string &symbol) const |
Get the id that corresponds to a symbol. More... | |
void | registerExport (const std::string &symbol, std::uint16_t id) |
Register a symbol to refer to a character id. More... | |
![]() | |
virtual void | addDisplayObject (std::uint16_t, DefinitionTag *) |
Add a DefinitionTag with given ID to the CharactersDictionary. More... | |
![]() | |
virtual | ~DefinitionTag () |
virtual DSOTEXPORT void | executeState (MovieClip *m, DisplayList &) const |
Executing a DefinitionTag adds its id to list of known characters. More... | |
std::uint16_t | id () const |
The immutable id of the DefinitionTag. More... | |
![]() | |
virtual | ~ControlTag () |
virtual void | executeActions (MovieClip *, DisplayList &) const |
Execute Action tags. More... | |
![]() | |
ref_counted () | |
ref_counted (const ref_counted &) | |
void | add_ref () const |
void | drop_ref () const |
long | get_ref_count () const |
Additional Inherited Members | |
![]() | |
typedef std::vector< boost::intrusive_ptr< SWF::ControlTag > > | PlayList |
typedef std::pair< int, std::string > | ImportSpec |
typedef std::vector< ImportSpec > | Imports |
![]() | |
enum | Type { TAG_ACTION = 1 << 0, TAG_DLIST = 1 << 1 } |
Type of ControlTag. More... | |
![]() | |
movie_definition (std::uint16_t id=0) | |
virtual | ~movie_definition () |
![]() | |
DefinitionTag (std::uint16_t id) | |
![]() | |
virtual | ~ref_counted () |
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 | ( | ) |
|
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.
Referenced by importResources().
|
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.
|
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 _, IF_VERBOSE_PARSE, gnash::log_parse(), and gnash::sound_sample::m_sound_handler_id.
|
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.
|
inlinevirtual |
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 DSOTEXPORT.
Referenced by addDisplayObject().
|
virtual |
References addControlTag(), and gnash::CharacterDictionary::addDisplayObject().
Referenced by importResources().
|
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 _, ensure_frame_loaded(), gnash::log_error(), read_all_swf(), gnash::SWFMovieLoader::start(), and gnash::SWFMovieLoader::started().
|
inlinevirtual |
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.
|
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::NSV::CLASS_MOVIE_CLIP, gnash::getObjectWithPrototype(), and gnash::key::o.
|
virtual |
Ensure that frame number 'framenum' (1-based offset) has been loaded (load on demand).
Reimplemented from gnash::movie_definition.
Referenced by completeLoad().
|
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.
|
inlinevirtual |
Get number of bytes loaded from input stream.
Implements gnash::movie_definition.
|
inlinevirtual |
Get total number of bytes as parsed from the SWF header.
Implements gnash::movie_definition.
References gnash::fontlib::add_font(), gnash::key::c, DSOTEXPORT, gnash::key::f, gnash::fontlib::get_font(), name, and source.
|
virtual |
Return the font with given DisplayObject id.
Reimplemented from gnash::movie_definition.
References gnash::key::f.
|
virtual |
Find a font from the movie (not shared) lib.
Reimplemented from gnash::movie_definition.
References gnash::key::f, and gnash::Font::matches().
|
inlinevirtual |
Return total number of frames advertised for the SWFMovie.
Implements gnash::movie_definition.
|
inlinevirtual |
Return frame rate advertised for the SWFMovie.
Implements gnash::movie_definition.
|
inlinevirtual |
Return dimensions of the SWFMovie.
Implements gnash::movie_definition.
|
inlinevirtual |
Frame height in pixels.
The frame size is in twips and may be rounded up.
Implements gnash::movie_definition.
References gnash::twipsToPixels().
|
inlinevirtual |
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.
|
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.
|
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.
Implements gnash::movie_definition.
References _, get_url(), IF_VERBOSE_MALFORMED_SWF, gnash::log_debug(), and gnash::log_swferror().
|
inlinevirtual |
Get the currently being loaded sound stream, if any.
The default implementation returns -1
Reimplemented from gnash::movie_definition.
|
virtual |
Get the sound sample with given ID.
The default implementation always returns NULL
Reimplemented from gnash::movie_definition.
|
inlinevirtual |
Return the URL of the SWF stream this definition has been read from.
Implements gnash::movie_definition.
Referenced by get_loading_frame(), importResources(), and registerExport().
|
inlinevirtual |
Return the advertised version for the SWFMovie.
This is stored and used in AS interpretation for some version-based behaviour.
Implements gnash::movie_definition.
|
inlinevirtual |
Frame width in pixels.
The frame size is in twips and may be rounded up.
Implements gnash::movie_definition.
References gnash::twipsToPixels().
|
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.
|
virtual |
Return a DisplayObject from the dictionary.
Reimplemented from gnash::movie_definition.
References gnash::CharacterDictionary::getDisplayObject().
|
inlinevirtual |
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 url.
|
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 _, add_font(), addDisplayObject(), gnash::key::f, get_url(), gnash::gnashSleep(), gnash::log_debug(), gnash::log_error(), and registerExport().
|
inlinevirtual |
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 gnash::SWFMovieLoader::isSelfThread(), and gnash::SWFMovieLoader::started().
Referenced by completeLoad(), and gnash::SWFMovieLoader::start().
bool gnash::SWFMovieDefinition::readHeader | ( | std::unique_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 _, IF_VERBOSE_MALFORMED_SWF, IF_VERBOSE_PARSE, gnash::SWFRect::is_null(), gnash::log_error(), gnash::log_parse(), gnash::log_swferror(), gnash::zlib_adapter::make_inflater(), gnash::readRect(), and url.
|
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 get_url(), gnash::SWF::DefinitionTag::id(), and gnash::log_debug().
Referenced by importResources().
|
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 _, and gnash::log_swferror().
|
inlinevirtual |
Set the currently being loaded sound stream.
The default implementation is a no-op
Reimplemented from gnash::movie_definition.
|
inlinevirtual |
Call this to inform callers that tags should be executed using AVM2.
Reimplemented from gnash::movie_definition.