Gnash  0.8.11dev
movie_definition.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
46 
47 
48 #ifndef GNASH_MOVIE_DEFINITION_H
49 #define GNASH_MOVIE_DEFINITION_H
50 
51 #ifdef HAVE_CONFIG_H
52 #include "gnashconfig.h" // for USE_SWFTREE
53 #endif
54 
55 #include <string>
56 #include <memory> // for unique_ptr
57 #include <vector> // for PlayList typedef
58 #include <boost/intrusive_ptr.hpp>
59 #include <cstdint>
60 
61 #include "DefinitionTag.h"
62 #include "log.h"
63 
64 // Forward declarations
65 namespace gnash {
66  class CachedBitmap;
67  class Movie;
68  class MovieClip;
69  namespace SWF {
70  class ControlTag;
71  }
72  class Font;
73  class sound_sample;
74  namespace image {
75  class JpegInput;
76  }
77 }
78 
79 namespace gnash
80 {
81 
83 //
96 {
97 public:
98  typedef std::vector<boost::intrusive_ptr<SWF::ControlTag> > PlayList;
99 
100  virtual int get_version() const = 0;
101 
103  //
105  virtual size_t get_width_pixels() const = 0;
106 
108  //
110  virtual size_t get_height_pixels() const = 0;
111 
112  virtual size_t get_frame_count() const = 0;
113  virtual float get_frame_rate() const = 0;
114 
116  virtual const SWFRect& get_frame_size() const = 0;
117 
118  virtual size_t get_bytes_loaded() const = 0;
119 
121  //
127  virtual size_t get_bytes_total() const = 0;
128 
130  //
143  virtual Movie* createMovie(Global_as& /*gl*/, DisplayObject* /*parent*/=nullptr)
144  {
145  return nullptr;
146  }
147 
148  virtual void incrementLoadedFrames() {}
149 
151  //
159  virtual const PlayList* getPlaylist(size_t /*frame_number*/) const
160  {
161  return nullptr;
162  }
163 
164 
165  typedef std::pair<int, std::string> ImportSpec;
166  typedef std::vector< ImportSpec > Imports;
167 
169  //
176  virtual void importResources(
177  boost::intrusive_ptr<movie_definition> /*source*/,
178  const Imports& /*imports*/)
179  {
181  log_swferror(_("IMPORT tag appears outside SWF definition"));
182  );
183  }
184 
185 
188  //
196  virtual DefinitionTag* getDefinitionTag(std::uint16_t /*id*/) const
197  {
198  return nullptr;
199  }
200 
202  //
216  virtual bool get_labeled_frame(const std::string& /*label*/,
217  size_t& /*frame_number*/) const
218  {
219  return false;
220  }
221 
223  virtual size_t get_loading_frame() const = 0;
224 
226  //
230  //
233  virtual void addDisplayObject(std::uint16_t /*id*/, DefinitionTag* /*c*/)
234  {
235  }
236 
238  //
242  virtual void add_font(int /*id*/, boost::intrusive_ptr<Font> /*ch*/)
243  {
244  }
245 
247  //
253  virtual Font* get_font(int /*id*/) const
254  {
255  return nullptr;
256  }
257 
259  virtual Font* get_font(const std::string& /*name*/,
260  bool /*bold*/, bool /*italic*/) const
261  {
262  return nullptr;
263  }
264 
266  //
273  virtual void addControlTag(boost::intrusive_ptr<SWF::ControlTag> /*c*/)
274  {
275  }
276 
278  //
285  virtual void add_frame_name(const std::string& /*name*/)
286  {
287  }
288 
296  virtual void set_jpeg_loader(std::unique_ptr<image::JpegInput> /*j_in*/)
297  {
298  }
299 
312  {
313  return nullptr;
314  }
315 
318  //
329  virtual CachedBitmap* getBitmap(int /*DisplayObject_id*/) const
330  {
331  return nullptr;
332  }
333 
337  //
340  virtual void addBitmap(int /*id*/, boost::intrusive_ptr<CachedBitmap> /*im*/)
341  {
342  }
343 
345  //
351  virtual sound_sample* get_sound_sample(int /*DisplayObject_id*/) const
352  {
353  return nullptr;
354  }
355 
359  //
362  virtual void add_sound_sample(int /*DisplayObject_id*/, sound_sample* /*sam*/)
363  {
364  }
365 
367  //
370  virtual void set_loading_sound_stream_id(int /*id*/)
371  {
372  }
373 
375  //
382  virtual int get_loading_sound_stream_id() const
383  {
384  return -1;
385  }
386 
388  //
390  virtual void registerExport(const std::string&, std::uint16_t) {}
391 
393  //
396  virtual std::uint16_t exportID(const std::string& /*symbol*/) const {
397  return 0;
398  }
399 
401  //
403  virtual void setAS3() {
404  }
405 
407  //
410  virtual bool isAS3() const {
411  return false;
412  }
413 
417  virtual const std::string& get_url() const = 0;
418 
419  // Start the loader thread. By default no loader thread is engaged
420  // so this function is a no-op.
421  virtual bool completeLoad() {
422  return true;
423  }
424 
428  //
437  virtual bool ensure_frame_loaded(size_t /*framenum*/) const {
438  return true;
439  }
440 
441 #ifdef USE_SWFTREE
442 
443  // These methods attach the contents of the METADATA tag
444  // to a movie_definition. They are not used by the player
445  // at all, but are stored for display in Movie Properties.
446  // To save memory and parsing time, this won't happen
447  // when the swf tree view is disabled.
448  virtual void storeDescriptiveMetadata(const std::string& /*data*/)
449  {
450  }
451 
452  virtual const std::string& getDescriptiveMetadata() const
453  {
454  static const std::string s;
455  return s;
456  }
457 
458 #endif
459 protected:
460 
461  movie_definition(std::uint16_t id = 0)
462  :
463  DefinitionTag(id)
464  {}
465 
466  virtual ~movie_definition() {}
467 };
468 
469 } // namespace gnash
470 
471 #endif // GNASH_MOVIE_DEFINITION_H
virtual Font * get_font(int) const
Return the font with given DisplayObject id.
Definition: movie_definition.h:253
virtual void registerExport(const std::string &, std::uint16_t)
Register a symbol to refer to a character id.
Definition: movie_definition.h:390
virtual CachedBitmap * getBitmap(int) const
Get a bitmap from the bitmap dictionary.
Definition: movie_definition.h:329
virtual void addBitmap(int, boost::intrusive_ptr< CachedBitmap >)
Add a bitmap DisplayObject in the dictionary, with the specified DisplayObject id.
Definition: movie_definition.h:340
Client program&#39;s interface to the definition of a movie or sprite.
Definition: movie_definition.h:95
std::vector< ImportSpec > Imports
Definition: movie_definition.h:166
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:168
A Font resource.
Definition: Font.h:89
movie_definition(std::uint16_t id=0)
Definition: movie_definition.h:461
virtual void set_loading_sound_stream_id(int)
Set the currently being loaded sound stream.
Definition: movie_definition.h:370
virtual void incrementLoadedFrames()
Definition: movie_definition.h:148
virtual void add_sound_sample(int, sound_sample *)
Add a sound sample DisplayObject in the dictionary, with the specified DisplayObject id...
Definition: movie_definition.h:362
A top-level, standalone Movie that can be loaded and played.
Definition: Movie.h:46
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:47
virtual bool completeLoad()
Definition: movie_definition.h:421
virtual const PlayList * getPlaylist(size_t) const
Return the list of execute tags for given frame number.
Definition: movie_definition.h:159
#define IF_VERBOSE_MALFORMED_SWF(x)
Definition: log.h:404
std::pair< int, std::string > ImportSpec
Definition: movie_definition.h:165
virtual void add_font(int, boost::intrusive_ptr< Font >)
Add a font DisplayObject with given ID to the CharacterDictionary.
Definition: movie_definition.h:242
virtual void addDisplayObject(std::uint16_t, DefinitionTag *)
Add a DefinitionTag with given ID to the CharactersDictionary.
Definition: movie_definition.h:233
virtual std::uint16_t exportID(const std::string &) const
Get the id that corresponds to a symbol.
Definition: movie_definition.h:396
virtual DefinitionTag * getDefinitionTag(std::uint16_t) const
Get a DisplayObject from the dictionary.
Definition: movie_definition.h:196
#define _(String)
Definition: log.h:44
virtual bool get_labeled_frame(const std::string &, size_t &) const
Get 0-based index of the frame with given label.
Definition: movie_definition.h:216
std::vector< boost::intrusive_ptr< SWF::ControlTag > > PlayList
Definition: movie_definition.h:98
virtual void setAS3()
Set whether the SWFMovie should use AVM2 or AVM1.
Definition: movie_definition.h:403
void log_swferror(StringType msg, Args... args)
Definition: log.h:325
virtual bool ensure_frame_loaded(size_t) const
Ensure that frame number &#39;framenum&#39; (1-based offset) has been loaded (load on demand).
Definition: movie_definition.h:437
virtual bool isAS3() const
True if the SWFMovie should use AVM2.
Definition: movie_definition.h:410
virtual void importResources(boost::intrusive_ptr< movie_definition >, const Imports &)
Import resources.
Definition: movie_definition.h:176
The Global object ultimately contains all objects in an ActionScript run.
Definition: Global_as.h:49
Class for reading JPEG image data.
Definition: GnashImageJpeg.h:49
virtual ~movie_definition()
Definition: movie_definition.h:466
virtual Font * get_font(const std::string &, bool, bool) const
Find a font from the movie (not shared) lib.
Definition: movie_definition.h:259
virtual image::JpegInput * get_jpeg_loader() const
Get the jpeg input loader, to load a DefineBits image (one without table info).
Definition: movie_definition.h:311
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:44
virtual void add_frame_name(const std::string &)
Labels the frame currently being loaded with the given name.
Definition: movie_definition.h:285
virtual void set_jpeg_loader(std::unique_ptr< image::JpegInput >)
Definition: movie_definition.h:296
Definition: GnashKey.h:165
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
virtual Movie * createMovie(Global_as &, DisplayObject *=nullptr)
Create a movie instance from a def.
Definition: movie_definition.h:143
virtual void addControlTag(boost::intrusive_ptr< SWF::ControlTag >)
Add an ControlTag to this movie_definition&#39;s playlist.
Definition: movie_definition.h:273
Definition: GnashKey.h:331
virtual sound_sample * get_sound_sample(int) const
Get the sound sample with given ID.
Definition: movie_definition.h:351
virtual int get_loading_sound_stream_id() const
Get the currently being loaded sound stream, if any.
Definition: movie_definition.h:382