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 #ifdef WITH_FFMPEG 00031 // needed for INT64_C 00032 #ifndef __STDC_CONSTANT_MACROS 00033 #define __STDC_CONSTANT_MACROS 00034 #endif 00035 #include "AUD_FFMPEGReader.h" 00036 #endif 00037 00038 #include "AUD_FileFactory.h" 00039 00040 #include <cstring> 00041 00042 #ifdef WITH_SNDFILE 00043 #include "AUD_SndFileReader.h" 00044 #endif 00045 00046 AUD_FileFactory::AUD_FileFactory(std::string filename) : 00047 m_filename(filename) 00048 { 00049 } 00050 00051 AUD_FileFactory::AUD_FileFactory(const data_t* buffer, int size) : 00052 m_buffer(new AUD_Buffer(size)) 00053 { 00054 memcpy(m_buffer->getBuffer(), buffer, size); 00055 } 00056 00057 static const char* read_error = "AUD_FileFactory: File couldn't be read."; 00058 00059 AUD_Reference<AUD_IReader> AUD_FileFactory::createReader() 00060 { 00061 #ifdef WITH_SNDFILE 00062 try 00063 { 00064 if(m_buffer.isNull()) 00065 return new AUD_SndFileReader(m_filename); 00066 else 00067 return new AUD_SndFileReader(m_buffer); 00068 } 00069 catch(AUD_Exception&) {} 00070 #endif 00071 00072 #ifdef WITH_FFMPEG 00073 try 00074 { 00075 if(m_buffer.isNull()) 00076 return new AUD_FFMPEGReader(m_filename); 00077 else 00078 return new AUD_FFMPEGReader(m_buffer); 00079 } 00080 catch(AUD_Exception&) {} 00081 #endif 00082 00083 AUD_THROW(AUD_ERROR_FILE, read_error); 00084 }