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: Wed, 30 May 2007 12:18:50 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/05/30 12:18:49

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

Log message:
                * libbase/FLVParser.{cpp,h}: drop setLoadThread method, require
                  a LoadThread to be passed on construction.
                * server/asobj/NetConnection.{cpp,h}: drop connectParser, 
substitute
                  with getConnectedParser().
                * server/asobj/: NetStreamFfmpeg.cpp, NetStreamGst.cpp: use
                  NetConnection::getConnectedParser() for initializing an FLV 
parser.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3407&r2=1.3408
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/FLVParser.cpp?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/FLVParser.h?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.cpp?cvsroot=gnash&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.h?cvsroot=gnash&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.cpp?cvsroot=gnash&r1=1.71&r2=1.72
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamGst.cpp?cvsroot=gnash&r1=1.50&r2=1.51

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3407
retrieving revision 1.3408
diff -u -b -r1.3407 -r1.3408
--- ChangeLog   30 May 2007 11:58:20 -0000      1.3407
+++ ChangeLog   30 May 2007 12:18:48 -0000      1.3408
@@ -1,5 +1,14 @@
 2007-05-30 Sandro Santilli <address@hidden>
 
+       * libbase/FLVParser.{cpp,h}: drop setLoadThread method, require
+         a LoadThread to be passed on construction.
+       * server/asobj/NetConnection.{cpp,h}: drop connectParser, substitute
+         with getConnectedParser().
+       * server/asobj/: NetStreamFfmpeg.cpp, NetStreamGst.cpp: use
+         NetConnection::getConnectedParser() for initializing an FLV parser.
+
+2007-05-30 Sandro Santilli <address@hidden>
+
        * server/asobj/NetConnection.h: add documentation about which calls
          are blocking and which not.
        * server/asobj/NetConnection.cpp (openConnection): return false if

Index: libbase/FLVParser.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/FLVParser.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- libbase/FLVParser.cpp       30 May 2007 09:52:46 -0000      1.17
+++ libbase/FLVParser.cpp       30 May 2007 12:18:49 -0000      1.18
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-// $Id: FLVParser.cpp,v 1.17 2007/05/30 09:52:46 strk Exp $
+// $Id: FLVParser.cpp,v 1.18 2007/05/30 12:18:49 strk Exp $
 
 #include "FLVParser.h"
 #include "amf.h"
@@ -26,9 +26,9 @@
 #define PADDING_BYTES 8
 
 
-FLVParser::FLVParser()
+FLVParser::FLVParser(LoadThread& lt)
        :
-       _lt(NULL),
+       _lt(lt),
        _lastParsedPosition(0),
        _parsingComplete(false),
        _videoInfo(NULL),
@@ -159,9 +159,9 @@
                frame->dataSize = _audioFrames[_nextAudioFrame]->dataSize;
                frame->timestamp = _audioFrames[_nextAudioFrame]->timestamp;
 
-               _lt->seek(_audioFrames[_nextAudioFrame]->dataPosition);
+               _lt.seek(_audioFrames[_nextAudioFrame]->dataPosition);
                frame->data = new uint8_t[frame->dataSize + PADDING_BYTES];
-               size_t bytesread = _lt->read(frame->data, frame->dataSize);
+               size_t bytesread = _lt.read(frame->data, frame->dataSize);
                memset(frame->data + bytesread, 0, PADDING_BYTES);
 
                frame->tag = 8;
@@ -173,9 +173,9 @@
                frame->dataSize = _videoFrames[_nextVideoFrame]->dataSize;
                frame->timestamp = _videoFrames[_nextVideoFrame]->timestamp;
 
-               _lt->seek(_videoFrames[_nextVideoFrame]->dataPosition);
+               _lt.seek(_videoFrames[_nextVideoFrame]->dataPosition);
                frame->data = new uint8_t[frame->dataSize + PADDING_BYTES];
-               size_t bytesread  = _lt->read(frame->data, frame->dataSize);
+               size_t bytesread  = _lt.read(frame->data, frame->dataSize);
                memset(frame->data + bytesread, 0, PADDING_BYTES);
 
                frame->tag = 9;
@@ -206,10 +206,10 @@
        frame->timestamp = _audioFrames[_nextAudioFrame]->timestamp;
        frame->tag = 8;
 
-       _lt->seek(_audioFrames[_nextAudioFrame]->dataPosition);
+       _lt.seek(_audioFrames[_nextAudioFrame]->dataPosition);
        frame->data = new uint8_t[_audioFrames[_nextAudioFrame]->dataSize +
                                  PADDING_BYTES];
-       size_t bytesread = _lt->read(frame->data, 
+       size_t bytesread = _lt.read(frame->data, 
                                _audioFrames[_nextAudioFrame]->dataSize);
        memset(frame->data + bytesread, 0, PADDING_BYTES);
 
@@ -248,10 +248,10 @@
        frame->timestamp = _videoFrames[_nextVideoFrame]->timestamp;
        frame->tag = 9;
 
-       _lt->seek(_videoFrames[_nextVideoFrame]->dataPosition);
+       _lt.seek(_videoFrames[_nextVideoFrame]->dataPosition);
        frame->data = new uint8_t[_videoFrames[_nextVideoFrame]->dataSize + 
                                  PADDING_BYTES];
-       size_t bytesread = _lt->read(frame->data, 
+       size_t bytesread = _lt.read(frame->data, 
                                _videoFrames[_nextVideoFrame]->dataSize);
        memset(frame->data + bytesread, 0, PADDING_BYTES);
 
@@ -506,27 +506,27 @@
        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);
+       _lt.seek(_lastParsedPosition+4);
 
        // Read the tag info
        uint8_t tag[12];
-       _lt->read(tag, 12);
+       _lt.read(tag, 12);
 
        // Extract length and timestamp
        uint32_t bodyLength = getUInt24(&tag[1]);
        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;
 
        if (tag[0] == AUDIO_TAG) {
                FLVAudioFrame* frame = new FLVAudioFrame;
                frame->dataSize = bodyLength - 1;
                frame->timestamp = timestamp;
-               frame->dataPosition = _lt->tell();
+               frame->dataPosition = _lt.tell();
                _audioFrames.push_back(frame);
 
                // If this is the first audioframe no info about the
@@ -550,7 +550,7 @@
                FLVVideoFrame* frame = new FLVVideoFrame;
                frame->dataSize = bodyLength - 1;
                frame->timestamp = timestamp;
-               frame->dataPosition = _lt->tell();
+               frame->dataPosition = _lt.tell();
                frame->frameType = (tag[11] & 0xf0) >> 4;
                _videoFrames.push_back(frame);
 
@@ -564,9 +564,9 @@
 
                        // Extract the video size from the videodata header
                        if (codec == VIDEO_CODEC_H263) {
-                               _lt->seek(frame->dataPosition);
+                               _lt.seek(frame->dataPosition);
                                uint8_t videohead[12];
-                               _lt->read(videohead, 12);
+                               _lt.read(videohead, 12);
 
                                bool sizebit1 = (videohead[3] & 0x02);
                                bool sizebit2 = (videohead[3] & 0x01);
@@ -611,9 +611,9 @@
 
        } else if (tag[0] == META_TAG) {
                // Extract information from the meta tag
-               /*_lt->seek(_lastParsedPosition+16);
+               /*_lt.seek(_lastParsedPosition+16);
                char* metaTag = new char[bodyLength];
-               _lt->read(metaTag, bodyLength);
+               _lt.read(metaTag, bodyLength);
                amf::AMF* amfParser = new amf::AMF();
                amfParser->parseAMF(metaTag);*/
 
@@ -629,11 +629,11 @@
 bool FLVParser::parseHeader()
 {
        // seek to the begining of the file
-       _lt->seek(0);
+       _lt.seek(0);
 
        // Read the header
        uint8_t header[9];
-       _lt->read(header, 9);
+       _lt.read(header, 9);
 
        // Check if this is really a FLV file
        if (header[0] != 'F' || header[1] != 'L' || header[2] != 'V') return 
false;
@@ -662,9 +662,4 @@
        return (in[0] << 16) | (in[1] << 8) | in[2];
 }
 
-void FLVParser::setLoadThread(LoadThread* lt)
-{
-       _lt = lt;
-}
-
 #undef PADDING_BYTES

Index: libbase/FLVParser.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/FLVParser.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- libbase/FLVParser.h 30 May 2007 09:52:47 -0000      1.11
+++ libbase/FLVParser.h 30 May 2007 12:18:49 -0000      1.12
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-// $Id: FLVParser.h,v 1.11 2007/05/30 09:52:47 strk Exp $
+// $Id: FLVParser.h,v 1.12 2007/05/30 12:18:49 strk Exp $
 
 // Information about the FLV format can be found at http://osflash.org/flv
 
@@ -154,12 +154,24 @@
 /// and fetching frames from there on, sequentially.
 /// See seek(), nextVideoFrame(), nextAudioFrame() and nextMediaFrame().
 ///
+/// Input is received from a LoadThread object.
+///
+/// TODO: have the LoadThread passed at construction time
+///
 class DSOEXPORT FLVParser
 {
 
 public:
-       /// Creating the object...
-       FLVParser();
+
+       /// \brief
+       /// Create an FLV parser reading input from
+       /// the given LoadThread
+       //
+       /// @param lt
+       ///     LoadThread to use for input.
+       ///     Ownership left to the caller.
+       ///
+       FLVParser(LoadThread& lt);
 
        /// Kills the parser...
        ~FLVParser();
@@ -200,9 +212,6 @@
        ///
        FLVAudioInfo* getAudioInfo();
 
-       /// Sets the LoadThread which is used as interface
-       void setLoadThread(LoadThread* lt);
-
        /// \brief
        /// Asks if a frame with with a timestamp larger than
        /// the given time is available.
@@ -273,8 +282,8 @@
        // Functions used to extract numbers from the file
        inline uint32_t getUInt24(uint8_t* in);
 
-       /// The interface to the file
-       LoadThread* _lt;
+       /// The interface to the file, externally owned
+       LoadThread& _lt;
 
        typedef std::vector<FLVVideoFrame*> VideoFrames;
 

Index: server/asobj/NetConnection.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetConnection.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- server/asobj/NetConnection.cpp      30 May 2007 11:58:21 -0000      1.46
+++ server/asobj/NetConnection.cpp      30 May 2007 12:18:49 -0000      1.47
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: NetConnection.cpp,v 1.46 2007/05/30 11:58:21 strk Exp $ */
+/* $Id: NetConnection.cpp,v 1.47 2007/05/30 12:18:49 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -175,13 +175,17 @@
        return _loader->completed();
 }
 
-bool
-NetConnection::connectParser(FLVParser& parser)
+std::auto_ptr<FLVParser>
+NetConnection::getConnectedParser() const
 {
-       if (!_loader.get()) return false;
+       std::auto_ptr<FLVParser> ret;
 
-       parser.setLoadThread(_loader.get());
-       return true;
+       if ( _loader.get() )
+       {
+               ret.reset(new FLVParser(*_loader));
+       }
+
+       return ret;
 }
 
 /// \brief callback to instantiate a new NetConnection object.

Index: server/asobj/NetConnection.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetConnection.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- server/asobj/NetConnection.h        30 May 2007 11:58:21 -0000      1.32
+++ server/asobj/NetConnection.h        30 May 2007 12:18:49 -0000      1.33
@@ -15,7 +15,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: NetConnection.h,v 1.32 2007/05/30 11:58:21 strk Exp $ */
+/* $Id: NetConnection.h,v 1.33 2007/05/30 12:18:49 strk Exp $ */
 
 #ifndef __NETCONNECTION_H__
 #define __NETCONNECTION_H__
@@ -123,12 +123,11 @@
        ///
        long getBytesTotal();
 
-       /// Connects FLV parser with the LoadThread
+       /// Return an FLVParser using our LoadThread for input
        //
-       /// This call never blocks.
-       /// If not connected, false is returned.
+       /// If not connected, a NULL auto_ptr is returned.
        ///
-       bool connectParser(FLVParser& parser);
+       std::auto_ptr<FLVParser> getConnectedParser() const;
 
        /// Returns whether the load is complete
        //

Index: server/asobj/NetStreamFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.cpp,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -b -r1.71 -r1.72
--- server/asobj/NetStreamFfmpeg.cpp    30 May 2007 11:32:13 -0000      1.71
+++ server/asobj/NetStreamFfmpeg.cpp    30 May 2007 12:18:49 -0000      1.72
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: NetStreamFfmpeg.cpp,v 1.71 2007/05/30 11:32:13 martinwguy Exp $ */
+/* $Id: NetStreamFfmpeg.cpp,v 1.72 2007/05/30 12:18:49 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -79,7 +79,6 @@
 NetStreamFfmpeg::~NetStreamFfmpeg()
 {
        close();
-       //delete m_parser;
 }
 
 void NetStreamFfmpeg::pause(int mode)
@@ -393,11 +392,11 @@
        if (std::string(head) == "FLV") {
                m_isFLV = true;
                if (!m_parser.get()) {
-                       m_parser.reset(new FLVParser()); // TODO: define 
ownership, use auto_ptr !
-                       if (!nc->connectParser(*m_parser)) {
+                       m_parser = nc->getConnectedParser();
+                       if (! m_parser.get() )
+                       {
                                setStatus(streamNotFound);
                                log_error(_("Gnash could not open FLV movie: 
%s"), url.c_str());
-                               m_parser.reset(); // release memory associated 
with parser
                                return false;
                        }
                }

Index: server/asobj/NetStreamGst.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamGst.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- server/asobj/NetStreamGst.cpp       28 May 2007 19:27:20 -0000      1.50
+++ server/asobj/NetStreamGst.cpp       30 May 2007 12:18:49 -0000      1.51
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: NetStreamGst.cpp,v 1.50 2007/05/28 19:27:20 tgc Exp $ */
+/* $Id: NetStreamGst.cpp,v 1.51 2007/05/30 12:18:49 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -98,7 +98,6 @@
 NetStreamGst::~NetStreamGst()
 {
        close();
-       //delete m_parser;
 }
 
 void NetStreamGst::pause(int mode)
@@ -759,12 +758,11 @@
        if (head[0] == 'F' && head[1] == 'L' && head[2] == 'V') { 
                m_isFLV = true;
                if (!m_parser.get()) {
-                       m_parser.reset(new FLVParser()); // TODO: define 
ownership, use auto_ptr !
-                       if (!nc->connectParser(*m_parser)) {
+                       m_parser = nc->getConnectedParser(); 
+                       if (! m_parser.get() )
+                       {
                                setStatus(streamNotFound);
                                log_error(_("Gnash could not open FLV movie: 
%s"), url.c_str());
-                               m_parser.reset(); // release memory associated 
with the parser
-                               //delete m_parser;
                                return;
                        }
                }




reply via email to

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