Remove voe::Statistics.
BUG=webrtc:4690
Review-Url: https://codereview.webrtc.org/3020473002
Cr-Commit-Position: refs/heads/master@{#20042}
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc
index 37985d8..704c86e 100644
--- a/audio/audio_receive_stream.cc
+++ b/audio/audio_receive_stream.cc
@@ -94,7 +94,7 @@
RTC_CHECK_EQ(config.decoder_factory,
channel_proxy_->GetAudioDecoderFactory());
- channel_proxy_->RegisterExternalTransport(config.rtcp_send_transport);
+ channel_proxy_->RegisterTransport(config.rtcp_send_transport);
channel_proxy_->SetReceiveCodecs(config.decoder_map);
for (const auto& extension : config.rtp.extensions) {
@@ -122,7 +122,7 @@
Stop();
}
channel_proxy_->DisassociateSendChannel();
- channel_proxy_->DeRegisterExternalTransport();
+ channel_proxy_->RegisterTransport(nullptr);
channel_proxy_->ResetReceiverCongestionControlObjects();
channel_proxy_->SetRtcEventLog(nullptr);
}
diff --git a/audio/audio_receive_stream_unittest.cc b/audio/audio_receive_stream_unittest.cc
index 69cf459..1ceaaab 100644
--- a/audio/audio_receive_stream_unittest.cc
+++ b/audio/audio_receive_stream_unittest.cc
@@ -101,10 +101,7 @@
.Times(1);
EXPECT_CALL(*channel_proxy_, ResetReceiverCongestionControlObjects())
.Times(1);
- EXPECT_CALL(*channel_proxy_, RegisterExternalTransport(nullptr))
- .Times(1);
- EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport())
- .Times(1);
+ EXPECT_CALL(*channel_proxy_, RegisterTransport(nullptr)).Times(2);
EXPECT_CALL(*channel_proxy_, GetAudioDecoderFactory())
.WillOnce(ReturnRef(decoder_factory_));
testing::Expectation expect_set =
diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc
index 4bdd42b..997c95e 100644
--- a/audio/audio_send_stream.cc
+++ b/audio/audio_send_stream.cc
@@ -120,7 +120,7 @@
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString();
transport_->send_side_cc()->DeRegisterPacketFeedbackObserver(this);
- channel_proxy_->DeRegisterExternalTransport();
+ channel_proxy_->RegisterTransport(nullptr);
channel_proxy_->ResetSenderCongestionControlObjects();
channel_proxy_->SetRtcEventLog(nullptr);
channel_proxy_->SetRtcpRttStats(nullptr);
@@ -164,7 +164,7 @@
if (first_time ||
new_config.send_transport != old_config.send_transport) {
if (old_config.send_transport) {
- channel_proxy->DeRegisterExternalTransport();
+ channel_proxy->RegisterTransport(nullptr);
}
if (new_config.send_transport) {
stream->timed_send_transport_adapter_.reset(new TimedTransport(
@@ -172,7 +172,7 @@
} else {
stream->timed_send_transport_adapter_.reset(nullptr);
}
- channel_proxy->RegisterExternalTransport(
+ channel_proxy->RegisterTransport(
stream->timed_send_transport_adapter_.get());
}
diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc
index e4312e5..d8d81a4 100644
--- a/audio/audio_send_stream_unittest.cc
+++ b/audio/audio_send_stream_unittest.cc
@@ -235,8 +235,7 @@
.Times(1);
EXPECT_CALL(*channel_proxy_, ResetSenderCongestionControlObjects())
.Times(1);
- EXPECT_CALL(*channel_proxy_, RegisterExternalTransport(nullptr)).Times(1);
- EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport()).Times(1);
+ EXPECT_CALL(*channel_proxy_, RegisterTransport(nullptr)).Times(2);
EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::NotNull())).Times(1);
EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull()))
.Times(1); // Destructor resets the event log
diff --git a/test/mock_voe_channel_proxy.h b/test/mock_voe_channel_proxy.h
index 0778bda..9bc48b1 100644
--- a/test/mock_voe_channel_proxy.h
+++ b/test/mock_voe_channel_proxy.h
@@ -65,8 +65,7 @@
// TODO(solenberg): Talk the compiler into accepting this mock method:
// MOCK_METHOD1(SetSink, void(std::unique_ptr<AudioSinkInterface> sink));
MOCK_METHOD1(SetInputMute, void(bool muted));
- MOCK_METHOD1(RegisterExternalTransport, void(Transport* transport));
- MOCK_METHOD0(DeRegisterExternalTransport, void());
+ MOCK_METHOD1(RegisterTransport, void(Transport* transport));
MOCK_METHOD1(OnRtpPacket, void(const RtpPacketReceived& packet));
MOCK_METHOD2(ReceivedRTCPPacket, bool(const uint8_t* packet, size_t length));
MOCK_CONST_METHOD0(GetAudioDecoderFactory,
diff --git a/voice_engine/BUILD.gn b/voice_engine/BUILD.gn
index 5eb1fc3..a7e837f 100644
--- a/voice_engine/BUILD.gn
+++ b/voice_engine/BUILD.gn
@@ -20,8 +20,6 @@
"include/voe_errors.h",
"shared_data.cc",
"shared_data.h",
- "statistics.cc",
- "statistics.h",
"transmit_mixer.cc",
"transmit_mixer.h",
"transport_feedback_packet_loss_tracker.cc",
diff --git a/voice_engine/channel.cc b/voice_engine/channel.cc
index 43088b6..5fa7973 100644
--- a/voice_engine/channel.cc
+++ b/voice_engine/channel.cc
@@ -40,7 +40,6 @@
#include "system_wrappers/include/field_trial.h"
#include "system_wrappers/include/metrics.h"
#include "system_wrappers/include/trace.h"
-#include "voice_engine/statistics.h"
#include "voice_engine/utility.h"
namespace webrtc {
@@ -447,9 +446,8 @@
// received from the capture device as
// undefined for voice for now.
-1, payloadData, payloadSize, fragmentation, nullptr, nullptr)) {
- _engineStatisticsPtr->SetLastError(
- VE_RTP_RTCP_MODULE_ERROR, kTraceWarning,
- "Channel::SendData() failed to send data to RTP/RTCP module");
+ LOG(LS_ERROR) <<
+ "Channel::SendData() failed to send data to RTP/RTCP module";
return -1;
}
@@ -475,11 +473,7 @@
size_t bufferLength = len;
if (!_transportPtr->SendRtp(bufferToSendPtr, bufferLength, options)) {
- std::string transport_name =
- _externalTransport ? "external transport" : "WebRtc sockets";
- WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
- "Channel::SendPacket() RTP transmission using %s failed",
- transport_name.c_str());
+ LOG(LS_ERROR) << "Channel::SendPacket() RTP transmission failed";
return false;
}
return true;
@@ -502,11 +496,7 @@
int n = _transportPtr->SendRtcp(bufferToSendPtr, bufferLength);
if (n < 0) {
- std::string transport_name =
- _externalTransport ? "external transport" : "WebRtc sockets";
- WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
- "Channel::SendRtcp() transmission using %s failed",
- transport_name.c_str());
+ LOG(LS_ERROR) << "Channel::SendRtcp() transmission failed";
return false;
}
return true;
@@ -556,7 +546,6 @@
"Channel::OnInitializeDecoder() invalid codec ("
"pt=%d, name=%s) received - 1",
payloadType, payloadName);
- _engineStatisticsPtr->SetLastError(VE_AUDIO_CODING_MODULE_ERROR);
return -1;
}
@@ -585,9 +574,8 @@
// Push the incoming payload (parsed and ready for decoding) into the ACM
if (audio_coding_->IncomingPacket(payloadData, payloadSize, *rtpHeader) !=
0) {
- _engineStatisticsPtr->SetLastError(
- VE_AUDIO_CODING_MODULE_ERROR, kTraceWarning,
- "Channel::OnReceivedPayloadData() unable to push data to the ACM");
+ LOG(LS_ERROR) <<
+ "Channel::OnReceivedPayloadData() unable to push data to the ACM";
return -1;
}
@@ -759,7 +747,6 @@
rtp_payload_registry_.get())),
telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()),
_outputAudioLevel(),
- _externalTransport(false),
_timeStamp(0), // This is just an offset, RTP module will add it's own
// random offset
ntp_estimator_(Clock::GetRealTimeClock()),
@@ -769,10 +756,8 @@
rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()),
capture_start_rtp_time_stamp_(-1),
capture_start_ntp_time_ms_(-1),
- _engineStatisticsPtr(NULL),
_moduleProcessThreadPtr(NULL),
_audioDeviceModulePtr(NULL),
- _callbackCritSectPtr(NULL),
_transportPtr(NULL),
input_mute_(false),
previous_frame_muted_(false),
@@ -835,7 +820,7 @@
// --- Initial sanity
- if ((_engineStatisticsPtr == NULL) || (_moduleProcessThreadPtr == NULL)) {
+ if (_moduleProcessThreadPtr == NULL) {
WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::Init() must call SetEngineInformation() first");
return -1;
@@ -848,9 +833,7 @@
// --- ACM initialization
if (audio_coding_->InitializeReceiver() == -1) {
- _engineStatisticsPtr->SetLastError(
- VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
- "Channel::Init() unable to initialize the ACM - 1");
+ LOG(LS_ERROR) << "Channel::Init() unable to initialize the ACM - 1";
return -1;
}
@@ -866,9 +849,7 @@
_rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound);
// --- Register all permanent callbacks
if (audio_coding_->RegisterTransportCallback(this) == -1) {
- _engineStatisticsPtr->SetLastError(
- VE_CANNOT_INIT_CHANNEL, kTraceError,
- "Channel::Init() callbacks not registered");
+ LOG(LS_ERROR) << "Channel::Init() callbacks not registered";
return -1;
}
@@ -903,19 +884,15 @@
// End of modules shutdown
}
-int32_t Channel::SetEngineInformation(Statistics& engineStatistics,
- ProcessThread& moduleProcessThread,
+int32_t Channel::SetEngineInformation(ProcessThread& moduleProcessThread,
AudioDeviceModule& audioDeviceModule,
- rtc::CriticalSection* callbackCritSect,
rtc::TaskQueue* encoder_queue) {
RTC_DCHECK(encoder_queue);
RTC_DCHECK(!encoder_queue_);
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::SetEngineInformation()");
- _engineStatisticsPtr = &engineStatistics;
_moduleProcessThreadPtr = &moduleProcessThread;
_audioDeviceModulePtr = &audioDeviceModule;
- _callbackCritSectPtr = callbackCritSect;
encoder_queue_ = encoder_queue;
return 0;
}
@@ -974,9 +951,7 @@
}
_rtpRtcpModule->SetSendingMediaStatus(true);
if (_rtpRtcpModule->SetSendingStatus(true) != 0) {
- _engineStatisticsPtr->SetLastError(
- VE_RTP_RTCP_MODULE_ERROR, kTraceError,
- "StartSend() RTP/RTCP failed to start sending");
+ LOG(LS_ERROR) << "StartSend() RTP/RTCP failed to start sending";
_rtpRtcpModule->SetSendingMediaStatus(false);
rtc::CritScope cs(&_callbackCritSect);
channel_state_.SetSending(false);
@@ -1023,9 +998,7 @@
// Reset sending SSRC and sequence number and triggers direct transmission
// of RTCP BYE
if (_rtpRtcpModule->SetSendingStatus(false) == -1) {
- _engineStatisticsPtr->SetLastError(
- VE_RTP_RTCP_MODULE_ERROR, kTraceWarning,
- "StartSend() RTP/RTCP failed to stop sending");
+ LOG(LS_ERROR) << "StartSend() RTP/RTCP failed to stop sending";
}
_rtpRtcpModule->SetSendingMediaStatus(false);
}
@@ -1198,39 +1171,9 @@
});
}
-int32_t Channel::RegisterExternalTransport(Transport* transport) {
- WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
- "Channel::RegisterExternalTransport()");
-
+void Channel::RegisterTransport(Transport* transport) {
rtc::CritScope cs(&_callbackCritSect);
- if (_externalTransport) {
- _engineStatisticsPtr->SetLastError(
- VE_INVALID_OPERATION, kTraceError,
- "RegisterExternalTransport() external transport already enabled");
- return -1;
- }
- _externalTransport = true;
_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) {
@@ -1380,9 +1323,7 @@
}
if (_rtpRtcpModule->SendTelephoneEventOutband(
event, duration_ms, kTelephoneEventAttenuationdB) != 0) {
- _engineStatisticsPtr->SetLastError(
- VE_SEND_DTMF_FAILED, kTraceWarning,
- "SendTelephoneEventOutband() failed to send event");
+ LOG(LS_ERROR) << "SendTelephoneEventOutband() failed to send event";
return -1;
}
return 0;
@@ -1401,10 +1342,8 @@
if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) {
_rtpRtcpModule->DeRegisterSendPayload(codec.pltype);
if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) {
- _engineStatisticsPtr->SetLastError(
- VE_RTP_RTCP_MODULE_ERROR, kTraceError,
- "SetSendTelephoneEventPayloadType() failed to register send"
- "payload type");
+ LOG(LS_ERROR) << "SetSendTelephoneEventPayloadType() failed to register "
+ "send payload type";
return -1;
}
}
@@ -1415,8 +1354,7 @@
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::SetLocalSSRC()");
if (channel_state_.Get().sending) {
- _engineStatisticsPtr->SetLastError(VE_ALREADY_SENDING, kTraceError,
- "SetLocalSSRC() already sending");
+ LOG(LS_ERROR) << "SetLocalSSRC() already sending";
return -1;
}
_rtpRtcpModule->SetSSRC(ssrc);
@@ -1517,9 +1455,7 @@
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::SetRTCP_CNAME()");
if (_rtpRtcpModule->SetCNAME(cName) != 0) {
- _engineStatisticsPtr->SetLastError(
- VE_RTP_RTCP_MODULE_ERROR, kTraceError,
- "SetRTCP_CNAME() failed to set RTCP CNAME");
+ LOG(LS_ERROR) << "SetRTCP_CNAME() failed to set RTCP CNAME";
return -1;
}
return 0;
@@ -1528,9 +1464,7 @@
int Channel::GetRemoteRTCPReportBlocks(
std::vector<ReportBlock>* report_blocks) {
if (report_blocks == NULL) {
- _engineStatisticsPtr->SetLastError(
- VE_INVALID_ARGUMENT, kTraceError,
- "GetRemoteRTCPReportBlock()s invalid report_blocks.");
+ LOG(LS_ERROR) << "GetRemoteRTCPReportBlock()s invalid report_blocks.";
return -1;
}
@@ -1788,15 +1722,11 @@
"Channel::SetMinimumPlayoutDelay()");
if ((delayMs < kVoiceEngineMinMinPlayoutDelayMs) ||
(delayMs > kVoiceEngineMaxMinPlayoutDelayMs)) {
- _engineStatisticsPtr->SetLastError(
- VE_INVALID_ARGUMENT, kTraceError,
- "SetMinimumPlayoutDelay() invalid min delay");
+ LOG(LS_ERROR) << "SetMinimumPlayoutDelay() invalid min delay";
return -1;
}
if (audio_coding_->SetMinimumPlayoutDelay(delayMs) != 0) {
- _engineStatisticsPtr->SetLastError(
- VE_AUDIO_CODING_MODULE_ERROR, kTraceError,
- "SetMinimumPlayoutDelay() failed to set min playout delay");
+ LOG(LS_ERROR) << "SetMinimumPlayoutDelay() failed to set min playout delay";
return -1;
}
return 0;
@@ -1809,9 +1739,7 @@
playout_timestamp_rtp = playout_timestamp_rtp_;
}
if (playout_timestamp_rtp == 0) {
- _engineStatisticsPtr->SetLastError(
- VE_CANNOT_RETRIEVE_VALUE, kTraceStateInfo,
- "GetPlayoutTimestamp() failed to retrieve timestamp");
+ LOG(LS_ERROR) << "GetPlayoutTimestamp() failed to retrieve timestamp";
return -1;
}
timestamp = playout_timestamp_rtp;
@@ -1839,9 +1767,6 @@
WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::UpdatePlayoutTimestamp() failed to read playout"
" delay from the ADM");
- _engineStatisticsPtr->SetLastError(
- VE_CANNOT_RETRIEVE_VALUE, kTraceError,
- "UpdatePlayoutTimestamp() failed to retrieve playout delay");
return;
}
diff --git a/voice_engine/channel.h b/voice_engine/channel.h
index 8c16365..696dd70 100644
--- a/voice_engine/channel.h
+++ b/voice_engine/channel.h
@@ -90,7 +90,6 @@
class RtcEventLogProxy;
class RtcpRttStatsProxy;
class RtpPacketSenderProxy;
-class Statistics;
class TransportFeedbackProxy;
class TransportSequenceNumberProxy;
class VoERtcpObserver;
@@ -157,10 +156,8 @@
const VoEBase::ChannelConfig& config);
int32_t Init();
void Terminate();
- int32_t SetEngineInformation(Statistics& engineStatistics,
- ProcessThread& moduleProcessThread,
+ int32_t SetEngineInformation(ProcessThread& moduleProcessThread,
AudioDeviceModule& audioDeviceModule,
- rtc::CriticalSection* callbackCritSect,
rtc::TaskQueue* encoder_queue);
void SetSink(std::unique_ptr<AudioSinkInterface> sink);
@@ -197,8 +194,7 @@
int max_frame_length_ms);
// Network
- int32_t RegisterExternalTransport(Transport* transport);
- int32_t DeRegisterExternalTransport();
+ void RegisterTransport(Transport* transport);
// TODO(nisse, solenberg): Delete when VoENetwork is deleted.
int32_t ReceivedRTCPPacket(const uint8_t* data, size_t length);
void OnRtpPacket(const RtpPacketReceived& packet);
@@ -286,10 +282,6 @@
int32_t ChannelId() const { return _channelId; }
bool Playing() const { return channel_state_.Get().playing; }
bool Sending() const { return channel_state_.Get().sending; }
- bool ExternalTransport() const {
- rtc::CritScope cs(&_callbackCritSect);
- return _externalTransport;
- }
RtpRtcp* RtpRtcpModulePtr() const { return _rtpRtcpModule.get(); }
int8_t OutputEnergyLevel() const { return _outputAudioLevel.Level(); }
@@ -395,7 +387,6 @@
acm2::RentACodec rent_a_codec_;
std::unique_ptr<AudioSinkInterface> audio_sink_;
AudioLevel _outputAudioLevel;
- bool _externalTransport;
// Downsamples to the codec rate if necessary.
PushResampler<int16_t> input_resampler_;
uint32_t _timeStamp RTC_ACCESS_ON(encoder_queue_);
@@ -420,10 +411,8 @@
int64_t capture_start_ntp_time_ms_ RTC_GUARDED_BY(ts_stats_lock_);
// uses
- Statistics* _engineStatisticsPtr;
ProcessThread* _moduleProcessThreadPtr;
AudioDeviceModule* _audioDeviceModulePtr;
- rtc::CriticalSection* _callbackCritSectPtr; // owned by base
Transport* _transportPtr; // WebRtc socket or external transport
RmsLevel rms_level_ RTC_ACCESS_ON(encoder_queue_);
bool input_mute_ RTC_GUARDED_BY(volume_settings_critsect_);
diff --git a/voice_engine/channel_proxy.cc b/voice_engine/channel_proxy.cc
index 15db60d..bea4c06 100644
--- a/voice_engine/channel_proxy.cc
+++ b/voice_engine/channel_proxy.cc
@@ -213,15 +213,9 @@
channel()->SetInputMute(muted);
}
-void ChannelProxy::RegisterExternalTransport(Transport* transport) {
+void ChannelProxy::RegisterTransport(Transport* transport) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
- int error = channel()->RegisterExternalTransport(transport);
- RTC_DCHECK_EQ(0, error);
-}
-
-void ChannelProxy::DeRegisterExternalTransport() {
- RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
- channel()->DeRegisterExternalTransport();
+ channel()->RegisterTransport(transport);
}
void ChannelProxy::OnRtpPacket(const RtpPacketReceived& packet) {
diff --git a/voice_engine/channel_proxy.h b/voice_engine/channel_proxy.h
index cb292ec..8c913fa 100644
--- a/voice_engine/channel_proxy.h
+++ b/voice_engine/channel_proxy.h
@@ -94,8 +94,7 @@
virtual void SetReceiveCodecs(const std::map<int, SdpAudioFormat>& codecs);
virtual void SetSink(std::unique_ptr<AudioSinkInterface> sink);
virtual void SetInputMute(bool muted);
- virtual void RegisterExternalTransport(Transport* transport);
- virtual void DeRegisterExternalTransport();
+ virtual void RegisterTransport(Transport* transport);
// Implements RtpPacketSinkInterface
void OnRtpPacket(const RtpPacketReceived& packet) override;
diff --git a/voice_engine/shared_data.cc b/voice_engine/shared_data.cc
index 48c8b0f..ac830c7 100644
--- a/voice_engine/shared_data.cc
+++ b/voice_engine/shared_data.cc
@@ -24,7 +24,6 @@
SharedData::SharedData()
: _instanceId(++_gInstanceCounter),
_channelManager(_gInstanceCounter),
- _engineStatistics(_gInstanceCounter),
_audioDevicePtr(NULL),
_moduleProcessThreadPtr(ProcessThread::Create("VoiceProcessThread")),
encoder_queue_("AudioEncoderQueue") {
@@ -84,20 +83,6 @@
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 webrtc
diff --git a/voice_engine/shared_data.h b/voice_engine/shared_data.h
index 336aab2..d313c24 100644
--- a/voice_engine/shared_data.h
+++ b/voice_engine/shared_data.h
@@ -22,7 +22,6 @@
#include "rtc_base/thread_annotations.h"
#include "rtc_base/thread_checker.h"
#include "voice_engine/channel_manager.h"
-#include "voice_engine/statistics.h"
#include "voice_engine/voice_engine_defines.h"
class ProcessThread;
@@ -37,7 +36,6 @@
public:
// Public accessors.
uint32_t instance_id() const { return _instanceId; }
- Statistics& statistics() { return _engineStatistics; }
ChannelManager& channel_manager() { return _channelManager; }
AudioDeviceModule* audio_device() { return _audioDevicePtr.get(); }
void set_audio_device(
@@ -51,18 +49,11 @@
int NumOfSendingChannels();
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:
rtc::ThreadChecker construction_thread_;
const uint32_t _instanceId;
rtc::CriticalSection _apiCritPtr;
ChannelManager _channelManager;
- Statistics _engineStatistics;
rtc::scoped_refptr<AudioDeviceModule> _audioDevicePtr;
TransmitMixer* _transmitMixerPtr;
std::unique_ptr<ProcessThread> _moduleProcessThreadPtr;
diff --git a/voice_engine/statistics.cc b/voice_engine/statistics.cc
deleted file mode 100644
index cfa7e91..0000000
--- a/voice_engine/statistics.cc
+++ /dev/null
@@ -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
diff --git a/voice_engine/statistics.h b/voice_engine/statistics.h
deleted file mode 100644
index 4f705266..0000000
--- a/voice_engine/statistics.h
+++ /dev/null
@@ -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_
diff --git a/voice_engine/transmit_mixer.cc b/voice_engine/transmit_mixer.cc
index a90ad48..8fe1d25 100644
--- a/voice_engine/transmit_mixer.cc
+++ b/voice_engine/transmit_mixer.cc
@@ -20,7 +20,6 @@
#include "system_wrappers/include/trace.h"
#include "voice_engine/channel.h"
#include "voice_engine/channel_manager.h"
-#include "voice_engine/statistics.h"
#include "voice_engine/utility.h"
namespace webrtc {
diff --git a/voice_engine/transmit_mixer.h b/voice_engine/transmit_mixer.h
index f263595..a983c3f 100644
--- a/voice_engine/transmit_mixer.h
+++ b/voice_engine/transmit_mixer.h
@@ -36,7 +36,6 @@
class ChannelManager;
class MixedAudio;
-class Statistics;
class TransmitMixer {
public:
diff --git a/voice_engine/voe_base_impl.cc b/voice_engine/voe_base_impl.cc
index 30842c5..b4c2b7a 100644
--- a/voice_engine/voe_base_impl.cc
+++ b/voice_engine/voe_base_impl.cc
@@ -42,7 +42,6 @@
}
void VoEBaseImpl::OnErrorIsReported(const ErrorCode error) {
- rtc::CritScope cs(&callbackCritSect_);
if (error == AudioDeviceObserver::kRecordingError) {
LOG_F(LS_ERROR) << "VE_RUNTIME_REC_ERROR";
} else if (error == AudioDeviceObserver::kPlayoutError) {
@@ -51,7 +50,6 @@
}
void VoEBaseImpl::OnWarningIsReported(const WarningCode warning) {
- rtc::CritScope cs(&callbackCritSect_);
if (warning == AudioDeviceObserver::kRecordingWarning) {
LOG_F(LS_WARNING) << "VE_RUNTIME_REC_WARNING";
} else if (warning == AudioDeviceObserver::kPlayoutWarning) {
@@ -167,9 +165,6 @@
RTC_DCHECK(audio_processing);
rtc::CritScope cs(shared_->crit_sec());
WebRtcSpl_Init();
- if (shared_->statistics().Initialized()) {
- return 0;
- }
if (shared_->process_thread()) {
shared_->process_thread()->Start();
}
@@ -185,8 +180,7 @@
VoEId(shared_->instance_id(), -1),
AudioDeviceModule::kPlatformDefaultAudio));
if (shared_->audio_device() == nullptr) {
- shared_->SetLastError(VE_NO_MEMORY, kTraceCritical,
- "Init() failed to create the ADM");
+ LOG(LS_ERROR) << "Init() failed to create the ADM";
return -1;
}
#endif // WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE
@@ -211,55 +205,44 @@
// Register the AudioObserver implementation
if (shared_->audio_device()->RegisterEventObserver(this) != 0) {
- shared_->SetLastError(
- VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning,
- "Init() failed to register event observer for the ADM");
+ LOG(LS_ERROR) << "Init() failed to register event observer for the ADM";
}
// Register the AudioTransport implementation
if (shared_->audio_device()->RegisterAudioCallback(this) != 0) {
- shared_->SetLastError(
- VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning,
- "Init() failed to register audio callback for the ADM");
+ LOG(LS_ERROR) << "Init() failed to register audio callback for the ADM";
}
// ADM initialization
if (shared_->audio_device()->Init() != 0) {
- shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
- "Init() failed to initialize the ADM");
+ LOG(LS_ERROR) << "Init() failed to initialize the ADM";
return -1;
}
// Initialize the default speaker
if (shared_->audio_device()->SetPlayoutDevice(
WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE) != 0) {
- shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceInfo,
- "Init() failed to set the default output device");
+ LOG(LS_ERROR) << "Init() failed to set the default output device";
}
if (shared_->audio_device()->InitSpeaker() != 0) {
- shared_->SetLastError(VE_CANNOT_ACCESS_SPEAKER_VOL, kTraceInfo,
- "Init() failed to initialize the speaker");
+ LOG(LS_ERROR) << "Init() failed to initialize the speaker";
}
// Initialize the default microphone
if (shared_->audio_device()->SetRecordingDevice(
WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE) != 0) {
- shared_->SetLastError(VE_SOUNDCARD_ERROR, kTraceInfo,
- "Init() failed to set the default input device");
+ LOG(LS_ERROR) << "Init() failed to set the default input device";
}
if (shared_->audio_device()->InitMicrophone() != 0) {
- shared_->SetLastError(VE_CANNOT_ACCESS_MIC_VOL, kTraceInfo,
- "Init() failed to initialize the microphone");
+ LOG(LS_ERROR) << "Init() failed to initialize the microphone";
}
// Set number of channels
if (shared_->audio_device()->StereoPlayoutIsAvailable(&available) != 0) {
- shared_->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning,
- "Init() failed to query stereo playout mode");
+ LOG(LS_ERROR) << "Init() failed to query stereo playout mode";
}
if (shared_->audio_device()->SetStereoPlayout(available) != 0) {
- shared_->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning,
- "Init() failed to set mono/stereo playout mode");
+ LOG(LS_ERROR) << "Init() failed to set mono/stereo playout mode";
}
// TODO(andrew): These functions don't tell us whether stereo recording
@@ -271,14 +254,11 @@
// http://code.google.com/p/webrtc/issues/detail?id=204
shared_->audio_device()->StereoRecordingIsAvailable(&available);
if (shared_->audio_device()->SetStereoRecording(available) != 0) {
- shared_->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning,
- "Init() failed to set mono/stereo recording mode");
+ LOG(LS_ERROR) << "Init() failed to set mono/stereo recording mode";
}
shared_->set_audio_processing(audio_processing);
- // Set the error state for any failures in this block.
- shared_->SetLastError(VE_APM_ERROR);
// Configure AudioProcessing components.
// TODO(peah): Move this initialization to webrtcvoiceengine.cc.
if (audio_processing->high_pass_filter()->Enable(true) != 0) {
@@ -309,14 +289,12 @@
LOG_F(LS_ERROR) << "Failed to set agc state: " << kDefaultAgcState;
return -1;
}
- shared_->SetLastError(0); // Clear error state.
#ifdef WEBRTC_VOICE_ENGINE_AGC
bool agc_enabled =
agc->mode() == GainControl::kAdaptiveAnalog && agc->is_enabled();
if (shared_->audio_device()->SetAGC(agc_enabled) != 0) {
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
// https://code.google.com/p/webrtc/issues/detail?id=1464
}
@@ -327,7 +305,7 @@
else
decoder_factory_ = CreateBuiltinAudioDecoderFactory();
- return shared_->statistics().SetInitialized();
+ return 0;
}
int VoEBaseImpl::Terminate() {
@@ -341,11 +319,6 @@
int VoEBaseImpl::CreateChannel(const ChannelConfig& config) {
rtc::CritScope cs(shared_->crit_sec());
- if (!shared_->statistics().Initialized()) {
- shared_->SetLastError(VE_NOT_INITED, kTraceError);
- return -1;
- }
-
ChannelConfig config_copy(config);
config_copy.acm_config.decoder_factory = decoder_factory_;
voe::ChannelOwner channel_owner =
@@ -355,21 +328,16 @@
int VoEBaseImpl::InitializeChannel(voe::ChannelOwner* channel_owner) {
if (channel_owner->channel()->SetEngineInformation(
- shared_->statistics(),
*shared_->process_thread(), *shared_->audio_device(),
- &callbackCritSect_, shared_->encoder_queue()) != 0) {
- shared_->SetLastError(
- VE_CHANNEL_NOT_CREATED, kTraceError,
- "CreateChannel() failed to associate engine and channel."
- " Destroying channel.");
+ shared_->encoder_queue()) != 0) {
+ LOG(LS_ERROR) << "CreateChannel() failed to associate engine and channel."
+ " Destroying channel.";
shared_->channel_manager().DestroyChannel(
channel_owner->channel()->ChannelId());
return -1;
} else if (channel_owner->channel()->Init() != 0) {
- shared_->SetLastError(
- VE_CHANNEL_NOT_CREATED, kTraceError,
- "CreateChannel() failed to initialize channel. Destroying"
- " channel.");
+ LOG(LS_ERROR) << "CreateChannel() failed to initialize channel. Destroying"
+ " channel.";
shared_->channel_manager().DestroyChannel(
channel_owner->channel()->ChannelId());
return -1;
@@ -379,17 +347,11 @@
int VoEBaseImpl::DeleteChannel(int channel) {
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::Channel* channelPtr = ch.channel();
if (channelPtr == nullptr) {
- shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
- "DeleteChannel() failed to locate channel");
+ LOG(LS_ERROR) << "DeleteChannel() failed to locate channel";
return -1;
}
}
@@ -406,23 +368,17 @@
int VoEBaseImpl::StartPlayout(int channel) {
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::Channel* channelPtr = ch.channel();
if (channelPtr == nullptr) {
- shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
- "StartPlayout() failed to locate channel");
+ LOG(LS_ERROR) << "StartPlayout() failed to locate channel";
return -1;
}
if (channelPtr->Playing()) {
return 0;
}
if (StartPlayout() != 0) {
- shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
- "StartPlayout() failed to start playout");
+ LOG(LS_ERROR) << "StartPlayout() failed to start playout";
return -1;
}
return channelPtr->StartPlayout();
@@ -430,15 +386,10 @@
int VoEBaseImpl::StopPlayout(int channel) {
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::Channel* channelPtr = ch.channel();
if (channelPtr == nullptr) {
- shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
- "StopPlayout() failed to locate channel");
+ LOG(LS_ERROR) << "StopPlayout() failed to locate channel";
return -1;
}
if (channelPtr->StopPlayout() != 0) {
@@ -450,23 +401,17 @@
int VoEBaseImpl::StartSend(int channel) {
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::Channel* channelPtr = ch.channel();
if (channelPtr == nullptr) {
- shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
- "StartSend() failed to locate channel");
+ LOG(LS_ERROR) << "StartSend() failed to locate channel";
return -1;
}
if (channelPtr->Sending()) {
return 0;
}
if (StartSend() != 0) {
- shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
- "StartSend() failed to start recording");
+ LOG(LS_ERROR) << "StartSend() failed to start recording";
return -1;
}
return channelPtr->StartSend();
@@ -474,15 +419,10 @@
int VoEBaseImpl::StopSend(int channel) {
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::Channel* channelPtr = ch.channel();
if (channelPtr == nullptr) {
- shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
- "StopSend() failed to locate channel");
+ LOG(LS_ERROR) << "StopSend() failed to locate channel";
return -1;
}
channelPtr->StopSend();
@@ -507,8 +447,7 @@
// Stop audio-device playing if no channel is playing out
if (shared_->NumOfPlayingChannels() == 0) {
if (shared_->audio_device()->StopPlayout() != 0) {
- shared_->SetLastError(VE_CANNOT_STOP_PLAYOUT, kTraceError,
- "StopPlayout() failed to stop playout");
+ LOG(LS_ERROR) << "StopPlayout() failed to stop playout";
return -1;
}
}
@@ -536,8 +475,7 @@
if (shared_->NumOfSendingChannels() == 0) {
// Stop audio-device recording if no channel is recording
if (shared_->audio_device()->StopRecording() != 0) {
- shared_->SetLastError(VE_CANNOT_STOP_RECORDING, kTraceError,
- "StopSend() failed to stop recording");
+ LOG(LS_ERROR) << "StopSend() failed to stop recording";
return -1;
}
shared_->transmit_mixer()->StopSend();
@@ -559,34 +497,27 @@
if (shared_->audio_device()) {
if (shared_->audio_device()->StopPlayout() != 0) {
- shared_->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning,
- "TerminateInternal() failed to stop playout");
+ LOG(LS_ERROR) << "TerminateInternal() failed to stop playout";
}
if (shared_->audio_device()->StopRecording() != 0) {
- shared_->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning,
- "TerminateInternal() failed to stop recording");
+ LOG(LS_ERROR) << "TerminateInternal() failed to stop recording";
}
if (shared_->audio_device()->RegisterEventObserver(nullptr) != 0) {
- shared_->SetLastError(
- VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning,
- "TerminateInternal() failed to de-register event observer "
- "for the ADM");
+ LOG(LS_ERROR) << "TerminateInternal() failed to de-register event "
+ "observer for the ADM";
}
if (shared_->audio_device()->RegisterAudioCallback(nullptr) != 0) {
- shared_->SetLastError(
- VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning,
- "TerminateInternal() failed to de-register audio callback "
- "for the ADM");
+ LOG(LS_ERROR) << "TerminateInternal() failed to de-register audio "
+ "callback for the ADM";
}
if (shared_->audio_device()->Terminate() != 0) {
- shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
- "TerminateInternal() failed to terminate the ADM");
+ LOG(LS_ERROR) << "TerminateInternal() failed to terminate the ADM";
}
shared_->set_audio_device(nullptr);
}
shared_->set_audio_processing(nullptr);
- return shared_->statistics().SetUnInitialized();
+ return 0;
}
} // namespace webrtc
diff --git a/voice_engine/voe_base_impl.h b/voice_engine/voe_base_impl.h
index ef163d6..d03a199 100644
--- a/voice_engine/voe_base_impl.h
+++ b/voice_engine/voe_base_impl.h
@@ -104,7 +104,6 @@
// Initialize channel by setting Engine Information then initializing
// channel.
int InitializeChannel(voe::ChannelOwner* channel_owner);
- rtc::CriticalSection callbackCritSect_;
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
AudioFrame audioFrame_;
diff --git a/voice_engine/voe_base_unittest.cc b/voice_engine/voe_base_unittest.cc
index 3375878..ef42fba 100644
--- a/voice_engine/voe_base_unittest.cc
+++ b/voice_engine/voe_base_unittest.cc
@@ -41,11 +41,6 @@
EXPECT_EQ(0, base_->Init(&adm_, apm_.get()));
}
-TEST_F(VoEBaseTest, CreateChannelBeforeInitShouldFail) {
- int channelID = base_->CreateChannel();
- EXPECT_EQ(channelID, -1);
-}
-
TEST_F(VoEBaseTest, CreateChannelAfterInit) {
EXPECT_EQ(0, base_->Init(&adm_, apm_.get(), nullptr));
int channelID = base_->CreateChannel();
diff --git a/voice_engine/voice_engine_impl.cc b/voice_engine/voice_engine_impl.cc
index 000907e..681f00e 100644
--- a/voice_engine/voice_engine_impl.cc
+++ b/voice_engine/voice_engine_impl.cc
@@ -65,7 +65,6 @@
int channel_id) {
RTC_DCHECK(channel_id >= 0);
rtc::CritScope cs(crit_sec());
- RTC_DCHECK(statistics().Initialized());
return std::unique_ptr<voe::ChannelProxy>(
new voe::ChannelProxy(channel_manager().GetChannel(channel_id)));
}