[Top][All Lists]
[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: |
Mon, 12 May 2008 08:33:15 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 08/05/12 08:33:15
Modified files:
. : ChangeLog
libbase : FLVParser.cpp FLVParser.h
server/asobj : NetStreamFfmpeg.cpp
Log message:
* libbase/FLVParser.{cpp,h}: keep audio/video stream info object
by auto_ptr, fixing a memory leak. Have getVideoInfo/getAudioInfo
NOT transfer ownership, avoiding useless memory copies. Document
the functions.
* server/asobj/NetStreamFfmpeg.cpp: update uses of getVideoInfo and
getAudioInfo to not take ownership, change initFlv{Audio/Video}
statics to take FLVParser by ref, not pointer.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6585&r2=1.6586
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/FLVParser.cpp?cvsroot=gnash&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/FLVParser.h?cvsroot=gnash&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.cpp?cvsroot=gnash&r1=1.118&r2=1.119
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6585
retrieving revision 1.6586
diff -u -b -r1.6585 -r1.6586
--- ChangeLog 12 May 2008 08:15:05 -0000 1.6585
+++ ChangeLog 12 May 2008 08:33:14 -0000 1.6586
@@ -1,5 +1,15 @@
2008-05-12 Sandro Santilli <address@hidden>
+ * libbase/FLVParser.{cpp,h}: keep audio/video stream info object
+ by auto_ptr, fixing a memory leak. Have getVideoInfo/getAudioInfo
+ NOT transfer ownership, avoiding useless memory copies. Document
+ the functions.
+ * server/asobj/NetStreamFfmpeg.cpp: update uses of getVideoInfo and
+ getAudioInfo to not take ownership, change initFlv{Audio/Video}
+ statics to take FLVParser by ref, not pointer.
+
+2008-05-12 Sandro Santilli <address@hidden>
+
* libbase/FLVParser.{cpp,h}: more dox about utility classes,
rename FLVVideoFrame and FLVAudioFrame to FLVVideoFrameInfo
and FLVAudioFrameInfo as they don't contain the actual data,
Index: libbase/FLVParser.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/FLVParser.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- libbase/FLVParser.cpp 12 May 2008 08:15:07 -0000 1.34
+++ libbase/FLVParser.cpp 12 May 2008 08:33:15 -0000 1.35
@@ -489,16 +489,9 @@
if (!_video && _lastParsedPosition > 0) return NULL;
// Make sure that there are parsed some video frames
- while(_videoInfo == NULL && !_parsingComplete) {
- parseNextTag();
- }
-
- // If there are no video data return NULL
- if (_videoInfo == NULL) return NULL;
-
- FLVVideoInfo* info = new FLVVideoInfo(_videoInfo->codec,
_videoInfo->width, _videoInfo->height, _videoInfo->frameRate,
_videoInfo->duration);
- return info;
+ while( ! _parsingComplete && !_videoInfo.get() ) parseNextTag();
+ return _videoInfo.get(); // may be null
}
FLVAudioInfo* FLVParser::getAudioInfo()
@@ -510,16 +503,12 @@
if (!_audio && _lastParsedPosition > 0) return NULL;
// Make sure that there are parsed some audio frames
- while(_audioInfo == NULL && !_parsingComplete) {
+ while (!_parsingComplete && ! _audioInfo.get() )
+ {
parseNextTag();
}
- // If there are no audio data return NULL
- if (_audioInfo == NULL) return NULL;
-
- FLVAudioInfo* info = new FLVAudioInfo(_audioInfo->codec,
_audioInfo->sampleRate, _audioInfo->sampleSize, _audioInfo->stereo,
_audioInfo->duration);
- return info;
-
+ return _audioInfo.get(); // may be null
}
bool FLVParser::isTimeLoaded(boost::uint32_t time)
@@ -597,7 +586,8 @@
// check for empty tag
if (bodyLength == 0) return true;
- if (tag[0] == AUDIO_TAG) {
+ if (tag[0] == AUDIO_TAG)
+ {
FLVAudioFrameInfo* frame = new FLVAudioFrameInfo;
frame->dataSize = bodyLength - 1;
frame->timestamp = timestamp;
@@ -606,7 +596,8 @@
// If this is the first audioframe no info about the
// audio format has been noted, so we do that now
- if (_audioInfo == NULL) {
+ if ( !_audioInfo.get() )
+ {
int samplerate = (tag[11] & 0x0C) >> 2;
if (samplerate == 0) samplerate = 5500;
else if (samplerate == 1) samplerate = 11000;
@@ -617,11 +608,13 @@
if (samplesize == 0) samplesize = 1;
else samplesize = 2;
- _audioInfo = new FLVAudioInfo((tag[11] & 0xf0) >> 4,
samplerate, samplesize, (tag[11] & 0x01) >> 0, 0);
+ _audioInfo.reset( new FLVAudioInfo((tag[11] & 0xf0) >>
4, samplerate, samplesize, (tag[11] & 0x01) >> 0, 0) );
}
- } else if (tag[0] == VIDEO_TAG) {
+ }
+ else if (tag[0] == VIDEO_TAG)
+ {
FLVVideoFrameInfo* frame = new FLVVideoFrameInfo;
frame->dataSize = bodyLength - 1;
frame->timestamp = timestamp;
@@ -631,7 +624,8 @@
// If this is the first videoframe no info about the
// video format has been noted, so we do that now
- if (_videoInfo == NULL) {
+ if ( ! _videoInfo.get() )
+ {
boost::uint16_t codec = (tag[11] & 0x0f) >> 0;
// Set standard guessed size...
boost::uint16_t width = 320;
@@ -691,7 +685,7 @@
}
// Create the videoinfo
- _videoInfo = new FLVVideoInfo(codec, width, height, 0
/*frameRate*/, 0 /*duration*/);
+ _videoInfo.reset( new FLVVideoInfo(codec, width,
height, 0 /*frameRate*/, 0 /*duration*/) );
}
} else if (tag[0] == META_TAG) {
Index: libbase/FLVParser.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/FLVParser.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- libbase/FLVParser.h 12 May 2008 08:15:07 -0000 1.28
+++ libbase/FLVParser.h 12 May 2008 08:33:15 -0000 1.29
@@ -27,6 +27,7 @@
#include "dsodefs.h"
#include <vector>
#include <boost/thread/mutex.hpp>
+#include <memory>
namespace gnash {
@@ -246,10 +247,14 @@
///
bool parsingCompleted() const { return _parsingComplete; }
- /// Returns a FLVVideoInfo class about the videostream
+ /// Returns information about video in the stream.
//
/// Locks the _mutex
///
+ /// The returned object is owned by the FLVParser object.
+ /// Can return NULL if video contains NO video frames.
+ /// Will block till either parsing finished or a video frame is found.
+ ///
FLVVideoInfo* getVideoInfo();
/// Returns a FLVAudioInfo class about the audiostream
@@ -326,6 +331,8 @@
/// Returns true if something was parsed, false otherwise.
/// Sets _parsingComplete=true on end of file.
///
+ /// TODO: make public (seems useful for an external parsing driver)
+ ///
bool parseNextTag();
/// Parses the header of the file
@@ -359,11 +366,11 @@
/// Whether the parsing is complete or not
bool _parsingComplete;
- /// Info about the video stream
- FLVVideoInfo* _videoInfo;
+ /// Info about the video stream (if any)
+ std::auto_ptr<FLVVideoInfo> _videoInfo;
- /// Info about the audio stream
- FLVAudioInfo* _audioInfo;
+ /// Info about the audio stream (if any)
+ std::auto_ptr<FLVAudioInfo> _audioInfo;
/// Last audio frame returned
size_t _nextAudioFrame;
Index: server/asobj/NetStreamFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.cpp,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -b -r1.118 -r1.119
--- server/asobj/NetStreamFfmpeg.cpp 12 May 2008 08:15:08 -0000 1.118
+++ server/asobj/NetStreamFfmpeg.cpp 12 May 2008 08:33:15 -0000 1.119
@@ -304,11 +304,11 @@
/// @return the initialized context, or NULL on failure. The caller
/// is responsible for deallocating this pointer.
static AVCodecContext*
-initFlvVideo(FLVParser* parser)
+initFlvVideo(FLVParser& parser)
{
// Get video info from the parser
- std::auto_ptr<FLVVideoInfo> videoInfo( parser->getVideoInfo() );
- if (!videoInfo.get())
+ FLVVideoInfo* videoInfo = parser.getVideoInfo();
+ if (!videoInfo)
{
return NULL;
}
@@ -340,11 +340,11 @@
/// Like initFlvVideo, but for audio.
static AVCodecContext*
-initFlvAudio(FLVParser* parser)
+initFlvAudio(FLVParser& parser)
{
// Get audio info from the parser
- std::auto_ptr<FLVAudioInfo> audioInfo( parser->getAudioInfo() );
- if (!audioInfo.get())
+ FLVAudioInfo* audioInfo = parser.getAudioInfo();
+ if (!audioInfo)
{
return NULL;
}
@@ -441,14 +441,14 @@
avcodec_init();
avcodec_register_all();
- m_VCodecCtx = initFlvVideo(m_parser.get());
+ m_VCodecCtx = initFlvVideo(*m_parser);
if (!m_VCodecCtx)
{
log_error(_("Failed to initialize FLV video codec"));
return false;
}
- m_ACodecCtx = initFlvAudio(m_parser.get());
+ m_ACodecCtx = initFlvAudio(*m_parser);
if (!m_ACodecCtx)
{
log_error(_("Failed to initialize FLV audio codec"));
- [Gnash-commit] gnash ChangeLog libbase/FLVParser.cpp libbase/F..., Sandro Santilli, 2008/05/09
- [Gnash-commit] gnash ChangeLog libbase/FLVParser.cpp libbase/F..., Sandro Santilli, 2008/05/11
- [Gnash-commit] gnash ChangeLog libbase/FLVParser.cpp libbase/F..., Sandro Santilli, 2008/05/11
- [Gnash-commit] gnash ChangeLog libbase/FLVParser.cpp libbase/F..., Sandro Santilli, 2008/05/12
- [Gnash-commit] gnash ChangeLog libbase/FLVParser.cpp libbase/F...,
Sandro Santilli <=
- [Gnash-commit] gnash ChangeLog libbase/FLVParser.cpp libbase/F..., Sandro Santilli, 2008/05/23
- [Gnash-commit] gnash ChangeLog libbase/FLVParser.cpp libbase/F..., Sandro Santilli, 2008/05/24
- [Gnash-commit] gnash ChangeLog libbase/FLVParser.cpp libbase/F..., Sandro Santilli, 2008/05/27