Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * Copyright 2009-2011 Jörg Hermann Müller 00005 * 00006 * This file is part of AudaSpace. 00007 * 00008 * Audaspace is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * AudaSpace is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with Audaspace; if not, write to the Free Software Foundation, 00020 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00021 * 00022 * ***** END GPL LICENSE BLOCK ***** 00023 */ 00024 00030 #ifndef AUD_FFMPEGREADER 00031 #define AUD_FFMPEGREADER 00032 00033 #include "AUD_ConverterFunctions.h" 00034 #include "AUD_IReader.h" 00035 #include "AUD_Reference.h" 00036 #include "AUD_Buffer.h" 00037 00038 #include <string> 00039 00040 struct AVCodecContext; 00041 extern "C" { 00042 #include <libavformat/avformat.h> 00043 } 00044 00051 class AUD_FFMPEGReader : public AUD_IReader 00052 { 00053 private: 00057 int m_position; 00058 00062 AUD_DeviceSpecs m_specs; 00063 00067 AUD_Buffer m_pkgbuf; 00068 00072 int m_pkgbuf_left; 00073 00077 AVFormatContext* m_formatCtx; 00078 00082 AVCodecContext* m_codecCtx; 00083 00087 AVIOContext* m_aviocontext; 00088 00092 int m_stream; 00093 00097 AUD_convert_f m_convert; 00098 00102 AUD_Reference<AUD_Buffer> m_membuffer; 00103 00107 data_t* m_membuf; 00108 00112 int64_t m_membufferpos; 00113 00120 int decode(AVPacket* packet, AUD_Buffer& buffer); 00121 00125 void init(); 00126 00127 // hide copy constructor and operator= 00128 AUD_FFMPEGReader(const AUD_FFMPEGReader&); 00129 AUD_FFMPEGReader& operator=(const AUD_FFMPEGReader&); 00130 00131 public: 00138 AUD_FFMPEGReader(std::string filename); 00139 00146 AUD_FFMPEGReader(AUD_Reference<AUD_Buffer> buffer); 00147 00151 virtual ~AUD_FFMPEGReader(); 00152 00153 static int read_packet(void* opaque, uint8_t* buf, int buf_size); 00154 static int64_t seek_packet(void* opaque, int64_t offset, int whence); 00155 00156 virtual bool isSeekable() const; 00157 virtual void seek(int position); 00158 virtual int getLength() const; 00159 virtual int getPosition() const; 00160 virtual AUD_Specs getSpecs() const; 00161 virtual void read(int& length, bool& eos, sample_t* buffer); 00162 }; 00163 00164 #endif //AUD_FFMPEGREADER