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 auto_ptr
57 #include <vector> // for PlayList typedef
58 #include <boost/intrusive_ptr.hpp>
59 #include <boost/cstdint.hpp>
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*/=0)
144  {
145  return NULL;
146  }
147 
148  virtual void incrementLoadedFrames() {}
149 
151  //
159  virtual const PlayList* getPlaylist(size_t /*frame_number*/) const
160  {
161  return 0;
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(boost::uint16_t /*id*/) const
197  {
198  return NULL;
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(boost::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 NULL;
256  }
257 
259  virtual Font* get_font(const std::string& /*name*/,
260  bool /*bold*/, bool /*italic*/) const
261  {
262  return 0;
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::auto_ptr<image::JpegInput> /*j_in*/)
297  {
298  }
299 
312  {
313  return NULL;
314  }
315 
318  //
329  virtual CachedBitmap* getBitmap(int /*DisplayObject_id*/) const
330  {
331  return 0;
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 NULL;
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&, boost::uint16_t) {}
391 
393  //
396  virtual boost::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(boost::uint16_t id = 0)
462  :
464  {}
465 
466  virtual ~movie_definition() {}
467 };
468 
469 } // namespace gnash
470 
471 #endif // GNASH_MOVIE_DEFINITION_H