Gnash 0.8.9

movie_definition.h

Go to the documentation of this file.
00001 //
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
00003 //   2011 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 <set>
00059 #include <boost/intrusive_ptr.hpp>
00060 #include <boost/cstdint.hpp>
00061 
00062 #include "DefinitionTag.h"
00063 #include "log.h"
00064 
00065 // Forward declarations
00066 namespace gnash {
00067         class CachedBitmap;
00068         class Movie;
00069         class MovieClip;
00070         namespace SWF {
00071         class ControlTag;
00072     }
00073     class Font;
00074     class sound_sample;
00075     namespace image {
00076         class JpegInput;
00077     }
00078 }
00079 
00080 namespace gnash
00081 {
00082 
00084 //
00096 class movie_definition : public SWF::DefinitionTag
00097 {
00098 public:
00099         typedef std::vector<boost::intrusive_ptr<SWF::ControlTag> > PlayList;
00100 
00101         virtual int     get_version() const = 0;
00102 
00104     //
00106         virtual size_t get_width_pixels() const = 0;
00107     
00109     //
00111         virtual size_t get_height_pixels() const = 0;
00112 
00113         virtual size_t get_frame_count() const = 0;
00114         virtual float get_frame_rate() const = 0;
00115 
00117         virtual const SWFRect& get_frame_size() const = 0;
00118 
00119         virtual size_t get_bytes_loaded() const = 0;
00120 
00122         //
00128         virtual size_t get_bytes_total() const = 0;
00129 
00131         //
00144         virtual Movie* createMovie(Global_as& /*gl*/, DisplayObject* /*parent*/=0)
00145         {
00146                 return NULL;
00147         }
00148 
00149     virtual void incrementLoadedFrames() {}
00150 
00152         //
00160         virtual const PlayList* getPlaylist(size_t /*frame_number*/) const
00161         {
00162                 return 0;
00163         }
00164 
00165 
00166         typedef std::pair<int, std::string> ImportSpec;
00167         typedef std::vector< ImportSpec > Imports;
00168 
00170         //
00177         virtual void importResources(
00178             boost::intrusive_ptr<movie_definition> /*source*/, 
00179             const Imports& /*imports*/)
00180         {
00181                 IF_VERBOSE_MALFORMED_SWF(
00182             log_swferror(_("IMPORT tag appears outside SWF definition"));
00183                 );
00184         }
00185 
00186 
00189         //
00197         virtual DefinitionTag* getDefinitionTag(boost::uint16_t /*id*/) const
00198         {
00199                 return NULL;
00200         }
00201 
00203         //
00217         virtual bool get_labeled_frame(const std::string& /*label*/,
00218             size_t& /*frame_number*/) const
00219         {
00220                 return false;
00221         }
00222 
00224         virtual size_t  get_loading_frame() const = 0;
00225 
00227         //
00231     //
00234         virtual void addDisplayObject(boost::uint16_t /*id*/, DefinitionTag* /*c*/)
00235         {
00236         }
00237 
00239         //
00243         virtual void add_font(int /*id*/, boost::intrusive_ptr<Font> /*ch*/)
00244         {
00245         }
00246 
00248         //
00254         virtual Font* get_font(int /*id*/) const
00255         {
00256                 return NULL;
00257         }
00258 
00260         virtual Font* get_font(const std::string& /*name*/,
00261             bool /*bold*/, bool /*italic*/) const
00262         {
00263                 return 0;
00264         }
00265 
00267         //
00274         virtual void addControlTag(boost::intrusive_ptr<SWF::ControlTag> /*c*/)
00275         {
00276         }
00277 
00279         //
00286         virtual void add_frame_name(const std::string& /*name*/)
00287         {
00288         }
00289 
00297         virtual void set_jpeg_loader(std::auto_ptr<image::JpegInput> /*j_in*/)
00298         {
00299         }
00300 
00312         virtual image::JpegInput* get_jpeg_loader() const
00313         {
00314                 return NULL;
00315         }
00316 
00319         //
00330         virtual CachedBitmap* getBitmap(int /*DisplayObject_id*/) const
00331         {
00332                 return 0;
00333         }
00334 
00338         //
00341         virtual void addBitmap(int /*id*/, boost::intrusive_ptr<CachedBitmap> /*im*/)
00342         {
00343         }
00344 
00346         //
00352         virtual sound_sample* get_sound_sample(int /*DisplayObject_id*/) const
00353         {
00354                 return NULL;
00355         }
00356 
00360         //
00363         virtual void add_sound_sample(int /*DisplayObject_id*/, sound_sample* /*sam*/)
00364         {
00365         }
00366 
00368         //
00371         virtual void set_loading_sound_stream_id(int /*id*/)
00372         {
00373         }
00374 
00376         //
00383         virtual int get_loading_sound_stream_id() const
00384         {
00385                 return -1;
00386         }
00387 
00389     //
00391     virtual void registerExport(const std::string&, boost::uint16_t) {}
00392     
00394     //
00397     virtual boost::uint16_t exportID(const std::string& /*symbol*/) const {
00398         return 0;
00399     }
00400 
00402     //
00404     virtual void setAS3() {
00405     }
00406 
00408     //
00411     virtual bool isAS3() const {
00412         return false;
00413     }
00414 
00418         virtual const std::string& get_url() const = 0;
00419 
00420         // Start the loader thread. By default no loader thread is engaged
00421         // so this function is a no-op.
00422         virtual bool completeLoad() {
00423                 return true;
00424         }
00425 
00429         //
00438         virtual bool ensure_frame_loaded(size_t /*framenum*/) const {
00439                 return true;
00440         }
00441 
00442 #ifdef USE_SWFTREE
00443 
00444         // These methods attach the contents of the METADATA tag
00445         // to a movie_definition. They are not used by the player
00446         // at all, but are stored for display in Movie Properties.
00447         // To save memory and parsing time, this won't happen
00448         // when the swf tree view is disabled.
00449         virtual void storeDescriptiveMetadata(const std::string& /*data*/)
00450         {
00451         }
00452 
00453         virtual const std::string& getDescriptiveMetadata() const
00454         {
00455             static const std::string s;
00456             return s;
00457         }
00458 
00459 #endif
00460 protected:
00461 
00462     movie_definition(boost::uint16_t id = 0)
00463         :
00464         DefinitionTag(id)
00465     {}
00466 
00467     virtual ~movie_definition() {}
00468 };
00469 
00470 } // namespace gnash
00471 
00472 #endif // GNASH_MOVIE_DEFINITION_H