• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

MediaParserFfmpeg.h

Go to the documentation of this file.
00001 // MediaParserFfmpeg.h: FFMEPG media parsers, for Gnash
00002 // 
00003 //   Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef GNASH_MEDIAPARSER_FFMPEG_H
00020 #define GNASH_MEDIAPARSER_FFMPEG_H
00021 
00022 #include "MediaParser.h" // for inheritance
00023 #include "ffmpegHeaders.h"
00024 
00025 #include <boost/scoped_array.hpp>
00026 #include <memory>
00027 
00028 // Forward declaration
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         // See dox in MediaParser.h
00085         virtual bool seek(boost::uint32_t&);
00086 
00087         // See dox in MediaParser.h
00088         virtual bool parseNextChunk();
00089 
00090         // See dox in MediaParser.h
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         // audio
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 } // gnash.media.ffmpeg namespace 
00182 } // gnash.media namespace 
00183 } // namespace gnash
00184 
00185 #endif // __MEDIAPARSER_FFMPEG_H__

Generated on Fri Mar 16 2012 15:46:11 for Gnash by  doxygen 1.7.1