23 #ifndef GNASH_SWF_MOVIE_DEFINITION_H
24 #define GNASH_SWF_MOVIE_DEFINITION_H
30 #include <boost/intrusive_ptr.hpp>
36 #include <boost/thread/thread.hpp>
37 #include <boost/thread/condition.hpp>
38 #include <boost/thread/barrier.hpp>
39 #include <boost/scoped_ptr.hpp>
54 class SWFMovieDefinition;
92 mutable boost::mutex _mutex;
93 std::auto_ptr<boost::thread> _thread;
98 boost::barrier _barrier;
118 typedef std::map<int, boost::intrusive_ptr<SWF::DefinitionTag> >
138 CharacterIterator
begin() {
return _map.begin(); }
141 CharacterConstIterator
begin()
const {
return _map.begin(); }
144 CharacterIterator
end() {
return _map.end(); }
147 CharacterConstIterator
end()
const {
return _map.end(); }
178 return m_frame_count;
224 virtual size_t get_loading_frame()
const;
231 boost::mutex::scoped_lock lock(_bytes_loaded_mutex);
232 return _bytes_loaded;
237 return m_file_length;
240 DSOTEXPORT virtual void importResources(boost::intrusive_ptr<movie_definition>
source,
241 const Imports& imports);
251 DSOTEXPORT bool get_labeled_frame(
const std::string& label,
size_t& frame_number)
264 void addBitmap(
int DisplayObject_id, boost::intrusive_ptr<CachedBitmap> im);
267 sound_sample* get_sound_sample(
int DisplayObject_id)
const;
270 virtual void add_sound_sample(
int DisplayObject_id,
sound_sample* sam);
274 m_loading_sound_stream = id;
279 return m_loading_sound_stream;
285 boost::mutex::scoped_lock lock(_frames_loaded_mutex);
286 m_playlist[_frames_loaded].push_back(tag);
297 DSOTEXPORT void set_jpeg_loader(std::auto_ptr<image::JpegInput> j_in);
301 return m_jpeg_in.get();
307 boost::mutex::scoped_lock lock(_frames_loaded_mutex);
308 assert(frame_number <= _frames_loaded);
311 PlayListMap::const_iterator it = m_playlist.find(frame_number);
312 if ( it == m_playlist.end() )
return NULL;
313 else return &(it->second);
325 bool readHeader(std::auto_ptr<IOChannel> in,
const std::string&
url);
339 bool ensure_frame_loaded(
size_t framenum)
const;
375 boost::uint16_t exportID(
const std::string& symbol)
const;
384 void registerExport(
const std::string& symbol, boost::uint16_t
id);
391 virtual void storeDescriptiveMetadata(
const std::string&
data) {
395 virtual const std::string& getDescriptiveMetadata()
const {
405 std::string _metadata;
409 CharacterDictionary _dictionary;
412 mutable boost::mutex _dictionaryMutex;
414 typedef std::map<int, boost::intrusive_ptr<Font> > FontMap;
417 typedef std::map<int, boost::intrusive_ptr<CachedBitmap> > Bitmaps;
420 typedef std::map<int, boost::intrusive_ptr<sound_sample> > SoundSampleMap;
421 SoundSampleMap m_sound_samples;
423 typedef std::map<size_t, PlayList> PlayListMap;
426 PlayListMap m_playlist;
429 typedef std::map<std::string, size_t, StringNoCaseLessThan> NamedFrameMap;
430 NamedFrameMap _namedFrames;
433 mutable boost::mutex _namedFramesMutex;
436 typedef std::map<std::string, boost::uint16_t,
437 StringNoCaseLessThan> Exports;
440 Exports _exportTable;
443 mutable boost::mutex _exportedResourcesMutex;
447 typedef std::vector<boost::intrusive_ptr<movie_definition> > ImportVect;
448 ImportVect m_import_source_movies;
450 SWFRect m_frame_size;
452 size_t m_frame_count;
456 size_t _frames_loaded;
463 mutable boost::mutex _frames_loaded_mutex;
466 mutable boost::condition _frame_reached_condition;
472 mutable size_t _waiting_for_frame;
475 unsigned long _bytes_loaded;
482 mutable boost::mutex _bytes_loaded_mutex;
484 int m_loading_sound_stream;
486 boost::uint32_t m_file_length;
488 std::auto_ptr<image::JpegInput> m_jpeg_in;
493 boost::scoped_ptr<SWFStream> _str;
495 std::auto_ptr<IOChannel> _in;
501 SWFMovieLoader _loader;
510 DSOTEXPORT virtual void incrementLoadedFrames();
515 void setBytesLoaded(
unsigned long bytes)
517 boost::mutex::scoped_lock lock(_bytes_loaded_mutex);
522 bool _loadingCanceled;
525 std::set< boost::intrusive_ptr<movie_definition> > _importSources;
535 const RunResources& _runResources;
bool isSelfThread() const
Return true if called from the loader thread.
Definition: SWFMovieDefinition.cpp:101
CharacterConstIterator end() const
Return a const_iterator to one-past last dictionary element.
Definition: SWFMovieDefinition.h:147
int get_loading_sound_stream_id() const
Get the currently being loaded sound stream, if any.
Definition: SWFMovieDefinition.h:278
size_t get_bytes_loaded() const
Get number of bytes loaded from input stream.
Definition: SWFMovieDefinition.h:230
void setAS3()
Call this to inform callers that tags should be executed using AVM2.
Definition: SWFMovieDefinition.h:200
bool started() const
Return true if the loader thread was started.
Definition: SWFMovieDefinition.cpp:93
size_t get_height_pixels() const
Frame height in pixels.
Definition: SWFMovieDefinition.h:195
std::map< int, boost::intrusive_ptr< SWF::DefinitionTag > > CharacterContainer
The container used by this dictionary.
Definition: SWFMovieDefinition.h:119
Client program's interface to the definition of a movie or sprite.
Definition: movie_definition.h:95
Definition: klash_part.cpp:329
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:168
A Font resource.
Definition: Font.h:90
SWFMovieLoader(SWFMovieDefinition &md)
Definition: SWFMovieDefinition.cpp:73
image::JpegInput * get_jpeg_loader() const
Get the jpeg input loader, to load a DefineBits image (one without table info).
Definition: SWFMovieDefinition.h:300
size_t get_frame_count() const
Return total number of frames advertised for the SWFMovie.
Definition: SWFMovieDefinition.h:177
virtual int get_version() const
Return the advertised version for the SWFMovie.
Definition: SWFMovieDefinition.h:213
Font * get_font(const std::string &name, bool bold, bool italic)
Definition: fontlib.cpp:50
CharacterConstIterator begin() const
Return a const_iterator to the first dictionary element.
Definition: SWFMovieDefinition.h:141
double twipsToPixels(int i)
Definition: GnashNumeric.h:96
A top-level, standalone Movie that can be loaded and played.
Definition: Movie.h:46
SimpleBuffer data
Definition: LocalConnection_as.cpp:153
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
Immutable data representing the definition of a movie display element.
Definition: DefinitionTag.h:48
Helper class handling start and execution of a loading thread.
Definition: SWFMovieDefinition.h:66
Definition: GnashKey.h:149
Definition: GnashKey.h:152
Definition: GnashKey.h:161
Immutable definition of a SWF movie's contents.
Definition: SWFMovieDefinition.h:164
The Characters dictionary associated with each SWF file.
Definition: SWFMovieDefinition.h:110
bool isAS3() const
Check whether tags should be executed using AVM2.
Definition: SWFMovieDefinition.h:205
CharacterContainer::const_iterator CharacterConstIterator
Definition: SWFMovieDefinition.h:123
const URL _url
Definition: NetConnection_as.cpp:258
CharacterIterator end()
Return an iterator to one-past last dictionary element.
Definition: SWFMovieDefinition.h:144
boost::intrusive_ptr< SWF::DefinitionTag > getDisplayObject(int id) const
Get the Character with the given id.
Definition: SWFMovieDefinition.cpp:425
~SWFMovieLoader()
Definition: SWFMovieDefinition.cpp:81
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:43
DSOTEXPORT void addDisplayObject(int id, boost::intrusive_ptr< SWF::DefinitionTag > c)
Add a Character assigning it the given id.
Definition: SWFMovieDefinition.cpp:440
virtual const std::string & get_url() const
Return the URL of the SWF stream this definition has been read from.
Definition: SWFMovieDefinition.h:365
std::vector< boost::intrusive_ptr< SWF::ControlTag > > PlayList
Definition: movie_definition.h:98
CharacterContainer::iterator CharacterIterator
Definition: SWFMovieDefinition.h:121
virtual void set_loading_sound_stream_id(int id)
Set the currently being loaded sound stream.
Definition: SWFMovieDefinition.h:273
bool start()
Start loading thread.
Definition: SWFMovieDefinition.cpp:126
void add_font(Font *f)
Definition: fontlib.cpp:68
void addControlTag(boost::intrusive_ptr< SWF::ControlTag > tag)
Add an ControlTag to this movie_definition's playlist.
Definition: SWFMovieDefinition.h:283
The Global object ultimately contains all objects in an ActionScript run.
Definition: Global_as.h:55
CharacterIterator begin()
Return an iterator to the first dictionary element.
Definition: SWFMovieDefinition.h:138
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:44
virtual const PlayList * getPlaylist(size_t frame_number) const
Return the list of execute tags for given frame number.
Definition: SWFMovieDefinition.h:304
std::string url
Definition: gnash.cpp:59
#define DSOTEXPORT
Definition: dsodefs.h:63
const SWFRect & get_frame_size() const
Return dimensions of the SWFMovie.
Definition: SWFMovieDefinition.h:187
size_t get_width_pixels() const
Frame width in pixels.
Definition: SWFMovieDefinition.h:191
size_t get_bytes_total() const
Get total number of bytes as parsed from the SWF header.
Definition: SWFMovieDefinition.h:236
virtual DisplayObject * createDisplayObject(Global_as &, DisplayObject *) const
Create a DisplayObject with the given parent.
Definition: SWFMovieDefinition.h:360
float get_frame_rate() const
Return frame rate advertised for the SWFMovie.
Definition: SWFMovieDefinition.h:182
An identifier for a sound sample managed by a sound_handler.
Definition: sound_definition.h:61
A CachedBitmap is created by the renderer in a format of its choosing.
Definition: CachedBitmap.h:37
std::string name
Definition: LocalConnection_as.cpp:151
friend std::ostream & operator<<(std::ostream &o, const CharacterDictionary &cd)
Definition: SWFMovieDefinition.cpp:410