gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/NetStream.cpp serv...


From: Tomas Groth
Subject: [Gnash-commit] gnash ChangeLog server/asobj/NetStream.cpp serv...
Date: Thu, 31 May 2007 15:52:29 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Tomas Groth <tgc>       07/05/31 15:52:29

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

Log message:
        * server/asobj/NetStream*.{h,cpp}: Always use milliseconds internally.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3425&r2=1.3426
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStream.cpp?cvsroot=gnash&r1=1.60&r2=1.61
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStream.h?cvsroot=gnash&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.cpp?cvsroot=gnash&r1=1.79&r2=1.80
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.h?cvsroot=gnash&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamGst.cpp?cvsroot=gnash&r1=1.51&r2=1.52
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamGst.h?cvsroot=gnash&r1=1.26&r2=1.27

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3425
retrieving revision 1.3426
diff -u -b -r1.3425 -r1.3426
--- ChangeLog   31 May 2007 15:40:44 -0000      1.3425
+++ ChangeLog   31 May 2007 15:52:28 -0000      1.3426
@@ -1,3 +1,7 @@
+2007-05-31 Tomas Groth Christensen <address@hidden>
+
+       * server/asobj/NetStream*.{h,cpp}: Always use milliseconds internally.
+
 2007-05-31  Rob Savoye  <address@hidden>
 
        * configure.ac: Change renderer default to opengl.

Index: server/asobj/NetStream.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStream.cpp,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -b -r1.60 -r1.61
--- server/asobj/NetStream.cpp  31 May 2007 14:35:18 -0000      1.60
+++ server/asobj/NetStream.cpp  31 May 2007 15:52:28 -0000      1.61
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: NetStream.cpp,v 1.60 2007/05/31 14:35:18 strk Exp $ */
+/* $Id: NetStream.cpp,v 1.61 2007/05/31 15:52:28 tgc Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -67,7 +67,7 @@
        as_object(getNetStreamInterface()),
        _netCon(NULL),
        m_env(NULL),
-       m_bufferTime(1000), // The default size needed to begin playback of 
media is 1000 miliseconds
+       m_bufferTime(100), // The default size needed to begin playback of 
media is 100 miliseconds
        m_videoFrameFormat(gnash::render::videoFrameFormat()),
        m_newFrameReady(false),
        m_go(false),
@@ -164,7 +164,7 @@
        {
                time = fn.arg(0).to_number(&fn.env());
        }
-       ns->seek(time);
+       ns->seek(static_cast<uint32_t>(time*1000.0));
 
        return as_value();
 }
@@ -281,7 +281,7 @@
        boost::intrusive_ptr<NetStream> ns = ensureType<NetStream>(fn.this_ptr);
 
        assert(fn.nargs == 0); // we're a getter
-       return as_value(double(ns->time()));
+       return as_value(double(ns->time()/1000.0));
 }
 
 // Both a getter and a (do-nothing) setter for bytesLoaded
@@ -528,7 +528,7 @@
        if (m_parser.get() == NULL) return 0;
 
        // m_parser will lock a mutex
-       return m_parser->getBufferLength();
+       return m_parser->getBufferLength()/1000;
 }
 
 bool

Index: server/asobj/NetStream.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStream.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- server/asobj/NetStream.h    30 May 2007 15:12:28 -0000      1.43
+++ server/asobj/NetStream.h    31 May 2007 15:52:28 -0000      1.44
@@ -19,7 +19,7 @@
 //
 //
 
-/*  $Id: NetStream.h,v 1.43 2007/05/30 15:12:28 strk Exp $ */
+/*  $Id: NetStream.h,v 1.44 2007/05/31 15:52:28 tgc Exp $ */
 
 #ifndef __NETSTREAM_H__
 #define __NETSTREAM_H__
@@ -186,15 +186,15 @@
        /// Seek in the media played by the current instance
        //
        /// @param position
-       ///     Defines in seconds where to seek to
+       ///     Defines in milliseconds where to seek to
        ///
-       virtual void seek(double /*pos*/){}
+       virtual void seek(uint32_t /*pos*/){}
 
        /// Tells where the playhead currently is
        //
-       /// @return The time in seconds of the current playhead position
+       /// @return The time in milliseconds of the current playhead position
        ///
-       virtual int64_t time() { return 0; }
+       virtual int32_t time() { return 0; }
 
        /// Called at the SWF framerate. Used to process queued status messages
        /// and (re)start after a buffering pause. In NetStreamFfmpeg it is also
@@ -227,7 +227,7 @@
        ///
        void setBufferTime(uint32_t time);
 
-       /// Returns what the buffer time has been set to. (1000 miliseconds is 
default)
+       /// Returns what the buffer time has been set to. (100 miliseconds is 
default)
        //
        /// @return The size of the buffer in milliseconds.
        ///

Index: server/asobj/NetStreamFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.cpp,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -b -r1.79 -r1.80
--- server/asobj/NetStreamFfmpeg.cpp    31 May 2007 14:35:18 -0000      1.79
+++ server/asobj/NetStreamFfmpeg.cpp    31 May 2007 15:52:28 -0000      1.80
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: NetStreamFfmpeg.cpp,v 1.79 2007/05/31 14:35:18 strk Exp $ */
+/* $Id: NetStreamFfmpeg.cpp,v 1.80 2007/05/31 15:52:28 tgc Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -645,7 +645,7 @@
        ns->m_last_audio_timestamp = 0;
        ns->m_current_timestamp = 0;
 
-       ns->m_start_clock = tu_timer::ticks_to_seconds(tu_timer::get_ticks());
+       ns->m_start_clock = tu_timer::get_ticks();
 
        ns->m_unqueued_data = NULL;
 
@@ -847,8 +847,8 @@
                // set presentation timestamp
                if (packet->dts != static_cast<signed long>(AV_NOPTS_VALUE))
                {
-                       if (!m_isFLV) raw->m_pts = 
as_double(m_audio_stream->time_base) * packet->dts;
-                       else raw->m_pts = as_double(m_ACodecCtx->time_base) * 
packet->dts;
+                       if (!m_isFLV) raw->m_pts = 
static_cast<uint32_t>(as_double(m_audio_stream->time_base) * packet->dts * 
1000.0);
+                       else raw->m_pts = 
static_cast<uint32_t>((as_double(m_ACodecCtx->time_base) * packet->dts) * 
1000.0);
                }
 
                if (raw->m_pts != 0)
@@ -862,9 +862,9 @@
                }
 
                // update video clock for next frame
-               double frame_delay;
-               if (!m_isFLV) frame_delay = 
as_double(m_audio_stream->codec->time_base);
-               else frame_delay = 
static_cast<double>(m_parser->audioFrameDelay())/1000.0;
+               uint32_t frame_delay;
+               if (!m_isFLV) frame_delay = 
static_cast<uint32_t>((as_double(m_audio_stream->time_base) * packet->dts) * 
1000.0);
+               else frame_delay = m_parser->audioFrameDelay();
 
                m_last_audio_timestamp += frame_delay;
 
@@ -918,8 +918,8 @@
                // set presentation timestamp
                if (packet->dts != static_cast<signed long>(AV_NOPTS_VALUE))
                {
-                       if (!m_isFLV)   video->m_pts = 
as_double(m_video_stream->time_base) * packet->dts;
-                       else video->m_pts = as_double(m_VCodecCtx->time_base) * 
packet->dts;
+                       if (!m_isFLV)   video->m_pts = 
static_cast<uint32_t>((as_double(m_video_stream->time_base) * packet->dts) * 
1000.0);
+                       else video->m_pts = 
static_cast<uint32_t>((as_double(m_VCodecCtx->time_base) * packet->dts) * 
1000.0);
                }
 
                if (video->m_pts != 0)
@@ -933,12 +933,12 @@
                }
 
                // update video clock for next frame
-               double frame_delay;
-               if (!m_isFLV) frame_delay = 
as_double(m_video_stream->codec->time_base);
-               else frame_delay = 
static_cast<double>(m_parser->videoFrameDelay())/1000.0;
+               uint32_t frame_delay;
+               if (!m_isFLV) frame_delay = 
static_cast<uint32_t>(as_double(m_video_stream->codec->time_base) * 1000.0);
+               else frame_delay = m_parser->videoFrameDelay();
 
                // for MPEG2, the frame can be repeated, so we update the clock 
accordingly
-               frame_delay += m_Frame->repeat_pict * (frame_delay * 0.5);
+               frame_delay += static_cast<uint32_t>(m_Frame->repeat_pict * 
(frame_delay * 0.5) * 1000.0);
 
                m_last_video_timestamp += frame_delay;
 
@@ -1053,7 +1053,7 @@
 }
 
 void
-NetStreamFfmpeg::seek(double pos)
+NetStreamFfmpeg::seek(uint32_t pos)
 {
        long newpos = 0;
        double timebase = 0;
@@ -1061,13 +1061,14 @@
        // Seek to new position
        if (m_isFLV) {
                if (m_parser.get()) {
-                       newpos = 
m_parser->seek(static_cast<uint32_t>(pos*1000));
+                       newpos = m_parser->seek(pos);
                } else {
                        newpos = 0;
                }
        } else if (m_FormatCtx) {
 
-               timebase = 
static_cast<double>(m_FormatCtx->streams[m_video_index]->time_base.num) / 
static_cast<double>(m_FormatCtx->streams[m_video_index]->time_base.den);
+               AVStream* videostream = m_FormatCtx->streams[m_video_index];
+               timebase = static_cast<double>(videostream->time_base.num / 
videostream->time_base.den);
                newpos = static_cast<long>(pos / timebase);
                
                if (av_seek_frame(m_FormatCtx, m_video_index, newpos, 0) < 0) {
@@ -1084,16 +1085,16 @@
                m_last_audio_timestamp = 0;
                m_current_timestamp = 0;
 
-               m_start_clock = 
tu_timer::ticks_to_seconds(tu_timer::get_ticks());
+               m_start_clock = tu_timer::get_ticks();
 
        } else if (m_isFLV) {
-               double newtime = static_cast<double>(newpos) / 1000.0;
-               if (m_VCodecCtx) m_start_clock += (m_last_video_timestamp - 
newtime) / 1000.0;
-               else m_start_clock += (m_last_audio_timestamp - newtime) / 
1000.0;
-
-               if (m_ACodecCtx) m_last_audio_timestamp = newtime;
-               if (m_VCodecCtx) m_last_video_timestamp = newtime;
-               m_current_timestamp = newtime;
+
+               if (m_VCodecCtx) m_start_clock += m_last_video_timestamp - 
newpos;
+               else m_start_clock += m_last_audio_timestamp - newpos;
+
+               if (m_ACodecCtx) m_last_audio_timestamp = newpos;
+               if (m_VCodecCtx) m_last_video_timestamp = newpos;
+               m_current_timestamp = newpos;
        } else {
                AVPacket Packet;
                av_init_packet(&Packet);
@@ -1110,12 +1111,12 @@
 
                av_free_packet(&Packet);
                av_seek_frame(m_FormatCtx, m_video_index, newpos, 0);
+               uint32_t newtime_ms = static_cast<int32_t>(newtime / 1000.0);
+               m_start_clock += m_last_audio_timestamp - newtime_ms;
 
-               m_start_clock += (m_last_audio_timestamp - newtime) / 1000.0;
-
-               m_last_audio_timestamp = newtime;
-               m_last_video_timestamp = newtime;
-               m_current_timestamp = newtime;
+               m_last_audio_timestamp = newtime_ms;
+               m_last_video_timestamp = newtime_ms;
+               m_current_timestamp = newtime_ms;
        }
        
        // Flush the queues
@@ -1158,15 +1159,15 @@
                }
 
                // Caclulate the current time
-               double current_clock;
+               uint32_t current_clock;
                if (m_ACodecCtx && get_sound_handler()) {
                        current_clock = m_current_timestamp;
                } else {
-                       current_clock = 
(tu_timer::ticks_to_seconds(tu_timer::get_ticks()) - m_start_clock)*1000;
+                       current_clock = tu_timer::get_ticks() - m_start_clock;
                        m_current_timestamp = current_clock;
                }
 
-               double video_clock = video->m_pts;
+               uint32_t video_clock = video->m_pts;
 
                // If the timestamp on the videoframe is smaller than the
                // current time, we put it in the output image.
@@ -1226,7 +1227,7 @@
        //    miliseconds).
        // 2) The buffer has be "starved" (not being filled as quickly as 
needed),
        //    and we then wait until the buffer contains some data (1 sec) 
again.
-       if (m_go && m_pause && m_start_onbuffer && m_parser.get() && 
m_parser->isTimeLoaded(uint32_t(m_current_timestamp*1000)+m_bufferTime))
+       if (m_go && m_pause && m_start_onbuffer && m_parser.get() && 
m_parser->isTimeLoaded(m_current_timestamp+m_bufferTime))
        {
 #ifdef GNASH_DEBUG_STATUS
                log_debug("(advance): setting buffer full");
@@ -1247,15 +1248,15 @@
        refreshVideoFrame();
 }
 
-int64_t
+int32_t
 NetStreamFfmpeg::time()
 {
 
        if (m_FormatCtx && m_FormatCtx->nb_streams > 0) {
                double time = (double)m_FormatCtx->streams[0]->time_base.num / 
(double)m_FormatCtx->streams[0]->time_base.den * 
(double)m_FormatCtx->streams[0]->cur_dts;
-               return static_cast<int64_t>(time);
+               return static_cast<int32_t>(time);
        } else if (m_isFLV) {
-               return static_cast<int64_t>(m_current_timestamp);
+               return m_current_timestamp;
        } else {
                return 0;
        }
@@ -1272,7 +1273,7 @@
        m_pause = true;
 
        // Save the current time so we later can tell how long the pause lasted
-       m_time_of_pause = tu_timer::ticks_to_seconds(tu_timer::get_ticks());
+       m_time_of_pause = tu_timer::get_ticks();
 }
 
 void NetStreamFfmpeg::unpauseDecoding()
@@ -1284,11 +1285,11 @@
        m_pause = false;        
 
        if (m_current_timestamp == 0) {
-               m_start_clock = 
tu_timer::ticks_to_seconds(tu_timer::get_ticks());
+               m_start_clock = tu_timer::get_ticks();
        } else {
                // Add the paused time to the start time so that the playhead 
doesn't
                // noticed that we have been paused
-               m_start_clock += 
tu_timer::ticks_to_seconds(tu_timer::get_ticks()) - m_time_of_pause;
+               m_start_clock += tu_timer::get_ticks() - m_time_of_pause;
        }
 
        // Notify the decode thread/loop that we are running again

Index: server/asobj/NetStreamFfmpeg.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- server/asobj/NetStreamFfmpeg.h      30 May 2007 15:12:28 -0000      1.43
+++ server/asobj/NetStreamFfmpeg.h      31 May 2007 15:52:28 -0000      1.44
@@ -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: NetStreamFfmpeg.h,v 1.43 2007/05/30 15:12:28 strk Exp $ */
+/* $Id: NetStreamFfmpeg.h,v 1.44 2007/05/31 15:52:28 tgc Exp $ */
 
 #ifndef __NETSTREAMFFMPEG_H__
 #define __NETSTREAMFFMPEG_H__
@@ -70,7 +70,7 @@
        uint32_t m_size;
        uint8_t* m_data;
        uint8_t* m_ptr;
-       double m_pts;   // presentation timestamp in sec
+       uint32_t m_pts; // presentation timestamp in millisec
 };
 
 /// Threadsafe elements-owning queue
@@ -259,9 +259,9 @@
        ///     - ::startPlayback() non locking but called by av_streamer which 
locks
        ///     - ::seekMedia() set as a callback with init_put_byte (??)
        ///
-       void seek(double pos);
+       void seek(uint32_t pos);
 
-       int64_t time();
+       int32_t time();
 
        // Locks decoding_mutex
        void advance();
@@ -374,21 +374,21 @@
        boost::condition decode_wait;
 
        // The timestamp of the last decoded video frame, in seconds.
-       volatile double m_last_video_timestamp;
+       volatile uint32_t m_last_video_timestamp;
 
        // The timestamp of the last decoded audio frame, in seconds.
-       volatile double m_last_audio_timestamp;
+       volatile uint32_t m_last_audio_timestamp;
 
        // The timestamp of the last played audio (default) or video (if no 
audio) frame.
        // Misured in seconds.
-       double m_current_timestamp;
+       uint32_t m_current_timestamp;
 
        // The queues of audio and video data.
        multithread_queue <raw_mediadata_t*> m_qaudio;
        multithread_queue <raw_mediadata_t*> m_qvideo;
 
        // The time we started playing in seconds (since VM start ?)
-       volatile double m_start_clock;
+       volatile uint64_t m_start_clock;
 
        // When the queues are full, this is where we keep the audio/video frame
        // there wasn't room for on its queue
@@ -397,7 +397,7 @@
        ByteIOContext ByteIOCxt;
 
        // Time of when pause started, in seconds since VM started
-       double m_time_of_pause;
+       volatile uint64_t m_time_of_pause;
 };
 
 } // gnash namespace

Index: server/asobj/NetStreamGst.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamGst.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- server/asobj/NetStreamGst.cpp       30 May 2007 12:18:49 -0000      1.51
+++ server/asobj/NetStreamGst.cpp       31 May 2007 15:52:28 -0000      1.52
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: NetStreamGst.cpp,v 1.51 2007/05/30 12:18:49 strk Exp $ */
+/* $Id: NetStreamGst.cpp,v 1.52 2007/05/31 15:52:28 tgc Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -951,11 +951,11 @@
 }
 
 void
-NetStreamGst::seek(double pos)
+NetStreamGst::seek(uint32_t pos)
 {
        if (!pipeline) {
                if (m_parser.get())  {
-                       m_parser->seek(static_cast<uint32_t>(pos*1000));
+                       m_parser->seek(pos);
                        m_clock_offset = 0;
                }
                return;
@@ -963,7 +963,7 @@
 
        if (m_isFLV) {
                assert(m_parser.get()); // why assumed here and not above ?
-               uint32_t newpos = 
m_parser->seek(static_cast<uint32_t>(pos*1000));
+               uint32_t newpos = m_parser->seek(pos);
                GstClock* clock = GST_ELEMENT_CLOCK(pipeline);
                uint64_t currenttime = gst_clock_get_time (clock);
                gst_object_unref(clock);
@@ -972,7 +972,7 @@
 
        } else {
                if (!gst_element_seek (pipeline, 1.0, GST_FORMAT_TIME, 
GST_SEEK_FLAG_FLUSH,
-                       GST_SEEK_TYPE_SET, GST_SECOND * static_cast<long>(pos),
+                       GST_SEEK_TYPE_SET, GST_MSECOND * pos,
                        GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) {
                        log_error("Gstreamer seek failed");
                        setStatus(invalidTime);
@@ -1061,7 +1061,7 @@
        processStatusNotifications();
 }
 
-int64_t
+int32_t
 NetStreamGst::time()
 {
 
@@ -1075,9 +1075,9 @@
        ret = gst_element_get_state (GST_ELEMENT (pipeline), &current, 
&pending, 0);
 
        if (current != GST_STATE_NULL && gst_element_query_position (pipeline, 
&fmt, &pos)) {
-               pos = pos / 1000000000;
+               pos = pos / 1000000;
 
-               return pos - m_clock_offset/1000;
+               return pos - m_clock_offset;
        } else {
                return 0;
        }

Index: server/asobj/NetStreamGst.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamGst.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- server/asobj/NetStreamGst.h 28 May 2007 19:27:20 -0000      1.26
+++ server/asobj/NetStreamGst.h 31 May 2007 15:52:29 -0000      1.27
@@ -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: NetStreamGst.h,v 1.26 2007/05/28 19:27:20 tgc Exp $ */
+/* $Id: NetStreamGst.h,v 1.27 2007/05/31 15:52:29 tgc Exp $ */
 
 #ifndef __NETSTREAMGST_H__
 #define __NETSTREAMGST_H__
@@ -53,8 +53,8 @@
        void close();
        void pause(int mode);
        void play(const std::string& source);
-       void seek(double pos);
-       int64_t time();
+       void seek(uint32_t pos);
+       int32_t time();
        void advance();
 
        // Used for gstreamer data read and seek callbacks




reply via email to

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