EMIPLIB
|
00001 /* 00002 00003 This file is a part of EMIPLIB, the EDM Media over IP Library. 00004 00005 Copyright (C) 2006-2011 Hasselt University - Expertise Centre for 00006 Digital Media (EDM) (http://www.edm.uhasselt.be) 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2.1 of the License, or (at your option) any later version. 00012 00013 This library 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 GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00021 USA 00022 00023 */ 00024 00029 #ifndef MIPAUDIOMIXER_H 00030 00031 #define MIPAUDIOMIXER_H 00032 00033 #include "mipconfig.h" 00034 #include "mipcomponent.h" 00035 #include "miptime.h" 00036 #include <list> 00037 #include <set> 00038 00039 class MIPRaw16bitAudioMessage; 00040 class MIPRawFloatAudioMessage; 00041 00048 class EMIPLIB_IMPORTEXPORT MIPAudioMixer : public MIPComponent 00049 { 00050 public: 00051 MIPAudioMixer(); 00052 ~MIPAudioMixer(); 00053 00067 bool init(int sampRate, int channels, MIPTime blockTime, bool useTimeInfo = true, bool floatSamples = true); 00068 00072 bool destroy(); 00073 00080 bool setExtraDelay(MIPTime t); 00081 00087 void setPlaybackTime(MIPTime t) { m_playTime = t; } 00088 00090 MIPTime getPlaybackTime() const { return m_playTime; } 00091 00093 void addSourceToIgnore(uint64_t id) { m_sourcesToIgnore.insert(id); } 00094 00096 void clearIgnoreList() { m_sourcesToIgnore.clear(); } 00097 00098 bool push(const MIPComponentChain &chain, int64_t iteration, MIPMessage *pMsg); 00099 bool pull(const MIPComponentChain &chain, int64_t iteration, MIPMessage **pMsg); 00100 bool processFeedback(const MIPComponentChain &chain, int64_t feedbackChainID, MIPFeedback *feedback); 00101 private: 00102 class MIPAudioMixerBlock 00103 { 00104 public: 00105 MIPAudioMixerBlock(int64_t playInterval, float *pFrames) { m_interval = playInterval; m_pFloatFrames = pFrames; m_pIntFrames = 0; } 00106 MIPAudioMixerBlock(int64_t playInterval, uint16_t *pFrames) { m_interval = playInterval; m_pFloatFrames = 0; m_pIntFrames = pFrames; } 00107 float *getFramesFloat() { return m_pFloatFrames; } 00108 uint16_t *getFramesInt() { return m_pIntFrames; } 00109 int64_t getInterval() const { return m_interval; } 00110 private: 00111 float *m_pFloatFrames; 00112 uint16_t *m_pIntFrames; 00113 int64_t m_interval; 00114 }; 00115 00116 void clearAudioBlocks(); 00117 void initBlockSearch(); 00118 MIPAudioMixerBlock searchBlock(int64_t intervalNumber); 00119 00120 bool m_init; 00121 bool m_useTimeInfo; 00122 int64_t m_prevIteration; 00123 bool m_gotMessage; 00124 bool m_floatSamples; 00125 00126 MIPTime m_blockTime, m_playTime; 00127 int m_sampRate, m_channels; 00128 size_t m_blockFrames,m_blockSize; 00129 int64_t m_curInterval; 00130 00131 MIPRawFloatAudioMessage *m_pMsgFloat; 00132 MIPRaw16bitAudioMessage *m_pMsgInt; 00133 float *m_pSilenceFramesFloat; 00134 uint16_t *m_pSilenceFramesInt; 00135 float *m_pBlockFramesFloat; 00136 uint16_t *m_pBlockFramesInt; 00137 00138 MIPTime m_extraDelay; 00139 00140 std::list<MIPAudioMixerBlock> m_audioBlocks; 00141 std::list<MIPAudioMixerBlock>::iterator m_it; 00142 00143 std::set<uint64_t> m_sourcesToIgnore; 00144 }; 00145 00146 #endif // MIPAUDIOMIXER_H 00147