gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/NetStreamFfmpeg.cp...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/asobj/NetStreamFfmpeg.cp...
Date: Tue, 03 Jun 2008 16:21:39 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/06/03 16:21:39

Modified files:
        .              : ChangeLog 
        server/asobj   : NetStreamFfmpeg.cpp NetStreamFfmpeg.h 

Log message:
        * server/asobj/NetStreamFfmpeg.{cpp,h}: drop ffmpeg includes, as this
          class is finally media-handler agnostic (except for expecting
          the sound_handler to implement the aux streamers).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6792&r2=1.6793
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.cpp?cvsroot=gnash&r1=1.140&r2=1.141
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.h?cvsroot=gnash&r1=1.72&r2=1.73

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6792
retrieving revision 1.6793
diff -u -b -r1.6792 -r1.6793
--- ChangeLog   3 Jun 2008 16:11:43 -0000       1.6792
+++ ChangeLog   3 Jun 2008 16:21:37 -0000       1.6793
@@ -1,5 +1,11 @@
 2008-06-03 Sandro Santilli <address@hidden>
 
+       * server/asobj/NetStreamFfmpeg.{cpp,h}: drop ffmpeg includes, as this
+         class is finally media-handler agnostic (except for expecting
+         the sound_handler to implement the aux streamers).
+
+2008-06-03 Sandro Santilli <address@hidden>
+
        * libmedia/MediaHandler.h: add createAudioDecoder, taking AudioInfo
          as input, change createVideoDecoder to take VideoInfo for
          consistency.

Index: server/asobj/NetStreamFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.cpp,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -b -r1.140 -r1.141
--- server/asobj/NetStreamFfmpeg.cpp    3 Jun 2008 16:11:45 -0000       1.140
+++ server/asobj/NetStreamFfmpeg.cpp    3 Jun 2008 16:21:38 -0000       1.141
@@ -61,17 +61,6 @@
 // Define the following macro to have decoding activity  debugged
 //#define GNASH_DEBUG_DECODING
 
-namespace {
-
-// Used to free data in the AVPackets we create our self
-void avpacket_destruct(AVPacket* av)
-{
-       delete [] av->data;
-}
-
-} // anonymous namespace
-
-
 namespace gnash {
 
 
@@ -94,17 +83,13 @@
 
        m_unqueued_data(NULL),
 
-       _decoderBuffer(0),
-       _soundHandler(get_sound_handler())
+       _soundHandler(get_sound_handler()),
+       _mediaHandler(media::MediaHandler::get())
 {
-
-       ByteIOCxt.buffer = NULL;
 }
 
 NetStreamFfmpeg::~NetStreamFfmpeg()
 {
-       if ( _decoderBuffer ) delete [] _decoderBuffer;
-
        close(); // close will also detach from sound handler
 
        delete m_imageframe;
@@ -153,60 +138,6 @@
        delete m_unqueued_data;
        m_unqueued_data = NULL;
 
-       delete [] ByteIOCxt.buffer;
-
-}
-
-// ffmpeg callback function
-int 
-NetStreamFfmpeg::readPacket(void* opaque, boost::uint8_t* buf, int buf_size)
-{
-
-       NetStreamFfmpeg* ns = static_cast<NetStreamFfmpeg*>(opaque);
-
-       assert( ns->_inputStream.get() );
-       tu_file& in = *(ns->_inputStream);
-
-       size_t ret = in.read_bytes(static_cast<void*>(buf), buf_size);
-       ns->inputPos += ret; // what for ??
-       return ret;
-
-}
-
-// ffmpeg callback function
-offset_t 
-NetStreamFfmpeg::seekMedia(void *opaque, offset_t offset, int whence)
-{
-
-       NetStreamFfmpeg* ns = static_cast<NetStreamFfmpeg*>(opaque);
-
-       tu_file& in = *(ns->_inputStream);
-
-       // Offset is absolute new position in the file
-       if (whence == SEEK_SET)
-       {       
-               in.set_position(offset);
-               ns->inputPos = offset; // what for ?!
-
-       // New position is offset + old position
-       }
-       else if (whence == SEEK_CUR)
-       {
-               in.set_position(ns->inputPos + offset);
-               ns->inputPos = ns->inputPos + offset; // what for ?!
-
-       // New position is offset + end of file
-       }
-       else if (whence == SEEK_END)
-       {
-               // This is (most likely) a streamed file, so we can't seek to 
the end!
-               // Instead we seek to 50.000 bytes... seems to work fine...
-               in.set_position(50000);
-               ns->inputPos = 50000; // what for ?!
-
-       }
-
-       return ns->inputPos; // ah, thats why ! :/
 }
 
 void
@@ -287,10 +218,9 @@
                return;
        }
 
-       media::MediaHandler* mh = media::MediaHandler::get();
-       assert ( mh ); // caller should check this
+       assert ( _mediaHandler ); // caller should check this
 
-       _videoDecoder = mh->createVideoDecoder(*videoInfo);
+       _videoDecoder = _mediaHandler->createVideoDecoder(*videoInfo);
        if ( ! _videoDecoder.get() )
                log_error(_("Could not create video decoder for codec %d"), 
videoInfo->codec);
 }
@@ -307,40 +237,14 @@
                return;
        }
 
-       media::MediaHandler* mh = media::MediaHandler::get();
-       assert ( mh ); // caller should check this
+       assert ( _mediaHandler ); // caller should check this
 
-       _audioDecoder = mh->createAudioDecoder(*audioInfo);
+       _audioDecoder = _mediaHandler->createAudioDecoder(*audioInfo);
        if ( ! _audioDecoder.get() )
                log_error(_("Could not create audio decoder for codec %d"), 
audioInfo->codec);
 }
 
 
-/// Probe the stream and try to figure out what the format is.
-//
-/// @param ns the netstream to use for reading
-/// @return a pointer to the AVInputFormat structure containing
-///         information about the input format, or NULL.
-static AVInputFormat*
-probeStream(NetStreamFfmpeg* ns)
-{
-       boost::scoped_array<boost::uint8_t> buffer(new boost::uint8_t[2048]);
-
-       // Probe the file to detect the format
-       AVProbeData probe_data;
-       probe_data.filename = "";
-       probe_data.buf = buffer.get();
-       probe_data.buf_size = 2048;
-
-       if (ns->readPacket(ns, probe_data.buf, probe_data.buf_size) < 1)
-       {
-               log_error(_("Gnash could not read from movie url"));
-               return NULL;
-       }
-
-       return av_probe_input_format(&probe_data, 1);
-}
-
 bool
 NetStreamFfmpeg::startPlayback()
 {
@@ -349,14 +253,13 @@
 
        inputPos = 0;
 
-       media::MediaHandler* mh = media::MediaHandler::get();
-       if ( ! mh )
+       if ( ! _mediaHandler )
        {
                LOG_ONCE( log_error(_("No Media handler registered, can't "
                        "parse NetStream input")) );
                return false;
        }
-       m_parser = mh->createMediaParser(_inputStream);
+       m_parser = _mediaHandler->createMediaParser(_inputStream);
        assert(!_inputStream.get());
 
        if ( ! m_parser.get() )
@@ -384,29 +287,6 @@
 }
 
 
-/// Copy RGB data from a source raw_mediadata_t to a destination image::rgb.
-/// @param dst the destination image::rgb, which must already be initialized
-///            with a buffer of size of at least src.m_size.
-/// @param src the source raw_mediadata_t to copy data from. The m_size member
-///            of this structure must be initialized.
-/// @param width the width, in bytes, of a row of video data.
-static void
-rgbcopy(image::rgb* dst, media::raw_mediadata_t* src, int width)
-{
-  assert( src->m_size <= static_cast<boost::uint32_t>(dst->width() * 
dst->height() * 3) ); 
-
-  boost::uint8_t* dstptr = dst->data();
-
-  boost::uint8_t* srcptr = src->m_data;
-  boost::uint8_t* srcend = src->m_data + src->m_size;
-
-  while (srcptr < srcend) {
-    memcpy(dstptr, srcptr, width);
-    dstptr += dst->pitch();
-    srcptr += width;
-  }
-}
-
 #ifdef LOAD_MEDIA_IN_A_SEPARATE_THREAD
 // to be run in parser thread
 void NetStreamFfmpeg::parseAllInput(NetStreamFfmpeg* ns)
@@ -669,7 +549,6 @@
        boost::uint32_t pos = posSeconds*1000;
 
        long newpos = 0;
-       double timebase = 0;
 
        // We'll pause the clock source and mark decoders as buffering.
        // In this way, next advance won't find the source time to 
@@ -798,7 +677,7 @@
 
                boost::mutex::scoped_lock lock(_audioQueueMutex);
 
-               static const int bufferLimit = 20;
+               static const unsigned int bufferLimit = 20;
                if ( _audioQueue.size() > bufferLimit )
                {
                        // we won't buffer more then 'bufferLimit' frames in 
the queue

Index: server/asobj/NetStreamFfmpeg.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.h,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -b -r1.72 -r1.73
--- server/asobj/NetStreamFfmpeg.h      3 Jun 2008 16:11:45 -0000       1.72
+++ server/asobj/NetStreamFfmpeg.h      3 Jun 2008 16:21:39 -0000       1.73
@@ -53,19 +53,6 @@
 #include <cassert>
 
 
-// TODO: drop ffmpeg-specific stuff here ?
-#ifdef HAVE_FFMPEG_AVFORMAT_H
-extern "C" {
-#include <ffmpeg/avformat.h>
-}
-#endif
-
-#ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
-extern "C" {
-#include <libavformat/avformat.h>
-}
-#endif
-
 /// Uncomment the following to load media in a separate thread
 //#define LOAD_MEDIA_IN_A_SEPARATE_THREAD
 
@@ -73,6 +60,7 @@
 namespace gnash {
        namespace media {
                class sound_handler;
+               class MediaHandler;
        }
 }
 
@@ -98,7 +86,6 @@
        // Users:
        //      - ::advance (VM), itself locking
        //      - ::startPlayback() non locking but called by av_streamer which 
locks
-       //      - ::seekMedia() set as a callback with init_put_byte (??)
        //
        void seek(boost::uint32_t pos);
 
@@ -108,12 +95,6 @@
        // See dox in NetStream.h
        void advance();
 
-       // Used for ffmpeg data read and seek callbacks with non-FLV
-       static int readPacket(void* opaque, boost::uint8_t* buf, int buf_size);
-
-       // Used for ffmpeg data read and seek callbacks with non-FLV
-       static offset_t seekMedia(void *opaque, offset_t offset, int whence);
-
 #ifdef LOAD_MEDIA_IN_A_SEPARATE_THREAD
        /// The parsing thread. Sets up the decoder, and decodes.
        static void parseAllInput(NetStreamFfmpeg* ns);
@@ -305,14 +286,12 @@
        // there wasn't room for on its queue
        media::raw_mediadata_t* m_unqueued_data;
 
-       ByteIOContext ByteIOCxt;
-
-       // Decoder buffer
-       boost::uint8_t* _decoderBuffer;
-
        // Current sound handler
        media::sound_handler* _soundHandler;
 
+       // Current media handler
+       media::MediaHandler* _mediaHandler;
+
        /// Parse a chunk of input
        /// Currently blocks, ideally should parse as much
        /// as possible w/out blocking




reply via email to

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