gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/parser/movie_def_impl.cp...


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog server/parser/movie_def_impl.cp...
Date: Wed, 04 Jun 2008 13:57:56 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/06/04 13:57:56

Modified files:
        .              : ChangeLog 
        server/parser  : movie_def_impl.cpp movie_def_impl.h 
                         movie_definition.h 
        server/swf     : tag_loaders.cpp 
        server         : impl.cpp 

Log message:
                * server/parser/movie_def_impl.{cpp,h}: rename movie_def_impl 
class to
                  SWFMovieDefinition. Add {store,get}DescriptiveMetadata() for 
dealing
                  with the METADATA tag, disabled if Movie Properties isn't 
used.
                  (--disable-swftree). Rearrange class so public methods are 
first, like
                  in almost all other classes. 
                * server/parser/movie_definition.h: add virtual
                  {store,get}DescriptiveMetadata() with no-op as default
                  implementation. (Not used for sprite_instance).
                * server/swf/tag_loaders.cpp: copy metadata to 
SWFMovieDefinition, add
                  comments.
                * server/impl.cpp: renamed movie_def_impl.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6806&r2=1.6807
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.cpp?cvsroot=gnash&r1=1.116&r2=1.117
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.h?cvsroot=gnash&r1=1.79&r2=1.80
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_definition.h?cvsroot=gnash&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.204&r2=1.205
http://cvs.savannah.gnu.org/viewcvs/gnash/server/impl.cpp?cvsroot=gnash&r1=1.150&r2=1.151

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6806
retrieving revision 1.6807
diff -u -b -r1.6806 -r1.6807
--- ChangeLog   4 Jun 2008 13:53:58 -0000       1.6806
+++ ChangeLog   4 Jun 2008 13:57:54 -0000       1.6807
@@ -1,5 +1,19 @@
 2008-06-04 Benjamin Wolsey <address@hidden>
 
+       * server/parser/movie_def_impl.{cpp,h}: rename movie_def_impl class to
+         SWFMovieDefinition. Add {store,get}DescriptiveMetadata() for dealing
+         with the METADATA tag, disabled if Movie Properties isn't used.
+         (--disable-swftree). Rearrange class so public methods are first, like
+         in almost all other classes. 
+       * server/parser/movie_definition.h: add virtual
+         {store,get}DescriptiveMetadata() with no-op as default
+         implementation. (Not used for sprite_instance).
+       * server/swf/tag_loaders.cpp: copy metadata to SWFMovieDefinition, add
+         comments.
+       * server/impl.cpp: renamed movie_def_impl.
+
+2008-06-04 Benjamin Wolsey <address@hidden>
+
        * server/actionscript.all/Microphone.as: a couple of tests.
        * server/fontlib.h: clean up forward declarations.
        * server/parser/character_def.h: header cleanups.

Index: server/parser/movie_def_impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.cpp,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -b -r1.116 -r1.117
--- server/parser/movie_def_impl.cpp    3 Jun 2008 18:02:42 -0000       1.116
+++ server/parser/movie_def_impl.cpp    4 Jun 2008 13:57:54 -0000       1.117
@@ -1,4 +1,4 @@
-// movie_def_impl.cpp:  Load in Movie definitions, for Gnash.
+// movie_def_impl.cpp: load a SWF definition
 //
 //   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 //
@@ -18,7 +18,7 @@
 //
 
 #ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
+#include "gnashconfig.h" // USE_SWFTREE
 #endif
 
 #include "smart_ptr.h" // GNASH_USE_GC
@@ -76,7 +76,7 @@
 namespace gnash
 {
 
-MovieLoader::MovieLoader(movie_def_impl& md)
+MovieLoader::MovieLoader(SWFMovieDefinition& md)
        :
        _movie_def(md),
        _thread(NULL),
@@ -124,7 +124,7 @@
 
 // static..
 void
-MovieLoader::execute(MovieLoader& ml, movie_def_impl* md)
+MovieLoader::execute(MovieLoader& ml, SWFMovieDefinition* md)
 {
        ml._barrier.wait(); // let _thread assignment happen before going on
        md->read_all_swf();
@@ -189,12 +189,15 @@
 
 
 //
-// movie_def_impl
+// SWFMovieDefinition
 //
 
-movie_def_impl::movie_def_impl()
+SWFMovieDefinition::SWFMovieDefinition()
        :
-       // FIXME: use a class-static TagLoadersTable for movie_def_impl
+       // FIXME: use a class-static TagLoadersTable for SWFMovieDefinition
+#ifdef USE_SWFTREE
+    _metadata(),
+#endif
        _tag_loaders(SWF::TagLoadersTable::getInstance()),
        m_frame_rate(30.0f),
        m_frame_count(0u),
@@ -209,7 +212,7 @@
 {
 }
 
-movie_def_impl::~movie_def_impl()
+SWFMovieDefinition::~SWFMovieDefinition()
 {
 
        // Request cancelation of the loading thread
@@ -231,7 +234,7 @@
        //assert(m_jpeg_in.get() == NULL);
 }
 
-void movie_def_impl::add_character(int character_id, character_def* c)
+void SWFMovieDefinition::add_character(int character_id, character_def* c)
 {
        assert(c);
        boost::mutex::scoped_lock lock(_dictionaryMutex);
@@ -239,7 +242,7 @@
 }
 
 character_def*
-movie_def_impl::get_character_def(int character_id)
+SWFMovieDefinition::get_character_def(int character_id)
 {
 
        boost::mutex::scoped_lock lock(_dictionaryMutex);
@@ -251,13 +254,13 @@
        return ch.get(); // mm... why don't we return the boost::intrusive_ptr?
 }
 
-void movie_def_impl::add_font(int font_id, font* f)
+void SWFMovieDefinition::add_font(int font_id, font* f)
 {
     assert(f);
     m_fonts.insert(std::make_pair(font_id, boost::intrusive_ptr<font>(f)));
 }
 
-font* movie_def_impl::get_font(int font_id) const
+font* SWFMovieDefinition::get_font(int font_id) const
 {
 
     FontMap::const_iterator it = m_fonts.find(font_id);
@@ -267,7 +270,7 @@
     return f.get();
 }
 
-bitmap_character_def* movie_def_impl::get_bitmap_character_def(int 
character_id)
+bitmap_character_def* SWFMovieDefinition::get_bitmap_character_def(int 
character_id)
 {
     BitmapMap::iterator it = m_bitmap_characters.find(character_id);
     if ( it == m_bitmap_characters.end() ) return NULL;
@@ -275,7 +278,7 @@
 }
 
 void
-movie_def_impl::add_bitmap_character_def(int character_id,
+SWFMovieDefinition::add_bitmap_character_def(int character_id,
                bitmap_character_def* ch)
 {
     assert(ch);
@@ -288,7 +291,7 @@
     add_bitmap_info(ch->get_bitmap_info());
 }
 
-sound_sample* movie_def_impl::get_sound_sample(int character_id)
+sound_sample* SWFMovieDefinition::get_sound_sample(int character_id)
 {
     SoundSampleMap::iterator it = m_sound_samples.find(character_id);
     if ( it == m_sound_samples.end() ) return NULL;
@@ -301,7 +304,7 @@
     return ch.get();
 }
 
-void movie_def_impl::add_sound_sample(int character_id, sound_sample* sam)
+void SWFMovieDefinition::add_sound_sample(int character_id, sound_sample* sam)
 {
     assert(sam);
     IF_VERBOSE_PARSE(
@@ -314,7 +317,7 @@
 
 // Read header and assign url
 bool
-movie_def_impl::readHeader(std::auto_ptr<tu_file> in, const std::string& url)
+SWFMovieDefinition::readHeader(std::auto_ptr<tu_file> in, const std::string& 
url)
 {
 
        _in = in;
@@ -335,7 +338,7 @@
                && (header & 0x0FFFFFF) != 0x00535743)
         {
                // ERROR
-               log_error(_("gnash::movie_def_impl::read() -- "
+               log_error(_("gnash::SWFMovieDefinition::read() -- "
                        "file does not start with a SWF header"));
                return false;
         }
@@ -355,7 +358,7 @@
        if (compressed)
         {
 #ifndef HAVE_ZLIB_H
-               log_error(_("movie_def_impl::read(): unable to read "
+               log_error(_("SWFMovieDefinition::read(): unable to read "
                        "zipped SWF data; gnash was compiled without zlib 
support"));
                return false;
 #else
@@ -424,7 +427,7 @@
 
 // Fire up the loading thread
 bool
-movie_def_impl::completeLoad()
+SWFMovieDefinition::completeLoad()
 {
 
        // should call this only once
@@ -464,7 +467,7 @@
 
 // Read a .SWF movie.
 bool
-movie_def_impl::read(std::auto_ptr<tu_file> in, const std::string& url)
+SWFMovieDefinition::read(std::auto_ptr<tu_file> in, const std::string& url)
 {
 
        if ( ! readHeader(in, url) ) return false;
@@ -475,7 +478,7 @@
 
 // 1-based frame number
 bool
-movie_def_impl::ensure_frame_loaded(size_t framenum)
+SWFMovieDefinition::ensure_frame_loaded(size_t framenum)
 {
        boost::mutex::scoped_lock lock(_frames_loaded_mutex);
 
@@ -497,7 +500,7 @@
 }
 
 movie_instance*
-movie_def_impl::create_movie_instance(character* parent)
+SWFMovieDefinition::create_movie_instance(character* parent)
 {
        return new movie_instance(this, parent);
 }
@@ -546,7 +549,7 @@
 // Load next chunk of this sprite frames.
 // This is possibly better defined in movie_definition
 void
-movie_def_impl::load_next_frame_chunk()
+SWFMovieDefinition::load_next_frame_chunk()
 {
 
        size_t framecount = get_frame_count();
@@ -585,7 +588,7 @@
 }
 
 void
-movie_def_impl::read_all_swf()
+SWFMovieDefinition::read_all_swf()
 {
        assert(_str.get() != NULL);
 
@@ -714,14 +717,14 @@
 }
 
 size_t
-movie_def_impl::get_loading_frame() const
+SWFMovieDefinition::get_loading_frame() const
 {
        boost::mutex::scoped_lock lock(_frames_loaded_mutex);
        return _frames_loaded;
 }
 
 size_t
-movie_def_impl::incrementLoadedFrames()
+SWFMovieDefinition::incrementLoadedFrames()
 {
        boost::mutex::scoped_lock lock(_frames_loaded_mutex);
 
@@ -757,7 +760,7 @@
 }
 
 void
-movie_def_impl::export_resource(const std::string& symbol, resource* res)
+SWFMovieDefinition::export_resource(const std::string& symbol, resource* res)
 {
        // _exportedResources access should be protected by a mutex
        boost::mutex::scoped_lock lock(_exportedResourcesMutex);
@@ -768,7 +771,7 @@
 
 
 boost::intrusive_ptr<resource>
-movie_def_impl::get_exported_resource(const std::string& symbol)
+SWFMovieDefinition::get_exported_resource(const std::string& symbol)
 {
 #ifdef DEBUG_EXPORTS
        log_debug(_("get_exported_resource called, frame count=%u"), 
m_frame_count);
@@ -849,7 +852,7 @@
 }
 
 void
-movie_def_impl::add_frame_name(const std::string& n)
+SWFMovieDefinition::add_frame_name(const std::string& n)
 {
        boost::mutex::scoped_lock lock1(_namedFramesMutex);
        boost::mutex::scoped_lock lock2(_frames_loaded_mutex);
@@ -858,7 +861,7 @@
 }
 
 bool
-movie_def_impl::get_labeled_frame(const std::string& label, size_t& 
frame_number)
+SWFMovieDefinition::get_labeled_frame(const std::string& label, size_t& 
frame_number)
 {
     boost::mutex::scoped_lock lock(_namedFramesMutex);
     NamedFrameMap::const_iterator it = _namedFrames.find(label);
@@ -869,7 +872,7 @@
 
 #ifdef GNASH_USE_GC
 void
-movie_def_impl::markReachableResources() const
+SWFMovieDefinition::markReachableResources() const
 {
        for (FontMap::const_iterator i=m_fonts.begin(), e=m_fonts.end(); i!=e; 
++i)
        {
@@ -912,7 +915,7 @@
 #endif // GNASH_USE_GC
 
 void
-movie_def_impl::importResources(boost::intrusive_ptr<movie_definition> source, 
Imports& imports)
+SWFMovieDefinition::importResources(boost::intrusive_ptr<movie_definition> 
source, Imports& imports)
 {
        size_t importedSyms=0;
        for (Imports::iterator i=imports.begin(), e=imports.end(); i!=e; ++i)

Index: server/parser/movie_def_impl.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.h,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -b -r1.79 -r1.80
--- server/parser/movie_def_impl.h      3 Jun 2008 18:02:42 -0000       1.79
+++ server/parser/movie_def_impl.h      4 Jun 2008 13:57:54 -0000       1.80
@@ -15,8 +15,16 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-#ifndef GNASH_MOVIE_DEF_IMPL_H
-#define GNASH_MOVIE_DEF_IMPL_H
+// The SWFMovieDefinition is the 'root' definition of a SWF movie, including
+// movies loaded into another SWF file. Each self-contained SWF file has 
exactly
+// one SWFMovieDefinition.
+
+#ifndef GNASH_SWF_MOVIE_DEFINITION_H
+#define GNASH_SWF_MOVIE_DEFINITION_H
+
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h" // for USE_SWFTREE
+#endif
 
 #include "smart_ptr.h" // GNASH_USE_GC
 #include "fontlib.h"
@@ -41,7 +49,7 @@
 //
 // Forward declarations
 namespace gnash {
-       class movie_def_impl;
+       class SWFMovieDefinition;
        class movie_root;
        class sprite_instance;
        class movie_instance;
@@ -54,20 +62,20 @@
 {
 
 /// \brief
-/// movie_def_impl helper class handling start and execution of
+/// SWFMovieDefinition helper class handling start and execution of
 /// an SWF loading thread
 ///
 class MovieLoader
 {
 public:
 
-       MovieLoader(movie_def_impl& md);
+       MovieLoader(SWFMovieDefinition& md);
 
        ~MovieLoader();
 
        /// Start loading thread.
        //
-       /// The associated movie_def_impl instance
+       /// The associated SWFMovieDefinition instance
        /// is expected to have already read the SWF
        /// header and applied a zlib adapter if needed.
        ///
@@ -81,7 +89,7 @@
 
 private:
 
-       movie_def_impl& _movie_def;
+       SWFMovieDefinition& _movie_def;
 
        mutable boost::mutex _mutex;
        std::auto_ptr<boost::thread> _thread;
@@ -92,7 +100,7 @@
        boost::barrier _barrier;
 
        /// Entry point for the actual thread
-       static void execute(MovieLoader& ml, movie_def_impl* md);
+       static void execute(MovieLoader& ml, SWFMovieDefinition* md);
 };
 
 /// The Characters dictionary associated with each SWF file.
@@ -164,142 +172,13 @@
 /// current state; for that you need to call create_movie_instance()
 /// to get a movie instance 
 ///
-class movie_def_impl : public movie_definition
+class SWFMovieDefinition : public movie_definition
 {
-private:
-       /// Characters Dictionary
-       CharacterDictionary     _dictionary;
-
-       /// Mutex protecting _dictionary
-       mutable boost::mutex _dictionaryMutex;
-
-       /// Tags loader table
-       SWF::TagLoadersTable& _tag_loaders;
-
-       typedef std::map<int, boost::intrusive_ptr<font> > FontMap;
-       FontMap m_fonts;
-
-       typedef std::map<int, boost::intrusive_ptr<bitmap_character_def> > 
BitmapMap;
-       BitmapMap m_bitmap_characters;
-
-       typedef std::map<int, boost::intrusive_ptr<sound_sample> > 
SoundSampleMap;
-       SoundSampleMap m_sound_samples;
-
-       typedef std::map<size_t, PlayList> PlayListMap;
-
-       /// Movie control events for each frame.
-       PlayListMap m_playlist;
-
-       /// 0-based frame #'s
-       typedef std::map<std::string, size_t, StringNoCaseLessThen> 
NamedFrameMap;
-       NamedFrameMap _namedFrames;
-
-       // Mutex protecting access to _namedFrames
-       mutable boost::mutex _namedFramesMutex;
-
-       typedef std::map<std::string, boost::intrusive_ptr<resource>, 
StringNoCaseLessThen > ExportMap;
-       ExportMap _exportedResources;
-
-       // Mutex protecting access to _exportedResources
-       mutable boost::mutex _exportedResourcesMutex;
-
-       /// Movies we import from; hold a ref on these,
-       /// to keep them alive
-       typedef std::vector<boost::intrusive_ptr<movie_definition> > ImportVect;
-       ImportVect m_import_source_movies;
-
-       /// Bitmaps used in this movie; collected in one place to make
-       /// it possible for the host to manage them as textures.
-       typedef std::vector<boost::intrusive_ptr<bitmap_info> > BitmapVect;
-       BitmapVect m_bitmap_list;
-
-       rect    m_frame_size;
-       float   m_frame_rate;
-       size_t  m_frame_count;
-       int     m_version;
-
-       /// Number of fully loaded frames
-       size_t  _frames_loaded;
-
-       /// A mutex protecting access to _frames_loaded
-       //
-       /// This is needed because the loader thread will
-       /// increment this number, while the virtual machine
-       /// thread will read it.
-       ///
-       mutable boost::mutex _frames_loaded_mutex;
-
-       /// A semaphore to signal load of a specific frame
-       boost::condition _frame_reached_condition;
-
-       /// Set this to trigger signaling of loaded frame
-       //
-       /// Make sure you _frames_loaded_mutex is locked
-       /// when accessing this member !
-       ///
-       size_t _waiting_for_frame;
-
-       /// Number bytes loaded / parsed
-       unsigned long _bytes_loaded;
-
-       /// A mutex protecting access to _bytes_loaded
-       //
-       /// This is needed because the loader thread will
-       /// increment this number, while the virtual machine
-       /// thread will read it.
-       ///
-       mutable boost::mutex _bytes_loaded_mutex;
-
-
-
-       int     m_loading_sound_stream;
-       boost::uint32_t m_file_length;
-
-       std::auto_ptr<jpeg::input> m_jpeg_in;
-
-       std::string _url;
-
-       std::auto_ptr<stream> _str;
-
-       std::auto_ptr<tu_file> _in;
-
-       /// swf end position (as read from header)
-       unsigned int _swf_end_pos;
-
-       /// asyncronous SWF loader and parser
-       MovieLoader _loader;
-
-       /// \brief
-       /// Increment loaded frames count, signaling frame reached condition if
-       /// any thread is waiting for that. See ensure_frame_loaded().
-       ///
-       /// NOTE: this method locks _frames_loaded_mutex
-       ///
-       /// @return the new value of _frames_loaded
-       ///
-       size_t incrementLoadedFrames();
-
-       /// Set number of bytes loaded from input stream
-       //
-       /// NOTE: this method locks _bytes_loaded_mutex
-       ///
-       void setBytesLoaded(unsigned long bytes)
-       {
-               boost::mutex::scoped_lock lock(_bytes_loaded_mutex);
-               _bytes_loaded=bytes;
-       }
-
-       /// A flag set to true when load cancelation is requested
-       bool _loadingCanceled;
-
-       /// Movies we import resources from
-       std::set< boost::intrusive_ptr<movie_definition> > _importSources;
-
 public:
 
-       movie_def_impl();
+       SWFMovieDefinition();
 
-       ~movie_def_impl();
+       ~SWFMovieDefinition();
 
        // ...
        size_t get_frame_count() const { return m_frame_count; }
@@ -534,10 +413,162 @@
                return unused;
        }
 
+#ifdef USE_SWFTREE
+
+       // These methods attach the contents of the METADATA tag
+       // to a movie_definition.
+       virtual void storeDescriptiveMetadata(const std::string& data)
+       {
+           _metadata = data;
+       }
+
+       virtual const std::string& getDescriptiveMetadata() const
+       {
+           return _metadata;
+       }       
+
+#endif
+
+private:
+
+#ifdef USE_SWFTREE
+    // For storing descriptive metadata (information only)
+    std::string _metadata;
+#endif
+
+       /// Characters Dictionary
+       CharacterDictionary     _dictionary;
+
+       /// Mutex protecting _dictionary
+       mutable boost::mutex _dictionaryMutex;
+
+       /// Tags loader table
+       SWF::TagLoadersTable& _tag_loaders;
+
+       typedef std::map<int, boost::intrusive_ptr<font> > FontMap;
+       FontMap m_fonts;
+
+       typedef std::map<int, boost::intrusive_ptr<bitmap_character_def> > 
BitmapMap;
+       BitmapMap m_bitmap_characters;
+
+       typedef std::map<int, boost::intrusive_ptr<sound_sample> > 
SoundSampleMap;
+       SoundSampleMap m_sound_samples;
+
+       typedef std::map<size_t, PlayList> PlayListMap;
+
+       /// Movie control events for each frame.
+       PlayListMap m_playlist;
+
+       /// 0-based frame #'s
+       typedef std::map<std::string, size_t, StringNoCaseLessThen> 
NamedFrameMap;
+       NamedFrameMap _namedFrames;
+
+       // Mutex protecting access to _namedFrames
+       mutable boost::mutex _namedFramesMutex;
+
+       typedef std::map<std::string, boost::intrusive_ptr<resource>, 
StringNoCaseLessThen > ExportMap;
+       ExportMap _exportedResources;
+
+       // Mutex protecting access to _exportedResources
+       mutable boost::mutex _exportedResourcesMutex;
+
+       /// Movies we import from; hold a ref on these,
+       /// to keep them alive
+       typedef std::vector<boost::intrusive_ptr<movie_definition> > ImportVect;
+       ImportVect m_import_source_movies;
+
+       /// Bitmaps used in this movie; collected in one place to make
+       /// it possible for the host to manage them as textures.
+       typedef std::vector<boost::intrusive_ptr<bitmap_info> > BitmapVect;
+       BitmapVect m_bitmap_list;
+
+       rect    m_frame_size;
+       float   m_frame_rate;
+       size_t  m_frame_count;
+       int     m_version;
+
+       /// Number of fully loaded frames
+       size_t  _frames_loaded;
+
+       /// A mutex protecting access to _frames_loaded
+       //
+       /// This is needed because the loader thread will
+       /// increment this number, while the virtual machine
+       /// thread will read it.
+       ///
+       mutable boost::mutex _frames_loaded_mutex;
+
+       /// A semaphore to signal load of a specific frame
+       boost::condition _frame_reached_condition;
+
+       /// Set this to trigger signaling of loaded frame
+       //
+       /// Make sure you _frames_loaded_mutex is locked
+       /// when accessing this member !
+       ///
+       size_t _waiting_for_frame;
+
+       /// Number bytes loaded / parsed
+       unsigned long _bytes_loaded;
+
+       /// A mutex protecting access to _bytes_loaded
+       //
+       /// This is needed because the loader thread will
+       /// increment this number, while the virtual machine
+       /// thread will read it.
+       ///
+       mutable boost::mutex _bytes_loaded_mutex;
+
+
+
+       int     m_loading_sound_stream;
+       boost::uint32_t m_file_length;
+
+       std::auto_ptr<jpeg::input> m_jpeg_in;
+
+       std::string _url;
+
+       std::auto_ptr<stream> _str;
+
+       std::auto_ptr<tu_file> _in;
+
+       /// swf end position (as read from header)
+       unsigned int _swf_end_pos;
+
+       /// asyncronous SWF loader and parser
+       MovieLoader _loader;
+
+       /// \brief
+       /// Increment loaded frames count, signaling frame reached condition if
+       /// any thread is waiting for that. See ensure_frame_loaded().
+       ///
+       /// NOTE: this method locks _frames_loaded_mutex
+       ///
+       /// @return the new value of _frames_loaded
+       ///
+       size_t incrementLoadedFrames();
+
+       /// Set number of bytes loaded from input stream
+       //
+       /// NOTE: this method locks _bytes_loaded_mutex
+       ///
+       void setBytesLoaded(unsigned long bytes)
+       {
+               boost::mutex::scoped_lock lock(_bytes_loaded_mutex);
+               _bytes_loaded=bytes;
+       }
+
+       /// A flag set to true when load cancelation is requested
+       bool _loadingCanceled;
+
+       /// Movies we import resources from
+       std::set< boost::intrusive_ptr<movie_definition> > _importSources;
+
+
 protected:
 
 #ifdef GNASH_USE_GC
-       /// Mark reachable resources of a movie_def_impl
+       /// Mark reachable resources of a SWFMovieDefinition
        //
        /// Reachable resources are:
        ///     - fonts (m_fonts)

Index: server/parser/movie_definition.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_definition.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- server/parser/movie_definition.h    30 May 2008 20:23:51 -0000      1.47
+++ server/parser/movie_definition.h    4 Jun 2008 13:57:55 -0000       1.48
@@ -30,12 +30,12 @@
 /// thus it can manage gnash::as_value members.
 ///
 /// The implementation of SWF parsing for a Movie definition
-/// is found in gnash::movie_def_impl::read.
+/// is found in gnash::SWFMovieDefinition::read.
 ///
 /// Note that movie_definition is also used as a base class
 /// for gnash::sprite_definition, which is a sub-movie defined in an SWF
 /// file. This seems to be the only reason to have a
-/// movie_def_impl class, being the top-level definition of
+/// SWFMovieDefinition class, being the top-level definition of
 /// a movie (the one with a CharacterDictionary in it).
 ///
 /// Also note that gnash::movie_instance is a subclass of 
gnash::sprite_instance,
@@ -47,6 +47,10 @@
 #ifndef GNASH_MOVIE_DEFINITION_H
 #define GNASH_MOVIE_DEFINITION_H
 
+#ifdef HAVE_CONFIG_H
+#include "gnashconfig.h" // for USE_SWFTREE
+#endif
+
 #include "character_def.h" // for inheritance
 #include "fontlib.h"
 #include "jpeg.h"
@@ -79,7 +83,7 @@
 /// unneeded for top-level movies, because they don't need
 /// to be put in any CharacterDictionary... anyway the
 /// current design requires both sprite_definition (a sprite)
-/// and movie_def_impl (a top-level movie) to derive from
+/// and SWFMovieDefinition (a top-level movie) to derive from
 /// a common class to allow tag_loaders to take a pointer
 /// to the base class to act on (consider PLACEOBJECT tags...).
 ///
@@ -125,7 +129,7 @@
        ///
        /// Override this method for any definition that is
        /// able to be instanciated as a movie_instance.
-       /// movie_def_impl is one such example, future examples
+       /// SWFMovieDefinition is one such example, future examples
        /// should include jpeg_movie_def and similar..
        ///
        virtual movie_instance* create_movie_instance(character* /*parent*/=0)
@@ -223,8 +227,8 @@
        //
        /// Note that only top-level movies (those belonging to a single
        /// SWF stream) have a characters dictionary, thus our
-       /// movie_def_impl. The other derived class, sprite_definition
-       /// will seek for characters in it's base movie_def_impl.
+       /// SWFMovieDefinition. The other derived class, sprite_definition
+       /// will seek for characters in it's base SWFMovieDefinition.
        ///
        /// @return NULL if no character with the given ID is found
        ///         (this is the default)
@@ -298,7 +302,7 @@
        /// @param tag
        ///     The tag to add in the list of executable tags for
        ///     the frame currently being loaded. Ownership is transferred
-       ///     to the movie_def_impl.
+       ///     to the SWFMovieDefinition.
        ///
        /// TODO: take an auto_ptr.
        /// NOTE: the default implementation just let the ControlTag leak.
@@ -351,8 +355,8 @@
        //
        /// Note that only top-level movies (those belonging to a single
        /// SWF stream) have a characters dictionary, thus our
-       /// movie_def_impl. The other derived class, sprite_definition
-       /// will seek for characters in it's base movie_def_impl.
+       /// SWFMovieDefinition. The other derived class, sprite_definition
+       /// will seek for characters in it's base SWFMovieDefinition.
        ///
        /// @return NULL if no character with the given ID is found, or
        ///         if the corresponding character is not a bitmap.
@@ -485,6 +489,25 @@
        {
        }
     
+#ifdef USE_SWFTREE
+
+       // These methods attach the contents of the METADATA tag
+       // to a movie_definition. They are not used by the player
+       // at all, but are stored for display in Movie Properties.
+       // To save memory and parsing time, this won't happen
+       // when the swf tree view is disabled.
+       virtual void storeDescriptiveMetadata(const std::string& /*data*/)
+       {
+       }
+
+       virtual const std::string& getDescriptiveMetadata() const
+       {
+           static const std::string s("");
+           return s;
+       }       
+
+#endif
+
 };
 
 } // namespace gnash

Index: server/swf/tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.204
retrieving revision 1.205
diff -u -b -r1.204 -r1.205
--- server/swf/tag_loaders.cpp  4 Jun 2008 07:59:12 -0000       1.204
+++ server/swf/tag_loaders.cpp  4 Jun 2008 13:57:55 -0000       1.205
@@ -19,7 +19,7 @@
 
 
 #ifdef HAVE_CONFIG_H
-#include "gnashconfig.h" // HAVE_ZLIB_H
+#include "gnashconfig.h" // HAVE_ZLIB_H, USE_SWFTREE
 #endif
 
 #include "tu_file.h"
@@ -902,7 +902,7 @@
     // would be a malformed SWF, anyway to be compatible
     // we should still allow that. See bug #22468.
     IF_VERBOSE_MALFORMED_SWF(
-    if ( ! dynamic_cast<movie_def_impl*>(m) )
+    if ( ! dynamic_cast<SWFMovieDefinition*>(m) )
     {
            log_swferror(_("Nested DEFINESPRITE tags. Will add to top-level 
characters dictionary."));
     }
@@ -1002,7 +1002,7 @@
     // would be a malformed SWF, anyway to be compatible
     // we should still allow that. See bug #22468.
     IF_VERBOSE_MALFORMED_SWF(
-    if ( ! dynamic_cast<movie_def_impl*>(m) )
+    if ( ! dynamic_cast<SWFMovieDefinition*>(m) )
     {
        log_swferror(_("EXPORT tag inside DEFINESPRITE. Will export in 
top-level symbol table."));
     }
@@ -1306,7 +1306,7 @@
     // no character id for soundstreams... so we make one up...
     // This only works if there is only one stream in the movie...
     // The right way to do it is to make seperate structures for streams
-    // in movie_def_impl.
+    // in SWFMovieDefinition.
 
     // 1 byte for playback info, 1 for stream info, 2 for sample count
     in->ensureBytes(4);
@@ -1516,7 +1516,7 @@
 
 
 void
-metadata_loader(stream* in, tag_type tag, movie_definition* /*m*/)
+metadata_loader(stream* in, tag_type tag, movie_definition* m)
 {
     assert(tag == SWF::METADATA); // 77
 
@@ -1528,10 +1528,30 @@
        log_parse(_("  RDF metadata (information only): [[\n%s\n]]"), metadata);
     );
 
-    // TODO: add to Movie Properties?
     // The metadata tag exists exclusively for external
     // description of the SWF file and should be ignored
     // by the SWF player.
+    //
+    // Note: the presence of metadata should correspond to the
+    // file attributes flag hasMetadata; otherwise the SWF
+    // is malformed.
+    //
+    // This should be in RDF format, so should be easy to parse
+    // (knowing how well Adobe conform to XML standards...) if
+    // it's worth it.
+    // See http://www.w3.org/TR/rdf-syntax-grammar/
+    log_debug(_("Descriptive metadata from movie %s: %s"),
+                   m->get_url(), metadata);
+
+#ifdef USE_SWFTREE
+    // If the Movie Properties tree is disabled, the metadata
+    // is discarded to save parsing time and memory. There seems
+    // to be no limit on its length, although you'd have to be
+    // malicious or stupid to put really enormous amounts of
+    // descriptive metadata in a SWF. There can be one tag for each
+    // loaded SWF, however, so it could mount up. 
+    m->storeDescriptiveMetadata(metadata);
+#endif
 
 }
 

Index: server/impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/impl.cpp,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -b -r1.150 -r1.151
--- server/impl.cpp     3 Jun 2008 17:38:31 -0000       1.150
+++ server/impl.cpp     4 Jun 2008 13:57:55 -0000       1.151
@@ -366,15 +366,15 @@
   return "unknown";
 }
 
-// Create a movie_def_impl from an SWF stream
+// Create a SWFMovieDefinition from an SWF stream
 // NOTE: this method assumes this *is* an SWF stream
 //
-static movie_def_impl*
+static SWFMovieDefinition*
 create_swf_movie(std::auto_ptr<tu_file> in, const std::string& url, bool 
startLoaderThread)
 {
 
   // Avoid leaks on error 
-  std::auto_ptr<movie_def_impl> m ( new movie_def_impl() );
+  std::auto_ptr<SWFMovieDefinition> m ( new SWFMovieDefinition() );
 
   if ( ! m->readHeader(in, url) )
   {
@@ -510,7 +510,7 @@
 
 /// Library of SWF movies indexed by URL strings
 //
-/// Elements are actually movie_def_impl, the ones
+/// Elements are actually SWFMovieDefinition, the ones
 /// associated with URLS. Dunno why, but we were using
 /// movie_definition here before so this didn't change
 /// when the new class was introduced.
@@ -717,7 +717,7 @@
   //
   if ( startLoaderThread )
   {
-    movie_def_impl* mdi = dynamic_cast<movie_def_impl*>(mov);
+    SWFMovieDefinition* mdi = dynamic_cast<SWFMovieDefinition*>(mov);
     if ( mdi ) {
       mdi->completeLoad();
     }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]