gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/rtmp r9576: Cleanup FLV Tag handling of th


From: rob
Subject: [Gnash-commit] /srv/bzr/gnash/rtmp r9576: Cleanup FLV Tag handling of the method name for MetaData.
Date: Fri, 08 Aug 2008 12:10:21 -0600
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9576
committer: address@hidden
branch nick: rtmp
timestamp: Fri 2008-08-08 12:10:21 -0600
message:
  Cleanup FLV Tag handling of the method name for MetaData.
  update from trunk.
added:
  libcore/swf/DefineButtonCxformTag.h
modified:
  libamf/flv.cpp
  libcore/Makefile.am
  libcore/impl.cpp
  libcore/impl.h
  libcore/movie_root.cpp
  libcore/parser/button_character_def.cpp
  libcore/parser/button_character_def.h
  libcore/parser/shape_character_def.cpp
  libcore/sprite_instance.cpp
  libcore/swf/PlaceObject2Tag.cpp
  testsuite/libamf.all/test_flv.cpp
  utilities/flvdumper.cpp
    ------------------------------------------------------------
    revno: 9483.42.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Fri 2008-08-08 11:06:20 +0200
    message:
      Drop commented-out and useless code.
    modified:
      libcore/parser/shape_character_def.cpp
    ------------------------------------------------------------
    revno: 9483.42.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Fri 2008-08-08 13:15:37 +0200
    message:
      Fix display of anything with a PlaceObject tag (SWF2).
    modified:
      libcore/swf/PlaceObject2Tag.cpp
    ------------------------------------------------------------
    revno: 9483.1.87
    committer: Benjamin Wolsey <address@hidden>
    branch nick: trunk
    timestamp: Fri 2008-08-08 13:57:18 +0200
    message:
      Restore support for SWF2 (PlaceObject tag), which stopped working sometime
      between 2006 and now.
    modified:
      libcore/parser/shape_character_def.cpp
      libcore/swf/PlaceObject2Tag.cpp
    ------------------------------------------------------------
    revno: 9483.1.88
    committer: Benjamin Wolsey <address@hidden>
    branch nick: trunk
    timestamp: Fri 2008-08-08 16:15:14 +0200
    message:
      Some cleanups, drop unused functions.
      
      Parse and implement DefineButtonCxform tag (SWF2 only).
    added:
      libcore/swf/DefineButtonCxformTag.h
    modified:
      libcore/Makefile.am
      libcore/impl.cpp
      libcore/impl.h
      libcore/movie_root.cpp
      libcore/parser/button_character_def.cpp
      libcore/parser/button_character_def.h
      libcore/sprite_instance.cpp
        ------------------------------------------------------------
        revno: 9483.42.3
        committer: Benjamin Wolsey <address@hidden>
        branch nick: work
        timestamp: Fri 2008-08-08 14:47:04 +0200
        message:
          Update comments, use LOG_ONCE.
        modified:
          libcore/parser/button_character_def.cpp
        ------------------------------------------------------------
        revno: 9483.42.4
        committer: Benjamin Wolsey <address@hidden>
        branch nick: work
        timestamp: Fri 2008-08-08 14:48:33 +0200
        message:
          Drop save_extern_movie and s_extern_sprites. Remove old includes.
        modified:
          libcore/impl.cpp
          libcore/impl.h
          libcore/movie_root.cpp
          libcore/sprite_instance.cpp
        ------------------------------------------------------------
        revno: 9483.42.5
        committer: Benjamin Wolsey <address@hidden>
        branch nick: work
        timestamp: Fri 2008-08-08 15:46:37 +0200
        message:
          Implement DefineButtonCxform tag. See 
          http://www.fortunecity.com/rivendell/krondor/531/2dwrebuild.swf for 
perhaps
          the only use of it you'll ever see (was replaced in SWF3 by 
DefineButton2).
        added:
          libcore/swf/DefineButtonCxformTag.h
        modified:
          libcore/Makefile.am
          libcore/impl.cpp
          libcore/parser/button_character_def.cpp
          libcore/parser/button_character_def.h
=== modified file 'libamf/flv.cpp'
--- a/libamf/flv.cpp    2008-08-08 04:39:08 +0000
+++ b/libamf/flv.cpp    2008-08-08 18:10:21 +0000
@@ -142,21 +142,21 @@
     AMF amf;
     Network::byte_t *ptr = buf;
     Network::byte_t *tooFar = ptr + size;
-    const char *name = 0;
+    char *name = 0;
     
     // Extract the onMetaData object name
     // In disk files, I always see the 0x2 type field for
-    // a string, but not always in streaming, at leat according to
+    // a string, but not always in streaming, at least according to
     // Gnash's libmedia/FLVParser code. So if we see the begining
     // of "onMetaData", then just grab the length without the type
     // field.
     if ((*ptr == 0) && (*ptr+3 == 'o')) {
-       boost::uint32_t length;
-       length = convert24(ptr);
-       ptr += 3;               // the size is a 24bit integer
-       name = new char(length);
+       boost::uint16_t length;
+       length = ntohs((*(boost::uint16_t *)ptr) & 0xffff);
+       name = new char(length+1);
+       memset(name, 0, length+1);
        std::copy(name, name + length, ptr);
-       ptr += length + 3;
+       ptr += length + AMF_HEADER_SIZE;
     } else {   
        Element *objname = amf.extractAMF(ptr, tooFar);
        if (objname == 0) {
@@ -164,9 +164,8 @@
            return 0;
        }
        ptr += objname->getLength() + AMF_HEADER_SIZE;
-       name = objname->to_string();
-    }
-    
+       name = const_cast<char *>(objname->to_string());
+    }    
     
     // Extract the properties for this metadata object.
     Element *el = amf.extractAMF(ptr, tooFar);

=== modified file 'libcore/Makefile.am'
--- a/libcore/Makefile.am       2008-08-07 18:51:54 +0000
+++ b/libcore/Makefile.am       2008-08-08 13:46:37 +0000
@@ -174,6 +174,7 @@
        swf/ControlTag.h \
        swf/DefineFontAlignZonesTag.h \
        swf/CSMTextSettingsTag.h \
+       swf/DefineButtonCxformTag.h \
        swf/PlaceObject2Tag.h \
        swf/RemoveObjectTag.h \
        swf/DisplayListTag.h \

=== modified file 'libcore/impl.cpp'
--- a/libcore/impl.cpp  2008-08-07 18:51:54 +0000
+++ b/libcore/impl.cpp  2008-08-08 13:46:37 +0000
@@ -21,19 +21,11 @@
 #include "smart_ptr.h" // GNASH_USE_GC
 #include "IOChannel.h"
 #include "utility.h"
-//#include "action.h"
 #include "impl.h"
 #include "font.h"
 #include "fontlib.h"
 #include "log.h"
 #include "image.h"
-//#include "render.h"
-//#include "shape.h"
-//#include "styles.h"
-//#include "dlist.h"
-//#include "timers.h"
-//#include "zlib_adapter.h"
-//#include "generic_character.h"
 #include "sprite_definition.h"
 #include "SWFMovieDefinition.h"
 #include "swf.h"
@@ -45,6 +37,7 @@
 #include "ScriptLimitsTag.h"
 #include "BitmapMovieDefinition.h"
 #include "DefineFontAlignZonesTag.h"
+#include "DefineButtonCxformTag.h"
 #include "CSMTextSettingsTag.h"
 #include "PlaceObject2Tag.h"
 #include "RemoveObjectTag.h"
@@ -134,7 +127,7 @@
 
     // End tag doesn't really need to exist.
     // TODO: use null_loader here ?
-    register_tag_loader(SWF::END,   end_loader);
+    register_tag_loader(SWF::END, end_loader);
 
     register_tag_loader(SWF::DEFINESHAPE, define_shape_loader);
     register_tag_loader(SWF::FREECHARACTER, fixme_loader); // 03
@@ -160,7 +153,7 @@
     register_tag_loader(SWF::DEFINELOSSLESS, define_bits_lossless_2_loader);
     register_tag_loader(SWF::DEFINEBITSJPEG2, define_bits_jpeg2_loader);
     register_tag_loader(SWF::DEFINESHAPE2,  define_shape_loader);
-    register_tag_loader(SWF::DEFINEBUTTONCXFORM, fixme_loader); // 23
+    register_tag_loader(SWF::DEFINEBUTTONCXFORM, 
DefineButtonCxformTag::loader); // 23
     // "protect" tag; we're not an authoring tool so we don't care.
     // (might be nice to dump the password instead..)
     register_tag_loader(SWF::PROTECT, null_loader);
@@ -628,12 +621,6 @@
 };
 
 static MovieLibrary s_movie_library;
-static std::vector<sprite_instance*> s_extern_sprites;
-
-void save_extern_movie(sprite_instance* m)
-{
-    s_extern_sprites.push_back(m);
-}
 
 static void clear_library()
     // Drop all library references to movie_definitions, so they

=== modified file 'libcore/impl.h'
--- a/libcore/impl.h    2008-08-07 13:21:24 +0000
+++ b/libcore/impl.h    2008-08-08 12:48:33 +0000
@@ -27,11 +27,6 @@
 
 namespace gnash {
 
-// Forward declarations
-class sprite_instance;
-
-DSOEXPORT void save_extern_movie(sprite_instance* m);
-
 //
 // Loader callbacks.
 //

=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp    2008-07-28 21:44:24 +0000
+++ b/libcore/movie_root.cpp    2008-08-08 12:48:33 +0000
@@ -423,8 +423,6 @@
        character* ch = extern_movie.get();
        ch->set_depth(num+character::staticDepthOffset);
 
-       save_extern_movie(extern_movie.get());
-
        setLevel(num, extern_movie);
 
        return true;

=== modified file 'libcore/parser/button_character_def.cpp'
--- a/libcore/parser/button_character_def.cpp   2008-08-07 10:02:35 +0000
+++ b/libcore/parser/button_character_def.cpp   2008-08-08 13:46:37 +0000
@@ -184,36 +184,30 @@
        in->ensureBytes(2);
        m_button_layer = in->read_u16();
 
-       // TODO: pass available range to button matrix read
+    // matrix::read() checks the length of the stream
        m_button_matrix.read(in);
 
        if (tag_type == SWF::DEFINEBUTTON2)
        {
-               // TODO: pass available range to button cxform read
+               // cxform::read_rgba() checks the length of the stream.
                m_button_cxform.read_rgba(in);
        }
 
        if ( buttonHasFilterList )
        {
                filter_factory::read(*in, true, &_filters);
-               static bool warned=false;
-               if ( ! warned )
-               {
+               LOG_ONCE(
                        log_unimpl("Button filters"); 
-                       warned=true;
-               }
+               );
        }
 
        if ( buttonHasBlendMode )
        {
                in->ensureBytes(1);
-               _blendMode = in->read_u8();
-               static bool warned=false;
-               if ( ! warned )
-               {
+        _blendMode = in->read_u8();
+               LOG_ONCE(
                        log_unimpl("Button blend mode");
-                       warned=true;
-               }
+               );
        }
 
        return true;
@@ -348,6 +342,20 @@
 }
 
 void
+button_character_definition::readDefineButtonCxform(SWFStream* in, 
movie_definition* /*m*/)
+{
+    // A simple rgb cxform for SWF2 buttons, superseded by DefineButton2.
+    for (ButtonRecVect::iterator i = m_button_records.begin(), e = 
m_button_records.end();
+            i != e; ++i)
+    {
+        (*i).m_button_cxform.read_rgb(in);
+        IF_VERBOSE_PARSE(
+            log_parse("Read DefineButtonCxform: %s", (*i).m_button_cxform);
+        );
+    }
+}
+
+void
 button_character_definition::readDefineButton2(SWFStream* in, 
movie_definition* m)
 {
        // Character ID has been read already

=== modified file 'libcore/parser/button_character_def.h'
--- a/libcore/parser/button_character_def.h     2008-06-09 13:55:51 +0000
+++ b/libcore/parser/button_character_def.h     2008-08-08 13:46:37 +0000
@@ -260,6 +260,9 @@
        /// Read a SWF::DEFINEBUTTONSOUND tag
        void    readDefineButtonSound(SWFStream* in, movie_definition* m);
        
+       /// Read a SWF::DEFINEBUTTONCXFORM tag
+       void readDefineButtonCxform(SWFStream* in, movie_definition* m);
+       
        const rect&     get_bound() const {
                // It is required that get_bound() is implemented in character 
definition
                // classes. However, button character definitions do not have 
shape 

=== modified file 'libcore/parser/shape_character_def.cpp'
--- a/libcore/parser/shape_character_def.cpp    2008-08-07 10:02:35 +0000
+++ b/libcore/parser/shape_character_def.cpp    2008-08-08 09:06:20 +0000
@@ -34,11 +34,6 @@
 #include <cfloat>
 #include <algorithm>
 
-//#ifdef __sgi
-//extern double round(double);
-//#pragma optional round
-//#endif
-
 // Define the macro below to always compute bounds for shape characters
 // and compare them with the bounds encoded in the SWF
 //#define GNASH_DEBUG_SHAPE_BOUNDS 1

=== modified file 'libcore/sprite_instance.cpp'
--- a/libcore/sprite_instance.cpp       2008-07-19 08:17:17 +0000
+++ b/libcore/sprite_instance.cpp       2008-08-08 12:48:33 +0000
@@ -4573,8 +4573,6 @@
     assert ( extern_movie->get_event_handlers().empty() );
     extern_movie->set_event_handlers(clipEvs);
 
-    save_extern_movie(extern_movie.get());
-
     const std::string& name = get_name();
     assert ( parent == extern_movie->get_parent() );
 

=== added file 'libcore/swf/DefineButtonCxformTag.h'
--- a/libcore/swf/DefineButtonCxformTag.h       1970-01-01 00:00:00 +0000
+++ b/libcore/swf/DefineButtonCxformTag.h       2008-08-08 13:46:37 +0000
@@ -0,0 +1,85 @@
+// DefineButtonCxformTag.h: parse SWF2 button cxform tag.
+// 
+//   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// 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_SWF_DEFINEBUTTONCXFORMTAG_H
+#define GNASH_SWF_DEFINEBUTTONCXFORMTAG_H
+
+#include "swf.h" // for tag_type definition
+#include "stream.h" // for inlines
+#include "movie_definition.h"
+#include "button_character_def.h"
+
+namespace gnash {
+namespace SWF {
+
+/// \brief Sets the desired limits for recursion and timeout for AS scripts
+//
+/// A loaded movie containing a ScriptLimits tag should change the *global*
+/// scriptlimits setting, so this is kept in movie_root rather than the
+/// immutable movie_definition. Whenever this tag is parsed, the value in
+/// movie_root is overridden.
+namespace DefineButtonCxformTag
+{
+
+void loader(SWFStream* in, tag_type tag, movie_definition* m)
+{
+
+    assert(tag == SWF::DEFINEBUTTONCXFORM);
+
+    in->ensureBytes(2);
+    const boost::uint16_t buttonID = in->read_u16();
+
+    IF_VERBOSE_PARSE (
+        log_debug("DefineButtonCxformTag: ButtonId=%d", buttonID);
+    );
+    
+    character_def* chdef = m->get_character_def(buttonID);
+    if ( ! chdef )
+    {
+        IF_VERBOSE_MALFORMED_SWF(
+        log_swferror(_("DefineButtonCxform refers to an unknown character 
%d"), buttonID);
+        );
+        return;
+    }
+
+    button_character_definition* ch = 
dynamic_cast<button_character_definition*> (chdef);
+    if ( ! ch )
+    {
+        IF_VERBOSE_MALFORMED_SWF(
+        log_swferror(_("DefineButtonCxform refers to character ID %d (%s)."
+                  " Expected a button definition"),
+                  buttonID, typeName(*chdef));
+        );
+        return;
+    }
+
+    ch->readDefineButtonCxform(in, m);
+    }
+}
+
+} // namespace gnash::SWF
+} // namespace gnash
+
+
+#endif // GNASH_SWF_DEFINEBUTTONCXFORMTAG_H
+
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:

=== modified file 'libcore/swf/PlaceObject2Tag.cpp'
--- a/libcore/swf/PlaceObject2Tag.cpp   2008-06-09 17:12:54 +0000
+++ b/libcore/swf/PlaceObject2Tag.cpp   2008-08-08 11:15:37 +0000
@@ -34,27 +34,38 @@
     // Original place_object tag; very simple.
     in.ensureBytes(2 + 2);
     m_character_id = in.read_u16();
-    m_depth = in.read_u16()+character::staticDepthOffset;
+    m_depth = in.read_u16() + character::staticDepthOffset;
     m_matrix.read(in);
 
     IF_VERBOSE_PARSE
     (
             log_parse(_("  PLACEOBJECT: depth=%d(%d) char=%d"),
-            m_depth, m_depth-character::staticDepthOffset,
+            m_depth, m_depth - character::staticDepthOffset,
             m_character_id);
-            log_parse("%s", m_matrix);
+            log_parse("  matrix: %s", m_matrix);
     );
 
+    // If these flags2 values aren't set here, nothing will
+    // ever be displayed.
+    m_has_flags2 |= ( HAS_CHARACTER_MASK
+                    | HAS_MATRIX_MASK );
+
+    // PlaceObject doesn't know about masks.
+    m_clip_depth = character::noClipDepthValue;
+
     if (in.tell() < in.get_tag_end_position())
     {
         m_color_transform.read_rgb(in);
 
+        m_has_flags2 |= HAS_CXFORM_MASK;
+
         IF_VERBOSE_PARSE
         (
             log_parse(_("  cxform: %s"), m_color_transform);
         );
 
     }
+    
 }
 
 // read placeObject2 actions

=== modified file 'testsuite/libamf.all/test_flv.cpp'
--- a/testsuite/libamf.all/test_flv.cpp 2008-08-08 04:39:08 +0000
+++ b/testsuite/libamf.all/test_flv.cpp 2008-08-08 18:10:21 +0000
@@ -211,9 +211,9 @@
     Flv::flv_tag_t *tag2 = flv.decodeTagHeader(hex2);
     if ((tag2->type == Flv::TAG_METADATA)
         && (flv.convert24(tag2->bodysize) == 164)) {
-        runtest.pass("Decoded FLV MetaData object");
+        runtest.pass("Decoded FLV MetaData header");
     } else {
-        runtest.fail("Decoded FLV MetaData object");
+        runtest.fail("Decoded FLV MetaData header");
     }
     delete tag2;
     delete hex2;

=== modified file 'utilities/flvdumper.cpp'
--- a/utilities/flvdumper.cpp   2008-08-08 04:38:15 +0000
+++ b/utilities/flvdumper.cpp   2008-08-08 18:10:21 +0000
@@ -186,17 +186,17 @@
            ifs.read(reinterpret_cast<char *>(buf.reference()), 
sizeof(Flv::flv_header_t));
            head  = flv.decodeHeader(&buf);
            if ((head->type & Flv::FLV_VIDEO) && (head->type & Flv::FLV_AUDIO)) 
{
-                cerr <<"FLV File type: Video and Audio" << endl;
+                cout <<"FLV File type: Video and Audio" << endl;
             } else if (head->type && Flv::FLV_VIDEO) {
-               cerr << "FLV File type: Video" << endl;
+               cout << "FLV File type: Video" << endl;
             } else if (head->type && Flv::FLV_AUDIO) {
-               cerr <<"FLV File type: Audio" << endl;
+               cout <<"FLV File type: Audio" << endl;
            }
            
-           cerr << "FLV Version: " << int(head->version) << " (should always 
be 1)" << endl;
+           cout << "FLV Version: " << int(head->version) << " (should always 
be 1)" << endl;
            boost::uint32_t headsize = flv.convert24(head->head_size);
            if (all) {   
-               cerr << "FLV Header size: " << headsize << " (should always be 
9)" << endl;
+               cout << "FLV Header size: " << headsize << " (should always be 
9)" << endl;
            }
             // Extract all the Tags
             size_t total = st.st_size - sizeof(Flv::flv_header_t);
@@ -205,15 +205,20 @@
                 previous = ntohl(previous);
                 total -= sizeof(Flv::previous_size_t);
                 if (all) {   
-                    cerr << "FLV Previous Tag Size was: " << previous << endl;
+                    cout << "FLV Previous Tag Size was: " << previous << endl;
                 }
                 ifs.read(reinterpret_cast<char *>(buf.reference()), 
sizeof(Flv::flv_tag_t));
                 tag  = flv.decodeTagHeader(&buf);
                 
                 total -= sizeof(Flv::previous_size_t);
                 boost::uint32_t bodysize = flv.convert24(tag->bodysize);
-                if (all) {   
-                    cerr << "FLV Tag size is: " << bodysize << endl;
+                if (bodysize == 0) {
+                    cerr << "FLV Tag size is zero, skipping reading packet 
body " << bodysize << endl;
+                    continue;
+                } else {
+                    if (all) {   
+                        cout << "FLV Tag size is: " << bodysize +  
sizeof(Flv::previous_size_t) << endl;
+                    }
                 }
                 buf.resize(bodysize);
                 ifs.read(reinterpret_cast<char *>(buf.reference()), bodysize);
@@ -228,28 +233,28 @@
                   {
                       if (all) {
                           cerr << "FLV Tag type is: Audio" << endl;
-                          Flv::flv_audio_t *data = 
flv.decodeAudioData(*(buf.reference() + sizeof(Flv::flv_tag_t)));
-                          cerr << "\tSound Type is: " << type_strs[data->type] 
<< endl;
-                          cerr << "\tSound Size is: " << size_strs[data->size] 
<< endl;
-                          cerr << "\tSound Rate is: " << rate_strs[data->rate] 
<< endl;
-                          cerr << "\tSound Format is: " << 
format_strs[data->format] << endl;
-                          break;
+                          Flv::flv_audio_t *data = 
flv.decodeAudioData(*(buf.reference() + sizeof(Flv::flv_tag_t)));
+                          cout << "\tSound Type is: "   << 
type_strs[data->type] << endl;
+                          cout << "\tSound Size is: "   << 
size_strs[data->size] << endl;
+                          cout << "\tSound Rate is: "   << 
rate_strs[data->rate] << endl;
+                          cout << "\tSound Format is: " << 
format_strs[data->format] << endl;
                       }
+                      break;
                   }
                   case Flv::TAG_VIDEO:
                   {
                       if (all) {
-                          cerr << "FLV Tag type is: Video" << endl;
-                          Flv::flv_video_t *data = 
flv.decodeVideoData(*(buf.reference() + sizeof(Flv::flv_tag_t)));
-                          cerr << "\tCodec ID is: " << 
codec_strs[data->codecID] << endl;
-                          cerr << "\tFrame Type is: " << 
frame_strs[data->type] << endl;
-                          break;
+                          cout << "FLV Tag type is: Video" << endl;
+                          Flv::flv_video_t *data = 
flv.decodeVideoData(*(buf.reference() + sizeof(Flv::flv_tag_t)));
+                          cout << "\tCodec ID is: "   << 
codec_strs[data->codecID] << endl;
+                          cout << "\tFrame Type is: " << 
frame_strs[data->type] << endl;
                       }
+                      break;
                   }
                   case Flv::TAG_METADATA:
-                      if (all) {
-                          cerr << "FLV Tag type is: MetaData" << endl;
-                      }
+                      if (meta || all) {
+                          cout << "FLV Tag type is: MetaData" << endl;
+                      }
                       Element *metadata = flv.decodeMetaData(buf.reference(), 
bodysize);
                       if (meta && metadata) {
                           metadata->dump();


reply via email to

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