2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-04-04 14:57:19 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "voice_engine/shared_data.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_processing/include/audio_processing.h"
|
|
|
|
|
#include "voice_engine/channel.h"
|
|
|
|
|
#include "voice_engine/transmit_mixer.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
namespace voe {
|
|
|
|
|
|
2013-04-09 10:09:10 +00:00
|
|
|
static int32_t _gInstanceCounter = 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-09-07 07:34:41 -07:00
|
|
|
SharedData::SharedData()
|
2015-09-11 09:52:15 -07:00
|
|
|
: _instanceId(++_gInstanceCounter),
|
2016-09-07 07:34:41 -07:00
|
|
|
_channelManager(_gInstanceCounter),
|
2015-09-11 09:52:15 -07:00
|
|
|
_audioDevicePtr(NULL),
|
2017-03-31 05:43:36 -07:00
|
|
|
_moduleProcessThreadPtr(ProcessThread::Create("VoiceProcessThread")),
|
|
|
|
|
encoder_queue_("AudioEncoderQueue") {
|
2017-10-04 09:53:35 +02:00
|
|
|
if (TransmitMixer::Create(_transmitMixerPtr) == 0) {
|
2017-09-26 09:35:01 -07:00
|
|
|
_transmitMixerPtr->SetEngineInformation(&_channelManager);
|
2017-03-31 05:43:36 -07:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SharedData::~SharedData()
|
|
|
|
|
{
|
|
|
|
|
TransmitMixer::Destroy(_transmitMixerPtr);
|
2011-09-07 15:11:18 +00:00
|
|
|
if (_audioDevicePtr) {
|
|
|
|
|
_audioDevicePtr->Release();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2015-02-06 09:44:12 +00:00
|
|
|
_moduleProcessThreadPtr->Stop();
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2017-03-31 05:43:36 -07:00
|
|
|
rtc::TaskQueue* SharedData::encoder_queue() {
|
|
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_);
|
|
|
|
|
return &encoder_queue_;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-21 16:44:31 +01:00
|
|
|
void SharedData::set_audio_device(
|
|
|
|
|
const rtc::scoped_refptr<AudioDeviceModule>& audio_device) {
|
|
|
|
|
_audioDevicePtr = audio_device;
|
2012-04-04 14:57:19 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-05 01:12:49 +00:00
|
|
|
void SharedData::set_audio_processing(AudioProcessing* audioproc) {
|
|
|
|
|
_transmitMixerPtr->SetAudioProcessingModule(audioproc);
|
2012-04-04 14:57:19 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-17 16:15:34 +00:00
|
|
|
int SharedData::NumOfSendingChannels() {
|
2013-08-07 17:57:36 +00:00
|
|
|
ChannelManager::Iterator it(&_channelManager);
|
2013-10-17 16:15:34 +00:00
|
|
|
int sending_channels = 0;
|
2012-06-27 03:25:31 +00:00
|
|
|
|
2013-08-07 17:57:36 +00:00
|
|
|
for (ChannelManager::Iterator it(&_channelManager); it.IsValid();
|
|
|
|
|
it.Increment()) {
|
|
|
|
|
if (it.GetChannel()->Sending())
|
|
|
|
|
++sending_channels;
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-08-07 17:57:36 +00:00
|
|
|
return sending_channels;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-17 16:15:34 +00:00
|
|
|
int SharedData::NumOfPlayingChannels() {
|
|
|
|
|
ChannelManager::Iterator it(&_channelManager);
|
|
|
|
|
int playout_channels = 0;
|
|
|
|
|
|
|
|
|
|
for (ChannelManager::Iterator it(&_channelManager); it.IsValid();
|
|
|
|
|
it.Increment()) {
|
|
|
|
|
if (it.GetChannel()->Playing())
|
|
|
|
|
++playout_channels;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return playout_channels;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace voe
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace webrtc
|