Gnash  0.8.10
movie_definition.h
Go to the documentation of this file.
00001 //
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00003 //   Free Software Foundation, Inc
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00046 
00047 
00048 #ifndef GNASH_MOVIE_DEFINITION_H
00049 #define GNASH_MOVIE_DEFINITION_H
00050 
00051 #ifdef HAVE_CONFIG_H
00052 #include "gnashconfig.h" // for USE_SWFTREE
00053 #endif
00054 
00055 #include <string>
00056 #include <memory> // for auto_ptr
00057 #include <vector> // for PlayList typedef
00058 #include <boost/intrusive_ptr.hpp>
00059 #include <boost/cstdint.hpp>
00060 
00061 #include "DefinitionTag.h"
00062 #include "log.h"
00063 
00064 // Forward declarations
00065 namespace gnash {
00066         class CachedBitmap;
00067         class Movie;
00068         class MovieClip;
00069         namespace SWF {
00070         class ControlTag;
00071     }
00072     class Font;
00073     class sound_sample;
00074     namespace image {
00075         class JpegInput;
00076     }
00077 }
00078 
00079 namespace gnash
00080 {
00081 
00083 //
00095 class movie_definition : public SWF::DefinitionTag
00096 {
00097 public:
00098         typedef std::vector<boost::intrusive_ptr<SWF::ControlTag> > PlayList;
00099 
00100         virtual int     get_version() const = 0;
00101 
00103     //
00105         virtual size_t get_width_pixels() const = 0;
00106     
00108     //
00110         virtual size_t get_height_pixels() const = 0;
00111 
00112         virtual size_t get_frame_count() const = 0;
00113         virtual float get_frame_rate() const = 0;
00114 
00116         virtual const SWFRect& get_frame_size() const = 0;
00117 
00118         virtual size_t get_bytes_loaded() const = 0;
00119 
00121         //
00127         virtual size_t get_bytes_total() const = 0;
00128 
00130         //
00143         virtual Movie* createMovie(Global_as& /*gl*/, DisplayObject* /*parent*/=0)
00144         {
00145                 return NULL;
00146         }
00147 
00148     virtual void incrementLoadedFrames() {}
00149 
00151         //
00159         virtual const PlayList* getPlaylist(size_t /*frame_number*/) const
00160         {
00161                 return 0;
00162         }
00163 
00164 
00165         typedef std::pair<int, std::string> ImportSpec;
00166         typedef std::vector< ImportSpec > Imports;
00167 
00169         //
00176         virtual void importResources(
00177             boost::intrusive_ptr<movie_definition> /*source*/, 
00178             const Imports& /*imports*/)
00179         {
00180                 IF_VERBOSE_MALFORMED_SWF(
00181             log_swferror(_("IMPORT tag appears outside SWF definition"));
00182                 );
00183         }
00184 
00185 
00188         //
00196         virtual DefinitionTag* getDefinitionTag(boost::uint16_t /*id*/) const
00197         {
00198                 return NULL;
00199         }
00200 
00202         //
00216         virtual bool get_labeled_frame(const std::string& /*label*/,
00217             size_t& /*frame_number*/) const
00218         {
00219                 return false;
00220         }
00221 
00223         virtual size_t  get_loading_frame() const = 0;
00224 
00226         //
00230     //
00233         virtual void addDisplayObject(boost::uint16_t /*id*/, DefinitionTag* /*c*/)
00234         {
00235         }
00236 
00238         //
00242         virtual void add_font(int /*id*/, boost::intrusive_ptr<Font> /*ch*/)
00243         {
00244         }
00245 
00247         //
00253         virtual Font* get_font(int /*id*/) const
00254         {
00255                 return NULL;
00256         }
00257 
00259         virtual Font* get_font(const std::string& /*name*/,
00260             bool /*bold*/, bool /*italic*/) const
00261         {
00262                 return 0;
00263         }
00264 
00266         //
00273         virtual void addControlTag(boost::intrusive_ptr<SWF::ControlTag> /*c*/)
00274         {
00275         }
00276 
00278         //
00285         virtual void add_frame_name(const std::string& /*name*/)
00286         {
00287         }
00288 
00296         virtual void set_jpeg_loader(std::auto_ptr<image::JpegInput> /*j_in*/)
00297         {
00298         }
00299 
00311         virtual image::JpegInput* get_jpeg_loader() const
00312         {
00313                 return NULL;
00314         }
00315 
00318         //
00329         virtual CachedBitmap* getBitmap(int /*DisplayObject_id*/) const
00330         {
00331                 return 0;
00332         }
00333 
00337         //
00340         virtual void addBitmap(int /*id*/, boost::intrusive_ptr<CachedBitmap> /*im*/)
00341         {
00342         }
00343 
00345         //
00351         virtual sound_sample* get_sound_sample(int /*DisplayObject_id*/) const
00352         {
00353                 return NULL;
00354         }
00355 
00359         //
00362         virtual void add_sound_sample(int /*DisplayObject_id*/, sound_sample* /*sam*/)
00363         {
00364         }
00365 
00367         //
00370         virtual void set_loading_sound_stream_id(int /*id*/)
00371         {
00372         }
00373 
00375         //
00382         virtual int get_loading_sound_stream_id() const
00383         {
00384                 return -1;
00385         }
00386 
00388     //
00390     virtual void registerExport(const std::string&, boost::uint16_t) {}
00391     
00393     //
00396     virtual boost::uint16_t exportID(const std::string& /*symbol*/) const {
00397         return 0;
00398     }
00399 
00401     //
00403     virtual void setAS3() {
00404     }
00405 
00407     //
00410     virtual bool isAS3() const {
00411         return false;
00412     }
00413 
00417         virtual const std::string& get_url() const = 0;
00418 
00419         // Start the loader thread. By default no loader thread is engaged
00420         // so this function is a no-op.
00421         virtual bool completeLoad() {
00422                 return true;
00423         }
00424 
00428         //
00437         virtual bool ensure_frame_loaded(size_t /*framenum*/) const {
00438                 return true;
00439         }
00440 
00441 #ifdef USE_SWFTREE
00442 
00443         // These methods attach the contents of the METADATA tag
00444         // to a movie_definition. They are not used by the player
00445         // at all, but are stored for display in Movie Properties.
00446         // To save memory and parsing time, this won't happen
00447         // when the swf tree view is disabled.
00448         virtual void storeDescriptiveMetadata(const std::string& /*data*/)
00449         {
00450         }
00451 
00452         virtual const std::string& getDescriptiveMetadata() const
00453         {
00454             static const std::string s;
00455             return s;
00456         }
00457 
00458 #endif
00459 protected:
00460 
00461     movie_definition(boost::uint16_t id = 0)
00462         :
00463         DefinitionTag(id)
00464     {}
00465 
00466     virtual ~movie_definition() {}
00467 };
00468 
00469 } // namespace gnash
00470 
00471 #endif // GNASH_MOVIE_DEFINITION_H