Public Types | Public Member Functions | Protected Member Functions

gnash::movie_definition Class Reference

Client program's interface to the definition of a movie or sprite. More...

#include <movie_definition.h>

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

List of all members.

Public Types

typedef std::vector
< boost::intrusive_ptr
< SWF::ControlTag > > 
PlayList
typedef std::pair< int,
std::string > 
ImportSpec
typedef std::vector< ImportSpecImports

Public Member Functions

virtual int get_version () const =0
virtual size_t get_width_pixels () const =0
 Frame width in pixels.
virtual size_t get_height_pixels () const =0
 Frame height in pixels.
virtual size_t get_frame_count () const =0
virtual float get_frame_rate () const =0
virtual const SWFRectget_frame_size () const =0
 Return size of frame, in TWIPS.
virtual size_t get_bytes_loaded () const =0
virtual size_t get_bytes_total () const =0
 Get total number of bytes in (uncompressed for SWF) input stream.
virtual MoviecreateMovie (Global_as &, DisplayObject *=0)
 Create a movie instance from a def.
virtual void incrementLoadedFrames ()
virtual const PlayListgetPlaylist (size_t) const
 Return the list of execute tags for given frame number.
virtual void importResources (boost::intrusive_ptr< movie_definition >, const Imports &)
 Import resources.
virtual DefinitionTag * getDefinitionTag (boost::uint16_t) const
 Get a DisplayObject from the dictionary.
virtual bool get_labeled_frame (const std::string &, size_t &) const
 Get 0-based index of the frame with given label.
virtual size_t get_loading_frame () const =0
 Returns 1 based index. Ex: if 1 then 1st frame as been fully loaded.
virtual void addDisplayObject (boost::uint16_t, DefinitionTag *)
 Add a DefinitionTag with given ID to the CharactersDictionary.
virtual void add_font (int, Font *)
 Add a font DisplayObject with given ID to the CharacterDictionary.
virtual Fontget_font (int) const
 Return the font with given DisplayObject id.
virtual Fontget_font (const std::string &, bool, bool) const
 Find a font from the movie (not shared) lib.
virtual void addControlTag (SWF::ControlTag *)
 Add an ControlTag to this movie_definition's playlist.
virtual void add_frame_name (const std::string &)
 Labels the frame currently being loaded with the given name.
virtual void set_jpeg_loader (std::auto_ptr< image::JpegInput >)
virtual image::JpegInputget_jpeg_loader () const
 Get the jpeg input loader, to load a DefineBits image (one without table info).
virtual CachedBitmapgetBitmap (int) const
 Get a bitmap from the bitmap dictionary.
virtual void addBitmap (int, boost::intrusive_ptr< CachedBitmap >)
 Add a bitmap DisplayObject in the dictionary, with the specified DisplayObject id.
virtual sound_sampleget_sound_sample (int) const
 Get the sound sample with given ID.
virtual void add_sound_sample (int, sound_sample *)
 Add a sound sample DisplayObject in the dictionary, with the specified DisplayObject id.
virtual void set_loading_sound_stream_id (int)
 Set the currently being loaded sound stream.
virtual int get_loading_sound_stream_id () const
 Get the currently being loaded sound stream, if any.
virtual void registerExport (const std::string &, boost::uint16_t)
 Register a symbol to refer to a character id.
virtual boost::uint16_t exportID (const std::string &) const
 Get the id that corresponds to a symbol.
virtual void setAS3 ()
 Set whether the SWFMovie should use AVM2 or AVM1.
virtual bool isAS3 () const
 True if the SWFMovie should use AVM2.
virtual const std::string & get_url () const =0
 Return the URL of the SWF stream this definition has been read from.
virtual bool completeLoad ()
virtual bool ensure_frame_loaded (size_t) const
 Ensure that frame number 'framenum' (1-based offset) has been loaded (load on demand).

Protected Member Functions

 movie_definition (boost::uint16_t id=0)

Detailed Description

Client program's interface to the definition of a movie or sprite.

This is the shared constant source info, the one that cannot be changed by ActionScript code.

The class derives from DefinitionTag to allow a movie to be put in the CharacterDictionary. This is probably unneeded for top-level movies, because they don't need to be put in any CharacterDictionary... anyway the current design requires both sprite_definition (a sprite) and SWFMovieDefinition (a top-level movie) to derive from a common class to allow tag_loaders to take a pointer to the base class to act on (consider PLACEOBJECT tags...).

This design is uncomfortable when it comes to programmatically created DisplayObjects, in that they do NOT have any *fixed* definition. A possible workaround to this would be not *requiring* DisplayObject instances to have an associated DefinitionTag. I'll work on this --strk 2006-12-05.


Member Typedef Documentation

typedef std::pair<int, std::string> gnash::movie_definition::ImportSpec
typedef std::vector<boost::intrusive_ptr<SWF::ControlTag> > gnash::movie_definition::PlayList

Constructor & Destructor Documentation

gnash::movie_definition::movie_definition ( boost::uint16_t  id = 0  )  [inline, protected]

Member Function Documentation

virtual void gnash::movie_definition::add_font ( int  ,
Font  
) [inline, 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 in gnash::sprite_definition, and gnash::SWFMovieDefinition.

Referenced by gnash::SWF::DefineFontTag::loader().

virtual void gnash::movie_definition::add_frame_name ( const std::string &   )  [inline, 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 in gnash::SWFMovieDefinition.

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

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

The default implementation is a no-op

Reimplemented in gnash::sprite_definition, and gnash::SWFMovieDefinition.

Referenced by gnash::sprite_definition::add_sound_sample().

virtual void gnash::movie_definition::addBitmap ( int  ,
boost::intrusive_ptr< CachedBitmap  
) [inline, 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 in gnash::sprite_definition, and gnash::SWFMovieDefinition.

virtual void gnash::movie_definition::addControlTag ( SWF::ControlTag  )  [inline, virtual]

Add an ControlTag to this movie_definition's playlist.

The default implementation is a no-op.

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

TODO: take an auto_ptr. NOTE: the default implementation just let the ControlTag leak.

Reimplemented in gnash::sprite_definition, and gnash::SWFMovieDefinition.

Referenced by gnash::SWF::SymbolClassTag::loader(), gnash::SWF::StreamSoundBlockTag::loader(), gnash::SWF::StartSoundTag::loader(), gnash::SWF::SetBackgroundColorTag::loader(), gnash::SWF::ScriptLimitsTag::loader(), gnash::SWF::RemoveObjectTag::loader(), gnash::SWF::PlaceObject2Tag::loader(), gnash::SWF::ImportAssetsTag::loader(), gnash::SWF::ExportAssetsTag::loader(), gnash::SWF::DoInitActionTag::loader(), gnash::SWF::DoActionTag::loader(), gnash::SWF::DoABCTag::loader(), and gnash::SWF::DefineSceneAndFrameLabelDataTag::loader().

virtual void gnash::movie_definition::addDisplayObject ( boost::uint16_t  ,
DefinitionTag *   
) [inline, virtual]

Add a DefinitionTag with given ID to the CharactersDictionary.

Parameters:
id The id of the tag. All tags store their own id, but imported characters receive a new id in the importing movie. This method is here to be called by DEFINE tags loaders. The default implementation does nothing.

Referenced by gnash::sprite_definition::addDisplayObject(), gnash::SWF::DefineVideoStreamTag::loader(), gnash::SWF::DefineText2Tag::loader(), gnash::SWF::DefineTextTag::loader(), gnash::SWF::DefineShapeTag::loader(), gnash::SWF::DefineMorphShapeTag::loader(), gnash::SWF::DefineEditTextTag::loader(), gnash::SWF::DefineButton2Tag::loader(), and gnash::SWF::DefineButtonTag::loader().

virtual bool gnash::movie_definition::completeLoad (  )  [inline, virtual]

Reimplemented in gnash::SWFMovieDefinition.

virtual Movie* gnash::movie_definition::createMovie ( Global_as ,
DisplayObject = 0 
) [inline, virtual]

Create a movie instance from a def.

Not all movie definitions allow creation of Movie. In particular, sprite_definition can only create MovieClip, so will return NULL from this method.

The default implementation returns NULL.

Override this method for any definition that is able to be instanciated as a Movie. SWFMovieDefinition is one such example, future examples should include jpeg_movie_def and similar..

Reimplemented in gnash::BitmapMovieDefinition, gnash::SWFMovieDefinition, and gnash::DummyMovieDefinition.

virtual bool gnash::movie_definition::ensure_frame_loaded ( size_t   )  const [inline, virtual]

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

Parameters:
framenum 1-based frame index that we want to be fully loaded before this function returns
Returns:
false on error (like not enough frames available).

The default implementation is to always return true.

Reimplemented in gnash::SWFMovieDefinition, and gnash::DummyMovieDefinition.

virtual boost::uint16_t gnash::movie_definition::exportID ( const std::string &   )  const [inline, virtual]

Get the id that corresponds to a symbol.

Returns:
The id corresponding to the passed symbol. The default implementation returns 0, as it has no export table.

Reimplemented in gnash::sprite_definition, and gnash::SWFMovieDefinition.

Referenced by gnash::SWF::ExportAssetsTag::executeState(), and gnash::sprite_definition::exportID().

virtual size_t gnash::movie_definition::get_bytes_loaded (  )  const [pure virtual]
virtual size_t gnash::movie_definition::get_bytes_total (  )  const [pure virtual]

Get total number of bytes in (uncompressed for SWF) input stream.

Note that this is different from actual file size if this is a *compressed* SWF. For other kind of movie definitions (Bitmaps, for example), the returned value should likely match the file size.

Implemented in gnash::BitmapMovieDefinition, gnash::sprite_definition, gnash::SWFMovieDefinition, and gnash::DummyMovieDefinition.

Referenced by gnash::sprite_definition::get_bytes_total().

virtual Font* gnash::movie_definition::get_font ( int   )  const [inline, 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 in gnash::sprite_definition, and gnash::SWFMovieDefinition.

Referenced by gnash::sprite_definition::get_font(), gnash::SWF::DefineFontInfoTag::loader(), gnash::SWF::DefineFontNameTag::loader(), gnash::SWF::DefineFontAlignZonesTag::loader(), and gnash::SWF::TextRecord::read().

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

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

Reimplemented in gnash::SWFMovieDefinition.

virtual size_t gnash::movie_definition::get_frame_count (  )  const [pure virtual]
virtual float gnash::movie_definition::get_frame_rate (  )  const [pure virtual]
virtual const SWFRect& gnash::movie_definition::get_frame_size (  )  const [pure virtual]
virtual size_t gnash::movie_definition::get_height_pixels (  )  const [pure virtual]

Frame height in pixels.

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

Implemented in gnash::BitmapMovieDefinition, gnash::sprite_definition, gnash::SWFMovieDefinition, and gnash::DummyMovieDefinition.

virtual image::JpegInput* gnash::movie_definition::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 in gnash::SWFMovieDefinition.

virtual bool gnash::movie_definition::get_labeled_frame ( const std::string &  ,
size_t &   
) const [inline, 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:
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.
Returns:
true if a frame with that label was found, false otherwise

Reimplemented in gnash::SWFMovieDefinition.

virtual size_t gnash::movie_definition::get_loading_frame (  )  const [pure virtual]

Returns 1 based index. Ex: if 1 then 1st frame as been fully loaded.

Implemented in gnash::BitmapMovieDefinition, gnash::sprite_definition, gnash::SWFMovieDefinition, and gnash::DummyMovieDefinition.

Referenced by gnash::SWF::DoActionTag::loader(), and gnash::SWF::DoABCTag::loader().

virtual int gnash::movie_definition::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 in gnash::sprite_definition, and gnash::SWFMovieDefinition.

Referenced by gnash::SWF::StreamSoundBlockTag::loader().

virtual sound_sample* gnash::movie_definition::get_sound_sample ( int   )  const [inline, 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 in gnash::sprite_definition, and gnash::SWFMovieDefinition.

Referenced by gnash::sprite_definition::get_sound_sample(), and gnash::SWF::StartSoundTag::loader().

virtual const std::string& gnash::movie_definition::get_url (  )  const [pure virtual]

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

Implemented in gnash::BitmapMovieDefinition, gnash::SWFMovieDefinition, and gnash::DummyMovieDefinition.

Referenced by gnash::action_buffer::getDefinitionURL().

virtual int gnash::movie_definition::get_version (  )  const [pure virtual]
virtual size_t gnash::movie_definition::get_width_pixels (  )  const [pure virtual]

Frame width in pixels.

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

Implemented in gnash::BitmapMovieDefinition, gnash::sprite_definition, gnash::SWFMovieDefinition, and gnash::DummyMovieDefinition.

virtual CachedBitmap* gnash::movie_definition::getBitmap ( int   )  const [inline, 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 in gnash::sprite_definition, and gnash::SWFMovieDefinition.

Referenced by gnash::sprite_definition::getBitmap().

virtual DefinitionTag* gnash::movie_definition::getDefinitionTag ( boost::uint16_t   )  const [inline, virtual]

Get a DisplayObject from the dictionary.

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

Returns:
NULL if no DisplayObject with the given ID is found (this is the default)

Reimplemented in gnash::sprite_definition, and gnash::SWFMovieDefinition.

Referenced by gnash::sprite_definition::getDefinitionTag(), gnash::SWF::VideoFrameTag::loader(), gnash::SWF::SymbolClassTag::loader(), gnash::SWF::DefineButtonSoundTag::loader(), gnash::SWF::DefineButtonCxformTag::loader(), and gnash::SWF::ButtonRecord::read().

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

Return the list of execute tags for given frame number.

Parameters:
frame_number Frame 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 in gnash::SWFMovieDefinition.

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

Import resources.

Parameters:
source Movie containing the resources being imported
imports Resources to import, each with the id to use in our dictionary

Reimplemented in gnash::SWFMovieDefinition.

References _, and IF_VERBOSE_MALFORMED_SWF.

virtual void gnash::movie_definition::incrementLoadedFrames (  )  [inline, virtual]

Reimplemented in gnash::sprite_definition.

Referenced by gnash::SWFParser::read().

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

True if the SWFMovie should use AVM2.

This is only sensible for SWFMovieDefinitions, and shouldn't be here once this inheritance mess is cleaned up.

Reimplemented in gnash::SWFMovieDefinition.

Referenced by gnash::SWF::SymbolClassTag::loader(), gnash::SWF::DoInitActionTag::loader(), gnash::SWF::DoActionTag::loader(), gnash::SWF::DoABCTag::loader(), and gnash::SWF::DefineSceneAndFrameLabelDataTag::loader().

virtual void gnash::movie_definition::registerExport ( const std::string &  ,
boost::uint16_t   
) [inline, virtual]

Register a symbol to refer to a character id.

The default implementation does nothing.

Reimplemented in gnash::sprite_definition, and gnash::SWFMovieDefinition.

Referenced by gnash::sprite_definition::registerExport().

virtual void gnash::movie_definition::set_jpeg_loader ( std::auto_ptr< image::JpegInput  )  [inline, virtual]

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

The default implementation is a no-op. Actually, an implicit op is* performed, and it is deleting the jpeg::input instance since it is passed in an auto_ptr...

Reimplemented in gnash::SWFMovieDefinition.

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

Set the currently being loaded sound stream.

The default implementation is a no-op

Reimplemented in gnash::sprite_definition, and gnash::SWFMovieDefinition.

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

Set whether the SWFMovie should use AVM2 or AVM1.

This is only sensible for SWFMovieDefinitions, so is a no-op here.

Reimplemented in gnash::SWFMovieDefinition.


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