[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r9659: Cleanups in amf::Element clas
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r9659: Cleanups in amf::Element class and libmedia |
Date: |
Tue, 02 Sep 2008 12:47:54 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9659
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Tue 2008-09-02 12:47:54 +0200
message:
Cleanups in amf::Element class and libmedia
modified:
libamf/element.cpp
libamf/element.h
libmedia/FLVParser.cpp
libmedia/FLVParser.h
libmedia/MediaParser.cpp
libmedia/MediaParser.h
libmedia/ffmpeg/VideoDecoderFfmpeg.cpp
------------------------------------------------------------
revno: 9657.1.1
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-02 11:34:35 +0200
message:
Output operator for amf::Element, some const-correctness
modified:
libamf/element.cpp
libamf/element.h
------------------------------------------------------------
revno: 9657.1.2
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-02 11:37:42 +0200
message:
don't leak amf::Element on FLV metatag, dump content in debug message
modified:
libmedia/FLVParser.cpp
------------------------------------------------------------
revno: 9657.1.3
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-02 11:40:22 +0200
message:
fix memory leak
modified:
libmedia/ffmpeg/VideoDecoderFfmpeg.cpp
------------------------------------------------------------
revno: 9657.1.4
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-02 12:00:19 +0200
message:
drop unused classes
modified:
libmedia/FLVParser.h
------------------------------------------------------------
revno: 9657.1.5
committer: Sandro Santilli <address@hidden>
branch nick: mybranch
timestamp: Tue 2008-09-02 12:11:27 +0200
message:
drop obsoleted code
modified:
libmedia/MediaParser.cpp
libmedia/MediaParser.h
=== modified file 'libamf/element.cpp'
--- a/libamf/element.cpp 2008-08-13 19:21:46 +0000
+++ b/libamf/element.cpp 2008-09-02 09:34:35 +0000
@@ -281,7 +281,7 @@
};
size_t
-Element::getLength()
+Element::getLength() const
{
// GNASH_REPORT_FUNCTION;
if (_buffer) {
@@ -291,7 +291,7 @@
};
double
-Element::to_number()
+Element::to_number() const
{
// GNASH_REPORT_FUNCTION;
if (_buffer) {
@@ -302,7 +302,7 @@
}
const char *
-Element::to_string()
+Element::to_string() const
{
// GNASH_REPORT_FUNCTION;
if (_buffer) {
@@ -315,7 +315,7 @@
};
bool
-Element::to_bool()
+Element::to_bool() const
{
// GNASH_REPORT_FUNCTION;
if (_buffer) {
@@ -924,34 +924,34 @@
}
void
-Element::dump()
+Element::dump(std::ostream& os) const
{
// GNASH_REPORT_FUNCTION;
if (_name) {
- cerr << "AMF object name: " << _name << ", length is " << getLength()
<< endl;
+ os << "AMF object name: " << _name << ", length is " << getLength() <<
endl;
}
- cerr << astype_str[_type] << ": ";
+ os << astype_str[_type] << ": ";
switch (_type) {
case Element::NUMBER_AMF0:
- cerr << to_number() << endl;
+ os << to_number() << endl;
break;
case Element::BOOLEAN_AMF0:
- cerr << (to_bool() ? "true" : "false") << endl;
+ os << (to_bool() ? "true" : "false") << endl;
break;
case Element::STRING_AMF0:
- cerr << "(" << getLength() << " bytes): ";
+ os << "(" << getLength() << " bytes): ";
if (getLength() > 0) {
#ifdef HAVE_STRNDUP
char *term = strndup(to_string(), getLength());
#else
char *term = const_cast<char *>(to_string());
#endif
- cerr << "\t\"" << term << "\"" << endl;
+ os << "\t\"" << term << "\"" << endl;
} else {
- cerr << endl;
+ os << endl;
}
break;
case Element::OBJECT_AMF0:
@@ -977,7 +977,7 @@
break;
// case Element::VARIABLE:
// case Element::FUNCTION:
-// cerr << "# of properties in object: " << properties.size() << endl;
+// os << "# of properties in object: " << properties.size() << endl;
// for (size_t i=0; i< properties.size(); i++) {
// properties[i]->dump();
// }
@@ -992,11 +992,11 @@
// }
if (_properties.size() > 0) {
- vector<amf::Element *>::iterator ait;
- cerr << "# of Properties in object: " << _properties.size() << endl;
+ vector<amf::Element *>::const_iterator ait;
+ os << "# of Properties in object: " << _properties.size() << endl;
for (ait = _properties.begin(); ait != _properties.end(); ait++) {
- amf::Element *el = (*(ait));
- el->dump();
+ const amf::Element *el = (*(ait));
+ el->dump(os);
}
}
}
=== modified file 'libamf/element.h'
--- a/libamf/element.h 2008-06-18 16:19:22 +0000
+++ b/libamf/element.h 2008-09-02 09:34:35 +0000
@@ -21,6 +21,7 @@
#include <vector>
#include <string>
#include <cstring>
+#include <iostream> // for output operator
#include <boost/cstdint.hpp>
//#include "buffer.h"
@@ -174,7 +175,7 @@
Element *operator[](size_t x);
gnash::Network::byte_t *getData();
- size_t getLength();
+ size_t getLength() const;
Buffer *getBuffer() { return _buffer; };
// These are all accessors for the various output formats
@@ -183,9 +184,9 @@
// void setData(Buffer *buf) { _buffer = buf; };
// These accessors convert the raw data to a standard data type we can use.
- double to_number();
- const char *to_string();
- bool to_bool();
+ double to_number() const;
+ const char *to_string() const;
+ bool to_bool() const;
void *to_reference();
char *getName() const { return _name; };
@@ -204,7 +205,8 @@
size_t propertySize() { return _properties.size(); };
amf::Buffer *encode();
std::vector<Element *> getProperties() { return _properties; };
- void dump();
+ void dump() const { dump(std::cerr); }
+ void dump(std::ostream& os) const;
private:
void check_buffer(size_t size);
char *_name;
@@ -213,6 +215,12 @@
std::vector<Element *> _properties;
}; // end of class definition
+inline std::ostream& operator << (std::ostream& os, const Element& el)
+{
+ el.dump(os);
+ return os;
+}
+
} // end of amf namespace
=== modified file 'libmedia/FLVParser.cpp'
--- a/libmedia/FLVParser.cpp 2008-08-28 16:58:46 +0000
+++ b/libmedia/FLVParser.cpp 2008-09-02 09:37:42 +0000
@@ -455,14 +455,10 @@
FLV_META_TAG, bodyLength, actuallyRead);
return false;
}
- std::string dump = hexify(metaTag.get(), actuallyRead, false);
- log_unimpl("FLV MetaTag parser. Data: %s", dump);
amf::Flv flv;
- amf::Element *el = flv.decodeMetaData(metaTag.get(),
actuallyRead);
- el->dump();
- /*
- amf::AMF* amfParser = new amf::AMF();
- amfParser->parseAMF(metaTag);*/
+ std::auto_ptr<amf::Element> el (
flv.decodeMetaData(metaTag.get(), actuallyRead) );
+ log_unimpl("FLV MetaTag handling. Data: %s", *el);
+ //el->dump();
}
else
{
=== modified file 'libmedia/FLVParser.h'
--- a/libmedia/FLVParser.h 2008-06-23 17:09:55 +0000
+++ b/libmedia/FLVParser.h 2008-09-02 10:00:19 +0000
@@ -35,130 +35,6 @@
namespace gnash {
namespace media {
-/// Frame type
-enum FrameType {
-
- /// Video frame
- videoFrame,
-
- /// Audio frame
- audioFrame
-};
-
-/// \brief
-/// The FLVFrame class contains an encoded
-/// video or audio frame, its size, its
-/// timestamp,
-class FLVFrame
-{
-public:
- /// Size of the encoded frame
- boost::uint32_t dataSize;
-
- /// Encoded data
- boost::uint8_t* data;
-
- /// Frame timestamp, in milliseconds
- boost::uint64_t timestamp;
-
- /// Frame type (audio/video)
- FrameType type;
-};
-
-/// \brief
-/// The FLVAudioInfo class contains information about the audiostream
-/// in the FLV being parsed. The information stored is codec-type,
-/// samplerate, samplesize, stereo flag and duration.
-//
-/// TODO: drop
-///
-class FLVAudioInfo
-{
-public:
- FLVAudioInfo(boost::uint16_t codeci, boost::uint16_t sampleRatei,
boost::uint16_t sampleSizei, bool stereoi, boost::uint64_t durationi)
- : codec(codeci),
- sampleRate(sampleRatei),
- sampleSize(sampleSizei),
- stereo(stereoi),
- duration(durationi)
- {
- }
-
- boost::uint16_t codec;
- boost::uint16_t sampleRate;
- boost::uint16_t sampleSize;
- bool stereo;
- boost::uint64_t duration;
-};
-
-/// \brief
-/// The FLVVideoInfo class contains information about the videostream
-/// in the FLV being parsed. The information stored is codec-type,
-/// width, height, framerate and duration.
-//
-/// TODO: drop
-///
-class FLVVideoInfo
-{
-public:
- FLVVideoInfo(boost::uint16_t codeci, boost::uint16_t widthi,
boost::uint16_t heighti, boost::uint16_t frameRatei, boost::uint64_t durationi)
- :
- codec(codeci),
- width(widthi),
- height(heighti),
- frameRate(frameRatei),
- duration(durationi)
- {
- }
-
- boost::uint16_t codec;
- boost::uint16_t width;
- boost::uint16_t height;
- boost::uint16_t frameRate;
- boost::uint64_t duration;
-};
-
-
-/// Information about an FLV Video Frame
-class FLVVideoFrameInfo
-{
-public:
-
- /// Type of this frame (should likely be videoFrameType)
- boost::uint16_t frameType;
-
- /// Size of the frame in bytes
- boost::uint32_t dataSize;
-
- /// Start of frame data in stream
- boost::uint64_t dataPosition;
-
- /// Timestamp in milliseconds
- boost::uint32_t timestamp;
-
- /// Return true if this video frame is a key frame
- bool isKeyFrame() const
- {
- return frameType == 1 /*KEY_FRAME*/;
- }
-
-};
-
-/// Information about an FLV Audio Frame
-class FLVAudioFrameInfo
-{
-public:
- /// Size of the frame in bytes
- boost::uint32_t dataSize;
-
- /// Start of frame data in stream
- boost::uint64_t dataPosition;
-
- /// Timestamp in milliseconds
- boost::uint32_t timestamp;
-
-};
-
/// The FLVParser class parses FLV streams
class DSOEXPORT FLVParser : public MediaParser
{
=== modified file 'libmedia/MediaParser.cpp'
--- a/libmedia/MediaParser.cpp 2008-08-18 23:53:04 +0000
+++ b/libmedia/MediaParser.cpp 2008-09-02 10:11:27 +0000
@@ -34,8 +34,6 @@
MediaParser::MediaParser(std::auto_ptr<IOChannel> stream)
:
- _isAudioMp3(false),
- _isAudioNellymoser(false),
_stream(stream),
_parsingComplete(false),
_bufferTime(100), // 100 ms
=== modified file 'libmedia/MediaParser.h'
--- a/libmedia/MediaParser.h 2008-07-22 04:07:26 +0000
+++ b/libmedia/MediaParser.h 2008-09-02 10:11:27 +0000
@@ -269,14 +269,10 @@
/// and returns the new position.
//
///
- /// TODO: throw something for sending Seek.InvalidTime ?
- /// (triggered by seeks beyond the end of video or beyond what's
- /// downloaded so far)
- ///
/// @param time input/output parameter, input requests a time, output
/// return the actual time seeked to.
///
- /// @return true if the seek was valid, false otherwise
+ /// @return true if the seek was valid, false otherwise.
///
virtual bool seek(boost::uint32_t& time)=0;
@@ -341,22 +337,6 @@
///
DSOEXPORT std::auto_ptr<EncodedAudioFrame> nextAudioFrame();
- /// Is the input MP3?
- //
- /// @return if the input audio is MP3
- ///
- /// TODO: drop ?
- ///
- bool isAudioMp3() { return _isAudioMp3; }
-
- /// Is the input Nellymoser?
- //
- /// @return if the input audio is Nellymoser
- ///
- /// TODO: drop ?
- ///
- bool isAudioNellymoser() { return _isAudioNellymoser; }
-
/// Returns a VideoInfo class about the videostream
//
/// @return a VideoInfo class about the videostream,
@@ -442,18 +422,6 @@
/// Info about the audio stream (if any)
std::auto_ptr<AudioInfo> _audioInfo;
- /// Is the input audio MP3?
- //
- /// TODO: drop ?
- ///
- bool _isAudioMp3;
-
- /// Is the input audio Nellymoser?
- //
- /// TODO: drop ?
- ///
- bool _isAudioNellymoser;
-
/// The stream used to access the file
std::auto_ptr<IOChannel> _stream;
mutable boost::mutex _streamMutex;
=== modified file 'libmedia/ffmpeg/VideoDecoderFfmpeg.cpp'
--- a/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp 2008-09-01 13:30:43 +0000
+++ b/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp 2008-09-02 09:40:22 +0000
@@ -246,12 +246,12 @@
return im;
}
- boost::uint8_t* buffer = new boost::uint8_t[bufsize];
+ boost::scoped_array<boost::uint8_t> buffer ( new boost::uint8_t[bufsize] );
AVPicture picture;
picture.data[0] = NULL;
- avpicture_fill(&picture, buffer, pixFmt, width, height);
+ avpicture_fill(&picture, buffer.get(), pixFmt, width, height);
#ifndef HAVE_SWSCALE_H
img_convert(&picture, PIX_FMT_RGB24, (AVPicture*) &srcFrame,
@@ -267,7 +267,6 @@
picture.linesize);
if (rv == -1) {
- delete [] buffer;
im.reset();
return im;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r9659: Cleanups in amf::Element class and libmedia,
Sandro Santilli <=