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 #ifndef GNASH_MEDIAPARSER_FFMPEG_H
00020 #define GNASH_MEDIAPARSER_FFMPEG_H
00021
00022 #include "MediaParser.h"
00023 #include "ffmpegHeaders.h"
00024
00025 #include <boost/scoped_array.hpp>
00026 #include <memory>
00027
00028
00029 namespace gnash {
00030 class IOChannel;
00031 }
00032
00033 namespace gnash {
00034 namespace media {
00035 namespace ffmpeg {
00036
00038
00041 class ExtraAudioInfoFfmpeg : public AudioInfo::ExtraInfo
00042 {
00043 public:
00044 ExtraAudioInfoFfmpeg(boost::uint8_t* nData, size_t nDataSize)
00045 :
00046 data(nData),
00047 dataSize(nDataSize)
00048 {
00049 }
00050 boost::uint8_t* data;
00051 size_t dataSize;
00052 };
00053
00055
00058 class ExtraVideoInfoFfmpeg : public VideoInfo::ExtraInfo
00059 {
00060 public:
00061 ExtraVideoInfoFfmpeg(boost::uint8_t* nData, size_t nDataSize)
00062 :
00063 data(nData),
00064 dataSize(nDataSize)
00065 {
00066 }
00067 boost::uint8_t* data;
00068 size_t dataSize;
00069 };
00070
00072 class MediaParserFfmpeg: public MediaParser
00073 {
00074 public:
00075
00077
00080 MediaParserFfmpeg(std::auto_ptr<IOChannel> stream);
00081
00082 ~MediaParserFfmpeg();
00083
00084
00085 virtual bool seek(boost::uint32_t&);
00086
00087
00088 virtual bool parseNextChunk();
00089
00090
00091 virtual boost::uint64_t getBytesLoaded() const;
00092
00093 private:
00094
00097 void initializeParser();
00098
00100
00104 size_t _nextVideoFrame;
00105
00107
00111 size_t _nextAudioFrame;
00112
00114
00117 bool parseNextFrame();
00118
00120 int readPacket(boost::uint8_t* buf, int buf_size);
00121
00123 static int readPacketWrapper(void* opaque, boost::uint8_t* buf, int buf_size);
00124
00126 boost::int64_t seekMedia(boost::int64_t offset, int whence);
00127
00129 static boost::int64_t seekMediaWrapper(void *opaque, boost::int64_t offset, int whence);
00130
00132 AVInputFormat* probeStream();
00133
00134 AVInputFormat* _inputFmt;
00135
00137 AVFormatContext *_formatCtx;
00138
00140 int _videoStreamIndex;
00141
00143 AVStream* _videoStream;
00144
00146 int _audioStreamIndex;
00147
00148
00149 AVStream* _audioStream;
00150
00152 ByteIOContext _byteIOCxt;
00153
00155
00159 static const size_t byteIOBufferSize = 1024;
00160
00161 boost::scoped_array<unsigned char> _byteIOBuffer;
00162
00164 boost::uint64_t _lastParsedPosition;
00165
00167
00170 boost::uint16_t SampleFormatToSampleSize(SampleFormat fmt);
00171
00173
00174 bool parseVideoFrame(AVPacket& packet);
00175
00177 bool parseAudioFrame(AVPacket& packet);
00178 };
00179
00180
00181 }
00182 }
00183 }
00184
00185 #endif // __MEDIAPARSER_FFMPEG_H__