WebRtc_Word32 -> int32_t in audio_conference_mixer/

BUG=314

Review URL: https://webrtc-codereview.appspot.com/1306004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3804 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org 2013-04-09 17:40:15 +00:00
parent b09130763b
commit ac891627c6
14 changed files with 286 additions and 284 deletions

View File

@ -40,44 +40,42 @@ public:
virtual ~AudioConferenceMixer() {} virtual ~AudioConferenceMixer() {}
// Module functions // Module functions
virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id) = 0; virtual int32_t ChangeUniqueId(const int32_t id) = 0;
virtual WebRtc_Word32 TimeUntilNextProcess() = 0 ; virtual int32_t TimeUntilNextProcess() = 0 ;
virtual WebRtc_Word32 Process() = 0; virtual int32_t Process() = 0;
// Register/unregister a callback class for receiving the mixed audio. // Register/unregister a callback class for receiving the mixed audio.
virtual WebRtc_Word32 RegisterMixedStreamCallback( virtual int32_t RegisterMixedStreamCallback(
AudioMixerOutputReceiver& receiver) = 0; AudioMixerOutputReceiver& receiver) = 0;
virtual WebRtc_Word32 UnRegisterMixedStreamCallback() = 0; virtual int32_t UnRegisterMixedStreamCallback() = 0;
// Register/unregister a callback class for receiving status information. // Register/unregister a callback class for receiving status information.
virtual WebRtc_Word32 RegisterMixerStatusCallback( virtual int32_t RegisterMixerStatusCallback(
AudioMixerStatusReceiver& mixerStatusCallback, AudioMixerStatusReceiver& mixerStatusCallback,
const WebRtc_UWord32 amountOf10MsBetweenCallbacks) = 0; const uint32_t amountOf10MsBetweenCallbacks) = 0;
virtual WebRtc_Word32 UnRegisterMixerStatusCallback() = 0; virtual int32_t UnRegisterMixerStatusCallback() = 0;
// Add/remove participants as candidates for mixing. // Add/remove participants as candidates for mixing.
virtual WebRtc_Word32 SetMixabilityStatus( virtual int32_t SetMixabilityStatus(MixerParticipant& participant,
MixerParticipant& participant, const bool mixable) = 0;
const bool mixable) = 0;
// mixable is set to true if a participant is a candidate for mixing. // mixable is set to true if a participant is a candidate for mixing.
virtual WebRtc_Word32 MixabilityStatus( virtual int32_t MixabilityStatus(MixerParticipant& participant,
MixerParticipant& participant, bool& mixable) = 0;
bool& mixable) = 0;
// Inform the mixer that the participant should always be mixed and not // Inform the mixer that the participant should always be mixed and not
// count toward the number of mixed participants. Note that a participant // count toward the number of mixed participants. Note that a participant
// must have been added to the mixer (by calling SetMixabilityStatus()) // must have been added to the mixer (by calling SetMixabilityStatus())
// before this function can be successfully called. // before this function can be successfully called.
virtual WebRtc_Word32 SetAnonymousMixabilityStatus( virtual int32_t SetAnonymousMixabilityStatus(MixerParticipant& participant,
MixerParticipant& participant, const bool mixable) = 0; const bool mixable) = 0;
// mixable is set to true if the participant is mixed anonymously. // mixable is set to true if the participant is mixed anonymously.
virtual WebRtc_Word32 AnonymousMixabilityStatus( virtual int32_t AnonymousMixabilityStatus(MixerParticipant& participant,
MixerParticipant& participant, bool& mixable) = 0; bool& mixable) = 0;
// Set the minimum sampling frequency at which to mix. The mixing algorithm // Set the minimum sampling frequency at which to mix. The mixing algorithm
// may still choose to mix at a higher samling frequency to avoid // may still choose to mix at a higher samling frequency to avoid
// downsampling of audio contributing to the mixed audio. // downsampling of audio contributing to the mixed audio.
virtual WebRtc_Word32 SetMinimumMixingFrequency(Frequency freq) = 0; virtual int32_t SetMinimumMixingFrequency(Frequency freq) = 0;
protected: protected:
AudioConferenceMixer() {} AudioConferenceMixer() {}

View File

@ -26,15 +26,14 @@ public:
// audio every time it's called. // audio every time it's called.
// //
// If it returns -1, the frame will not be added to the mix. // If it returns -1, the frame will not be added to the mix.
virtual WebRtc_Word32 GetAudioFrame(const WebRtc_Word32 id, virtual int32_t GetAudioFrame(const int32_t id, AudioFrame& audioFrame) = 0;
AudioFrame& audioFrame) = 0;
// mixed will be set to true if the participant was mixed this mix iteration // mixed will be set to true if the participant was mixed this mix iteration
WebRtc_Word32 IsMixed(bool& mixed) const; int32_t IsMixed(bool& mixed) const;
// This function specifies the sampling frequency needed for the AudioFrame // This function specifies the sampling frequency needed for the AudioFrame
// for future GetAudioFrame(..) calls. // for future GetAudioFrame(..) calls.
virtual WebRtc_Word32 NeededFrequency(const WebRtc_Word32 id) = 0; virtual int32_t NeededFrequency(const int32_t id) = 0;
MixHistory* _mixHistory; MixHistory* _mixHistory;
protected: protected:
@ -45,8 +44,8 @@ protected:
// Container struct for participant statistics. // Container struct for participant statistics.
struct ParticipantStatistics struct ParticipantStatistics
{ {
WebRtc_Word32 participant; int32_t participant;
WebRtc_Word32 level; int32_t level;
}; };
class AudioMixerStatusReceiver class AudioMixerStatusReceiver
@ -55,20 +54,20 @@ public:
// Callback function that provides an array of ParticipantStatistics for the // Callback function that provides an array of ParticipantStatistics for the
// participants that were mixed last mix iteration. // participants that were mixed last mix iteration.
virtual void MixedParticipants( virtual void MixedParticipants(
const WebRtc_Word32 id, const int32_t id,
const ParticipantStatistics* participantStatistics, const ParticipantStatistics* participantStatistics,
const WebRtc_UWord32 size) = 0; const uint32_t size) = 0;
// Callback function that provides an array of the ParticipantStatistics for // Callback function that provides an array of the ParticipantStatistics for
// the participants that had a positiv VAD last mix iteration. // the participants that had a positiv VAD last mix iteration.
virtual void VADPositiveParticipants( virtual void VADPositiveParticipants(
const WebRtc_Word32 id, const int32_t id,
const ParticipantStatistics* participantStatistics, const ParticipantStatistics* participantStatistics,
const WebRtc_UWord32 size) = 0; const uint32_t size) = 0;
// Callback function that provides the audio level of the mixed audio frame // Callback function that provides the audio level of the mixed audio frame
// from the last mix iteration. // from the last mix iteration.
virtual void MixedAudioLevel( virtual void MixedAudioLevel(
const WebRtc_Word32 id, const int32_t id,
const WebRtc_UWord32 level) = 0; const uint32_t level) = 0;
protected: protected:
AudioMixerStatusReceiver() {} AudioMixerStatusReceiver() {}
virtual ~AudioMixerStatusReceiver() {} virtual ~AudioMixerStatusReceiver() {}
@ -80,10 +79,10 @@ public:
// This callback function provides the mixed audio for this mix iteration. // This callback function provides the mixed audio for this mix iteration.
// Note that uniqueAudioFrames is an array of AudioFrame pointers with the // Note that uniqueAudioFrames is an array of AudioFrame pointers with the
// size according to the size parameter. // size according to the size parameter.
virtual void NewMixedAudio(const WebRtc_Word32 id, virtual void NewMixedAudio(const int32_t id,
const AudioFrame& generalAudioFrame, const AudioFrame& generalAudioFrame,
const AudioFrame** uniqueAudioFrames, const AudioFrame** uniqueAudioFrames,
const WebRtc_UWord32 size) = 0; const uint32_t size) = 0;
protected: protected:
AudioMixerOutputReceiver() {} AudioMixerOutputReceiver() {}
virtual ~AudioMixerOutputReceiver() {} virtual ~AudioMixerOutputReceiver() {}
@ -95,7 +94,7 @@ public:
// This callback function provides the mix decision for this mix iteration. // This callback function provides the mix decision for this mix iteration.
// mixerList is a list of elements of the type // mixerList is a list of elements of the type
// [int,MixerParticipant*] // [int,MixerParticipant*]
virtual void NewAudioToRelay(const WebRtc_Word32 id, virtual void NewAudioToRelay(const int32_t id,
const MapWrapper& mixerList) = 0; const MapWrapper& mixerList) = 0;
protected: protected:
AudioRelayReceiver() {} AudioRelayReceiver() {}

View File

@ -71,7 +71,7 @@ MixerParticipant::~MixerParticipant()
delete _mixHistory; delete _mixHistory;
} }
WebRtc_Word32 MixerParticipant::IsMixed(bool& mixed) const int32_t MixerParticipant::IsMixed(bool& mixed) const
{ {
return _mixHistory->IsMixed(mixed); return _mixHistory->IsMixed(mixed);
} }
@ -85,20 +85,20 @@ MixHistory::~MixHistory()
{ {
} }
WebRtc_Word32 MixHistory::IsMixed(bool& mixed) const int32_t MixHistory::IsMixed(bool& mixed) const
{ {
mixed = _isMixed; mixed = _isMixed;
return 0; return 0;
} }
WebRtc_Word32 MixHistory::WasMixed(bool& wasMixed) const int32_t MixHistory::WasMixed(bool& wasMixed) const
{ {
// Was mixed is the same as is mixed depending on perspective. This function // Was mixed is the same as is mixed depending on perspective. This function
// is for the perspective of AudioConferenceMixerImpl. // is for the perspective of AudioConferenceMixerImpl.
return IsMixed(wasMixed); return IsMixed(wasMixed);
} }
WebRtc_Word32 MixHistory::SetIsMixed(const bool mixed) int32_t MixHistory::SetIsMixed(const bool mixed)
{ {
_isMixed = mixed; _isMixed = mixed;
return 0; return 0;
@ -202,16 +202,16 @@ AudioConferenceMixerImpl::~AudioConferenceMixerImpl()
assert(_audioFramePool == NULL); assert(_audioFramePool == NULL);
} }
WebRtc_Word32 AudioConferenceMixerImpl::ChangeUniqueId(const WebRtc_Word32 id) int32_t AudioConferenceMixerImpl::ChangeUniqueId(const int32_t id)
{ {
_id = id; _id = id;
return 0; return 0;
} }
// Process should be called every kProcessPeriodicityInMs ms // Process should be called every kProcessPeriodicityInMs ms
WebRtc_Word32 AudioConferenceMixerImpl::TimeUntilNextProcess() int32_t AudioConferenceMixerImpl::TimeUntilNextProcess()
{ {
WebRtc_Word32 timeUntilNextProcess = 0; int32_t timeUntilNextProcess = 0;
CriticalSectionScoped cs(_crit.get()); CriticalSectionScoped cs(_crit.get());
if(_timeScheduler.TimeToNextUpdate(timeUntilNextProcess) != 0) if(_timeScheduler.TimeToNextUpdate(timeUntilNextProcess) != 0)
{ {
@ -224,9 +224,9 @@ WebRtc_Word32 AudioConferenceMixerImpl::TimeUntilNextProcess()
return timeUntilNextProcess; return timeUntilNextProcess;
} }
WebRtc_Word32 AudioConferenceMixerImpl::Process() int32_t AudioConferenceMixerImpl::Process()
{ {
WebRtc_UWord32 remainingParticipantsAllowedToMix = uint32_t remainingParticipantsAllowedToMix =
kMaximumAmountOfMixedParticipants; kMaximumAmountOfMixedParticipants;
{ {
CriticalSectionScoped cs(_crit.get()); CriticalSectionScoped cs(_crit.get());
@ -244,7 +244,7 @@ WebRtc_Word32 AudioConferenceMixerImpl::Process()
{ {
CriticalSectionScoped cs(_cbCrit.get()); CriticalSectionScoped cs(_cbCrit.get());
WebRtc_Word32 lowFreq = GetLowestMixingFrequency(); int32_t lowFreq = GetLowestMixingFrequency();
// SILK can run in 12 kHz and 24 kHz. These frequencies are not // SILK can run in 12 kHz and 24 kHz. These frequencies are not
// supported so use the closest higher frequency to not lose any // supported so use the closest higher frequency to not lose any
// information. // information.
@ -322,7 +322,7 @@ WebRtc_Word32 AudioConferenceMixerImpl::Process()
bool timeForMixerCallback = false; bool timeForMixerCallback = false;
int retval = 0; int retval = 0;
WebRtc_Word32 audioLevel = 0; int32_t audioLevel = 0;
{ {
CriticalSectionScoped cs(_crit.get()); CriticalSectionScoped cs(_crit.get());
@ -415,7 +415,7 @@ WebRtc_Word32 AudioConferenceMixerImpl::Process()
return retval; return retval;
} }
WebRtc_Word32 AudioConferenceMixerImpl::RegisterMixedStreamCallback( int32_t AudioConferenceMixerImpl::RegisterMixedStreamCallback(
AudioMixerOutputReceiver& mixReceiver) AudioMixerOutputReceiver& mixReceiver)
{ {
CriticalSectionScoped cs(_cbCrit.get()); CriticalSectionScoped cs(_cbCrit.get());
@ -427,7 +427,7 @@ WebRtc_Word32 AudioConferenceMixerImpl::RegisterMixedStreamCallback(
return 0; return 0;
} }
WebRtc_Word32 AudioConferenceMixerImpl::UnRegisterMixedStreamCallback() int32_t AudioConferenceMixerImpl::UnRegisterMixedStreamCallback()
{ {
CriticalSectionScoped cs(_cbCrit.get()); CriticalSectionScoped cs(_cbCrit.get());
if(_mixReceiver == NULL) if(_mixReceiver == NULL)
@ -438,7 +438,7 @@ WebRtc_Word32 AudioConferenceMixerImpl::UnRegisterMixedStreamCallback()
return 0; return 0;
} }
WebRtc_Word32 AudioConferenceMixerImpl::SetOutputFrequency( int32_t AudioConferenceMixerImpl::SetOutputFrequency(
const Frequency frequency) const Frequency frequency)
{ {
CriticalSectionScoped cs(_crit.get()); CriticalSectionScoped cs(_crit.get());
@ -481,9 +481,9 @@ bool AudioConferenceMixerImpl::SetNumLimiterChannels(int numChannels)
return true; return true;
} }
WebRtc_Word32 AudioConferenceMixerImpl::RegisterMixerStatusCallback( int32_t AudioConferenceMixerImpl::RegisterMixerStatusCallback(
AudioMixerStatusReceiver& mixerStatusCallback, AudioMixerStatusReceiver& mixerStatusCallback,
const WebRtc_UWord32 amountOf10MsBetweenCallbacks) const uint32_t amountOf10MsBetweenCallbacks)
{ {
if(amountOf10MsBetweenCallbacks == 0) if(amountOf10MsBetweenCallbacks == 0)
{ {
@ -513,7 +513,7 @@ WebRtc_Word32 AudioConferenceMixerImpl::RegisterMixerStatusCallback(
return 0; return 0;
} }
WebRtc_Word32 AudioConferenceMixerImpl::UnRegisterMixerStatusCallback() int32_t AudioConferenceMixerImpl::UnRegisterMixerStatusCallback()
{ {
{ {
CriticalSectionScoped cs(_crit.get()); CriticalSectionScoped cs(_crit.get());
@ -532,7 +532,7 @@ WebRtc_Word32 AudioConferenceMixerImpl::UnRegisterMixerStatusCallback()
return 0; return 0;
} }
WebRtc_Word32 AudioConferenceMixerImpl::SetMixabilityStatus( int32_t AudioConferenceMixerImpl::SetMixabilityStatus(
MixerParticipant& participant, MixerParticipant& participant,
const bool mixable) const bool mixable)
{ {
@ -542,7 +542,7 @@ WebRtc_Word32 AudioConferenceMixerImpl::SetMixabilityStatus(
// participant is in the _participantList if it is being mixed. // participant is in the _participantList if it is being mixed.
SetAnonymousMixabilityStatus(participant, false); SetAnonymousMixabilityStatus(participant, false);
} }
WebRtc_UWord32 numMixedParticipants; uint32_t numMixedParticipants;
{ {
CriticalSectionScoped cs(_cbCrit.get()); CriticalSectionScoped cs(_cbCrit.get());
const bool isMixed = const bool isMixed =
@ -589,7 +589,7 @@ WebRtc_Word32 AudioConferenceMixerImpl::SetMixabilityStatus(
return 0; return 0;
} }
WebRtc_Word32 AudioConferenceMixerImpl::MixabilityStatus( int32_t AudioConferenceMixerImpl::MixabilityStatus(
MixerParticipant& participant, MixerParticipant& participant,
bool& mixable) bool& mixable)
{ {
@ -598,7 +598,7 @@ WebRtc_Word32 AudioConferenceMixerImpl::MixabilityStatus(
return 0; return 0;
} }
WebRtc_Word32 AudioConferenceMixerImpl::SetAnonymousMixabilityStatus( int32_t AudioConferenceMixerImpl::SetAnonymousMixabilityStatus(
MixerParticipant& participant, const bool anonymous) MixerParticipant& participant, const bool anonymous)
{ {
CriticalSectionScoped cs(_cbCrit.get()); CriticalSectionScoped cs(_cbCrit.get());
@ -638,7 +638,7 @@ WebRtc_Word32 AudioConferenceMixerImpl::SetAnonymousMixabilityStatus(
0 : -1; 0 : -1;
} }
WebRtc_Word32 AudioConferenceMixerImpl::AnonymousMixabilityStatus( int32_t AudioConferenceMixerImpl::AnonymousMixabilityStatus(
MixerParticipant& participant, bool& mixable) MixerParticipant& participant, bool& mixable)
{ {
CriticalSectionScoped cs(_cbCrit.get()); CriticalSectionScoped cs(_cbCrit.get());
@ -647,7 +647,7 @@ WebRtc_Word32 AudioConferenceMixerImpl::AnonymousMixabilityStatus(
return 0; return 0;
} }
WebRtc_Word32 AudioConferenceMixerImpl::SetMinimumMixingFrequency( int32_t AudioConferenceMixerImpl::SetMinimumMixingFrequency(
Frequency freq) Frequency freq)
{ {
// Make sure that only allowed sampling frequencies are used. Use closest // Make sure that only allowed sampling frequencies are used. Use closest
@ -676,7 +676,7 @@ WebRtc_Word32 AudioConferenceMixerImpl::SetMinimumMixingFrequency(
// Check all AudioFrames that are to be mixed. The highest sampling frequency // Check all AudioFrames that are to be mixed. The highest sampling frequency
// found is the lowest that can be used without losing information. // found is the lowest that can be used without losing information.
WebRtc_Word32 AudioConferenceMixerImpl::GetLowestMixingFrequency() int32_t AudioConferenceMixerImpl::GetLowestMixingFrequency()
{ {
const int participantListFrequency = const int participantListFrequency =
GetLowestMixingFrequencyFromList(_participantList); GetLowestMixingFrequencyFromList(_participantList);
@ -696,16 +696,16 @@ WebRtc_Word32 AudioConferenceMixerImpl::GetLowestMixingFrequency()
return highestFreq; return highestFreq;
} }
WebRtc_Word32 AudioConferenceMixerImpl::GetLowestMixingFrequencyFromList( int32_t AudioConferenceMixerImpl::GetLowestMixingFrequencyFromList(
ListWrapper& mixList) ListWrapper& mixList)
{ {
WebRtc_Word32 highestFreq = 8000; int32_t highestFreq = 8000;
ListItem* item = mixList.First(); ListItem* item = mixList.First();
while(item) while(item)
{ {
MixerParticipant* participant = MixerParticipant* participant =
static_cast<MixerParticipant*>(item->GetItem()); static_cast<MixerParticipant*>(item->GetItem());
const WebRtc_Word32 neededFrequency = participant->NeededFrequency(_id); const int32_t neededFrequency = participant->NeededFrequency(_id);
if(neededFrequency > highestFreq) if(neededFrequency > highestFreq)
{ {
highestFreq = neededFrequency; highestFreq = neededFrequency;
@ -719,12 +719,12 @@ void AudioConferenceMixerImpl::UpdateToMix(
ListWrapper& mixList, ListWrapper& mixList,
ListWrapper& rampOutList, ListWrapper& rampOutList,
MapWrapper& mixParticipantList, MapWrapper& mixParticipantList,
WebRtc_UWord32& maxAudioFrameCounter) uint32_t& maxAudioFrameCounter)
{ {
WEBRTC_TRACE(kTraceStream, kTraceAudioMixerServer, _id, WEBRTC_TRACE(kTraceStream, kTraceAudioMixerServer, _id,
"UpdateToMix(mixList,rampOutList,mixParticipantList,%d)", "UpdateToMix(mixList,rampOutList,mixParticipantList,%d)",
maxAudioFrameCounter); maxAudioFrameCounter);
const WebRtc_UWord32 mixListStartSize = mixList.GetSize(); const uint32_t mixListStartSize = mixList.GetSize();
ListWrapper activeList; // Elements are AudioFrames ListWrapper activeList; // Elements are AudioFrames
// Struct needed by the passive lists to keep track of which AudioFrame // Struct needed by the passive lists to keep track of which AudioFrame
// belongs to which MixerParticipant. // belongs to which MixerParticipant.
@ -790,7 +790,7 @@ void AudioConferenceMixerImpl::UpdateToMix(
// mixed. Only keep the ones with the highest energy. // mixed. Only keep the ones with the highest energy.
ListItem* replaceItem = NULL; ListItem* replaceItem = NULL;
CalculateEnergy(*audioFrame); CalculateEnergy(*audioFrame);
WebRtc_UWord32 lowestEnergy = audioFrame->energy_; uint32_t lowestEnergy = audioFrame->energy_;
ListItem* activeItem = activeList.First(); ListItem* activeItem = activeList.First();
while(activeItem) while(activeItem)
@ -1108,13 +1108,13 @@ bool AudioConferenceMixerImpl::RemoveParticipantFromList(
return false; return false;
} }
WebRtc_Word32 AudioConferenceMixerImpl::MixFromList( int32_t AudioConferenceMixerImpl::MixFromList(
AudioFrame& mixedAudio, AudioFrame& mixedAudio,
const ListWrapper& audioFrameList) const ListWrapper& audioFrameList)
{ {
WEBRTC_TRACE(kTraceStream, kTraceAudioMixerServer, _id, WEBRTC_TRACE(kTraceStream, kTraceAudioMixerServer, _id,
"MixFromList(mixedAudio, audioFrameList)"); "MixFromList(mixedAudio, audioFrameList)");
WebRtc_UWord32 position = 0; uint32_t position = 0;
ListItem* item = audioFrameList.First(); ListItem* item = audioFrameList.First();
if(item == NULL) if(item == NULL)
{ {
@ -1159,7 +1159,7 @@ WebRtc_Word32 AudioConferenceMixerImpl::MixFromList(
} }
// TODO(andrew): consolidate this function with MixFromList. // TODO(andrew): consolidate this function with MixFromList.
WebRtc_Word32 AudioConferenceMixerImpl::MixAnonomouslyFromList( int32_t AudioConferenceMixerImpl::MixAnonomouslyFromList(
AudioFrame& mixedAudio, AudioFrame& mixedAudio,
const ListWrapper& audioFrameList) const ListWrapper& audioFrameList)
{ {

View File

@ -32,14 +32,14 @@ public:
~MixHistory(); ~MixHistory();
// MixerParticipant function // MixerParticipant function
WebRtc_Word32 IsMixed(bool& mixed) const; int32_t IsMixed(bool& mixed) const;
// Sets wasMixed to true if the participant was mixed previous mix // Sets wasMixed to true if the participant was mixed previous mix
// iteration. // iteration.
WebRtc_Word32 WasMixed(bool& wasMixed) const; int32_t WasMixed(bool& wasMixed) const;
// Updates the mixed status. // Updates the mixed status.
WebRtc_Word32 SetIsMixed(const bool mixed); int32_t SetIsMixed(const bool mixed);
void ResetMixedStatus(); void ResetMixedStatus();
private: private:
@ -59,32 +59,32 @@ public:
bool Init(); bool Init();
// Module functions // Module functions
virtual WebRtc_Word32 ChangeUniqueId(const WebRtc_Word32 id); virtual int32_t ChangeUniqueId(const int32_t id);
virtual WebRtc_Word32 TimeUntilNextProcess(); virtual int32_t TimeUntilNextProcess();
virtual WebRtc_Word32 Process(); virtual int32_t Process();
// AudioConferenceMixer functions // AudioConferenceMixer functions
virtual WebRtc_Word32 RegisterMixedStreamCallback( virtual int32_t RegisterMixedStreamCallback(
AudioMixerOutputReceiver& mixReceiver); AudioMixerOutputReceiver& mixReceiver);
virtual WebRtc_Word32 UnRegisterMixedStreamCallback(); virtual int32_t UnRegisterMixedStreamCallback();
virtual WebRtc_Word32 RegisterMixerStatusCallback( virtual int32_t RegisterMixerStatusCallback(
AudioMixerStatusReceiver& mixerStatusCallback, AudioMixerStatusReceiver& mixerStatusCallback,
const WebRtc_UWord32 amountOf10MsBetweenCallbacks); const uint32_t amountOf10MsBetweenCallbacks);
virtual WebRtc_Word32 UnRegisterMixerStatusCallback(); virtual int32_t UnRegisterMixerStatusCallback();
virtual WebRtc_Word32 SetMixabilityStatus(MixerParticipant& participant, virtual int32_t SetMixabilityStatus(MixerParticipant& participant,
const bool mixable); const bool mixable);
virtual WebRtc_Word32 MixabilityStatus(MixerParticipant& participant, virtual int32_t MixabilityStatus(MixerParticipant& participant,
bool& mixable); bool& mixable);
virtual WebRtc_Word32 SetMinimumMixingFrequency(Frequency freq); virtual int32_t SetMinimumMixingFrequency(Frequency freq);
virtual WebRtc_Word32 SetAnonymousMixabilityStatus( virtual int32_t SetAnonymousMixabilityStatus(
MixerParticipant& participant, const bool mixable); MixerParticipant& participant, const bool mixable);
virtual WebRtc_Word32 AnonymousMixabilityStatus( virtual int32_t AnonymousMixabilityStatus(
MixerParticipant& participant, bool& mixable); MixerParticipant& participant, bool& mixable);
private: private:
enum{DEFAULT_AUDIO_FRAME_POOLSIZE = 50}; enum{DEFAULT_AUDIO_FRAME_POOLSIZE = 50};
// Set/get mix frequency // Set/get mix frequency
WebRtc_Word32 SetOutputFrequency(const Frequency frequency); int32_t SetOutputFrequency(const Frequency frequency);
Frequency OutputFrequency() const; Frequency OutputFrequency() const;
// Must be called whenever an audio frame indicates the number of channels // Must be called whenever an audio frame indicates the number of channels
@ -101,12 +101,12 @@ private:
// should be ramped out over this AudioFrame to avoid audio discontinuities. // should be ramped out over this AudioFrame to avoid audio discontinuities.
void UpdateToMix(ListWrapper& mixList, ListWrapper& rampOutList, void UpdateToMix(ListWrapper& mixList, ListWrapper& rampOutList,
MapWrapper& mixParticipantList, MapWrapper& mixParticipantList,
WebRtc_UWord32& maxAudioFrameCounter); uint32_t& maxAudioFrameCounter);
// Return the lowest mixing frequency that can be used without having to // Return the lowest mixing frequency that can be used without having to
// downsample any audio. // downsample any audio.
WebRtc_Word32 GetLowestMixingFrequency(); int32_t GetLowestMixingFrequency();
WebRtc_Word32 GetLowestMixingFrequencyFromList(ListWrapper& mixList); int32_t GetLowestMixingFrequencyFromList(ListWrapper& mixList);
// Return the AudioFrames that should be mixed anonymously. // Return the AudioFrames that should be mixed anonymously.
void GetAdditionalAudio(ListWrapper& additionalFramesList); void GetAdditionalAudio(ListWrapper& additionalFramesList);
@ -139,31 +139,31 @@ private:
ListWrapper& participantList); ListWrapper& participantList);
// Mix the AudioFrames stored in audioFrameList into mixedAudio. // Mix the AudioFrames stored in audioFrameList into mixedAudio.
WebRtc_Word32 MixFromList( int32_t MixFromList(
AudioFrame& mixedAudio, AudioFrame& mixedAudio,
const ListWrapper& audioFrameList); const ListWrapper& audioFrameList);
// Mix the AudioFrames stored in audioFrameList into mixedAudio. No // Mix the AudioFrames stored in audioFrameList into mixedAudio. No
// record will be kept of this mix (e.g. the corresponding MixerParticipants // record will be kept of this mix (e.g. the corresponding MixerParticipants
// will not be marked as IsMixed() // will not be marked as IsMixed()
WebRtc_Word32 MixAnonomouslyFromList(AudioFrame& mixedAudio, int32_t MixAnonomouslyFromList(AudioFrame& mixedAudio,
const ListWrapper& audioFrameList); const ListWrapper& audioFrameList);
bool LimitMixedAudio(AudioFrame& mixedAudio); bool LimitMixedAudio(AudioFrame& mixedAudio);
// Scratch memory // Scratch memory
// Note that the scratch memory may only be touched in the scope of // Note that the scratch memory may only be touched in the scope of
// Process(). // Process().
WebRtc_UWord32 _scratchParticipantsToMixAmount; uint32_t _scratchParticipantsToMixAmount;
ParticipantStatistics _scratchMixedParticipants[ ParticipantStatistics _scratchMixedParticipants[
kMaximumAmountOfMixedParticipants]; kMaximumAmountOfMixedParticipants];
WebRtc_UWord32 _scratchVadPositiveParticipantsAmount; uint32_t _scratchVadPositiveParticipantsAmount;
ParticipantStatistics _scratchVadPositiveParticipants[ ParticipantStatistics _scratchVadPositiveParticipants[
kMaximumAmountOfMixedParticipants]; kMaximumAmountOfMixedParticipants];
scoped_ptr<CriticalSectionWrapper> _crit; scoped_ptr<CriticalSectionWrapper> _crit;
scoped_ptr<CriticalSectionWrapper> _cbCrit; scoped_ptr<CriticalSectionWrapper> _cbCrit;
WebRtc_Word32 _id; int32_t _id;
Frequency _minimumMixingFreq; Frequency _minimumMixingFreq;
@ -171,13 +171,13 @@ private:
AudioMixerOutputReceiver* _mixReceiver; AudioMixerOutputReceiver* _mixReceiver;
AudioMixerStatusReceiver* _mixerStatusCallback; AudioMixerStatusReceiver* _mixerStatusCallback;
WebRtc_UWord32 _amountOf10MsBetweenCallbacks; uint32_t _amountOf10MsBetweenCallbacks;
WebRtc_UWord32 _amountOf10MsUntilNextCallback; uint32_t _amountOf10MsUntilNextCallback;
bool _mixerStatusCb; bool _mixerStatusCb;
// The current sample frequency and sample size when mixing. // The current sample frequency and sample size when mixing.
Frequency _outputFrequency; Frequency _outputFrequency;
WebRtc_UWord16 _sampleSize; uint16_t _sampleSize;
// Memory pool to avoid allocating/deallocating AudioFrames // Memory pool to avoid allocating/deallocating AudioFrames
MemoryPool<AudioFrame>* _audioFramePool; MemoryPool<AudioFrame>* _audioFramePool;
@ -186,9 +186,9 @@ private:
ListWrapper _participantList; // May be mixed. ListWrapper _participantList; // May be mixed.
ListWrapper _additionalParticipantList; // Always mixed, anonomously. ListWrapper _additionalParticipantList; // Always mixed, anonomously.
WebRtc_UWord32 _numMixedParticipants; uint32_t _numMixedParticipants;
WebRtc_UWord32 _timeStamp; uint32_t _timeStamp;
// Metronome class. // Metronome class.
TimeScheduler _timeScheduler; TimeScheduler _timeScheduler;
@ -198,7 +198,7 @@ private:
// Counter keeping track of concurrent calls to process. // Counter keeping track of concurrent calls to process.
// Note: should never be higher than 1 or lower than 0. // Note: should never be higher than 1 or lower than 0.
WebRtc_Word16 _processCalls; int16_t _processCalls;
// Used for inhibiting saturation in mixing. // Used for inhibiting saturation in mixing.
scoped_ptr<AudioProcessing> _limiter; scoped_ptr<AudioProcessing> _limiter;

View File

@ -60,8 +60,8 @@ void RampIn(AudioFrame& audioFrame)
assert(rampSize <= audioFrame.samples_per_channel_); assert(rampSize <= audioFrame.samples_per_channel_);
for(int i = 0; i < rampSize; i++) for(int i = 0; i < rampSize; i++)
{ {
audioFrame.data_[i] = static_cast<WebRtc_Word16> audioFrame.data_[i] = static_cast<int16_t>(rampArray[i] *
(rampArray[i] * audioFrame.data_[i]); audioFrame.data_[i]);
} }
} }
@ -71,8 +71,8 @@ void RampOut(AudioFrame& audioFrame)
for(int i = 0; i < rampSize; i++) for(int i = 0; i < rampSize; i++)
{ {
const int rampPos = rampSize - 1 - i; const int rampPos = rampSize - 1 - i;
audioFrame.data_[i] = static_cast<WebRtc_Word16> audioFrame.data_[i] = static_cast<int16_t>(rampArray[rampPos] *
(rampArray[rampPos] * audioFrame.data_[i]); audioFrame.data_[i]);
} }
memset(&audioFrame.data_[rampSize], 0, memset(&audioFrame.data_[rampSize], 0,
(audioFrame.samples_per_channel_ - rampSize) * (audioFrame.samples_per_channel_ - rampSize) *

View File

@ -12,7 +12,7 @@
namespace webrtc { namespace webrtc {
// Array for adding smothing to level changes (ad-hoc). // Array for adding smothing to level changes (ad-hoc).
const WebRtc_UWord32 perm[] = const uint32_t perm[] =
{0,1,2,3,4,4,5,5,5,5,6,6,6,6,6,7,7,7,7,8,8,8,9,9,9,9,9,9,9,9,9,9,9}; {0,1,2,3,4,4,5,5,5,5,6,6,6,6,6,7,7,7,7,8,8,8,9,9,9,9,9,9,9,9,9,9,9};
LevelIndicator::LevelIndicator() LevelIndicator::LevelIndicator()
@ -27,11 +27,11 @@ LevelIndicator::~LevelIndicator()
} }
// Level is based on the highest absolute value for all samples. // Level is based on the highest absolute value for all samples.
void LevelIndicator::ComputeLevel(const WebRtc_Word16* speech, void LevelIndicator::ComputeLevel(const int16_t* speech,
const WebRtc_UWord16 nrOfSamples) const uint16_t nrOfSamples)
{ {
WebRtc_Word32 min = 0; int32_t min = 0;
for(WebRtc_UWord32 i = 0; i < nrOfSamples; i++) for(uint32_t i = 0; i < nrOfSamples; i++)
{ {
if(_max < speech[i]) if(_max < speech[i])
{ {
@ -52,7 +52,7 @@ void LevelIndicator::ComputeLevel(const WebRtc_Word16* speech,
if(_count == TICKS_BEFORE_CALCULATION) if(_count == TICKS_BEFORE_CALCULATION)
{ {
// Highest sample value maps directly to a level. // Highest sample value maps directly to a level.
WebRtc_Word32 position = _max / 1000; int32_t position = _max / 1000;
if ((position == 0) && if ((position == 0) &&
(_max > 250)) (_max > 250))
{ {
@ -68,7 +68,7 @@ void LevelIndicator::ComputeLevel(const WebRtc_Word16* speech,
} }
} }
WebRtc_Word32 LevelIndicator::GetLevel() int32_t LevelIndicator::GetLevel()
{ {
return _currentLevel; return _currentLevel;
} }

View File

@ -23,14 +23,14 @@ public:
~LevelIndicator(); ~LevelIndicator();
// Updates the level. // Updates the level.
void ComputeLevel(const WebRtc_Word16* speech, void ComputeLevel(const int16_t* speech,
const WebRtc_UWord16 nrOfSamples); const uint16_t nrOfSamples);
WebRtc_Word32 GetLevel(); int32_t GetLevel();
private: private:
WebRtc_Word32 _max; int32_t _max;
WebRtc_UWord32 _count; uint32_t _count;
WebRtc_UWord32 _currentLevel; uint32_t _currentLevel;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -28,26 +28,26 @@ class MemoryPool
{ {
public: public:
// Factory method, constructor disabled. // Factory method, constructor disabled.
static WebRtc_Word32 CreateMemoryPool(MemoryPool*& memoryPool, static int32_t CreateMemoryPool(MemoryPool*& memoryPool,
WebRtc_UWord32 initialPoolSize); uint32_t initialPoolSize);
// Try to delete the memory pool. Fail with return value -1 if there is // Try to delete the memory pool. Fail with return value -1 if there is
// outstanding memory. // outstanding memory.
static WebRtc_Word32 DeleteMemoryPool( static int32_t DeleteMemoryPool(
MemoryPool*& memoryPool); MemoryPool*& memoryPool);
// Get/return unused memory. // Get/return unused memory.
WebRtc_Word32 PopMemory(MemoryType*& memory); int32_t PopMemory(MemoryType*& memory);
WebRtc_Word32 PushMemory(MemoryType*& memory); int32_t PushMemory(MemoryType*& memory);
private: private:
MemoryPool(WebRtc_Word32 initialPoolSize); MemoryPool(int32_t initialPoolSize);
~MemoryPool(); ~MemoryPool();
MemoryPoolImpl<MemoryType>* _ptrImpl; MemoryPoolImpl<MemoryType>* _ptrImpl;
}; };
template<class MemoryType> template<class MemoryType>
MemoryPool<MemoryType>::MemoryPool(WebRtc_Word32 initialPoolSize) MemoryPool<MemoryType>::MemoryPool(int32_t initialPoolSize)
{ {
_ptrImpl = new MemoryPoolImpl<MemoryType>(initialPoolSize); _ptrImpl = new MemoryPoolImpl<MemoryType>(initialPoolSize);
} }
@ -58,9 +58,9 @@ MemoryPool<MemoryType>::~MemoryPool()
delete _ptrImpl; delete _ptrImpl;
} }
template<class MemoryType> WebRtc_Word32 template<class MemoryType> int32_t
MemoryPool<MemoryType>::CreateMemoryPool(MemoryPool*& memoryPool, MemoryPool<MemoryType>::CreateMemoryPool(MemoryPool*& memoryPool,
WebRtc_UWord32 initialPoolSize) uint32_t initialPoolSize)
{ {
memoryPool = new MemoryPool(initialPoolSize); memoryPool = new MemoryPool(initialPoolSize);
if(memoryPool == NULL) if(memoryPool == NULL)
@ -83,7 +83,7 @@ MemoryPool<MemoryType>::CreateMemoryPool(MemoryPool*& memoryPool,
} }
template<class MemoryType> template<class MemoryType>
WebRtc_Word32 MemoryPool<MemoryType>::DeleteMemoryPool(MemoryPool*& memoryPool) int32_t MemoryPool<MemoryType>::DeleteMemoryPool(MemoryPool*& memoryPool)
{ {
if(memoryPool == NULL) if(memoryPool == NULL)
{ {
@ -103,13 +103,13 @@ WebRtc_Word32 MemoryPool<MemoryType>::DeleteMemoryPool(MemoryPool*& memoryPool)
} }
template<class MemoryType> template<class MemoryType>
WebRtc_Word32 MemoryPool<MemoryType>::PopMemory(MemoryType*& memory) int32_t MemoryPool<MemoryType>::PopMemory(MemoryType*& memory)
{ {
return _ptrImpl->PopMemory(memory); return _ptrImpl->PopMemory(memory);
} }
template<class MemoryType> template<class MemoryType>
WebRtc_Word32 MemoryPool<MemoryType>::PushMemory(MemoryType*& memory) int32_t MemoryPool<MemoryType>::PushMemory(MemoryType*& memory)
{ {
if(memory == NULL) if(memory == NULL)
{ {

View File

@ -23,18 +23,18 @@ class MemoryPoolImpl
{ {
public: public:
// MemoryPool functions. // MemoryPool functions.
WebRtc_Word32 PopMemory(MemoryType*& memory); int32_t PopMemory(MemoryType*& memory);
WebRtc_Word32 PushMemory(MemoryType*& memory); int32_t PushMemory(MemoryType*& memory);
MemoryPoolImpl(WebRtc_Word32 initialPoolSize); MemoryPoolImpl(int32_t initialPoolSize);
~MemoryPoolImpl(); ~MemoryPoolImpl();
// Atomic functions // Atomic functions
WebRtc_Word32 Terminate(); int32_t Terminate();
bool Initialize(); bool Initialize();
private: private:
// Non-atomic function. // Non-atomic function.
WebRtc_Word32 CreateMemory(WebRtc_UWord32 amountToCreate); int32_t CreateMemory(uint32_t amountToCreate);
CriticalSectionWrapper* _crit; CriticalSectionWrapper* _crit;
@ -42,13 +42,13 @@ private:
ListWrapper _memoryPool; ListWrapper _memoryPool;
WebRtc_UWord32 _initialPoolSize; uint32_t _initialPoolSize;
WebRtc_UWord32 _createdMemory; uint32_t _createdMemory;
WebRtc_UWord32 _outstandingMemory; uint32_t _outstandingMemory;
}; };
template<class MemoryType> template<class MemoryType>
MemoryPoolImpl<MemoryType>::MemoryPoolImpl(WebRtc_Word32 initialPoolSize) MemoryPoolImpl<MemoryType>::MemoryPoolImpl(int32_t initialPoolSize)
: _crit(CriticalSectionWrapper::CreateCriticalSection()), : _crit(CriticalSectionWrapper::CreateCriticalSection()),
_terminate(false), _terminate(false),
_memoryPool(), _memoryPool(),
@ -68,7 +68,7 @@ MemoryPoolImpl<MemoryType>::~MemoryPoolImpl()
} }
template<class MemoryType> template<class MemoryType>
WebRtc_Word32 MemoryPoolImpl<MemoryType>::PopMemory(MemoryType*& memory) int32_t MemoryPoolImpl<MemoryType>::PopMemory(MemoryType*& memory)
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
if(_terminate) if(_terminate)
@ -95,7 +95,7 @@ WebRtc_Word32 MemoryPoolImpl<MemoryType>::PopMemory(MemoryType*& memory)
} }
template<class MemoryType> template<class MemoryType>
WebRtc_Word32 MemoryPoolImpl<MemoryType>::PushMemory(MemoryType*& memory) int32_t MemoryPoolImpl<MemoryType>::PushMemory(MemoryType*& memory)
{ {
if(memory == NULL) if(memory == NULL)
{ {
@ -124,7 +124,7 @@ bool MemoryPoolImpl<MemoryType>::Initialize()
} }
template<class MemoryType> template<class MemoryType>
WebRtc_Word32 MemoryPoolImpl<MemoryType>::Terminate() int32_t MemoryPoolImpl<MemoryType>::Terminate()
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
assert(_createdMemory == _outstandingMemory + _memoryPool.GetSize()); assert(_createdMemory == _outstandingMemory + _memoryPool.GetSize());
@ -148,10 +148,10 @@ WebRtc_Word32 MemoryPoolImpl<MemoryType>::Terminate()
} }
template<class MemoryType> template<class MemoryType>
WebRtc_Word32 MemoryPoolImpl<MemoryType>::CreateMemory( int32_t MemoryPoolImpl<MemoryType>::CreateMemory(
WebRtc_UWord32 amountToCreate) uint32_t amountToCreate)
{ {
for(WebRtc_UWord32 i = 0; i < amountToCreate; i++) for(uint32_t i = 0; i < amountToCreate; i++)
{ {
MemoryType* memory = new MemoryType(); MemoryType* memory = new MemoryType();
if(memory == NULL) if(memory == NULL)

View File

@ -47,14 +47,14 @@ class MemoryPoolImpl
{ {
public: public:
// MemoryPool functions. // MemoryPool functions.
WebRtc_Word32 PopMemory(MemoryType*& memory); int32_t PopMemory(MemoryType*& memory);
WebRtc_Word32 PushMemory(MemoryType*& memory); int32_t PushMemory(MemoryType*& memory);
MemoryPoolImpl(WebRtc_Word32 /*initialPoolSize*/); MemoryPoolImpl(int32_t /*initialPoolSize*/);
~MemoryPoolImpl(); ~MemoryPoolImpl();
// Atomic functions. // Atomic functions.
WebRtc_Word32 Terminate(); int32_t Terminate();
bool Initialize(); bool Initialize();
private: private:
// Non-atomic function. // Non-atomic function.
@ -72,7 +72,7 @@ private:
template<class MemoryType> template<class MemoryType>
MemoryPoolImpl<MemoryType>::MemoryPoolImpl( MemoryPoolImpl<MemoryType>::MemoryPoolImpl(
WebRtc_Word32 /*initialPoolSize*/) int32_t /*initialPoolSize*/)
: _pListHead(NULL), : _pListHead(NULL),
_createdMemory(0), _createdMemory(0),
_outstandingMemory(0) _outstandingMemory(0)
@ -94,7 +94,7 @@ MemoryPoolImpl<MemoryType>::~MemoryPoolImpl()
} }
template<class MemoryType> template<class MemoryType>
WebRtc_Word32 MemoryPoolImpl<MemoryType>::PopMemory(MemoryType*& memory) int32_t MemoryPoolImpl<MemoryType>::PopMemory(MemoryType*& memory)
{ {
PSLIST_ENTRY pListEntry = InterlockedPopEntrySList(_pListHead); PSLIST_ENTRY pListEntry = InterlockedPopEntrySList(_pListHead);
if(pListEntry == NULL) if(pListEntry == NULL)
@ -112,7 +112,7 @@ WebRtc_Word32 MemoryPoolImpl<MemoryType>::PopMemory(MemoryType*& memory)
} }
template<class MemoryType> template<class MemoryType>
WebRtc_Word32 MemoryPoolImpl<MemoryType>::PushMemory(MemoryType*& memory) int32_t MemoryPoolImpl<MemoryType>::PushMemory(MemoryType*& memory)
{ {
if(memory == NULL) if(memory == NULL)
{ {
@ -122,9 +122,9 @@ WebRtc_Word32 MemoryPoolImpl<MemoryType>::PushMemory(MemoryType*& memory)
MemoryPoolItem<MemoryType>* item = MemoryPoolItem<MemoryType>* item =
((MemoryPoolItemPayload<MemoryType>*)memory)->base; ((MemoryPoolItemPayload<MemoryType>*)memory)->base;
const WebRtc_Word32 usedItems = --_outstandingMemory; const int32_t usedItems = --_outstandingMemory;
const WebRtc_Word32 totalItems = _createdMemory.Value(); const int32_t totalItems = _createdMemory.Value();
const WebRtc_Word32 freeItems = totalItems - usedItems; const int32_t freeItems = totalItems - usedItems;
if(freeItems < 0) if(freeItems < 0)
{ {
assert(false); assert(false);
@ -157,9 +157,9 @@ bool MemoryPoolImpl<MemoryType>::Initialize()
} }
template<class MemoryType> template<class MemoryType>
WebRtc_Word32 MemoryPoolImpl<MemoryType>::Terminate() int32_t MemoryPoolImpl<MemoryType>::Terminate()
{ {
WebRtc_Word32 itemsFreed = 0; int32_t itemsFreed = 0;
PSLIST_ENTRY pListEntry = InterlockedPopEntrySList(_pListHead); PSLIST_ENTRY pListEntry = InterlockedPopEntrySList(_pListHead);
while(pListEntry != NULL) while(pListEntry != NULL)
{ {

View File

@ -12,7 +12,7 @@
#include "time_scheduler.h" #include "time_scheduler.h"
namespace webrtc { namespace webrtc {
TimeScheduler::TimeScheduler(const WebRtc_UWord32 periodicityInMs) TimeScheduler::TimeScheduler(const uint32_t periodicityInMs)
: _crit(CriticalSectionWrapper::CreateCriticalSection()), : _crit(CriticalSectionWrapper::CreateCriticalSection()),
_isStarted(false), _isStarted(false),
_lastPeriodMark(), _lastPeriodMark(),
@ -27,7 +27,7 @@ TimeScheduler::~TimeScheduler()
delete _crit; delete _crit;
} }
WebRtc_Word32 TimeScheduler::UpdateScheduler() int32_t TimeScheduler::UpdateScheduler()
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
if(!_isStarted) if(!_isStarted)
@ -47,11 +47,11 @@ WebRtc_Word32 TimeScheduler::UpdateScheduler()
// Calculate the time that has past since previous call to this function. // Calculate the time that has past since previous call to this function.
TickTime tickNow = TickTime::Now(); TickTime tickNow = TickTime::Now();
TickInterval amassedTicks = tickNow - _lastPeriodMark; TickInterval amassedTicks = tickNow - _lastPeriodMark;
WebRtc_Word64 amassedMs = amassedTicks.Milliseconds(); int64_t amassedMs = amassedTicks.Milliseconds();
// Calculate the number of periods the time that has passed correspond to. // Calculate the number of periods the time that has passed correspond to.
WebRtc_Word32 periodsToClaim = (WebRtc_Word32)amassedMs / int32_t periodsToClaim = static_cast<int32_t>(amassedMs /
((WebRtc_Word32)_periodicityInMs); static_cast<int32_t>(_periodicityInMs));
// One period will be worked off by this call. Make sure that the number of // One period will be worked off by this call. Make sure that the number of
// pending periods don't end up being negative (e.g. if this function is // pending periods don't end up being negative (e.g. if this function is
@ -65,7 +65,7 @@ WebRtc_Word32 TimeScheduler::UpdateScheduler()
// Note that if this fuunction is called to often _lastPeriodMark can // Note that if this fuunction is called to often _lastPeriodMark can
// refer to a time in the future which in turn will yield TimeToNextUpdate // refer to a time in the future which in turn will yield TimeToNextUpdate
// that is greater than the periodicity // that is greater than the periodicity
for(WebRtc_Word32 i = 0; i < periodsToClaim; i++) for(int32_t i = 0; i < periodsToClaim; i++)
{ {
_lastPeriodMark += _periodicityInTicks; _lastPeriodMark += _periodicityInTicks;
} }
@ -76,8 +76,8 @@ WebRtc_Word32 TimeScheduler::UpdateScheduler()
return 0; return 0;
} }
WebRtc_Word32 TimeScheduler::TimeToNextUpdate( int32_t TimeScheduler::TimeToNextUpdate(
WebRtc_Word32& updateTimeInMS) const int32_t& updateTimeInMS) const
{ {
CriticalSectionScoped cs(_crit); CriticalSectionScoped cs(_crit);
// Missed periods means that the next UpdateScheduler() should happen // Missed periods means that the next UpdateScheduler() should happen
@ -92,8 +92,8 @@ WebRtc_Word32 TimeScheduler::TimeToNextUpdate(
// UpdateScheduler() // UpdateScheduler()
TickTime tickNow = TickTime::Now(); TickTime tickNow = TickTime::Now();
TickInterval ticksSinceLastUpdate = tickNow - _lastPeriodMark; TickInterval ticksSinceLastUpdate = tickNow - _lastPeriodMark;
const WebRtc_Word32 millisecondsSinceLastUpdate = const int32_t millisecondsSinceLastUpdate =
(WebRtc_Word32) ticksSinceLastUpdate.Milliseconds(); static_cast<int32_t>(ticksSinceLastUpdate.Milliseconds());
updateTimeInMS = _periodicityInMs - millisecondsSinceLastUpdate; updateTimeInMS = _periodicityInMs - millisecondsSinceLastUpdate;
updateTimeInMS = (updateTimeInMS < 0) ? 0 : updateTimeInMS; updateTimeInMS = (updateTimeInMS < 0) ? 0 : updateTimeInMS;

View File

@ -22,15 +22,15 @@ class CriticalSectionWrapper;
class TimeScheduler class TimeScheduler
{ {
public: public:
TimeScheduler(const WebRtc_UWord32 periodicityInMs); TimeScheduler(const uint32_t periodicityInMs);
~TimeScheduler(); ~TimeScheduler();
// Signal that a periodic event has been triggered. // Signal that a periodic event has been triggered.
WebRtc_Word32 UpdateScheduler(); int32_t UpdateScheduler();
// Set updateTimeInMs to the amount of time until UpdateScheduler() should // Set updateTimeInMs to the amount of time until UpdateScheduler() should
// be called. This time will never be negative. // be called. This time will never be negative.
WebRtc_Word32 TimeToNextUpdate(WebRtc_Word32& updateTimeInMS) const; int32_t TimeToNextUpdate(int32_t& updateTimeInMS) const;
private: private:
CriticalSectionWrapper* _crit; CriticalSectionWrapper* _crit;
@ -38,9 +38,9 @@ private:
bool _isStarted; bool _isStarted;
TickTime _lastPeriodMark; TickTime _lastPeriodMark;
WebRtc_UWord32 _periodicityInMs; uint32_t _periodicityInMs;
WebRtc_Word64 _periodicityInTicks; int64_t _periodicityInTicks;
WebRtc_UWord32 _missedPeriods; uint32_t _missedPeriods;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -46,8 +46,8 @@ int main(int /*argc*/, char* /*argv[]*/)
} }
char versionString[256] = ""; char versionString[256] = "";
WebRtc_UWord32 remainingBufferInBytes = 256; uint32_t remainingBufferInBytes = 256;
WebRtc_UWord32 position = 0; uint32_t position = 0;
AudioConferenceMixer::GetVersion(versionString,remainingBufferInBytes,position); AudioConferenceMixer::GetVersion(versionString,remainingBufferInBytes,position);
int read = 1; int read = 1;
@ -70,7 +70,7 @@ int main(int /*argc*/, char* /*argv[]*/)
getchar(); getchar();
MixerParticipant::ParticipantType participantType; MixerParticipant::ParticipantType participantType;
int option = 0; int option = 0;
WebRtc_UWord32 id = 0; uint32_t id = 0;
ListItem* item = NULL; ListItem* item = NULL;
ListWrapper participants; ListWrapper participants;
if(read == 0) if(read == 0)
@ -122,7 +122,7 @@ int main(int /*argc*/, char* /*argv[]*/)
std::cout << "The following participants have been created: " << std::endl; std::cout << "The following participants have been created: " << std::endl;
while(item) while(item)
{ {
WebRtc_UWord32 id = item->GetUnsignedItem(); uint32_t id = item->GetUnsignedItem();
std::cout << id; std::cout << id;
item = participants.Next(item); item = participants.Next(item);
if(item != NULL) if(item != NULL)
@ -147,7 +147,7 @@ int main(int /*argc*/, char* /*argv[]*/)
} }
else if(read == 8) else if(read == 8)
{ {
const WebRtc_Word32 amountOfParticipants = 4; const int32_t amountOfParticipants = 4;
MixerParticipant::ParticipantType instance1Participants[] = MixerParticipant::ParticipantType instance1Participants[] =
{MixerParticipant::VIP, {MixerParticipant::VIP,
MixerParticipant::REGULAR, MixerParticipant::REGULAR,
@ -158,9 +158,9 @@ int main(int /*argc*/, char* /*argv[]*/)
MixerParticipant::REGULAR, MixerParticipant::REGULAR,
MixerParticipant::REGULAR, MixerParticipant::REGULAR,
MixerParticipant::REGULAR}; MixerParticipant::REGULAR};
for(WebRtc_Word32 i = 0; i < amountOfParticipants; i++) for(int32_t i = 0; i < amountOfParticipants; i++)
{ {
WebRtc_Word32 startPosition = 0; int32_t startPosition = 0;
GenerateRandomPosition(startPosition); GenerateRandomPosition(startPosition);
testInstance1->CreateParticipant(instance1Participants[i],startPosition); testInstance1->CreateParticipant(instance1Participants[i],startPosition);
testInstance2->CreateParticipant(instance2Participants[i],startPosition); testInstance2->CreateParticipant(instance2Participants[i],startPosition);
@ -210,7 +210,9 @@ bool
FileWriter::WriteToFile( FileWriter::WriteToFile(
const AudioFrame& audioFrame) const AudioFrame& audioFrame)
{ {
WebRtc_Word32 written = (WebRtc_Word32)fwrite(audioFrame.data_,sizeof(WebRtc_Word16),audioFrame.samples_per_channel_,_file); int32_t written =
static_cast<int32_t>(fwrite(audioFrame.data_, sizeof(int16_t),
audioFrame.samples_per_channel_, _file));
// Do not flush buffers since that will add (a lot of) delay // Do not flush buffers since that will add (a lot of) delay
return written == audioFrame.samples_per_channel_; return written == audioFrame.samples_per_channel_;
} }
@ -269,7 +271,7 @@ FileReader::ReadFromFile(
AudioFrame& audioFrame) AudioFrame& audioFrame)
{ {
WebRtc_Word16 buffer[AudioFrame::kMaxDataSizeSamples]; int16_t buffer[AudioFrame::kMaxDataSizeSamples];
LoopedFileRead(buffer,AudioFrame::kMaxDataSizeSamples,_sampleSize,_file); LoopedFileRead(buffer,AudioFrame::kMaxDataSizeSamples,_sampleSize,_file);
bool vad = false; bool vad = false;
@ -278,7 +280,7 @@ FileReader::ReadFromFile(
AudioFrame::kVadPassive; AudioFrame::kVadPassive;
_volumeCalculator.ComputeLevel(buffer,_sampleSize); _volumeCalculator.ComputeLevel(buffer,_sampleSize);
const WebRtc_Word32 level = _volumeCalculator.GetLevel(); const int32_t level = _volumeCalculator.GetLevel();
return audioFrame.UpdateFrame( -1, return audioFrame.UpdateFrame( -1,
_timeStamp, _timeStamp,
buffer, buffer,
@ -293,9 +295,9 @@ FileReader::ReadFromFile(
bool bool
FileReader::FastForwardFile( FileReader::FastForwardFile(
const WebRtc_Word32 samples) const int32_t samples)
{ {
WebRtc_Word16* tempBuffer = new WebRtc_Word16[samples]; int16_t* tempBuffer = new int16_t[samples];
bool success = LoopedFileRead(tempBuffer,samples,samples,_file); bool success = LoopedFileRead(tempBuffer,samples,samples,_file);
delete[] tempBuffer; delete[] tempBuffer;
return success; return success;
@ -333,13 +335,13 @@ FileReader::SetVAD(
bool bool
FileReader::GetVAD( FileReader::GetVAD(
WebRtc_Word16* buffer, int16_t* buffer,
WebRtc_UWord8 bufferLengthInSamples, uint8_t bufferLengthInSamples,
bool& vad) bool& vad)
{ {
if(_automaticVad) if(_automaticVad)
{ {
WebRtc_Word16 result = WebRtcVad_Process(_vadInstr,_frequency,buffer,bufferLengthInSamples); int16_t result = WebRtcVad_Process(_vadInstr,_frequency,buffer,bufferLengthInSamples);
if(result == -1) if(result == -1)
{ {
assert(false); assert(false);
@ -353,9 +355,9 @@ FileReader::GetVAD(
MixerParticipant* MixerParticipant*
MixerParticipant::CreateParticipant( MixerParticipant::CreateParticipant(
const WebRtc_UWord32 id, const uint32_t id,
ParticipantType participantType, ParticipantType participantType,
const WebRtc_Word32 startPosition, const int32_t startPosition,
char* outputPath) char* outputPath)
{ {
if(participantType == RANDOM) if(participantType == RANDOM)
@ -376,7 +378,7 @@ MixerParticipant::CreateParticipant(
} }
MixerParticipant::MixerParticipant( MixerParticipant::MixerParticipant(
const WebRtc_UWord32 id, const uint32_t id,
ParticipantType participantType) ParticipantType participantType)
: :
_id(id), _id(id),
@ -390,9 +392,9 @@ MixerParticipant::~MixerParticipant()
{ {
} }
WebRtc_Word32 int32_t
MixerParticipant::GetAudioFrame( MixerParticipant::GetAudioFrame(
const WebRtc_Word32 /*id*/, const int32_t /*id*/,
AudioFrame& audioFrame) AudioFrame& audioFrame)
{ {
if(!_fileReader.ReadFromFile(audioFrame)) if(!_fileReader.ReadFromFile(audioFrame))
@ -403,14 +405,14 @@ MixerParticipant::GetAudioFrame(
return 0; return 0;
} }
WebRtc_Word32 int32_t
MixerParticipant::MixedAudioFrame( MixerParticipant::MixedAudioFrame(
const AudioFrame& audioFrame) const AudioFrame& audioFrame)
{ {
return _fileWriter.WriteToFile(audioFrame); return _fileWriter.WriteToFile(audioFrame);
} }
WebRtc_Word32 int32_t
MixerParticipant::GetParticipantType( MixerParticipant::GetParticipantType(
ParticipantType& participantType) ParticipantType& participantType)
{ {
@ -420,7 +422,7 @@ MixerParticipant::GetParticipantType(
bool bool
MixerParticipant::InitializeFileReader( MixerParticipant::InitializeFileReader(
const WebRtc_Word32 startPositionInSamples) const int32_t startPositionInSamples)
{ {
char fileName[128] = ""; char fileName[128] = "";
if(_participantType == REGULAR) if(_participantType == REGULAR)
@ -446,7 +448,7 @@ bool
MixerParticipant::InitializeFileWriter( MixerParticipant::InitializeFileWriter(
char* outputPath) char* outputPath)
{ {
const WebRtc_Word32 stringsize = 128; const int32_t stringsize = 128;
char fileName[stringsize] = ""; char fileName[stringsize] = "";
strncpy(fileName,outputPath,stringsize); strncpy(fileName,outputPath,stringsize);
fileName[stringsize-1] = '\0'; fileName[stringsize-1] = '\0';
@ -461,7 +463,7 @@ MixerParticipant::InitializeFileWriter(
} }
StatusReceiver::StatusReceiver( StatusReceiver::StatusReceiver(
const WebRtc_Word32 id) const int32_t id)
: :
_id(id), _id(id),
_mixedParticipants(NULL), _mixedParticipants(NULL),
@ -482,9 +484,9 @@ StatusReceiver::~StatusReceiver()
void void
StatusReceiver::MixedParticipants( StatusReceiver::MixedParticipants(
const WebRtc_Word32 id, const int32_t id,
const ParticipantStatistics* participantStatistics, const ParticipantStatistics* participantStatistics,
const WebRtc_UWord32 size) const uint32_t size)
{ {
if(id != _id) if(id != _id)
{ {
@ -502,9 +504,9 @@ StatusReceiver::MixedParticipants(
void void
StatusReceiver::VADPositiveParticipants( StatusReceiver::VADPositiveParticipants(
const WebRtc_Word32 id, const int32_t id,
const ParticipantStatistics* participantStatistics, const ParticipantStatistics* participantStatistics,
const WebRtc_UWord32 size) const uint32_t size)
{ {
if(id != _id) if(id != _id)
{ {
@ -523,8 +525,8 @@ StatusReceiver::VADPositiveParticipants(
void void
StatusReceiver::MixedAudioLevel( StatusReceiver::MixedAudioLevel(
const WebRtc_Word32 id, const int32_t id,
const WebRtc_UWord32 level) const uint32_t level)
{ {
if(id != _id) if(id != _id)
{ {
@ -541,7 +543,7 @@ StatusReceiver::PrintMixedParticipants()
{ {
std::cout << "N/A" << std::endl; std::cout << "N/A" << std::endl;
} }
for(WebRtc_UWord16 i = 0; i < _mixedParticipantsAmount; i++) for(uint16_t i = 0; i < _mixedParticipantsAmount; i++)
{ {
std::cout << i + 1 << ". Participant " << _mixedParticipants[i].participant << ": level = " << _mixedParticipants[i].level << std::endl; std::cout << i + 1 << ". Participant " << _mixedParticipants[i].participant << ": level = " << _mixedParticipants[i].level << std::endl;
} }
@ -555,7 +557,7 @@ StatusReceiver::PrintVadPositiveParticipants()
{ {
std::cout << "N/A" << std::endl; std::cout << "N/A" << std::endl;
} }
for(WebRtc_UWord16 i = 0; i < _mixedParticipantsAmount; i++) for(uint16_t i = 0; i < _mixedParticipantsAmount; i++)
{ {
std::cout << i + 1 << ". Participant " << _mixedParticipants[i].participant << ": level = " << _mixedParticipants[i].level << std::endl; std::cout << i + 1 << ". Participant " << _mixedParticipants[i].participant << ": level = " << _mixedParticipants[i].level << std::endl;
} }
@ -567,7 +569,7 @@ StatusReceiver::PrintMixedAudioLevel()
std::cout << "Mixed audio level = " << _mixedAudioLevel << std::endl; std::cout << "Mixed audio level = " << _mixedAudioLevel << std::endl;
} }
WebRtc_Word32 MixerWrapper::_mixerWrapperIdCounter = 0; int32_t MixerWrapper::_mixerWrapperIdCounter = 0;
MixerWrapper::MixerWrapper() MixerWrapper::MixerWrapper()
: :
@ -648,7 +650,7 @@ bool
MixerWrapper::CreateParticipant( MixerWrapper::CreateParticipant(
MixerParticipant::ParticipantType participantType) MixerParticipant::ParticipantType participantType)
{ {
WebRtc_Word32 startPosition = 0; int32_t startPosition = 0;
GenerateRandomPosition(startPosition); GenerateRandomPosition(startPosition);
return CreateParticipant(participantType,startPosition); return CreateParticipant(participantType,startPosition);
} }
@ -656,9 +658,9 @@ MixerWrapper::CreateParticipant(
bool bool
MixerWrapper::CreateParticipant( MixerWrapper::CreateParticipant(
MixerParticipant::ParticipantType participantType, MixerParticipant::ParticipantType participantType,
const WebRtc_Word32 startPosition) const int32_t startPosition)
{ {
WebRtc_UWord32 id; uint32_t id;
if(!GetFreeItemIds(id)) if(!GetFreeItemIds(id))
{ {
return false; return false;
@ -684,7 +686,7 @@ MixerWrapper::CreateParticipant(
bool bool
MixerWrapper::DeleteParticipant( MixerWrapper::DeleteParticipant(
const WebRtc_UWord32 id) const uint32_t id)
{ {
bool success = StopMixingParticipant(id); bool success = StopMixingParticipant(id);
if(!success) if(!success)
@ -706,7 +708,7 @@ MixerWrapper::DeleteParticipant(
bool bool
MixerWrapper::StartMixing( MixerWrapper::StartMixing(
const WebRtc_UWord32 mixedParticipants) const uint32_t mixedParticipants)
{ {
if(_processThread) if(_processThread)
{ {
@ -716,7 +718,7 @@ MixerWrapper::StartMixing(
{ {
assert(false); assert(false);
} }
WebRtc_UWord32 mixedParticipantsTest = 0; uint32_t mixedParticipantsTest = 0;
_mixer->AmountOfMixedParticipants(mixedParticipantsTest); _mixer->AmountOfMixedParticipants(mixedParticipantsTest);
assert(mixedParticipantsTest == mixedParticipants); assert(mixedParticipantsTest == mixedParticipants);
@ -752,10 +754,10 @@ MixerWrapper::StopMixing()
void void
MixerWrapper::NewMixedAudio( MixerWrapper::NewMixedAudio(
const WebRtc_Word32 id, const int32_t id,
const AudioFrame& generalAudioFrame, const AudioFrame& generalAudioFrame,
const AudioFrame** uniqueAudioFrames, const AudioFrame** uniqueAudioFrames,
const WebRtc_UWord32 size) const uint32_t size)
{ {
if(id < 0) if(id < 0)
{ {
@ -766,9 +768,9 @@ MixerWrapper::NewMixedAudio(
// Send the unique audio frames to its corresponding participants // Send the unique audio frames to its corresponding participants
ListWrapper uniqueAudioFrameList; ListWrapper uniqueAudioFrameList;
for(WebRtc_UWord32 i = 0; i < size; i++) for(uint32_t i = 0; i < size; i++)
{ {
WebRtc_UWord32 id = (uniqueAudioFrames[i])->_id; uint32_t id = (uniqueAudioFrames[i])->_id;
MapItem* resultItem = _mixerParticipants.Find(id); MapItem* resultItem = _mixerParticipants.Find(id);
if(resultItem == NULL) if(resultItem == NULL)
{ {
@ -833,7 +835,7 @@ MixerWrapper::PrintStatus()
bool bool
MixerWrapper::InitializeFileWriter() MixerWrapper::InitializeFileWriter()
{ {
const WebRtc_Word32 stringsize = 128; const int32_t stringsize = 128;
char fileName[stringsize] = ""; char fileName[stringsize] = "";
strncpy(fileName,_instanceOutputPath,stringsize); strncpy(fileName,_instanceOutputPath,stringsize);
fileName[stringsize-1] = '\0'; fileName[stringsize-1] = '\0';
@ -869,7 +871,7 @@ MixerWrapper::Process()
assert(false); assert(false);
return false; return false;
} }
WebRtc_Word32 processOfset = 0; int32_t processOfset = 0;
const TickTime currentTime = TickTime::Now(); const TickTime currentTime = TickTime::Now();
if(_firstProcessCall) if(_firstProcessCall)
{ {
@ -880,12 +882,12 @@ MixerWrapper::Process()
{ {
TickInterval deltaTime = (currentTime - _previousTime); TickInterval deltaTime = (currentTime - _previousTime);
_previousTime += _periodicityInTicks; _previousTime += _periodicityInTicks;
processOfset = (WebRtc_Word32) deltaTime.Milliseconds(); processOfset = (int32_t) deltaTime.Milliseconds();
processOfset -= FileReader::kProcessPeriodicityInMs; processOfset -= FileReader::kProcessPeriodicityInMs;
} }
_mixer->Process(); _mixer->Process();
WebRtc_Word32 timeUntilNextProcess = _mixer->TimeUntilNextProcess(); int32_t timeUntilNextProcess = _mixer->TimeUntilNextProcess();
if(processOfset > FileReader::kProcessPeriodicityInMs) if(processOfset > FileReader::kProcessPeriodicityInMs)
{ {
std::cout << "Performance Warning: Process running " << processOfset << " too slow" << std::endl; std::cout << "Performance Warning: Process running " << processOfset << " too slow" << std::endl;
@ -910,7 +912,7 @@ MixerWrapper::Process()
bool bool
MixerWrapper::StartMixingParticipant( MixerWrapper::StartMixingParticipant(
const WebRtc_UWord32 id) const uint32_t id)
{ {
MapItem* item = _mixerParticipants.Find(id); MapItem* item = _mixerParticipants.Find(id);
if(item == NULL) if(item == NULL)
@ -944,7 +946,7 @@ MixerWrapper::StartMixingParticipant(
assert(anonymouslyMixed); assert(anonymouslyMixed);
return success; return success;
} }
WebRtc_UWord32 previousAmountOfMixableParticipants = 0; uint32_t previousAmountOfMixableParticipants = 0;
bool success = _mixer->AmountOfMixables(previousAmountOfMixableParticipants) == 0; bool success = _mixer->AmountOfMixables(previousAmountOfMixableParticipants) == 0;
assert(success); assert(success);
@ -963,7 +965,7 @@ MixerWrapper::StartMixingParticipant(
return false; return false;
} }
WebRtc_UWord32 currentAmountOfMixableParticipants = 0; uint32_t currentAmountOfMixableParticipants = 0;
success = _mixer->AmountOfMixables(currentAmountOfMixableParticipants) == 0; success = _mixer->AmountOfMixables(currentAmountOfMixableParticipants) == 0;
assert(currentAmountOfMixableParticipants == previousAmountOfMixableParticipants + 1); assert(currentAmountOfMixableParticipants == previousAmountOfMixableParticipants + 1);
@ -1001,7 +1003,7 @@ MixerWrapper::StartMixingParticipant(
bool bool
MixerWrapper::StopMixingParticipant( MixerWrapper::StopMixingParticipant(
const WebRtc_UWord32 id) const uint32_t id)
{ {
MapItem* item = _mixerParticipants.Find(id); MapItem* item = _mixerParticipants.Find(id);
if(item == NULL) if(item == NULL)
@ -1010,12 +1012,12 @@ MixerWrapper::StopMixingParticipant(
} }
MixerParticipant* participant = static_cast<MixerParticipant*>(item->GetItem()); MixerParticipant* participant = static_cast<MixerParticipant*>(item->GetItem());
bool success = false; bool success = false;
WebRtc_UWord32 previousAmountOfMixableParticipants = 0; uint32_t previousAmountOfMixableParticipants = 0;
success = _mixer->AmountOfMixables(previousAmountOfMixableParticipants) == 0; success = _mixer->AmountOfMixables(previousAmountOfMixableParticipants) == 0;
assert(success); assert(success);
success = _mixer->SetMixabilityStatus(*participant,false) == 0; success = _mixer->SetMixabilityStatus(*participant,false) == 0;
assert(success); assert(success);
WebRtc_UWord32 currentAmountOfMixableParticipants = 0; uint32_t currentAmountOfMixableParticipants = 0;
success = _mixer->AmountOfMixables(currentAmountOfMixableParticipants) == 0; success = _mixer->AmountOfMixables(currentAmountOfMixableParticipants) == 0;
assert(success); assert(success);
assert(success ? currentAmountOfMixableParticipants == previousAmountOfMixableParticipants -1 : assert(success ? currentAmountOfMixableParticipants == previousAmountOfMixableParticipants -1 :
@ -1025,17 +1027,17 @@ MixerWrapper::StopMixingParticipant(
bool bool
MixerWrapper::GetFreeItemIds( MixerWrapper::GetFreeItemIds(
WebRtc_UWord32& itemId) uint32_t& itemId)
{ {
if(!_freeItemIds.Empty()) if(!_freeItemIds.Empty())
{ {
ListItem* item = _freeItemIds.First(); ListItem* item = _freeItemIds.First();
WebRtc_UWord32* id = static_cast<WebRtc_UWord32*>(item->GetItem()); uint32_t* id = static_cast<uint32_t*>(item->GetItem());
itemId = *id; itemId = *id;
delete id; delete id;
return true; return true;
} }
if(_itemIdCounter == (WebRtc_UWord32) -1) if(_itemIdCounter == (uint32_t) -1)
{ {
return false; return false;
} }
@ -1045,9 +1047,9 @@ MixerWrapper::GetFreeItemIds(
void void
MixerWrapper::AddFreeItemIds( MixerWrapper::AddFreeItemIds(
const WebRtc_UWord32 itemId) const uint32_t itemId)
{ {
WebRtc_UWord32* id = new WebRtc_UWord32; uint32_t* id = new uint32_t;
*id = itemId; *id = itemId;
_freeItemIds.PushBack(static_cast<void*>(id)); _freeItemIds.PushBack(static_cast<void*>(id));
} }
@ -1058,7 +1060,7 @@ MixerWrapper::ClearAllItemIds()
ListItem* item = _freeItemIds.First(); ListItem* item = _freeItemIds.First();
while(item != NULL) while(item != NULL)
{ {
WebRtc_UWord32* id = static_cast<WebRtc_UWord32*>(item->GetItem()); uint32_t* id = static_cast<uint32_t*>(item->GetItem());
delete id; delete id;
_freeItemIds.Erase(item); _freeItemIds.Erase(item);
item = _freeItemIds.First(); item = _freeItemIds.First();
@ -1067,21 +1069,24 @@ MixerWrapper::ClearAllItemIds()
bool bool
LoopedFileRead( LoopedFileRead(
WebRtc_Word16* buffer, int16_t* buffer,
WebRtc_UWord32 bufferSizeInSamples, uint32_t bufferSizeInSamples,
WebRtc_UWord32 samplesToRead, uint32_t samplesToRead,
FILE* file) FILE* file)
{ {
if(bufferSizeInSamples < samplesToRead) if(bufferSizeInSamples < samplesToRead)
{ {
return false; return false;
} }
WebRtc_UWord32 gottenSamples = (WebRtc_UWord32)fread(buffer,sizeof(WebRtc_Word16),samplesToRead,file); uint32_t gottenSamples = static_cast<uint32_t>(
fread(buffer, sizeof(int16_t), samplesToRead, file));
if(gottenSamples != samplesToRead) if(gottenSamples != samplesToRead)
{ {
WebRtc_UWord32 missingSamples = samplesToRead - gottenSamples; uint32_t missingSamples = samplesToRead - gottenSamples;
fseek(file,0,0); fseek(file,0,0);
gottenSamples += (WebRtc_UWord32)fread(&buffer[gottenSamples],sizeof(WebRtc_Word16),missingSamples,file); gottenSamples +=
static_cast<uint32_t>(fread(&buffer[gottenSamples], sizeof(int16_t),
missingSamples, file));
} }
if(gottenSamples != samplesToRead) if(gottenSamples != samplesToRead)
{ {
@ -1092,7 +1097,7 @@ LoopedFileRead(
void void
GenerateRandomPosition( GenerateRandomPosition(
WebRtc_Word32& startPosition) int32_t& startPosition)
{ {
startPosition = (rand() % (60*16000/160)) * 160; startPosition = (rand() % (60*16000/160)) * 160;
} }

View File

@ -62,7 +62,7 @@ public:
AudioFrame& audioFrame); AudioFrame& audioFrame);
bool FastForwardFile( bool FastForwardFile(
const WebRtc_Word32 samples); const int32_t samples);
bool EnableAutomaticVAD( bool EnableAutomaticVAD(
bool enable, bool enable,
@ -72,14 +72,14 @@ public:
bool vad); bool vad);
private: private:
bool GetVAD( bool GetVAD(
WebRtc_Word16* buffer, int16_t* buffer,
WebRtc_UWord8 bufferLengthInSamples, uint8_t bufferLengthInSamples,
bool& vad); bool& vad);
Frequency _frequency; Frequency _frequency;
WebRtc_UWord8 _sampleSize; uint8_t _sampleSize;
WebRtc_UWord32 _timeStamp; uint32_t _timeStamp;
FILE* _file; FILE* _file;
@ -102,33 +102,33 @@ public:
}; };
static MixerParticipant* CreateParticipant( static MixerParticipant* CreateParticipant(
const WebRtc_UWord32 id, const uint32_t id,
ParticipantType participantType, ParticipantType participantType,
const WebRtc_Word32 startPosition, const int32_t startPosition,
char* outputPath); char* outputPath);
~MixerParticipant(); ~MixerParticipant();
WebRtc_Word32 GetAudioFrame( int32_t GetAudioFrame(
const WebRtc_Word32 id, const int32_t id,
AudioFrame& audioFrame); AudioFrame& audioFrame);
WebRtc_Word32 MixedAudioFrame( int32_t MixedAudioFrame(
const AudioFrame& audioFrame); const AudioFrame& audioFrame);
WebRtc_Word32 GetParticipantType( int32_t GetParticipantType(
ParticipantType& participantType); ParticipantType& participantType);
private: private:
MixerParticipant( MixerParticipant(
const WebRtc_UWord32 id, const uint32_t id,
ParticipantType participantType); ParticipantType participantType);
bool InitializeFileReader( bool InitializeFileReader(
const WebRtc_Word32 startPositionInSamples); const int32_t startPositionInSamples);
bool InitializeFileWriter( bool InitializeFileWriter(
char* outputPath); char* outputPath);
WebRtc_UWord32 _id; uint32_t _id;
ParticipantType _participantType; ParticipantType _participantType;
FileReader _fileReader; FileReader _fileReader;
@ -139,22 +139,22 @@ class StatusReceiver : public AudioMixerStatusReceiver
{ {
public: public:
StatusReceiver( StatusReceiver(
const WebRtc_Word32 id); const int32_t id);
~StatusReceiver(); ~StatusReceiver();
void MixedParticipants( void MixedParticipants(
const WebRtc_Word32 id, const int32_t id,
const ParticipantStatistics* participantStatistics, const ParticipantStatistics* participantStatistics,
const WebRtc_UWord32 size); const uint32_t size);
void VADPositiveParticipants( void VADPositiveParticipants(
const WebRtc_Word32 id, const int32_t id,
const ParticipantStatistics* participantStatistics, const ParticipantStatistics* participantStatistics,
const WebRtc_UWord32 size); const uint32_t size);
void MixedAudioLevel( void MixedAudioLevel(
const WebRtc_Word32 id, const int32_t id,
const WebRtc_UWord32 level); const uint32_t level);
void PrintMixedParticipants(); void PrintMixedParticipants();
@ -162,17 +162,17 @@ public:
void PrintMixedAudioLevel(); void PrintMixedAudioLevel();
private: private:
WebRtc_Word32 _id; int32_t _id;
ParticipantStatistics* _mixedParticipants; ParticipantStatistics* _mixedParticipants;
WebRtc_UWord32 _mixedParticipantsAmount; uint32_t _mixedParticipantsAmount;
WebRtc_UWord32 _mixedParticipantsSize; uint32_t _mixedParticipantsSize;
ParticipantStatistics* _vadPositiveParticipants; ParticipantStatistics* _vadPositiveParticipants;
WebRtc_UWord32 _vadPositiveParticipantsAmount; uint32_t _vadPositiveParticipantsAmount;
WebRtc_UWord32 _vadPositiveParticipantsSize; uint32_t _vadPositiveParticipantsSize;
WebRtc_UWord32 _mixedAudioLevel; uint32_t _mixedAudioLevel;
}; };
class MixerWrapper : public AudioMixerOutputReceiver class MixerWrapper : public AudioMixerOutputReceiver
@ -189,21 +189,21 @@ public:
bool CreateParticipant( bool CreateParticipant(
MixerParticipant::ParticipantType participantType, MixerParticipant::ParticipantType participantType,
const WebRtc_Word32 startPosition); const int32_t startPosition);
bool DeleteParticipant( bool DeleteParticipant(
const WebRtc_UWord32 id); const uint32_t id);
bool StartMixing( bool StartMixing(
const WebRtc_UWord32 mixedParticipants = AudioConferenceMixer::kDefaultAmountOfMixedParticipants); const uint32_t mixedParticipants = AudioConferenceMixer::kDefaultAmountOfMixedParticipants);
bool StopMixing(); bool StopMixing();
void NewMixedAudio( void NewMixedAudio(
const WebRtc_Word32 id, const int32_t id,
const AudioFrame& generalAudioFrame, const AudioFrame& generalAudioFrame,
const AudioFrame** uniqueAudioFrames, const AudioFrame** uniqueAudioFrames,
const WebRtc_UWord32 size); const uint32_t size);
bool GetParticipantList( bool GetParticipantList(
ListWrapper& participants); ListWrapper& participants);
@ -220,16 +220,16 @@ private:
bool Process(); bool Process();
bool StartMixingParticipant( bool StartMixingParticipant(
const WebRtc_UWord32 id); const uint32_t id);
bool StopMixingParticipant( bool StopMixingParticipant(
const WebRtc_UWord32 id); const uint32_t id);
bool GetFreeItemIds( bool GetFreeItemIds(
WebRtc_UWord32& itemId); uint32_t& itemId);
void AddFreeItemIds( void AddFreeItemIds(
const WebRtc_UWord32 itemId); const uint32_t itemId);
void ClearAllItemIds(); void ClearAllItemIds();
@ -241,17 +241,17 @@ private:
bool _firstProcessCall; bool _firstProcessCall;
TickTime _previousTime; // Tick time of previous process TickTime _previousTime; // Tick time of previous process
const WebRtc_Word64 _periodicityInTicks; // Periodicity const int64_t _periodicityInTicks; // Periodicity
webrtc::EventWrapper* _synchronizationEvent; webrtc::EventWrapper* _synchronizationEvent;
ListWrapper _freeItemIds; ListWrapper _freeItemIds;
WebRtc_UWord32 _itemIdCounter; uint32_t _itemIdCounter;
MapWrapper _mixerParticipants; MapWrapper _mixerParticipants;
static WebRtc_Word32 _mixerWrapperIdCounter; static int32_t _mixerWrapperIdCounter;
WebRtc_Word32 _mixerWrappererId; int32_t _mixerWrappererId;
char _instanceOutputPath[128]; char _instanceOutputPath[128];
webrtc::Trace* _trace; webrtc::Trace* _trace;
@ -264,13 +264,13 @@ private:
bool bool
LoopedFileRead( LoopedFileRead(
WebRtc_Word16* buffer, int16_t* buffer,
WebRtc_UWord32 bufferSizeInSamples, uint32_t bufferSizeInSamples,
WebRtc_UWord32 samplesToRead, uint32_t samplesToRead,
FILE* file); FILE* file);
void void
GenerateRandomPosition( GenerateRandomPosition(
WebRtc_Word32& startPosition); int32_t& startPosition);
#endif // WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_TEST_FUNCTIONTEST_FUNCTIONTEST_H_ #endif // WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_TEST_FUNCTIONTEST_FUNCTIONTEST_H_