[Top][All Lists]
[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: |
Wed, 04 Jun 2008 19:26:33 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 08/06/04 19:26:33
Modified files:
. : ChangeLog
server/asobj : NetStreamFfmpeg.cpp
libmedia/ffmpeg: MediaParserFfmpeg.cpp MediaParserFfmpeg.h
Log message:
* server/asobj/NetStreamFfmpeg.cpp (pushDecodedAudioFrames):
do nothing if no audio decoder is available.
* libmedia/ffmpeg/MediaParserFfmpeg.{cpp,h}:
Implement nextAudioFrameTimestamp and nextVideoFrameTimestamp.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6817&r2=1.6818
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.cpp?cvsroot=gnash&r1=1.142&r2=1.143
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/MediaParserFfmpeg.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/ffmpeg/MediaParserFfmpeg.h?cvsroot=gnash&r1=1.4&r2=1.5
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6817
retrieving revision 1.6818
diff -u -b -r1.6817 -r1.6818
--- ChangeLog 4 Jun 2008 17:05:25 -0000 1.6817
+++ ChangeLog 4 Jun 2008 19:26:32 -0000 1.6818
@@ -1,5 +1,12 @@
2008-06-04 Sandro Santilli <address@hidden>
+ * server/asobj/NetStreamFfmpeg.cpp (pushDecodedAudioFrames):
+ do nothing if no audio decoder is available.
+ * libmedia/ffmpeg/MediaParserFfmpeg.{cpp,h}:
+ Implement nextAudioFrameTimestamp and nextVideoFrameTimestamp.
+
+2008-06-04 Sandro Santilli <address@hidden>
+
* libmedia/ffmpeg/MediaParserFfmpeg.{cpp,h}: implement
getBufferLength; reduce chunk size for reads; modify
getBytesLoaded to be immune to seek backs; don't check
Index: server/asobj/NetStreamFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.cpp,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -b -r1.142 -r1.143
--- server/asobj/NetStreamFfmpeg.cpp 4 Jun 2008 14:06:57 -0000 1.142
+++ server/asobj/NetStreamFfmpeg.cpp 4 Jun 2008 19:26:33 -0000 1.143
@@ -642,6 +642,9 @@
{
assert(m_parser.get());
+ // nothing to do if we don't have an audio decoder
+ if ( ! _audioDecoder.get() ) return;
+
bool consumed = false;
boost::uint64_t nextTimestamp;
Index: libmedia/ffmpeg/MediaParserFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/MediaParserFfmpeg.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- libmedia/ffmpeg/MediaParserFfmpeg.cpp 4 Jun 2008 17:05:26 -0000
1.4
+++ libmedia/ffmpeg/MediaParserFfmpeg.cpp 4 Jun 2008 19:26:33 -0000
1.5
@@ -104,10 +104,27 @@
}
bool
-MediaParserFfmpeg::nextVideoFrameTimestamp(boost::uint64_t& /*ts*/)
+MediaParserFfmpeg::nextVideoFrameTimestamp(boost::uint64_t& ts)
{
- LOG_ONCE( log_unimpl("%s", __PRETTY_FUNCTION__) );
+ // If there is no video in this stream return NULL
+ if (!_videoStream) return false;
+
+ // Make sure that there are parsed enough frames to return the need
frame
+ while(_videoFrames.size() <= _nextVideoFrame && !_parsingComplete)
+ {
+ if (!parseNextFrame()) break;
+ }
+
+ // If the needed frame can't be parsed (EOF reached) return NULL
+ if (_videoFrames.empty() || _videoFrames.size() <= _nextVideoFrame)
+ {
+ //gnash::log_debug("The needed frame (%d) can't be parsed (EOF
reached)", _lastVideoFrame);
return false;
+ }
+
+ VideoFrameInfo* info = _videoFrames[_nextVideoFrame];
+ ts = info->timestamp;
+ return true;
}
std::auto_ptr<EncodedVideoFrame>
@@ -119,10 +136,27 @@
}
bool
-MediaParserFfmpeg::nextAudioFrameTimestamp(boost::uint64_t& /*ts*/)
+MediaParserFfmpeg::nextAudioFrameTimestamp(boost::uint64_t& ts)
{
- LOG_ONCE( log_unimpl("%s", __PRETTY_FUNCTION__) );
+ // If there is no audio in this stream return NULL
+ if (!_audioStream) return false;
+
+ // Make sure that there are parsed enough frames to return the need
frame
+ while(_audioFrames.size() <= _nextAudioFrame && !_parsingComplete)
+ {
+ if (!parseNextFrame()) break;
+ }
+
+ // If the needed frame can't be parsed (EOF reached) return NULL
+ if (_audioFrames.empty() || _audioFrames.size() <= _nextAudioFrame)
+ {
+ //gnash::log_debug("The needed frame (%d) can't be parsed (EOF
reached)", _lastAudioFrame);
return false;
+ }
+
+ AudioFrameInfo* info = _audioFrames[_nextAudioFrame];
+ ts = info->timestamp;
+ return true;
}
std::auto_ptr<EncodedAudioFrame>
@@ -137,16 +171,13 @@
VideoInfo*
MediaParserFfmpeg::getVideoInfo()
{
- //VideoInfo(int codeci, boost::uint16_t widthi, boost::uint16_t
heighti, boost::uint16_t frameRatei, boost::uint64_t durationi, codecType typei)
- LOG_ONCE( log_unimpl("%s", __PRETTY_FUNCTION__) );
- return 0;
+ return _videoInfo.get();
}
AudioInfo*
MediaParserFfmpeg::getAudioInfo()
{
- LOG_ONCE( log_unimpl("%s", __PRETTY_FUNCTION__) );
- return 0;
+ return _audioInfo.get();
}
boost::uint32_t
@@ -210,8 +241,8 @@
boost::int64_t offset = packet.pos;
if ( offset < 0 )
{
- log_error("Unknown offset of video frame, what to use here ?");
- return false;
+ LOG_ONCE(log_debug("Unknown offset of video frame, should we
pretend we know ? or rely on ffmpeg seeking ? I guess the latter will do for a
start."));
+ //return false;
}
VideoFrameInfo* info = new VideoFrameInfo;
@@ -245,7 +276,7 @@
boost::int64_t offset = packet.pos;
if ( offset < 0 )
{
- log_error("Unknown offset of audio frame, should we pretend we
know ? or rely on ffmpeg seeking ? I guess the latter will do for a start.");
+ LOG_ONCE(log_debug("Unknown offset of audio frame, should we
pretend we know ? or rely on ffmpeg seeking ? I guess the latter will do for a
start."));
//return false;
}
@@ -264,7 +295,7 @@
{
if ( _parsingComplete )
{
- log_debug("MediaParserFfmpeg::parseNextFrame: parsing complete,
nothing to do");
+ //log_debug("MediaParserFfmpeg::parseNextFrame: parsing
complete, nothing to do");
return false;
}
@@ -272,9 +303,9 @@
AVPacket packet;
- log_debug("av_read_frame call");
+ //log_debug("av_read_frame call");
int rc = av_read_frame(_formatCtx, &packet);
- log_debug("av_read_frame returned %d", rc);
+ //log_debug("av_read_frame returned %d", rc);
if ( rc < 0 )
{
log_error(_("MediaParserFfmpeg::parseNextChunk: Problems
parsing next frame"));
@@ -330,6 +361,10 @@
MediaParserFfmpeg::MediaParserFfmpeg(std::auto_ptr<tu_file> stream)
:
MediaParser(stream),
+ _videoFrames(),
+ _nextVideoFrame(0),
+ _audioFrames(),
+ _nextAudioFrame(0),
_inputFmt(0),
_formatCtx(0),
_videoStreamIndex(-1),
@@ -397,6 +432,12 @@
break;
}
}
+
+ // TODO: create _videoInfo and _audioInfo here ...
+ //VideoInfo(int codeci, boost::uint16_t widthi, boost::uint16_t
heighti, boost::uint16_t frameRatei, boost::uint64_t durationi, codecType typei)
+ if ( _videoStream) LOG_ONCE( log_unimpl("VideoInfo from _videoStream")
);
+ if ( _audioStream) LOG_ONCE( log_unimpl("AudioInfo from _audioStream")
);
+
}
MediaParserFfmpeg::~MediaParserFfmpeg()
Index: libmedia/ffmpeg/MediaParserFfmpeg.h
===================================================================
RCS file: /sources/gnash/gnash/libmedia/ffmpeg/MediaParserFfmpeg.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- libmedia/ffmpeg/MediaParserFfmpeg.h 4 Jun 2008 17:05:26 -0000 1.4
+++ libmedia/ffmpeg/MediaParserFfmpeg.h 4 Jun 2008 19:26:33 -0000 1.5
@@ -149,6 +149,16 @@
///
VideoFrames _videoFrames;
+ /// Video frame cursor position
+ //
+ /// This is the video frame number that will
+ /// be referenced by nextVideoFrame and nextVideoFrameTimestamp
+ ///
+ size_t _nextVideoFrame;
+
+ /// Info about the video stream (if any)
+ std::auto_ptr<VideoInfo> _videoInfo;
+
// NOTE: AudioFrameInfo is a relatively small structure,
// chances are keeping by value here would reduce
// memory fragmentation with no big cost
@@ -159,6 +169,16 @@
/// Elements owned by this class.
AudioFrames _audioFrames;
+ /// Audio frame cursor position
+ //
+ /// This is the video frame number that will
+ /// be referenced by nextVideoFrame and nextVideoFrameTimestamp
+ ///
+ size_t _nextAudioFrame;
+
+ /// Info about the audio stream (if any)
+ std::auto_ptr<AudioInfo> _audioInfo;
+
/// Parse next media frame
//
/// @return false on error or eof, true otherwise