Gnash  0.8.11dev
Public Member Functions | List of all members
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

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 SWFRectget_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::DefinitionTaggetDefinitionTag (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 Fontget_font (int font_id) const
 Return the font with given DisplayObject id. More...
 
Fontget_font (const std::string &name, bool bold, bool italic) const
 Find a font from the movie (not shared) lib. More...
 
DSOTEXPORT CachedBitmapgetBitmap (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_sampleget_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::JpegInputget_jpeg_loader () const
 Get the jpeg input loader, to load a DefineBits image (one without table info). More...
 
virtual const PlayListgetPlaylist (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...
 
MoviecreateMovie (Global_as &gl, DisplayObject *parent=nullptr)
 Create an instance of this movie. More...
 
virtual DisplayObjectcreateDisplayObject (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...
 
- Public Member Functions inherited from gnash::movie_definition
virtual void addDisplayObject (std::uint16_t, DefinitionTag *)
 Add a DefinitionTag with given ID to the CharactersDictionary. More...
 
- Public Member Functions inherited from gnash::SWF::DefinitionTag
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...
 
- Public Member Functions inherited from gnash::SWF::ControlTag
virtual ~ControlTag ()
 
virtual void executeActions (MovieClip *, DisplayList &) const
 Execute Action tags. More...
 
- Public Member Functions inherited from gnash::ref_counted
 ref_counted ()
 
 ref_counted (const ref_counted &)
 
void add_ref () const
 
void drop_ref () const
 
long get_ref_count () const
 

Additional Inherited Members

- Public Types inherited from gnash::movie_definition
typedef std::vector< boost::intrusive_ptr< SWF::ControlTag > > PlayList
 
typedef std::pair< int, std::string > ImportSpec
 
typedef std::vector< ImportSpecImports
 
- Public Types inherited from gnash::SWF::ControlTag
enum  Type { TAG_ACTION = 1 << 0, TAG_DLIST = 1 << 1 }
 Type of ControlTag. More...
 
- Protected Member Functions inherited from gnash::movie_definition
 movie_definition (std::uint16_t id=0)
 
virtual ~movie_definition ()
 
- Protected Member Functions inherited from gnash::SWF::DefinitionTag
 DefinitionTag (std::uint16_t id)
 
- Protected Member Functions inherited from gnash::ref_counted
virtual ~ref_counted ()
 

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

§ SWFMovieDefinition()

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

Construct a SWF movie.

Parameters
runResourcesA RunResources containing information used for parsing.

§ ~SWFMovieDefinition()

gnash::SWFMovieDefinition::~SWFMovieDefinition ( )

Member Function Documentation

§ add_font()

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.

Referenced by importResources().

§ add_frame_name()

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.

§ add_sound_sample()

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 _, IF_VERBOSE_PARSE, gnash::log_parse(), and gnash::sound_sample::m_sound_handler_id.

§ addBitmap()

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.

§ addControlTag()

void gnash::SWFMovieDefinition::addControlTag ( boost::intrusive_ptr< SWF::ControlTag )
inlinevirtual

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 DSOTEXPORT.

Referenced by addDisplayObject().

§ addDisplayObject()

void gnash::SWFMovieDefinition::addDisplayObject ( std::uint16_t  id,
SWF::DefinitionTag c 
)
virtual

§ completeLoad()

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 _, ensure_frame_loaded(), gnash::log_error(), read_all_swf(), gnash::SWFMovieLoader::start(), and gnash::SWFMovieLoader::started().

§ createDisplayObject()

virtual DisplayObject* gnash::SWFMovieDefinition::createDisplayObject ( Global_as gl,
DisplayObject parent 
) const
inlinevirtual

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.

§ createMovie()

Movie * gnash::SWFMovieDefinition::createMovie ( Global_as gl,
DisplayObject parent = nullptr 
)
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.

§ ensure_frame_loaded()

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

§ exportID()

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

§ get_bytes_loaded()

size_t gnash::SWFMovieDefinition::get_bytes_loaded ( ) const
inlinevirtual

Get number of bytes loaded from input stream.

Implements gnash::movie_definition.

§ get_bytes_total()

size_t gnash::SWFMovieDefinition::get_bytes_total ( ) const
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.

§ get_font() [1/2]

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.

§ get_font() [2/2]

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

§ get_frame_count()

size_t gnash::SWFMovieDefinition::get_frame_count ( ) const
inlinevirtual

Return total number of frames advertised for the SWFMovie.

Implements gnash::movie_definition.

§ get_frame_rate()

float gnash::SWFMovieDefinition::get_frame_rate ( ) const
inlinevirtual

Return frame rate advertised for the SWFMovie.

Implements gnash::movie_definition.

§ get_frame_size()

const SWFRect& gnash::SWFMovieDefinition::get_frame_size ( ) const
inlinevirtual

Return dimensions of the SWFMovie.

Implements gnash::movie_definition.

§ get_height_pixels()

size_t gnash::SWFMovieDefinition::get_height_pixels ( ) const
inlinevirtual

Frame height in pixels.

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

Implements gnash::movie_definition.

References gnash::twipsToPixels().

§ get_jpeg_loader()

image::JpegInput* gnash::SWFMovieDefinition::get_jpeg_loader ( ) const
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.

§ get_labeled_frame()

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.

§ get_loading_frame()

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.

Implements gnash::movie_definition.

References _, get_url(), IF_VERBOSE_MALFORMED_SWF, gnash::log_debug(), and gnash::log_swferror().

§ get_loading_sound_stream_id()

int gnash::SWFMovieDefinition::get_loading_sound_stream_id ( ) const
inlinevirtual

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.

§ get_sound_sample()

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.

§ get_url()

virtual const std::string& gnash::SWFMovieDefinition::get_url ( ) const
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().

§ get_version()

virtual int gnash::SWFMovieDefinition::get_version ( ) const
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.

§ get_width_pixels()

size_t gnash::SWFMovieDefinition::get_width_pixels ( ) const
inlinevirtual

Frame width in pixels.

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

Implements gnash::movie_definition.

References gnash::twipsToPixels().

§ getBitmap()

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.

§ getDefinitionTag()

SWF::DefinitionTag * gnash::SWFMovieDefinition::getDefinitionTag ( std::uint16_t  id) const
virtual

Return a DisplayObject from the dictionary.

Reimplemented from gnash::movie_definition.

References gnash::CharacterDictionary::getDisplayObject().

§ getPlaylist()

virtual const PlayList* gnash::SWFMovieDefinition::getPlaylist ( size_t  ) const
inlinevirtual

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 url.

§ importResources()

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 _, add_font(), addDisplayObject(), gnash::key::f, get_url(), gnash::gnashSleep(), gnash::log_debug(), gnash::log_error(), and registerExport().

§ isAS3()

bool gnash::SWFMovieDefinition::isAS3 ( ) const
inlinevirtual

Check whether tags should be executed using AVM2.

Reimplemented from gnash::movie_definition.

§ read_all_swf()

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

§ readHeader()

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.

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

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.

§ registerExport()

void gnash::SWFMovieDefinition::registerExport ( const std::string &  symbol,
std::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 get_url(), gnash::SWF::DefinitionTag::id(), and gnash::log_debug().

Referenced by importResources().

§ set_jpeg_loader()

void gnash::SWFMovieDefinition::set_jpeg_loader ( std::unique_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 _, and gnash::log_swferror().

§ set_loading_sound_stream_id()

virtual void gnash::SWFMovieDefinition::set_loading_sound_stream_id ( int  )
inlinevirtual

Set the currently being loaded sound stream.

The default implementation is a no-op

Reimplemented from gnash::movie_definition.

§ setAS3()

void gnash::SWFMovieDefinition::setAS3 ( )
inlinevirtual

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: