webrtc_m130/voice_engine/shared_data.cc
Fredrik Solenberg 39cefdb3c5 Revert "Reland "Remove WEBRTC_TRACE.""
This reverts commit 68007e97ec9399125e4be9964af8b0338766cd91.

Reason for revert: More downstream breakages.

Original change's description:
> Reland "Remove WEBRTC_TRACE."
> 
> This is a reland of 2209b90449473e1df3e0797b6271c7624b41907d
> Original change's description:
> > Remove WEBRTC_TRACE.
> > 
> > Bug: webrtc:5118
> > Change-Id: I0af0f8845ee016fa61d7cecc526e2a672ec8732d
> > Reviewed-on: https://webrtc-review.googlesource.com/5382
> > Reviewed-by: Niels Moller <nisse@webrtc.org>
> > Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
> > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> > Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#20114}
> 
> Bug: webrtc:5118
> Change-Id: I2d93fd40fcaa251c363bdcfb1c04b834a3a7f0e9
> Reviewed-on: https://webrtc-review.googlesource.com/6000
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Reviewed-by: Niels Moller <nisse@webrtc.org>
> Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#20132}

TBR=solenberg@webrtc.org,sakal@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org

Change-Id: I093ee8c5c997c0dd46b3a3ca0e6271e3ea083d82
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:5118
Reviewed-on: https://webrtc-review.googlesource.com/6320
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20133}
2017-10-04 08:49:49 +00:00

89 lines
2.3 KiB
C++

/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#include "voice_engine/shared_data.h"
#include "modules/audio_processing/include/audio_processing.h"
#include "system_wrappers/include/trace.h"
#include "voice_engine/channel.h"
#include "voice_engine/transmit_mixer.h"
namespace webrtc {
namespace voe {
static int32_t _gInstanceCounter = 0;
SharedData::SharedData()
: _instanceId(++_gInstanceCounter),
_channelManager(_gInstanceCounter),
_audioDevicePtr(NULL),
_moduleProcessThreadPtr(ProcessThread::Create("VoiceProcessThread")),
encoder_queue_("AudioEncoderQueue") {
Trace::CreateTrace();
if (TransmitMixer::Create(_transmitMixerPtr, _gInstanceCounter) == 0) {
_transmitMixerPtr->SetEngineInformation(&_channelManager);
}
}
SharedData::~SharedData()
{
TransmitMixer::Destroy(_transmitMixerPtr);
if (_audioDevicePtr) {
_audioDevicePtr->Release();
}
_moduleProcessThreadPtr->Stop();
Trace::ReturnTrace();
}
rtc::TaskQueue* SharedData::encoder_queue() {
RTC_DCHECK_RUN_ON(&construction_thread_);
return &encoder_queue_;
}
void SharedData::set_audio_device(
const rtc::scoped_refptr<AudioDeviceModule>& audio_device) {
_audioDevicePtr = audio_device;
}
void SharedData::set_audio_processing(AudioProcessing* audioproc) {
_transmitMixerPtr->SetAudioProcessingModule(audioproc);
}
int SharedData::NumOfSendingChannels() {
ChannelManager::Iterator it(&_channelManager);
int sending_channels = 0;
for (ChannelManager::Iterator it(&_channelManager); it.IsValid();
it.Increment()) {
if (it.GetChannel()->Sending())
++sending_channels;
}
return sending_channels;
}
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;
}
} // namespace voe
} // namespace webrtc