gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog libbase/FLVParser.cpp libbase/F...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog libbase/FLVParser.cpp libbase/F...
Date: Fri, 09 May 2008 15:33:46 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/05/09 15:33:45

Modified files:
        .              : ChangeLog 
        libbase        : FLVParser.cpp FLVParser.h 
        server/asobj   : NetConnection.cpp NetConnection.h 

Log message:
        * libbase/FLVParser.{cpp,h}: take a tu_file rather then a LoadThread.
        * server/asobj/NetConnection.{cpp,h}: don't construct a LoadThread,
          let users create a thread for download/parser/decode.
        
        NOTE: this change only affects NetStreamFfmpeg.cpp, it reduces number of
              threads used for downloading/parsing/decoding to only one.
        
        Total number of threads used for a youtube run with ffmpeg becomes then
              4 (main, swf loader, flv loader/parser/decoder, sdl sound handler)
              from 5.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6573&r2=1.6574
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/FLVParser.cpp?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/FLVParser.h?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.cpp?cvsroot=gnash&r1=1.60&r2=1.61
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.h?cvsroot=gnash&r1=1.41&r2=1.42

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6573
retrieving revision 1.6574
diff -u -b -r1.6573 -r1.6574
--- ChangeLog   9 May 2008 15:30:14 -0000       1.6573
+++ ChangeLog   9 May 2008 15:33:44 -0000       1.6574
@@ -1,3 +1,9 @@
+2008-05-09 Sandro Santilli <address@hidden>
+
+       * libbase/FLVParser.{cpp,h}: take a tu_file rather then a LoadThread.
+       * server/asobj/NetConnection.{cpp,h}: don't construct a LoadThread,
+         let users create a thread for download/parser/decode.
+
 2008-05-09 Russ Nelson <address@hidden>
 
        * Fix dump-gnash's -D switch.

Index: libbase/FLVParser.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/FLVParser.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- libbase/FLVParser.cpp       9 May 2008 11:12:04 -0000       1.29
+++ libbase/FLVParser.cpp       9 May 2008 15:33:45 -0000       1.30
@@ -33,7 +33,7 @@
 
 namespace gnash {
 
-FLVParser::FLVParser(LoadThread& lt)
+FLVParser::FLVParser(tu_file& lt)
        :
        _lt(lt),
        _lastParsedPosition(0),
@@ -166,9 +166,9 @@
                frame->dataSize = _audioFrames[_nextAudioFrame]->dataSize;
                frame->timestamp = _audioFrames[_nextAudioFrame]->timestamp;
 
-               _lt.seek(_audioFrames[_nextAudioFrame]->dataPosition);
+               _lt.set_position(_audioFrames[_nextAudioFrame]->dataPosition); 
// TODO: check return code...
                frame->data = new boost::uint8_t[frame->dataSize + 
PADDING_BYTES];
-               size_t bytesread = _lt.read(frame->data, frame->dataSize);
+               size_t bytesread = _lt.read_bytes(frame->data, frame->dataSize);
                memset(frame->data + bytesread, 0, PADDING_BYTES);
 
                frame->tag = 8;
@@ -180,9 +180,9 @@
                frame->dataSize = _videoFrames[_nextVideoFrame]->dataSize;
                frame->timestamp = _videoFrames[_nextVideoFrame]->timestamp;
 
-               _lt.seek(_videoFrames[_nextVideoFrame]->dataPosition);
+               _lt.set_position(_videoFrames[_nextVideoFrame]->dataPosition); 
// TODO: check return code
                frame->data = new boost::uint8_t[frame->dataSize + 
PADDING_BYTES];
-               size_t bytesread  = _lt.read(frame->data, frame->dataSize);
+               size_t bytesread  = _lt.read_bytes(frame->data, 
frame->dataSize);
                memset(frame->data + bytesread, 0, PADDING_BYTES);
 
                frame->tag = 9;
@@ -213,10 +213,10 @@
        frame->timestamp = _audioFrames[_nextAudioFrame]->timestamp;
        frame->tag = 8;
 
-       _lt.seek(_audioFrames[_nextAudioFrame]->dataPosition);
+       _lt.set_position(_audioFrames[_nextAudioFrame]->dataPosition); // TODO: 
check return code
        frame->data = new 
boost::uint8_t[_audioFrames[_nextAudioFrame]->dataSize +
                                  PADDING_BYTES];
-       size_t bytesread = _lt.read(frame->data, 
+       size_t bytesread = _lt.read_bytes(frame->data, 
                                _audioFrames[_nextAudioFrame]->dataSize);
        memset(frame->data + bytesread, 0, PADDING_BYTES);
 
@@ -255,10 +255,10 @@
        frame->timestamp = _videoFrames[_nextVideoFrame]->timestamp;
        frame->tag = 9;
 
-       _lt.seek(_videoFrames[_nextVideoFrame]->dataPosition);
+       _lt.set_position(_videoFrames[_nextVideoFrame]->dataPosition); // TODO: 
check return code
        frame->data = new 
boost::uint8_t[_videoFrames[_nextVideoFrame]->dataSize + 
                                  PADDING_BYTES];
-       size_t bytesread = _lt.read(frame->data, 
+       size_t bytesread = _lt.read_bytes(frame->data, 
                                _videoFrames[_nextVideoFrame]->dataSize);
        memset(frame->data + bytesread, 0, PADDING_BYTES);
 
@@ -517,21 +517,25 @@
        if (_lastParsedPosition == 0 && !parseHeader()) return false;
 
        // Check if there is enough data to parse the header of the frame
-       if (!_lt.isPositionConfirmed(_lastParsedPosition+14)) return false;
+       //if (!_lt.isPositionConfirmed(_lastParsedPosition+14)) return false;
 
        // Seek to next frame and skip the size of the last tag
-       _lt.seek(_lastParsedPosition+4);
+       if ( _lt.set_position(_lastParsedPosition+4) )
+       {
+               log_error("FLVParser::parseNextFrame: can't seek to %d", 
_lastParsedPosition+4);
+               return false;
+       }
 
        // Read the tag info
        boost::uint8_t tag[12];
-       _lt.read(tag, 12);
+       _lt.read_bytes(tag, 12);
 
        // Extract length and timestamp
        boost::uint32_t bodyLength = getUInt24(&tag[1]);
        boost::uint32_t timestamp = getUInt24(&tag[4]);
 
        // Check if there is enough data to parse the body of the frame
-       if (!_lt.isPositionConfirmed(_lastParsedPosition+15+bodyLength)) return 
false;
+       //if (!_lt.isPositionConfirmed(_lastParsedPosition+15+bodyLength)) 
return false;
 
        _lastParsedPosition += 15 + bodyLength;
 
@@ -542,7 +546,7 @@
                FLVAudioFrame* frame = new FLVAudioFrame;
                frame->dataSize = bodyLength - 1;
                frame->timestamp = timestamp;
-               frame->dataPosition = _lt.tell();
+               frame->dataPosition = _lt.get_position();
                _audioFrames.push_back(frame);
 
                // If this is the first audioframe no info about the
@@ -566,7 +570,7 @@
                FLVVideoFrame* frame = new FLVVideoFrame;
                frame->dataSize = bodyLength - 1;
                frame->timestamp = timestamp;
-               frame->dataPosition = _lt.tell();
+               frame->dataPosition = _lt.get_position();
                frame->frameType = (tag[11] & 0xf0) >> 4;
                _videoFrames.push_back(frame);
 
@@ -580,9 +584,13 @@
 
                        // Extract the video size from the videodata header
                        if (codec == VIDEO_CODEC_H263) {
-                               _lt.seek(frame->dataPosition);
+                               if ( _lt.set_position(frame->dataPosition) )
+                               {
+                                       log_error(" Couldn't seek to VideoTag 
data position");
+                                       return false;
+                               }
                                boost::uint8_t videohead[12];
-                               _lt.read(videohead, 12);
+                               _lt.read_bytes(videohead, 12); // TODO: use 
return code
 
                                bool sizebit1 = (videohead[3] & 0x02);
                                bool sizebit2 = (videohead[3] & 0x01);
@@ -643,11 +651,15 @@
 bool FLVParser::parseHeader()
 {
        // seek to the begining of the file
-       _lt.seek(0);
+       _lt.set_position(0); // seek back ? really ?
 
        // Read the header
        boost::uint8_t header[9];
-       _lt.read(header, 9);
+       if ( _lt.read_bytes(header, 9) != 9 )
+       {
+               log_error("FLVParser::parseHeader: couldn't read 9 bytes of 
header");
+               return false;
+       }
 
        // Check if this is really a FLV file
        if (header[0] != 'F' || header[1] != 'L' || header[2] != 'V') return 
false;

Index: libbase/FLVParser.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/FLVParser.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- libbase/FLVParser.h 27 Mar 2008 16:12:33 -0000      1.24
+++ libbase/FLVParser.h 9 May 2008 15:33:45 -0000       1.25
@@ -130,8 +130,6 @@
 ///
 /// Input is received from a LoadThread object.
 ///
-/// TODO: have the LoadThread passed at construction time
-///
 class DSOEXPORT FLVParser
 {
 
@@ -179,7 +177,7 @@
        ///     LoadThread to use for input.
        ///     Ownership left to the caller.
        ///
-       FLVParser(LoadThread& lt);
+       FLVParser(tu_file& lt);
 
        /// Kills the parser...
        ~FLVParser();
@@ -307,7 +305,7 @@
        inline boost::uint32_t getUInt24(boost::uint8_t* in);
 
        /// The interface to the file, externally owned
-       LoadThread& _lt;
+       tu_file& _lt;
 
        typedef std::vector<FLVVideoFrame*> VideoFrames;
 

Index: server/asobj/NetConnection.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetConnection.cpp,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -b -r1.60 -r1.61
--- server/asobj/NetConnection.cpp      6 Mar 2008 15:29:57 -0000       1.60
+++ server/asobj/NetConnection.cpp      9 May 2008 15:33:45 -0000       1.61
@@ -36,6 +36,8 @@
 #include "URLAccessManager.h"
 #include "URL.h"
 
+#include "FLVParser.h"
+
 namespace gnash {
 
 static as_value netconnection_new(const fn_call& fn);
@@ -92,23 +94,26 @@
   assert( uriStr.find( "://" ) != std::string::npos );
 
   // Check if we're allowed to open url
+#if 1 // done by getStream I guess...
   if ( ! URLAccessManager::allow( uri ) ) {
     log_security( _("Gnash is not allowed to open this url: %s"), 
uriStr.c_str() );
     return false;
   }
+#endif
 
-  log_security( _("Connecting to movie: %s"), uriStr.c_str() );
+  log_security( _("Connecting to movie: %s"), uriStr );
 
-  _loader.reset( new LoadThread() );
+  StreamProvider& streamProvider = StreamProvider::getDefaultInstance();
+  _loader.reset( streamProvider.getStream( uri ) );
 
-  if ( ! _loader->setStream( 
std::auto_ptr<tu_file>(StreamProvider::getDefaultInstance().getStream( uri ) ) 
) ) {
-    log_error( _("Gnash could not open this url: %s"), uriStr.c_str() );
+  if ( ! _loader.get() ) {
+    log_error( _("Gnash could not open this url: %s"), uriStr );
     _loader.reset();
 
     return false;
   }
 
-  log_debug( _("Connection established to movie: %s"), uriStr.c_str() );
+  log_debug( _("Connection established to movie: %s"), uriStr );
 
   return true;
 }
@@ -119,7 +124,7 @@
 NetConnection::eof()
 {
        if (!_loader.get()) return true; // @@ correct ?
-       return _loader->eof();
+       return _loader->get_eof();
 }
 
 
@@ -172,7 +177,7 @@
     return 0;
   }
 
-  return _loader->read( dst, bytes );
+  return _loader->read_bytes( dst, bytes );
 }
 
 
@@ -184,7 +189,7 @@
     return false;
   }
 
-  return _loader->seek( pos );
+  return ! _loader->set_position( pos );
 }
 
 
@@ -193,7 +198,7 @@
 NetConnection::tell()
 {
        if (!_loader.get()) return 0; // @@ correct ?
-       return _loader->tell();
+       return _loader->get_position();
 }
 
 
@@ -202,7 +207,7 @@
 NetConnection::getBytesLoaded()
 {
        if (!_loader.get()) return 0; // @@ correct ?
-       return _loader->getBytesLoaded();
+       return _loader->get_position(); // getBytesLoaded();
 }
 
 
@@ -211,7 +216,7 @@
 NetConnection::getBytesTotal()
 {
        if (!_loader.get()) return 0; // @@ correct ?
-       return _loader->getBytesTotal();
+       return _loader->get_size(); // getBytesTotal();
 }
 
 
@@ -223,7 +228,8 @@
     return false;
   }
 
-  return _loader->completed();
+  // is the below correct ?
+  return _loader->get_eof(); // completed();
 }
 
 

Index: server/asobj/NetConnection.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetConnection.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- server/asobj/NetConnection.h        26 Mar 2008 21:34:22 -0000      1.41
+++ server/asobj/NetConnection.h        9 May 2008 15:33:45 -0000       1.42
@@ -20,8 +20,8 @@
 #define __NETCONNECTION_H__
 
 #include "tu_file.h"
-#include "LoadThread.h"
-#include "FLVParser.h"
+//#include "LoadThread.h"
+//#include "FLVParser.h"
 
 #include <stdexcept>
 #include <cstdio>
@@ -39,6 +39,7 @@
 // Forward declarations
 namespace gnash {
        //class NetStream;
+       class FLVParser;
 }
 
 namespace gnash {
@@ -164,7 +165,7 @@
        std::string _completeUrl;
 
        /// The file/stream loader thread and interface
-       std::auto_ptr<LoadThread> _loader;
+       std::auto_ptr<tu_file> _loader;
 
        /// Attach ActionScript instance properties
        void attachProperties();




reply via email to

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