Remove voe::Statistics.

BUG=webrtc:4690

Review-Url: https://codereview.webrtc.org/3020473002
Cr-Commit-Position: refs/heads/master@{#20042}
This commit is contained in:
solenberg 2017-09-29 06:00:28 -07:00 committed by Commit Bot
parent 2666cf7eba
commit 1c239d476e
20 changed files with 69 additions and 408 deletions

View File

@ -94,7 +94,7 @@ AudioReceiveStream::AudioReceiveStream(
RTC_CHECK_EQ(config.decoder_factory, RTC_CHECK_EQ(config.decoder_factory,
channel_proxy_->GetAudioDecoderFactory()); channel_proxy_->GetAudioDecoderFactory());
channel_proxy_->RegisterExternalTransport(config.rtcp_send_transport); channel_proxy_->RegisterTransport(config.rtcp_send_transport);
channel_proxy_->SetReceiveCodecs(config.decoder_map); channel_proxy_->SetReceiveCodecs(config.decoder_map);
for (const auto& extension : config.rtp.extensions) { for (const auto& extension : config.rtp.extensions) {
@ -122,7 +122,7 @@ AudioReceiveStream::~AudioReceiveStream() {
Stop(); Stop();
} }
channel_proxy_->DisassociateSendChannel(); channel_proxy_->DisassociateSendChannel();
channel_proxy_->DeRegisterExternalTransport(); channel_proxy_->RegisterTransport(nullptr);
channel_proxy_->ResetReceiverCongestionControlObjects(); channel_proxy_->ResetReceiverCongestionControlObjects();
channel_proxy_->SetRtcEventLog(nullptr); channel_proxy_->SetRtcEventLog(nullptr);
} }

View File

@ -101,10 +101,7 @@ struct ConfigHelper {
.Times(1); .Times(1);
EXPECT_CALL(*channel_proxy_, ResetReceiverCongestionControlObjects()) EXPECT_CALL(*channel_proxy_, ResetReceiverCongestionControlObjects())
.Times(1); .Times(1);
EXPECT_CALL(*channel_proxy_, RegisterExternalTransport(nullptr)) EXPECT_CALL(*channel_proxy_, RegisterTransport(nullptr)).Times(2);
.Times(1);
EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport())
.Times(1);
EXPECT_CALL(*channel_proxy_, GetAudioDecoderFactory()) EXPECT_CALL(*channel_proxy_, GetAudioDecoderFactory())
.WillOnce(ReturnRef(decoder_factory_)); .WillOnce(ReturnRef(decoder_factory_));
testing::Expectation expect_set = testing::Expectation expect_set =

View File

@ -120,7 +120,7 @@ AudioSendStream::~AudioSendStream() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString();
transport_->send_side_cc()->DeRegisterPacketFeedbackObserver(this); transport_->send_side_cc()->DeRegisterPacketFeedbackObserver(this);
channel_proxy_->DeRegisterExternalTransport(); channel_proxy_->RegisterTransport(nullptr);
channel_proxy_->ResetSenderCongestionControlObjects(); channel_proxy_->ResetSenderCongestionControlObjects();
channel_proxy_->SetRtcEventLog(nullptr); channel_proxy_->SetRtcEventLog(nullptr);
channel_proxy_->SetRtcpRttStats(nullptr); channel_proxy_->SetRtcpRttStats(nullptr);
@ -164,7 +164,7 @@ void AudioSendStream::ConfigureStream(
if (first_time || if (first_time ||
new_config.send_transport != old_config.send_transport) { new_config.send_transport != old_config.send_transport) {
if (old_config.send_transport) { if (old_config.send_transport) {
channel_proxy->DeRegisterExternalTransport(); channel_proxy->RegisterTransport(nullptr);
} }
if (new_config.send_transport) { if (new_config.send_transport) {
stream->timed_send_transport_adapter_.reset(new TimedTransport( stream->timed_send_transport_adapter_.reset(new TimedTransport(
@ -172,7 +172,7 @@ void AudioSendStream::ConfigureStream(
} else { } else {
stream->timed_send_transport_adapter_.reset(nullptr); stream->timed_send_transport_adapter_.reset(nullptr);
} }
channel_proxy->RegisterExternalTransport( channel_proxy->RegisterTransport(
stream->timed_send_transport_adapter_.get()); stream->timed_send_transport_adapter_.get());
} }

View File

@ -235,8 +235,7 @@ struct ConfigHelper {
.Times(1); .Times(1);
EXPECT_CALL(*channel_proxy_, ResetSenderCongestionControlObjects()) EXPECT_CALL(*channel_proxy_, ResetSenderCongestionControlObjects())
.Times(1); .Times(1);
EXPECT_CALL(*channel_proxy_, RegisterExternalTransport(nullptr)).Times(1); EXPECT_CALL(*channel_proxy_, RegisterTransport(nullptr)).Times(2);
EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport()).Times(1);
EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::NotNull())).Times(1); EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::NotNull())).Times(1);
EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull())) EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull()))
.Times(1); // Destructor resets the event log .Times(1); // Destructor resets the event log

View File

@ -65,8 +65,7 @@ class MockVoEChannelProxy : public voe::ChannelProxy {
// TODO(solenberg): Talk the compiler into accepting this mock method: // TODO(solenberg): Talk the compiler into accepting this mock method:
// MOCK_METHOD1(SetSink, void(std::unique_ptr<AudioSinkInterface> sink)); // MOCK_METHOD1(SetSink, void(std::unique_ptr<AudioSinkInterface> sink));
MOCK_METHOD1(SetInputMute, void(bool muted)); MOCK_METHOD1(SetInputMute, void(bool muted));
MOCK_METHOD1(RegisterExternalTransport, void(Transport* transport)); MOCK_METHOD1(RegisterTransport, void(Transport* transport));
MOCK_METHOD0(DeRegisterExternalTransport, void());
MOCK_METHOD1(OnRtpPacket, void(const RtpPacketReceived& packet)); MOCK_METHOD1(OnRtpPacket, void(const RtpPacketReceived& packet));
MOCK_METHOD2(ReceivedRTCPPacket, bool(const uint8_t* packet, size_t length)); MOCK_METHOD2(ReceivedRTCPPacket, bool(const uint8_t* packet, size_t length));
MOCK_CONST_METHOD0(GetAudioDecoderFactory, MOCK_CONST_METHOD0(GetAudioDecoderFactory,

View File

@ -20,8 +20,6 @@ rtc_static_library("voice_engine") {
"include/voe_errors.h", "include/voe_errors.h",
"shared_data.cc", "shared_data.cc",
"shared_data.h", "shared_data.h",
"statistics.cc",
"statistics.h",
"transmit_mixer.cc", "transmit_mixer.cc",
"transmit_mixer.h", "transmit_mixer.h",
"transport_feedback_packet_loss_tracker.cc", "transport_feedback_packet_loss_tracker.cc",

View File

@ -40,7 +40,6 @@
#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/field_trial.h"
#include "system_wrappers/include/metrics.h" #include "system_wrappers/include/metrics.h"
#include "system_wrappers/include/trace.h" #include "system_wrappers/include/trace.h"
#include "voice_engine/statistics.h"
#include "voice_engine/utility.h" #include "voice_engine/utility.h"
namespace webrtc { namespace webrtc {
@ -447,9 +446,8 @@ int32_t Channel::SendData(FrameType frameType,
// received from the capture device as // received from the capture device as
// undefined for voice for now. // undefined for voice for now.
-1, payloadData, payloadSize, fragmentation, nullptr, nullptr)) { -1, payloadData, payloadSize, fragmentation, nullptr, nullptr)) {
_engineStatisticsPtr->SetLastError( LOG(LS_ERROR) <<
VE_RTP_RTCP_MODULE_ERROR, kTraceWarning, "Channel::SendData() failed to send data to RTP/RTCP module";
"Channel::SendData() failed to send data to RTP/RTCP module");
return -1; return -1;
} }
@ -475,11 +473,7 @@ bool Channel::SendRtp(const uint8_t* data,
size_t bufferLength = len; size_t bufferLength = len;
if (!_transportPtr->SendRtp(bufferToSendPtr, bufferLength, options)) { if (!_transportPtr->SendRtp(bufferToSendPtr, bufferLength, options)) {
std::string transport_name = LOG(LS_ERROR) << "Channel::SendPacket() RTP transmission failed";
_externalTransport ? "external transport" : "WebRtc sockets";
WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::SendPacket() RTP transmission using %s failed",
transport_name.c_str());
return false; return false;
} }
return true; return true;
@ -502,11 +496,7 @@ bool Channel::SendRtcp(const uint8_t* data, size_t len) {
int n = _transportPtr->SendRtcp(bufferToSendPtr, bufferLength); int n = _transportPtr->SendRtcp(bufferToSendPtr, bufferLength);
if (n < 0) { if (n < 0) {
std::string transport_name = LOG(LS_ERROR) << "Channel::SendRtcp() transmission failed";
_externalTransport ? "external transport" : "WebRtc sockets";
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::SendRtcp() transmission using %s failed",
transport_name.c_str());
return false; return false;
} }
return true; return true;
@ -556,7 +546,6 @@ int32_t Channel::OnInitializeDecoder(
"Channel::OnInitializeDecoder() invalid codec (" "Channel::OnInitializeDecoder() invalid codec ("
"pt=%d, name=%s) received - 1", "pt=%d, name=%s) received - 1",
payloadType, payloadName); payloadType, payloadName);
_engineStatisticsPtr->SetLastError(VE_AUDIO_CODING_MODULE_ERROR);
return -1; return -1;
} }
@ -585,9 +574,8 @@ int32_t Channel::OnReceivedPayloadData(const uint8_t* payloadData,
// Push the incoming payload (parsed and ready for decoding) into the ACM // Push the incoming payload (parsed and ready for decoding) into the ACM
if (audio_coding_->IncomingPacket(payloadData, payloadSize, *rtpHeader) != if (audio_coding_->IncomingPacket(payloadData, payloadSize, *rtpHeader) !=
0) { 0) {
_engineStatisticsPtr->SetLastError( LOG(LS_ERROR) <<
VE_AUDIO_CODING_MODULE_ERROR, kTraceWarning, "Channel::OnReceivedPayloadData() unable to push data to the ACM";
"Channel::OnReceivedPayloadData() unable to push data to the ACM");
return -1; return -1;
} }
@ -759,7 +747,6 @@ Channel::Channel(int32_t channelId,
rtp_payload_registry_.get())), rtp_payload_registry_.get())),
telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()), telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()),
_outputAudioLevel(), _outputAudioLevel(),
_externalTransport(false),
_timeStamp(0), // This is just an offset, RTP module will add it's own _timeStamp(0), // This is just an offset, RTP module will add it's own
// random offset // random offset
ntp_estimator_(Clock::GetRealTimeClock()), ntp_estimator_(Clock::GetRealTimeClock()),
@ -769,10 +756,8 @@ Channel::Channel(int32_t channelId,
rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()), rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()),
capture_start_rtp_time_stamp_(-1), capture_start_rtp_time_stamp_(-1),
capture_start_ntp_time_ms_(-1), capture_start_ntp_time_ms_(-1),
_engineStatisticsPtr(NULL),
_moduleProcessThreadPtr(NULL), _moduleProcessThreadPtr(NULL),
_audioDeviceModulePtr(NULL), _audioDeviceModulePtr(NULL),
_callbackCritSectPtr(NULL),
_transportPtr(NULL), _transportPtr(NULL),
input_mute_(false), input_mute_(false),
previous_frame_muted_(false), previous_frame_muted_(false),
@ -835,7 +820,7 @@ int32_t Channel::Init() {
// --- Initial sanity // --- Initial sanity
if ((_engineStatisticsPtr == NULL) || (_moduleProcessThreadPtr == NULL)) { if (_moduleProcessThreadPtr == NULL) {
WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::Init() must call SetEngineInformation() first"); "Channel::Init() must call SetEngineInformation() first");
return -1; return -1;
@ -848,9 +833,7 @@ int32_t Channel::Init() {
// --- ACM initialization // --- ACM initialization
if (audio_coding_->InitializeReceiver() == -1) { if (audio_coding_->InitializeReceiver() == -1) {
_engineStatisticsPtr->SetLastError( LOG(LS_ERROR) << "Channel::Init() unable to initialize the ACM - 1";
VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
"Channel::Init() unable to initialize the ACM - 1");
return -1; return -1;
} }
@ -866,9 +849,7 @@ int32_t Channel::Init() {
_rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound); _rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound);
// --- Register all permanent callbacks // --- Register all permanent callbacks
if (audio_coding_->RegisterTransportCallback(this) == -1) { if (audio_coding_->RegisterTransportCallback(this) == -1) {
_engineStatisticsPtr->SetLastError( LOG(LS_ERROR) << "Channel::Init() callbacks not registered";
VE_CANNOT_INIT_CHANNEL, kTraceError,
"Channel::Init() callbacks not registered");
return -1; return -1;
} }
@ -903,19 +884,15 @@ void Channel::Terminate() {
// End of modules shutdown // End of modules shutdown
} }
int32_t Channel::SetEngineInformation(Statistics& engineStatistics, int32_t Channel::SetEngineInformation(ProcessThread& moduleProcessThread,
ProcessThread& moduleProcessThread,
AudioDeviceModule& audioDeviceModule, AudioDeviceModule& audioDeviceModule,
rtc::CriticalSection* callbackCritSect,
rtc::TaskQueue* encoder_queue) { rtc::TaskQueue* encoder_queue) {
RTC_DCHECK(encoder_queue); RTC_DCHECK(encoder_queue);
RTC_DCHECK(!encoder_queue_); RTC_DCHECK(!encoder_queue_);
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::SetEngineInformation()"); "Channel::SetEngineInformation()");
_engineStatisticsPtr = &engineStatistics;
_moduleProcessThreadPtr = &moduleProcessThread; _moduleProcessThreadPtr = &moduleProcessThread;
_audioDeviceModulePtr = &audioDeviceModule; _audioDeviceModulePtr = &audioDeviceModule;
_callbackCritSectPtr = callbackCritSect;
encoder_queue_ = encoder_queue; encoder_queue_ = encoder_queue;
return 0; return 0;
} }
@ -974,9 +951,7 @@ int32_t Channel::StartSend() {
} }
_rtpRtcpModule->SetSendingMediaStatus(true); _rtpRtcpModule->SetSendingMediaStatus(true);
if (_rtpRtcpModule->SetSendingStatus(true) != 0) { if (_rtpRtcpModule->SetSendingStatus(true) != 0) {
_engineStatisticsPtr->SetLastError( LOG(LS_ERROR) << "StartSend() RTP/RTCP failed to start sending";
VE_RTP_RTCP_MODULE_ERROR, kTraceError,
"StartSend() RTP/RTCP failed to start sending");
_rtpRtcpModule->SetSendingMediaStatus(false); _rtpRtcpModule->SetSendingMediaStatus(false);
rtc::CritScope cs(&_callbackCritSect); rtc::CritScope cs(&_callbackCritSect);
channel_state_.SetSending(false); channel_state_.SetSending(false);
@ -1023,9 +998,7 @@ void Channel::StopSend() {
// Reset sending SSRC and sequence number and triggers direct transmission // Reset sending SSRC and sequence number and triggers direct transmission
// of RTCP BYE // of RTCP BYE
if (_rtpRtcpModule->SetSendingStatus(false) == -1) { if (_rtpRtcpModule->SetSendingStatus(false) == -1) {
_engineStatisticsPtr->SetLastError( LOG(LS_ERROR) << "StartSend() RTP/RTCP failed to stop sending";
VE_RTP_RTCP_MODULE_ERROR, kTraceWarning,
"StartSend() RTP/RTCP failed to stop sending");
} }
_rtpRtcpModule->SetSendingMediaStatus(false); _rtpRtcpModule->SetSendingMediaStatus(false);
} }
@ -1198,39 +1171,9 @@ void Channel::SetReceiverFrameLengthRange(int min_frame_length_ms,
}); });
} }
int32_t Channel::RegisterExternalTransport(Transport* transport) { void Channel::RegisterTransport(Transport* transport) {
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::RegisterExternalTransport()");
rtc::CritScope cs(&_callbackCritSect); rtc::CritScope cs(&_callbackCritSect);
if (_externalTransport) {
_engineStatisticsPtr->SetLastError(
VE_INVALID_OPERATION, kTraceError,
"RegisterExternalTransport() external transport already enabled");
return -1;
}
_externalTransport = true;
_transportPtr = transport; _transportPtr = transport;
return 0;
}
int32_t Channel::DeRegisterExternalTransport() {
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::DeRegisterExternalTransport()");
rtc::CritScope cs(&_callbackCritSect);
if (_transportPtr) {
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
"DeRegisterExternalTransport() all transport is disabled");
} else {
_engineStatisticsPtr->SetLastError(
VE_INVALID_OPERATION, kTraceWarning,
"DeRegisterExternalTransport() external transport already "
"disabled");
}
_externalTransport = false;
_transportPtr = NULL;
return 0;
} }
void Channel::OnRtpPacket(const RtpPacketReceived& packet) { void Channel::OnRtpPacket(const RtpPacketReceived& packet) {
@ -1380,9 +1323,7 @@ int Channel::SendTelephoneEventOutband(int event, int duration_ms) {
} }
if (_rtpRtcpModule->SendTelephoneEventOutband( if (_rtpRtcpModule->SendTelephoneEventOutband(
event, duration_ms, kTelephoneEventAttenuationdB) != 0) { event, duration_ms, kTelephoneEventAttenuationdB) != 0) {
_engineStatisticsPtr->SetLastError( LOG(LS_ERROR) << "SendTelephoneEventOutband() failed to send event";
VE_SEND_DTMF_FAILED, kTraceWarning,
"SendTelephoneEventOutband() failed to send event");
return -1; return -1;
} }
return 0; return 0;
@ -1401,10 +1342,8 @@ int Channel::SetSendTelephoneEventPayloadType(int payload_type,
if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) {
_rtpRtcpModule->DeRegisterSendPayload(codec.pltype); _rtpRtcpModule->DeRegisterSendPayload(codec.pltype);
if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) {
_engineStatisticsPtr->SetLastError( LOG(LS_ERROR) << "SetSendTelephoneEventPayloadType() failed to register "
VE_RTP_RTCP_MODULE_ERROR, kTraceError, "send payload type";
"SetSendTelephoneEventPayloadType() failed to register send"
"payload type");
return -1; return -1;
} }
} }
@ -1415,8 +1354,7 @@ int Channel::SetLocalSSRC(unsigned int ssrc) {
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::SetLocalSSRC()"); "Channel::SetLocalSSRC()");
if (channel_state_.Get().sending) { if (channel_state_.Get().sending) {
_engineStatisticsPtr->SetLastError(VE_ALREADY_SENDING, kTraceError, LOG(LS_ERROR) << "SetLocalSSRC() already sending";
"SetLocalSSRC() already sending");
return -1; return -1;
} }
_rtpRtcpModule->SetSSRC(ssrc); _rtpRtcpModule->SetSSRC(ssrc);
@ -1517,9 +1455,7 @@ int Channel::SetRTCP_CNAME(const char cName[256]) {
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::SetRTCP_CNAME()"); "Channel::SetRTCP_CNAME()");
if (_rtpRtcpModule->SetCNAME(cName) != 0) { if (_rtpRtcpModule->SetCNAME(cName) != 0) {
_engineStatisticsPtr->SetLastError( LOG(LS_ERROR) << "SetRTCP_CNAME() failed to set RTCP CNAME";
VE_RTP_RTCP_MODULE_ERROR, kTraceError,
"SetRTCP_CNAME() failed to set RTCP CNAME");
return -1; return -1;
} }
return 0; return 0;
@ -1528,9 +1464,7 @@ int Channel::SetRTCP_CNAME(const char cName[256]) {
int Channel::GetRemoteRTCPReportBlocks( int Channel::GetRemoteRTCPReportBlocks(
std::vector<ReportBlock>* report_blocks) { std::vector<ReportBlock>* report_blocks) {
if (report_blocks == NULL) { if (report_blocks == NULL) {
_engineStatisticsPtr->SetLastError( LOG(LS_ERROR) << "GetRemoteRTCPReportBlock()s invalid report_blocks.";
VE_INVALID_ARGUMENT, kTraceError,
"GetRemoteRTCPReportBlock()s invalid report_blocks.");
return -1; return -1;
} }
@ -1788,15 +1722,11 @@ int Channel::SetMinimumPlayoutDelay(int delayMs) {
"Channel::SetMinimumPlayoutDelay()"); "Channel::SetMinimumPlayoutDelay()");
if ((delayMs < kVoiceEngineMinMinPlayoutDelayMs) || if ((delayMs < kVoiceEngineMinMinPlayoutDelayMs) ||
(delayMs > kVoiceEngineMaxMinPlayoutDelayMs)) { (delayMs > kVoiceEngineMaxMinPlayoutDelayMs)) {
_engineStatisticsPtr->SetLastError( LOG(LS_ERROR) << "SetMinimumPlayoutDelay() invalid min delay";
VE_INVALID_ARGUMENT, kTraceError,
"SetMinimumPlayoutDelay() invalid min delay");
return -1; return -1;
} }
if (audio_coding_->SetMinimumPlayoutDelay(delayMs) != 0) { if (audio_coding_->SetMinimumPlayoutDelay(delayMs) != 0) {
_engineStatisticsPtr->SetLastError( LOG(LS_ERROR) << "SetMinimumPlayoutDelay() failed to set min playout delay";
VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
"SetMinimumPlayoutDelay() failed to set min playout delay");
return -1; return -1;
} }
return 0; return 0;
@ -1809,9 +1739,7 @@ int Channel::GetPlayoutTimestamp(unsigned int& timestamp) {
playout_timestamp_rtp = playout_timestamp_rtp_; playout_timestamp_rtp = playout_timestamp_rtp_;
} }
if (playout_timestamp_rtp == 0) { if (playout_timestamp_rtp == 0) {
_engineStatisticsPtr->SetLastError( LOG(LS_ERROR) << "GetPlayoutTimestamp() failed to retrieve timestamp";
VE_CANNOT_RETRIEVE_VALUE, kTraceStateInfo,
"GetPlayoutTimestamp() failed to retrieve timestamp");
return -1; return -1;
} }
timestamp = playout_timestamp_rtp; timestamp = playout_timestamp_rtp;
@ -1839,9 +1767,6 @@ void Channel::UpdatePlayoutTimestamp(bool rtcp) {
WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::UpdatePlayoutTimestamp() failed to read playout" "Channel::UpdatePlayoutTimestamp() failed to read playout"
" delay from the ADM"); " delay from the ADM");
_engineStatisticsPtr->SetLastError(
VE_CANNOT_RETRIEVE_VALUE, kTraceError,
"UpdatePlayoutTimestamp() failed to retrieve playout delay");
return; return;
} }

View File

@ -90,7 +90,6 @@ namespace voe {
class RtcEventLogProxy; class RtcEventLogProxy;
class RtcpRttStatsProxy; class RtcpRttStatsProxy;
class RtpPacketSenderProxy; class RtpPacketSenderProxy;
class Statistics;
class TransportFeedbackProxy; class TransportFeedbackProxy;
class TransportSequenceNumberProxy; class TransportSequenceNumberProxy;
class VoERtcpObserver; class VoERtcpObserver;
@ -157,10 +156,8 @@ class Channel
const VoEBase::ChannelConfig& config); const VoEBase::ChannelConfig& config);
int32_t Init(); int32_t Init();
void Terminate(); void Terminate();
int32_t SetEngineInformation(Statistics& engineStatistics, int32_t SetEngineInformation(ProcessThread& moduleProcessThread,
ProcessThread& moduleProcessThread,
AudioDeviceModule& audioDeviceModule, AudioDeviceModule& audioDeviceModule,
rtc::CriticalSection* callbackCritSect,
rtc::TaskQueue* encoder_queue); rtc::TaskQueue* encoder_queue);
void SetSink(std::unique_ptr<AudioSinkInterface> sink); void SetSink(std::unique_ptr<AudioSinkInterface> sink);
@ -197,8 +194,7 @@ class Channel
int max_frame_length_ms); int max_frame_length_ms);
// Network // Network
int32_t RegisterExternalTransport(Transport* transport); void RegisterTransport(Transport* transport);
int32_t DeRegisterExternalTransport();
// TODO(nisse, solenberg): Delete when VoENetwork is deleted. // TODO(nisse, solenberg): Delete when VoENetwork is deleted.
int32_t ReceivedRTCPPacket(const uint8_t* data, size_t length); int32_t ReceivedRTCPPacket(const uint8_t* data, size_t length);
void OnRtpPacket(const RtpPacketReceived& packet); void OnRtpPacket(const RtpPacketReceived& packet);
@ -286,10 +282,6 @@ class Channel
int32_t ChannelId() const { return _channelId; } int32_t ChannelId() const { return _channelId; }
bool Playing() const { return channel_state_.Get().playing; } bool Playing() const { return channel_state_.Get().playing; }
bool Sending() const { return channel_state_.Get().sending; } bool Sending() const { return channel_state_.Get().sending; }
bool ExternalTransport() const {
rtc::CritScope cs(&_callbackCritSect);
return _externalTransport;
}
RtpRtcp* RtpRtcpModulePtr() const { return _rtpRtcpModule.get(); } RtpRtcp* RtpRtcpModulePtr() const { return _rtpRtcpModule.get(); }
int8_t OutputEnergyLevel() const { return _outputAudioLevel.Level(); } int8_t OutputEnergyLevel() const { return _outputAudioLevel.Level(); }
@ -395,7 +387,6 @@ class Channel
acm2::RentACodec rent_a_codec_; acm2::RentACodec rent_a_codec_;
std::unique_ptr<AudioSinkInterface> audio_sink_; std::unique_ptr<AudioSinkInterface> audio_sink_;
AudioLevel _outputAudioLevel; AudioLevel _outputAudioLevel;
bool _externalTransport;
// Downsamples to the codec rate if necessary. // Downsamples to the codec rate if necessary.
PushResampler<int16_t> input_resampler_; PushResampler<int16_t> input_resampler_;
uint32_t _timeStamp RTC_ACCESS_ON(encoder_queue_); uint32_t _timeStamp RTC_ACCESS_ON(encoder_queue_);
@ -420,10 +411,8 @@ class Channel
int64_t capture_start_ntp_time_ms_ RTC_GUARDED_BY(ts_stats_lock_); int64_t capture_start_ntp_time_ms_ RTC_GUARDED_BY(ts_stats_lock_);
// uses // uses
Statistics* _engineStatisticsPtr;
ProcessThread* _moduleProcessThreadPtr; ProcessThread* _moduleProcessThreadPtr;
AudioDeviceModule* _audioDeviceModulePtr; AudioDeviceModule* _audioDeviceModulePtr;
rtc::CriticalSection* _callbackCritSectPtr; // owned by base
Transport* _transportPtr; // WebRtc socket or external transport Transport* _transportPtr; // WebRtc socket or external transport
RmsLevel rms_level_ RTC_ACCESS_ON(encoder_queue_); RmsLevel rms_level_ RTC_ACCESS_ON(encoder_queue_);
bool input_mute_ RTC_GUARDED_BY(volume_settings_critsect_); bool input_mute_ RTC_GUARDED_BY(volume_settings_critsect_);

View File

@ -213,15 +213,9 @@ void ChannelProxy::SetInputMute(bool muted) {
channel()->SetInputMute(muted); channel()->SetInputMute(muted);
} }
void ChannelProxy::RegisterExternalTransport(Transport* transport) { void ChannelProxy::RegisterTransport(Transport* transport) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
int error = channel()->RegisterExternalTransport(transport); channel()->RegisterTransport(transport);
RTC_DCHECK_EQ(0, error);
}
void ChannelProxy::DeRegisterExternalTransport() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
channel()->DeRegisterExternalTransport();
} }
void ChannelProxy::OnRtpPacket(const RtpPacketReceived& packet) { void ChannelProxy::OnRtpPacket(const RtpPacketReceived& packet) {

View File

@ -94,8 +94,7 @@ class ChannelProxy : public RtpPacketSinkInterface {
virtual void SetReceiveCodecs(const std::map<int, SdpAudioFormat>& codecs); virtual void SetReceiveCodecs(const std::map<int, SdpAudioFormat>& codecs);
virtual void SetSink(std::unique_ptr<AudioSinkInterface> sink); virtual void SetSink(std::unique_ptr<AudioSinkInterface> sink);
virtual void SetInputMute(bool muted); virtual void SetInputMute(bool muted);
virtual void RegisterExternalTransport(Transport* transport); virtual void RegisterTransport(Transport* transport);
virtual void DeRegisterExternalTransport();
// Implements RtpPacketSinkInterface // Implements RtpPacketSinkInterface
void OnRtpPacket(const RtpPacketReceived& packet) override; void OnRtpPacket(const RtpPacketReceived& packet) override;

View File

@ -24,7 +24,6 @@ static int32_t _gInstanceCounter = 0;
SharedData::SharedData() SharedData::SharedData()
: _instanceId(++_gInstanceCounter), : _instanceId(++_gInstanceCounter),
_channelManager(_gInstanceCounter), _channelManager(_gInstanceCounter),
_engineStatistics(_gInstanceCounter),
_audioDevicePtr(NULL), _audioDevicePtr(NULL),
_moduleProcessThreadPtr(ProcessThread::Create("VoiceProcessThread")), _moduleProcessThreadPtr(ProcessThread::Create("VoiceProcessThread")),
encoder_queue_("AudioEncoderQueue") { encoder_queue_("AudioEncoderQueue") {
@ -84,20 +83,6 @@ int SharedData::NumOfPlayingChannels() {
return playout_channels; return playout_channels;
} }
void SharedData::SetLastError(int32_t error) const {
_engineStatistics.SetLastError(error);
}
void SharedData::SetLastError(int32_t error,
TraceLevel level) const {
_engineStatistics.SetLastError(error, level);
}
void SharedData::SetLastError(int32_t error, TraceLevel level,
const char* msg) const {
_engineStatistics.SetLastError(error, level, msg);
}
} // namespace voe } // namespace voe
} // namespace webrtc } // namespace webrtc

View File

@ -22,7 +22,6 @@
#include "rtc_base/thread_annotations.h" #include "rtc_base/thread_annotations.h"
#include "rtc_base/thread_checker.h" #include "rtc_base/thread_checker.h"
#include "voice_engine/channel_manager.h" #include "voice_engine/channel_manager.h"
#include "voice_engine/statistics.h"
#include "voice_engine/voice_engine_defines.h" #include "voice_engine/voice_engine_defines.h"
class ProcessThread; class ProcessThread;
@ -37,7 +36,6 @@ class SharedData
public: public:
// Public accessors. // Public accessors.
uint32_t instance_id() const { return _instanceId; } uint32_t instance_id() const { return _instanceId; }
Statistics& statistics() { return _engineStatistics; }
ChannelManager& channel_manager() { return _channelManager; } ChannelManager& channel_manager() { return _channelManager; }
AudioDeviceModule* audio_device() { return _audioDevicePtr.get(); } AudioDeviceModule* audio_device() { return _audioDevicePtr.get(); }
void set_audio_device( void set_audio_device(
@ -51,18 +49,11 @@ public:
int NumOfSendingChannels(); int NumOfSendingChannels();
int NumOfPlayingChannels(); int NumOfPlayingChannels();
// Convenience methods for calling statistics().SetLastError().
void SetLastError(int32_t error) const;
void SetLastError(int32_t error, TraceLevel level) const;
void SetLastError(int32_t error, TraceLevel level,
const char* msg) const;
protected: protected:
rtc::ThreadChecker construction_thread_; rtc::ThreadChecker construction_thread_;
const uint32_t _instanceId; const uint32_t _instanceId;
rtc::CriticalSection _apiCritPtr; rtc::CriticalSection _apiCritPtr;
ChannelManager _channelManager; ChannelManager _channelManager;
Statistics _engineStatistics;
rtc::scoped_refptr<AudioDeviceModule> _audioDevicePtr; rtc::scoped_refptr<AudioDeviceModule> _audioDevicePtr;
TransmitMixer* _transmitMixerPtr; TransmitMixer* _transmitMixerPtr;
std::unique_ptr<ProcessThread> _moduleProcessThreadPtr; std::unique_ptr<ProcessThread> _moduleProcessThreadPtr;

View File

@ -1,86 +0,0 @@
/*
* 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 <assert.h>
#include <stdio.h>
#include "voice_engine/statistics.h"
#include "system_wrappers/include/trace.h"
namespace webrtc {
namespace voe {
Statistics::Statistics(uint32_t instanceId) :
_instanceId(instanceId),
_lastError(0),
_isInitialized(false)
{
}
Statistics::~Statistics()
{
}
int32_t Statistics::SetInitialized()
{
_isInitialized = true;
return 0;
}
int32_t Statistics::SetUnInitialized()
{
_isInitialized = false;
return 0;
}
bool Statistics::Initialized() const
{
return _isInitialized;
}
int32_t Statistics::SetLastError(int32_t error) const
{
rtc::CritScope cs(&lock_);
_lastError = error;
return 0;
}
int32_t Statistics::SetLastError(int32_t error,
TraceLevel level) const
{
WEBRTC_TRACE(level, kTraceVoice, VoEId(_instanceId,-1),
"error code is set to %d",
error);
rtc::CritScope cs(&lock_);
_lastError = error;
return 0;
}
int32_t Statistics::SetLastError(
int32_t error,
TraceLevel level, const char* msg) const
{
char traceMessage[KTraceMaxMessageSize];
assert(strlen(msg) < KTraceMaxMessageSize);
sprintf(traceMessage, "%s (error=%d)", msg, error);
WEBRTC_TRACE(level, kTraceVoice, VoEId(_instanceId,-1), "%s",
traceMessage);
rtc::CritScope cs(&lock_);
_lastError = error;
return 0;
}
} // namespace voe
} // namespace webrtc

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2011 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.
*/
#ifndef VOICE_ENGINE_STATISTICS_H_
#define VOICE_ENGINE_STATISTICS_H_
#include "common_types.h" // NOLINT(build/include)
#include "rtc_base/criticalsection.h"
#include "typedefs.h" // NOLINT(build/include)
#include "voice_engine/include/voe_errors.h"
#include "voice_engine/voice_engine_defines.h"
namespace webrtc {
namespace voe {
class Statistics
{
public:
enum {KTraceMaxMessageSize = 256};
public:
Statistics(uint32_t instanceId);
~Statistics();
int32_t SetInitialized();
int32_t SetUnInitialized();
bool Initialized() const;
int32_t SetLastError(int32_t error) const;
int32_t SetLastError(int32_t error, TraceLevel level) const;
int32_t SetLastError(int32_t error,
TraceLevel level,
const char* msg) const;
private:
rtc::CriticalSection lock_;
const uint32_t _instanceId;
mutable int32_t _lastError;
bool _isInitialized;
};
} // namespace voe
} // namespace webrtc
#endif // VOICE_ENGINE_STATISTICS_H_

View File

@ -20,7 +20,6 @@
#include "system_wrappers/include/trace.h" #include "system_wrappers/include/trace.h"
#include "voice_engine/channel.h" #include "voice_engine/channel.h"
#include "voice_engine/channel_manager.h" #include "voice_engine/channel_manager.h"
#include "voice_engine/statistics.h"
#include "voice_engine/utility.h" #include "voice_engine/utility.h"
namespace webrtc { namespace webrtc {

View File

@ -36,7 +36,6 @@ namespace voe {
class ChannelManager; class ChannelManager;
class MixedAudio; class MixedAudio;
class Statistics;
class TransmitMixer { class TransmitMixer {
public: public:

View File

@ -42,7 +42,6 @@ VoEBaseImpl::~VoEBaseImpl() {
} }
void VoEBaseImpl::OnErrorIsReported(const ErrorCode error) { void VoEBaseImpl::OnErrorIsReported(const ErrorCode error) {
rtc::CritScope cs(&callbackCritSect_);
if (error == AudioDeviceObserver::kRecordingError) { if (error == AudioDeviceObserver::kRecordingError) {
LOG_F(LS_ERROR) << "VE_RUNTIME_REC_ERROR"; LOG_F(LS_ERROR) << "VE_RUNTIME_REC_ERROR";
} else if (error == AudioDeviceObserver::kPlayoutError) { } else if (error == AudioDeviceObserver::kPlayoutError) {
@ -51,7 +50,6 @@ void VoEBaseImpl::OnErrorIsReported(const ErrorCode error) {
} }
void VoEBaseImpl::OnWarningIsReported(const WarningCode warning) { void VoEBaseImpl::OnWarningIsReported(const WarningCode warning) {
rtc::CritScope cs(&callbackCritSect_);
if (warning == AudioDeviceObserver::kRecordingWarning) { if (warning == AudioDeviceObserver::kRecordingWarning) {
LOG_F(LS_WARNING) << "VE_RUNTIME_REC_WARNING"; LOG_F(LS_WARNING) << "VE_RUNTIME_REC_WARNING";
} else if (warning == AudioDeviceObserver::kPlayoutWarning) { } else if (warning == AudioDeviceObserver::kPlayoutWarning) {
@ -167,9 +165,6 @@ int VoEBaseImpl::Init(
RTC_DCHECK(audio_processing); RTC_DCHECK(audio_processing);
rtc::CritScope cs(shared_->crit_sec()); rtc::CritScope cs(shared_->crit_sec());
WebRtcSpl_Init(); WebRtcSpl_Init();
if (shared_->statistics().Initialized()) {
return 0;
}
if (shared_->process_thread()) { if (shared_->process_thread()) {
shared_->process_thread()->Start(); shared_->process_thread()->Start();
} }
@ -185,8 +180,7 @@ int VoEBaseImpl::Init(
VoEId(shared_->instance_id(), -1), VoEId(shared_->instance_id(), -1),
AudioDeviceModule::kPlatformDefaultAudio)); AudioDeviceModule::kPlatformDefaultAudio));
if (shared_->audio_device() == nullptr) { if (shared_->audio_device() == nullptr) {
shared_->SetLastError(VE_NO_MEMORY, kTraceCritical, LOG(LS_ERROR) << "Init() failed to create the ADM";
"Init() failed to create the ADM");
return -1; return -1;
} }
#endif // WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE #endif // WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE
@ -211,55 +205,44 @@ int VoEBaseImpl::Init(
// Register the AudioObserver implementation // Register the AudioObserver implementation
if (shared_->audio_device()->RegisterEventObserver(this) != 0) { if (shared_->audio_device()->RegisterEventObserver(this) != 0) {
shared_->SetLastError( LOG(LS_ERROR) << "Init() failed to register event observer for the ADM";
VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning,
"Init() failed to register event observer for the ADM");
} }
// Register the AudioTransport implementation // Register the AudioTransport implementation
if (shared_->audio_device()->RegisterAudioCallback(this) != 0) { if (shared_->audio_device()->RegisterAudioCallback(this) != 0) {
shared_->SetLastError( LOG(LS_ERROR) << "Init() failed to register audio callback for the ADM";
VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning,
"Init() failed to register audio callback for the ADM");
} }
// ADM initialization // ADM initialization
if (shared_->audio_device()->Init() != 0) { if (shared_->audio_device()->Init() != 0) {
shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, LOG(LS_ERROR) << "Init() failed to initialize the ADM";
"Init() failed to initialize the ADM");
return -1; return -1;
} }
// Initialize the default speaker // Initialize the default speaker
if (shared_->audio_device()->SetPlayoutDevice( if (shared_->audio_device()->SetPlayoutDevice(
WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE) != 0) { WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE) != 0) {
shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceInfo, LOG(LS_ERROR) << "Init() failed to set the default output device";
"Init() failed to set the default output device");
} }
if (shared_->audio_device()->InitSpeaker() != 0) { if (shared_->audio_device()->InitSpeaker() != 0) {
shared_->SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceInfo, LOG(LS_ERROR) << "Init() failed to initialize the speaker";
"Init() failed to initialize the speaker");
} }
// Initialize the default microphone // Initialize the default microphone
if (shared_->audio_device()->SetRecordingDevice( if (shared_->audio_device()->SetRecordingDevice(
WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE) != 0) { WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE) != 0) {
shared_->SetLastError(VE_SOUNDCARD_ERROR, kTraceInfo, LOG(LS_ERROR) << "Init() failed to set the default input device";
"Init() failed to set the default input device");
} }
if (shared_->audio_device()->InitMicrophone() != 0) { if (shared_->audio_device()->InitMicrophone() != 0) {
shared_->SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceInfo, LOG(LS_ERROR) << "Init() failed to initialize the microphone";
"Init() failed to initialize the microphone");
} }
// Set number of channels // Set number of channels
if (shared_->audio_device()->StereoPlayoutIsAvailable(&available) != 0) { if (shared_->audio_device()->StereoPlayoutIsAvailable(&available) != 0) {
shared_->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, LOG(LS_ERROR) << "Init() failed to query stereo playout mode";
"Init() failed to query stereo playout mode");
} }
if (shared_->audio_device()->SetStereoPlayout(available) != 0) { if (shared_->audio_device()->SetStereoPlayout(available) != 0) {
shared_->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, LOG(LS_ERROR) << "Init() failed to set mono/stereo playout mode";
"Init() failed to set mono/stereo playout mode");
} }
// TODO(andrew): These functions don't tell us whether stereo recording // TODO(andrew): These functions don't tell us whether stereo recording
@ -271,14 +254,11 @@ int VoEBaseImpl::Init(
// http://code.google.com/p/webrtc/issues/detail?id=204 // http://code.google.com/p/webrtc/issues/detail?id=204
shared_->audio_device()->StereoRecordingIsAvailable(&available); shared_->audio_device()->StereoRecordingIsAvailable(&available);
if (shared_->audio_device()->SetStereoRecording(available) != 0) { if (shared_->audio_device()->SetStereoRecording(available) != 0) {
shared_->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, LOG(LS_ERROR) << "Init() failed to set mono/stereo recording mode";
"Init() failed to set mono/stereo recording mode");
} }
shared_->set_audio_processing(audio_processing); shared_->set_audio_processing(audio_processing);
// Set the error state for any failures in this block.
shared_->SetLastError(VE_APM_ERROR);
// Configure AudioProcessing components. // Configure AudioProcessing components.
// TODO(peah): Move this initialization to webrtcvoiceengine.cc. // TODO(peah): Move this initialization to webrtcvoiceengine.cc.
if (audio_processing->high_pass_filter()->Enable(true) != 0) { if (audio_processing->high_pass_filter()->Enable(true) != 0) {
@ -309,14 +289,12 @@ int VoEBaseImpl::Init(
LOG_F(LS_ERROR) << "Failed to set agc state: " << kDefaultAgcState; LOG_F(LS_ERROR) << "Failed to set agc state: " << kDefaultAgcState;
return -1; return -1;
} }
shared_->SetLastError(0); // Clear error state.
#ifdef WEBRTC_VOICE_ENGINE_AGC #ifdef WEBRTC_VOICE_ENGINE_AGC
bool agc_enabled = bool agc_enabled =
agc->mode() == GainControl::kAdaptiveAnalog && agc->is_enabled(); agc->mode() == GainControl::kAdaptiveAnalog && agc->is_enabled();
if (shared_->audio_device()->SetAGC(agc_enabled) != 0) { if (shared_->audio_device()->SetAGC(agc_enabled) != 0) {
LOG_F(LS_ERROR) << "Failed to set agc to enabled: " << agc_enabled; LOG_F(LS_ERROR) << "Failed to set agc to enabled: " << agc_enabled;
shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR);
// TODO(ajm): No error return here due to // TODO(ajm): No error return here due to
// https://code.google.com/p/webrtc/issues/detail?id=1464 // https://code.google.com/p/webrtc/issues/detail?id=1464
} }
@ -327,7 +305,7 @@ int VoEBaseImpl::Init(
else else
decoder_factory_ = CreateBuiltinAudioDecoderFactory(); decoder_factory_ = CreateBuiltinAudioDecoderFactory();
return shared_->statistics().SetInitialized(); return 0;
} }
int VoEBaseImpl::Terminate() { int VoEBaseImpl::Terminate() {
@ -341,11 +319,6 @@ int VoEBaseImpl::CreateChannel() {
int VoEBaseImpl::CreateChannel(const ChannelConfig& config) { int VoEBaseImpl::CreateChannel(const ChannelConfig& config) {
rtc::CritScope cs(shared_->crit_sec()); rtc::CritScope cs(shared_->crit_sec());
if (!shared_->statistics().Initialized()) {
shared_->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
ChannelConfig config_copy(config); ChannelConfig config_copy(config);
config_copy.acm_config.decoder_factory = decoder_factory_; config_copy.acm_config.decoder_factory = decoder_factory_;
voe::ChannelOwner channel_owner = voe::ChannelOwner channel_owner =
@ -355,21 +328,16 @@ int VoEBaseImpl::CreateChannel(const ChannelConfig& config) {
int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) { int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) {
if (channel_owner->channel()->SetEngineInformation( if (channel_owner->channel()->SetEngineInformation(
shared_->statistics(),
*shared_->process_thread(), *shared_->audio_device(), *shared_->process_thread(), *shared_->audio_device(),
&callbackCritSect_, shared_->encoder_queue()) != 0) { shared_->encoder_queue()) != 0) {
shared_->SetLastError( LOG(LS_ERROR) << "CreateChannel() failed to associate engine and channel."
VE_CHANNEL_NOT_CREATED, kTraceError, " Destroying channel.";
"CreateChannel() failed to associate engine and channel."
" Destroying channel.");
shared_->channel_manager().DestroyChannel( shared_->channel_manager().DestroyChannel(
channel_owner->channel()->ChannelId()); channel_owner->channel()->ChannelId());
return -1; return -1;
} else if (channel_owner->channel()->Init() != 0) { } else if (channel_owner->channel()->Init() != 0) {
shared_->SetLastError( LOG(LS_ERROR) << "CreateChannel() failed to initialize channel. Destroying"
VE_CHANNEL_NOT_CREATED, kTraceError, " channel.";
"CreateChannel() failed to initialize channel. Destroying"
" channel.");
shared_->channel_manager().DestroyChannel( shared_->channel_manager().DestroyChannel(
channel_owner->channel()->ChannelId()); channel_owner->channel()->ChannelId());
return -1; return -1;
@ -379,17 +347,11 @@ int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) {
int VoEBaseImpl::DeleteChannel(int channel) { int VoEBaseImpl::DeleteChannel(int channel) {
rtc::CritScope cs(shared_->crit_sec()); rtc::CritScope cs(shared_->crit_sec());
if (!shared_->statistics().Initialized()) {
shared_->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
{ {
voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel);
voe::Channel* channelPtr = ch.channel(); voe::Channel* channelPtr = ch.channel();
if (channelPtr == nullptr) { if (channelPtr == nullptr) {
shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, LOG(LS_ERROR) << "DeleteChannel() failed to locate channel";
"DeleteChannel() failed to locate channel");
return -1; return -1;
} }
} }
@ -406,23 +368,17 @@ int VoEBaseImpl::DeleteChannel(int channel) {
int VoEBaseImpl::StartPlayout(int channel) { int VoEBaseImpl::StartPlayout(int channel) {
rtc::CritScope cs(shared_->crit_sec()); rtc::CritScope cs(shared_->crit_sec());
if (!shared_->statistics().Initialized()) {
shared_->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel);
voe::Channel* channelPtr = ch.channel(); voe::Channel* channelPtr = ch.channel();
if (channelPtr == nullptr) { if (channelPtr == nullptr) {
shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, LOG(LS_ERROR) << "StartPlayout() failed to locate channel";
"StartPlayout() failed to locate channel");
return -1; return -1;
} }
if (channelPtr->Playing()) { if (channelPtr->Playing()) {
return 0; return 0;
} }
if (StartPlayout() != 0) { if (StartPlayout() != 0) {
shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, LOG(LS_ERROR) << "StartPlayout() failed to start playout";
"StartPlayout() failed to start playout");
return -1; return -1;
} }
return channelPtr->StartPlayout(); return channelPtr->StartPlayout();
@ -430,15 +386,10 @@ int VoEBaseImpl::StartPlayout(int channel) {
int VoEBaseImpl::StopPlayout(int channel) { int VoEBaseImpl::StopPlayout(int channel) {
rtc::CritScope cs(shared_->crit_sec()); rtc::CritScope cs(shared_->crit_sec());
if (!shared_->statistics().Initialized()) {
shared_->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel);
voe::Channel* channelPtr = ch.channel(); voe::Channel* channelPtr = ch.channel();
if (channelPtr == nullptr) { if (channelPtr == nullptr) {
shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, LOG(LS_ERROR) << "StopPlayout() failed to locate channel";
"StopPlayout() failed to locate channel");
return -1; return -1;
} }
if (channelPtr->StopPlayout() != 0) { if (channelPtr->StopPlayout() != 0) {
@ -450,23 +401,17 @@ int VoEBaseImpl::StopPlayout(int channel) {
int VoEBaseImpl::StartSend(int channel) { int VoEBaseImpl::StartSend(int channel) {
rtc::CritScope cs(shared_->crit_sec()); rtc::CritScope cs(shared_->crit_sec());
if (!shared_->statistics().Initialized()) {
shared_->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel);
voe::Channel* channelPtr = ch.channel(); voe::Channel* channelPtr = ch.channel();
if (channelPtr == nullptr) { if (channelPtr == nullptr) {
shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, LOG(LS_ERROR) << "StartSend() failed to locate channel";
"StartSend() failed to locate channel");
return -1; return -1;
} }
if (channelPtr->Sending()) { if (channelPtr->Sending()) {
return 0; return 0;
} }
if (StartSend() != 0) { if (StartSend() != 0) {
shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, LOG(LS_ERROR) << "StartSend() failed to start recording";
"StartSend() failed to start recording");
return -1; return -1;
} }
return channelPtr->StartSend(); return channelPtr->StartSend();
@ -474,15 +419,10 @@ int VoEBaseImpl::StartSend(int channel) {
int VoEBaseImpl::StopSend(int channel) { int VoEBaseImpl::StopSend(int channel) {
rtc::CritScope cs(shared_->crit_sec()); rtc::CritScope cs(shared_->crit_sec());
if (!shared_->statistics().Initialized()) {
shared_->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel);
voe::Channel* channelPtr = ch.channel(); voe::Channel* channelPtr = ch.channel();
if (channelPtr == nullptr) { if (channelPtr == nullptr) {
shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, LOG(LS_ERROR) << "StopSend() failed to locate channel";
"StopSend() failed to locate channel");
return -1; return -1;
} }
channelPtr->StopSend(); channelPtr->StopSend();
@ -507,8 +447,7 @@ int32_t VoEBaseImpl::StopPlayout() {
// Stop audio-device playing if no channel is playing out // Stop audio-device playing if no channel is playing out
if (shared_->NumOfPlayingChannels() == 0) { if (shared_->NumOfPlayingChannels() == 0) {
if (shared_->audio_device()->StopPlayout() != 0) { if (shared_->audio_device()->StopPlayout() != 0) {
shared_->SetLastError(VE_CANNOT_STOP_PLAYOUT, kTraceError, LOG(LS_ERROR) << "StopPlayout() failed to stop playout";
"StopPlayout() failed to stop playout");
return -1; return -1;
} }
} }
@ -536,8 +475,7 @@ int32_t VoEBaseImpl::StopSend() {
if (shared_->NumOfSendingChannels() == 0) { if (shared_->NumOfSendingChannels() == 0) {
// Stop audio-device recording if no channel is recording // Stop audio-device recording if no channel is recording
if (shared_->audio_device()->StopRecording() != 0) { if (shared_->audio_device()->StopRecording() != 0) {
shared_->SetLastError(VE_CANNOT_STOP_RECORDING, kTraceError, LOG(LS_ERROR) << "StopSend() failed to stop recording";
"StopSend() failed to stop recording");
return -1; return -1;
} }
shared_->transmit_mixer()->StopSend(); shared_->transmit_mixer()->StopSend();
@ -559,34 +497,27 @@ int32_t VoEBaseImpl::TerminateInternal() {
if (shared_->audio_device()) { if (shared_->audio_device()) {
if (shared_->audio_device()->StopPlayout() != 0) { if (shared_->audio_device()->StopPlayout() != 0) {
shared_->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, LOG(LS_ERROR) << "TerminateInternal() failed to stop playout";
"TerminateInternal() failed to stop playout");
} }
if (shared_->audio_device()->StopRecording() != 0) { if (shared_->audio_device()->StopRecording() != 0) {
shared_->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, LOG(LS_ERROR) << "TerminateInternal() failed to stop recording";
"TerminateInternal() failed to stop recording");
} }
if (shared_->audio_device()->RegisterEventObserver(nullptr) != 0) { if (shared_->audio_device()->RegisterEventObserver(nullptr) != 0) {
shared_->SetLastError( LOG(LS_ERROR) << "TerminateInternal() failed to de-register event "
VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning, "observer for the ADM";
"TerminateInternal() failed to de-register event observer "
"for the ADM");
} }
if (shared_->audio_device()->RegisterAudioCallback(nullptr) != 0) { if (shared_->audio_device()->RegisterAudioCallback(nullptr) != 0) {
shared_->SetLastError( LOG(LS_ERROR) << "TerminateInternal() failed to de-register audio "
VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning, "callback for the ADM";
"TerminateInternal() failed to de-register audio callback "
"for the ADM");
} }
if (shared_->audio_device()->Terminate() != 0) { if (shared_->audio_device()->Terminate() != 0) {
shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, LOG(LS_ERROR) << "TerminateInternal() failed to terminate the ADM";
"TerminateInternal() failed to terminate the ADM");
} }
shared_->set_audio_device(nullptr); shared_->set_audio_device(nullptr);
} }
shared_->set_audio_processing(nullptr); shared_->set_audio_processing(nullptr);
return shared_->statistics().SetUnInitialized(); return 0;
} }
} // namespace webrtc } // namespace webrtc

View File

@ -104,7 +104,6 @@ class VoEBaseImpl : public VoEBase,
// Initialize channel by setting Engine Information then initializing // Initialize channel by setting Engine Information then initializing
// channel. // channel.
int InitializeChannel(voe::ChannelOwner* channel_owner); int InitializeChannel(voe::ChannelOwner* channel_owner);
rtc::CriticalSection callbackCritSect_;
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
AudioFrame audioFrame_; AudioFrame audioFrame_;

View File

@ -41,11 +41,6 @@ TEST_F(VoEBaseTest, InitWithExternalAudioDevice) {
EXPECT_EQ(0, base_->Init(&adm_, apm_.get())); EXPECT_EQ(0, base_->Init(&adm_, apm_.get()));
} }
TEST_F(VoEBaseTest, CreateChannelBeforeInitShouldFail) {
int channelID = base_->CreateChannel();
EXPECT_EQ(channelID, -1);
}
TEST_F(VoEBaseTest, CreateChannelAfterInit) { TEST_F(VoEBaseTest, CreateChannelAfterInit) {
EXPECT_EQ(0, base_->Init(&adm_, apm_.get(), nullptr)); EXPECT_EQ(0, base_->Init(&adm_, apm_.get(), nullptr));
int channelID = base_->CreateChannel(); int channelID = base_->CreateChannel();

View File

@ -65,7 +65,6 @@ std::unique_ptr<voe::ChannelProxy> VoiceEngineImpl::GetChannelProxy(
int channel_id) { int channel_id) {
RTC_DCHECK(channel_id >= 0); RTC_DCHECK(channel_id >= 0);
rtc::CritScope cs(crit_sec()); rtc::CritScope cs(crit_sec());
RTC_DCHECK(statistics().Initialized());
return std::unique_ptr<voe::ChannelProxy>( return std::unique_ptr<voe::ChannelProxy>(
new voe::ChannelProxy(channel_manager().GetChannel(channel_id))); new voe::ChannelProxy(channel_manager().GetChannel(channel_id)));
} }