Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GNASH_MEDIAPARSER_FFMPEG_H
00021 #define GNASH_MEDIAPARSER_FFMPEG_H
00022
00023 #include <boost/scoped_array.hpp>
00024 #include <memory>
00025 #include <boost/optional.hpp>
00026
00027 #include "MediaParser.h"
00028 #include "ffmpegHeaders.h"
00029 #include "Id3Info.h"
00030
00031
00032 namespace gnash {
00033 class IOChannel;
00034 }
00035
00036 namespace gnash {
00037 namespace media {
00038 namespace ffmpeg {
00039
00041
00044 class ExtraAudioInfoFfmpeg : public AudioInfo::ExtraInfo
00045 {
00046 public:
00047 ExtraAudioInfoFfmpeg(boost::uint8_t* nData, size_t nDataSize)
00048 :
00049 data(nData),
00050 dataSize(nDataSize)
00051 {
00052 }
00053 boost::uint8_t* data;
00054 size_t dataSize;
00055 };
00056
00058
00061 class ExtraVideoInfoFfmpeg : public VideoInfo::ExtraInfo
00062 {
00063 public:
00064 ExtraVideoInfoFfmpeg(boost::uint8_t* nData, size_t nDataSize)
00065 :
00066 data(nData),
00067 dataSize(nDataSize)
00068 {
00069 }
00070 boost::uint8_t* data;
00071 size_t dataSize;
00072 };
00073
00075 class MediaParserFfmpeg: public MediaParser
00076 {
00077 public:
00078
00080
00083 MediaParserFfmpeg(std::auto_ptr<IOChannel> stream);
00084
00085 ~MediaParserFfmpeg();
00086
00087
00088 virtual bool seek(boost::uint32_t&);
00089
00090
00091 virtual bool parseNextChunk();
00092
00093
00094 virtual boost::uint64_t getBytesLoaded() const;
00095
00096 virtual boost::optional<Id3Info> getId3Info() const;
00097
00098 private:
00099
00102 void initializeParser();
00103
00105
00109 size_t _nextVideoFrame;
00110
00112
00116 size_t _nextAudioFrame;
00117
00119
00122 bool parseNextFrame();
00123
00125 int readPacket(boost::uint8_t* buf, int buf_size);
00126
00128 static int readPacketWrapper(void* opaque, boost::uint8_t* buf, int buf_size);
00129
00131 boost::int64_t seekMedia(boost::int64_t offset, int whence);
00132
00134 static boost::int64_t seekMediaWrapper(void *opaque, boost::int64_t offset, int whence);
00135
00137 AVInputFormat* probeStream();
00138
00139 AVInputFormat* _inputFmt;
00140
00142 AVFormatContext *_formatCtx;
00143
00145 int _videoStreamIndex;
00146
00148 AVStream* _videoStream;
00149
00151 int _audioStreamIndex;
00152
00153
00154 AVStream* _audioStream;
00155
00157 ByteIOContext _byteIOCxt;
00158
00160
00164 static const size_t byteIOBufferSize = 1024;
00165
00166 boost::scoped_array<unsigned char> _byteIOBuffer;
00167
00169 boost::uint64_t _lastParsedPosition;
00170
00172
00175 boost::uint16_t SampleFormatToSampleSize(SampleFormat fmt);
00176
00178
00179 bool parseVideoFrame(AVPacket& packet);
00180
00182 bool parseAudioFrame(AVPacket& packet);
00183
00184 boost::optional<Id3Info> _id3Object;
00185 };
00186
00187
00188 }
00189 }
00190 }
00191
00192 #endif // __MEDIAPARSER_FFMPEG_H__