Go to the documentation of this file.
23 #ifndef GNASH_SWF_MOVIE_DEFINITION_H
24 #define GNASH_SWF_MOVIE_DEFINITION_H
30 #include <boost/intrusive_ptr.hpp>
40 #include <condition_variable>
54 class SWFMovieDefinition;
95 mutable std::mutex _mutex;
112 typedef std::map<int, boost::intrusive_ptr<SWF::DefinitionTag> >
172 return m_frame_count;
216 virtual size_t get_loading_frame()
const;
220 return _bytes_loaded.load();
225 return m_file_length;
228 DSOTEXPORT virtual void importResources(boost::intrusive_ptr<movie_definition>
source,
229 const Imports& imports);
239 DSOTEXPORT bool get_labeled_frame(
const std::string& label,
size_t& frame_number)
252 void addBitmap(
int DisplayObject_id, boost::intrusive_ptr<CachedBitmap> im);
255 sound_sample* get_sound_sample(
int DisplayObject_id)
const;
258 virtual void add_sound_sample(
int DisplayObject_id,
sound_sample* sam);
262 m_loading_sound_stream = id;
267 return m_loading_sound_stream;
273 size_t frames_loaded = get_loading_frame();
274 m_playlist[frames_loaded].push_back(tag);
285 DSOTEXPORT void set_jpeg_loader(std::unique_ptr<image::JpegInput> j_in);
289 return m_jpeg_in.get();
295 assert(frame_number <= _frames_loaded.load());
298 PlayListMap::const_iterator it = m_playlist.find(frame_number);
299 if ( it == m_playlist.end() )
return nullptr;
300 else return &(it->second);
312 bool readHeader(std::unique_ptr<IOChannel> in,
const std::string&
url);
326 bool ensure_frame_loaded(
size_t framenum)
const;
352 virtual const std::string&
get_url()
const {
return _url; }
362 std::uint16_t exportID(
const std::string& symbol)
const;
371 void registerExport(
const std::string& symbol, std::uint16_t
id);
378 virtual void storeDescriptiveMetadata(
const std::string&
data) {
382 virtual const std::string& getDescriptiveMetadata()
const {
392 std::string _metadata;
396 CharacterDictionary _dictionary;
399 mutable std::mutex _dictionaryMutex;
401 typedef std::map<int, boost::intrusive_ptr<Font> > FontMap;
404 typedef std::map<int, boost::intrusive_ptr<CachedBitmap> > Bitmaps;
407 typedef std::map<int, boost::intrusive_ptr<sound_sample> > SoundSampleMap;
408 SoundSampleMap m_sound_samples;
410 typedef std::map<size_t, PlayList> PlayListMap;
413 PlayListMap m_playlist;
416 typedef std::map<std::string, size_t, StringNoCaseLessThan> NamedFrameMap;
417 NamedFrameMap _namedFrames;
420 mutable std::mutex _namedFramesMutex;
423 typedef std::map<std::string, std::uint16_t,
424 StringNoCaseLessThan> Exports;
427 Exports _exportTable;
430 mutable std::mutex _exportedResourcesMutex;
434 typedef std::vector<boost::intrusive_ptr<movie_definition> > ImportVect;
435 ImportVect m_import_source_movies;
437 SWFRect m_frame_size;
439 size_t m_frame_count;
443 std::atomic<size_t> _frames_loaded;
446 mutable std::condition_variable _frame_reached_condition;
449 mutable std::atomic<size_t> _waiting_for_frame;
452 std::atomic<unsigned long> _bytes_loaded;
454 int m_loading_sound_stream;
456 std::uint32_t m_file_length;
458 std::unique_ptr<image::JpegInput> m_jpeg_in;
463 std::unique_ptr<SWFStream> _str;
465 std::unique_ptr<IOChannel> _in;
473 SWFMovieLoader _loader;
478 DSOTEXPORT virtual void incrementLoadedFrames();
481 void setBytesLoaded(
unsigned long bytes)
487 mutable std::mutex _loadingCanceledMutex;
488 bool _loadingCanceled;
491 std::set< boost::intrusive_ptr<movie_definition> > _importSources;
501 const RunResources& _runResources;
503 std::atomic<bool> _as3;
@ CLASS_MOVIE_CLIP
Definition: namedStrings.h:227
bool readHeader(std::unique_ptr< IOChannel > in, const std::string &url)
Read the header of the SWF file.
Definition: SWFMovieDefinition.cpp:246
DSOTEXPORT ~SWFMovieDefinition()
Definition: SWFMovieDefinition.cpp:150
std::string name
Definition: LocalConnection_as.cpp:149
void log_swferror(StringType msg, Args... args)
Definition: log.h:325
virtual DisplayObject * createDisplayObject(Global_as &, DisplayObject *) const
Create a DisplayObject with the given parent.
Definition: SWFMovieDefinition.h:347
CharacterIterator end()
Return an iterator to one-past last dictionary element.
Definition: SWFMovieDefinition.h:138
The base class for all ActionScript objects.
Definition: as_object.h:162
DSOTEXPORT void set_jpeg_loader(std::unique_ptr< image::JpegInput > j_in)
Definition: SWFMovieDefinition.cpp:585
boost::intrusive_ptr< SWF::DefinitionTag > getDisplayObject(int id) const
Get the Character with the given id.
Definition: SWFMovieDefinition.cpp:412
void setAS3()
Call this to inform callers that tags should be executed using AVM2.
Definition: SWFMovieDefinition.h:194
void read_all_swf()
Read and parse all the SWF stream (blocking until load is finished)
Definition: SWFMovieDefinition.cpp:435
Immutable data representing the definition of a movie display element.
Definition: DefinitionTag.h:48
virtual DSOTEXPORT void importResources(boost::intrusive_ptr< movie_definition > source, const Imports &imports)
Import resources.
Definition: SWFMovieDefinition.cpp:611
void log_debug(StringType msg, Args... args)
Definition: log.h:301
virtual const PlayList * getPlaylist(size_t frame_number) const
Return the list of execute tags for given frame number.
Definition: SWFMovieDefinition.h:292
CharacterConstIterator begin() const
Return a const_iterator to the first dictionary element.
Definition: SWFMovieDefinition.h:135
SWFMovieDefinition(const RunResources &runResources)
Construct a SWF movie.
Definition: SWFMovieDefinition.cpp:131
#define _(String)
Definition: log.h:44
virtual size_t get_loading_frame() const
Get the number of fully loaded frames.
Definition: SWFMovieDefinition.cpp:515
CharacterContainer::iterator CharacterIterator
Definition: SWFMovieDefinition.h:115
Immutable definition of a SWF movie's contents.
Definition: SWFMovieDefinition.h:159
Helper class handling start and execution of a loading thread.
Definition: SWFMovieDefinition.h:70
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
bool is_null() const
returns true if this is a NULL rectangle
Definition: SWFRect.h:75
void addBitmap(int DisplayObject_id, boost::intrusive_ptr< CachedBitmap > im)
Add a bitmap DisplayObject in the dictionary, with the specified DisplayObject id.
Definition: SWFMovieDefinition.cpp:215
void registerExport(const std::string &symbol, std::uint16_t id)
Register a symbol to refer to a character id.
Definition: SWFMovieDefinition.cpp:552
DSOTEXPORT bool get_labeled_frame(const std::string &label, size_t &frame_number) const
Get 0-based index of the frame with given label.
Definition: SWFMovieDefinition.cpp:574
@ n
Definition: GnashKey.h:160
std::vector< ImportSpec > Imports
Definition: movie_definition.h:166
std::unique_ptr< IOChannel > make_inflater(std::unique_ptr< IOChannel >)
Returns a read-only IOChannel stream that inflates the remaining content of the given input stream,...
Definition: zlib_adapter.cpp:28
double twipsToPixels(int i)
Definition: GnashNumeric.h:97
bool ensure_frame_loaded(size_t framenum) const
Ensure that frame number 'framenum' (1-based offset) has been loaded (load on demand).
Definition: SWFMovieDefinition.cpp:361
size_t get_bytes_loaded() const
Get number of bytes loaded from input stream.
Definition: SWFMovieDefinition.h:219
Client program's interface to the definition of a movie or sprite.
Definition: movie_definition.h:96
size_t bytesRead() const
The number of bytes processed by this SWFParser.
Definition: SWFParser.h:69
void log_error(StringType msg, Args... args)
Definition: log.h:283
bool start()
Start loading thread.
Definition: SWFMovieDefinition.cpp:110
bool read(std::streamsize bytes)
Parse a specified number of bytes from the stream.
Definition: SWFParser.cpp:51
bool completeLoad()
Complete load of the SWF file.
Definition: SWFMovieDefinition.cpp:328
CharacterContainer::const_iterator CharacterConstIterator
Definition: SWFMovieDefinition.h:117
#define IF_VERBOSE_MALFORMED_SWF(x)
Definition: log.h:404
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:45
DSOTEXPORT void add_frame_name(const std::string &name)
Labels the frame currently being loaded with the given name.
Definition: SWFMovieDefinition.cpp:566
An identifier for a sound sample managed by a sound_handler.
Definition: sound_definition.h:62
virtual void addDisplayObject(std::uint16_t id, SWF::DefinitionTag *c)
Definition: SWFMovieDefinition.cpp:158
DSOTEXPORT void addDisplayObject(int id, boost::intrusive_ptr< SWF::DefinitionTag > c)
Add a Character assigning it the given id.
Definition: SWFMovieDefinition.cpp:427
Font * get_font(const std::string &name, bool bold, bool italic)
Definition: fontlib.cpp:50
int get_loading_sound_stream_id() const
Get the currently being loaded sound stream, if any.
Definition: SWFMovieDefinition.h:266
std::uint16_t id() const
The immutable id of the DefinitionTag.
Definition: DefinitionTag.h:76
float get_frame_rate() const
Return frame rate advertised for the SWFMovie.
Definition: SWFMovieDefinition.h:176
std::vector< boost::intrusive_ptr< SWF::ControlTag > > PlayList
Definition: movie_definition.h:98
bool isAS3() const
Check whether tags should be executed using AVM2.
Definition: SWFMovieDefinition.h:199
CharacterConstIterator end() const
Return a const_iterator to one-past last dictionary element.
Definition: SWFMovieDefinition.h:141
An SWF parsing exception.
Definition: GnashException.h:90
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:54
int m_sound_handler_id
Definition: sound_definition.h:65
virtual void set_loading_sound_stream_id(int id)
Set the currently being loaded sound stream.
Definition: SWFMovieDefinition.h:261
DSOTEXPORT Font * get_font(int font_id) const
Return the font with given DisplayObject id.
Definition: SWFMovieDefinition.cpp:183
A top-level, standalone Movie that can be loaded and played.
Definition: Movie.h:47
size_t get_bytes_total() const
Get total number of bytes as parsed from the SWF header.
Definition: SWFMovieDefinition.h:224
sound_sample * get_sound_sample(int DisplayObject_id) const
Get the sound sample with given ID.
Definition: SWFMovieDefinition.cpp:222
Movie * createMovie(Global_as &gl, DisplayObject *parent=nullptr)
Create an instance of this movie.
Definition: SWFMovieDefinition.cpp:386
#define IF_VERBOSE_PARSE(x)
Definition: log.h:378
void log_parse(StringType msg, Args... args)
Definition: log.h:313
DSOTEXPORT SWF::DefinitionTag * getDefinitionTag(std::uint16_t id) const
Return a DisplayObject from the dictionary.
Definition: SWFMovieDefinition.cpp:167
void gnashSleep(time_t useconds)
Sleep compatibly for the specified number of microseconds.
Definition: GnashSleep.h:35
size_t get_height_pixels() const
Frame height in pixels.
Definition: SWFMovieDefinition.h:189
Stateful Movie object (a special kind of sprite)
Definition: SWFMovie.h:51
const SWFRect & get_frame_size() const
Return dimensions of the SWFMovie.
Definition: SWFMovieDefinition.h:181
std::string url
Definition: gnash.cpp:59
DSOTEXPORT void add_font(int font_id, boost::intrusive_ptr< Font > f)
Add a font DisplayObject with given ID to the CharacterDictionary.
Definition: SWFMovieDefinition.cpp:176
@ f
Definition: GnashKey.h:152
A Font resource.
Definition: Font.h:90
#define DSOTEXPORT
Definition: dsodefs.h:63
The Global object ultimately contains all objects in an ActionScript run.
Definition: Global_as.h:50
bool isSelfThread() const
Return true if called from the loader thread.
Definition: SWFMovieDefinition.cpp:99
@ c
Definition: GnashKey.h:149
~SWFMovieLoader()
Definition: SWFMovieDefinition.cpp:79
as_object * getObjectWithPrototype(Global_as &gl, const ObjectURI &c)
Definition: as_object.cpp:1109
image::JpegInput * get_jpeg_loader() const
Get the jpeg input loader, to load a DefineBits image (one without table info).
Definition: SWFMovieDefinition.h:288
virtual int get_version() const
Return the advertised version for the SWFMovie.
Definition: SWFMovieDefinition.h:207
std::uint16_t exportID(const std::string &symbol) const
Get the id that corresponds to a symbol.
Definition: SWFMovieDefinition.cpp:602
DSOTEXPORT CachedBitmap * getBitmap(int DisplayObject_id) const
Get a bitmap from the bitmap dictionary.
Definition: SWFMovieDefinition.cpp:207
The Characters dictionary associated with each SWF file.
Definition: SWFMovieDefinition.h:105
size_t get_width_pixels() const
Frame width in pixels.
Definition: SWFMovieDefinition.h:185
virtual void add_sound_sample(int DisplayObject_id, sound_sample *sam)
Add a sound sample DisplayObject in the dictionary, with the specified DisplayObject id.
Definition: SWFMovieDefinition.cpp:233
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:169
The SWFParser parses tags from a SWFStream.
Definition: SWFParser.h:51
CharacterIterator begin()
Return an iterator to the first dictionary element.
Definition: SWFMovieDefinition.h:132
@ source
Definition: klash_part.cpp:329
SWFMovieLoader(SWFMovieDefinition &md)
Definition: SWFMovieDefinition.cpp:74
SWF stream wrapper class.
Definition: SWFStream.h:59
void add_font(Font *f)
Definition: fontlib.cpp:67
void addControlTag(boost::intrusive_ptr< SWF::ControlTag > tag)
Add an ControlTag to this movie_definition's playlist.
Definition: SWFMovieDefinition.h:271
SWFRect readRect(SWFStream &in)
Read a bit-packed rectangle from an SWF stream.
Definition: TypesParser.cpp:130
@ o
Definition: GnashKey.h:161
@ SWF
Definition: GnashKey.h:331
@ u
Definition: GnashKey.h:167
A CachedBitmap is created by the renderer in a format of its choosing.
Definition: CachedBitmap.h:38
SimpleBuffer data
Definition: LocalConnection_as.cpp:151
@ e
Definition: GnashKey.h:151
std::map< int, boost::intrusive_ptr< SWF::DefinitionTag > > CharacterContainer
The container used by this dictionary.
Definition: SWFMovieDefinition.h:113
bool started() const
Return true if the loader thread was started.
Definition: SWFMovieDefinition.cpp:91
friend std::ostream & operator<<(std::ostream &o, const CharacterDictionary &cd)
Definition: SWFMovieDefinition.cpp:398
virtual const std::string & get_url() const
Return the URL of the SWF stream this definition has been read from.
Definition: SWFMovieDefinition.h:352
std::ostream & operator<<(std::ostream &o, const URL &u)
Definition: URL.cpp:447
size_t get_frame_count() const
Return total number of frames advertised for the SWFMovie.
Definition: SWFMovieDefinition.h:171