AudioESInfo.cpp

00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: AudioESInfo.cpp * 00006 * * 00007 * * 00008 * * 00009 * ITEC institute of the University of Klagenfurt (Austria) * 00010 * http://www.itec.uni-klu.ac.at * 00011 * * 00012 * * 00013 * For more information visit the ViTooKi homepage: * 00014 * http://ViTooKi.sourceforge.net * 00015 * vitooki-user@lists.sourceforge.net * 00016 * vitooki-devel@lists.sourceforge.net * 00017 * * 00018 * This file is part of ViTooKi, a free video toolkit. * 00019 * ViTooKi is free software; you can redistribute it and/or * 00020 * modify it under the terms of the GNU General Public License * 00021 * as published by the Free Software Foundation; either version 2 * 00022 * of the License, or (at your option) any later version. * 00023 * * 00024 * This program is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU General Public License * 00030 * along with this program; if not, write to the Free Software * 00031 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00032 * MA 02111-1307, USA. * 00033 * * 00034 ***********************************************************************/ 00035 00036 #include "AudioESInfo.hpp" 00037 #include "adaptors/MP4audioDecoder.hpp" 00038 #include "ReferenceCounter.hpp" 00039 #include "BitField.hpp" 00046 AudioESInfo::AudioESInfo(u32 streamId, u32 streamtype, ContainerInfo * vob, u32 timeIncrement, 00047 u8 * encodeddecconf, u32 objtype, u32 bufsize, 00048 u32 avgBW, u32 maxBW, u32 timeScale, 00049 u64 duration, u32 size, 00050 u32 samplerate, u32 numAudioChannels, 00051 bool complete, 00052 CodecID codec_id, float quality, u32 BitsPerSample) 00053 : ESInfo(streamId, 00054 streamType,vob,timeIncrement,encodeddecconf, 00055 objtype,bufsize,avgBW,maxBW, 00056 timeScale,duration,size,complete,codec_id,quality) 00057 { 00058 00059 //the following are for audio only 00060 sample_rate = samplerate; 00061 audio_channels = numAudioChannels; 00062 /* MP3 specific channelMod is unsed so far */ 00063 channelMod=0; 00064 bitsPerSample = BitsPerSample; 00065 generateDescriptionText(); 00066 /* This is used to set up certain information by parsing the header 00067 * of first mp3 frame 00068 #ifndef ISOMP4 00069 MP4audioDecoder *mp4audio = new MP4audioDecoder(this,false); 00070 mp4audio->initialize(); 00071 delete mp4audio; 00072 #endif 00073 */ 00074 } 00075 00076 00077 u32 AudioESInfo::getHandlerType() const { 00078 return MP4AudioHandlerType; 00079 } 00080 00081 00082 u32 AudioESInfo::getBitsPerSample() const { 00083 return bitsPerSample; 00084 } 00085 00086 00087 u32 AudioESInfo::getSampleRate() const { 00088 return sample_rate; 00089 } 00090 00091 00092 void AudioESInfo::setSampleRate(u32 sampleRate) { 00093 sample_rate = sampleRate; 00094 generateDescriptionText(); 00095 } 00096 00097 00098 u32 AudioESInfo::getAudioChannels() const { 00099 return audio_channels; 00100 } 00101 00102 00103 void AudioESInfo::setAudioChannels(u32 channels) { 00104 audio_channels = channels; 00105 } 00106 00107 00108 bool AudioESInfo::isVisualStream() const { 00109 return false; 00110 } 00111 00112 00113 bool AudioESInfo::isAudioStream() const { 00114 return true; 00115 } 00116 00117 00118 bool AudioESInfo::isODStream() const { 00119 return false; 00120 } 00121 00122 00123 bool AudioESInfo::isSceneDescriptionStream() const { 00124 return false; 00125 } 00126 00127 00129 u32 AudioESInfo::getChannelMod() const { 00130 return channelMod; 00131 } 00132 00133 00134 void AudioESInfo::setChannelMod(u32 uiChannelMod) { 00135 channelMod = uiChannelMod; 00136 generateDescriptionText(); 00137 } 00138 00139 00141 ESInfo *AudioESInfo::clone(ContainerInfo * mp4) { 00142 dprintf_full("AudioESInfo::clone id %llu\n",streamId); 00143 u8 *decConf = NULL; 00144 if (encodedDecoderConfig) 00145 { 00146 decConf = new u8[strlen((char *) encodedDecoderConfig) + 1]; 00147 strcpy((char *) decConf, (const char *) encodedDecoderConfig); 00148 } 00149 ESInfo *es = new AudioESInfo(streamId, streamType, mp4, vopTimeIncrement, decConf, objectType, 00150 bufferSize, avgBandwidth, maxBandwidth, 00151 mediaTimeScale, duration, mediaSize, sample_rate, 00152 audio_channels, complete, codec_id, this->quality, 00153 bitsPerSample); 00154 es->setInput(input); 00155 if(!existingClones) { 00156 existingClones=new ReferenceCounter(); 00157 existingClones->increase(); 00158 } 00159 existingClones->increase(); 00160 es->setCloneCounter(existingClones); 00161 BitField* fs=getFrameStatistic(); 00162 if(fs) { 00163 es->setFrameStatistic(fs->createWithNewSize(fs->getSize(),false)); 00164 } 00165 ((AudioESInfo*)es)->setChannelMod(channelMod); 00166 return es; 00167 } 00168 00169 00170 void AudioESInfo::generateDescriptionText() { 00171 char *codecName = new char[MAX_STR_LEN]; 00172 strcpy(codecName,"Unknown"); 00173 #ifdef ENABLE_FFMPEG 00174 AVCodec* av=avcodec_find_decoder(this->codec_id); 00175 if(av) 00176 strcpy(codecName,av->name); 00177 #endif 00178 snprintf(description,MAX_STR_LEN,"%10s: %4ukBps; %5uHz; %3uBit; %1uCh.", 00179 codecName,avgBandwidth/1024,sample_rate,bitsPerSample,channelMod); 00180 00181 delete [] codecName; 00182 }