Reland of "Move RtcEventLog object from inside VoiceEngine to Call.", "Fix to make the start/stop functions for the Rtc Eventlog non-virtual." and "Fix for RtcEventLog ObjC interface"
The breaking tests in Chromium have been temporarily disabled, they will be fixed and reenabled soon.
Original CLs: https://codereview.webrtc.org/1748403002/, https://codereview.webrtc.org/2107253002/ and https://codereview.webrtc.org/2106103003/.
TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org,tkchin@webrtc.org
BUG=webrtc:4741, webrtc:5603, chromium:609749
Review-Url: https://codereview.webrtc.org/2110113003
Cr-Commit-Position: refs/heads/master@{#13379}
diff --git a/webrtc/api/android/java/src/org/webrtc/PeerConnection.java b/webrtc/api/android/java/src/org/webrtc/PeerConnection.java
index 70813a6..965cea4 100644
--- a/webrtc/api/android/java/src/org/webrtc/PeerConnection.java
+++ b/webrtc/api/android/java/src/org/webrtc/PeerConnection.java
@@ -257,6 +257,23 @@
return nativeGetStats(observer, (track == null) ? 0 : track.nativeTrack);
}
+ // Starts recording an RTC event log. Ownership of the file is transfered to
+ // the native code. If an RTC event log is already being recorded, it will be
+ // stopped and a new one will start using the provided file. Logging will
+ // continue until the stopRtcEventLog function is called. The max_size_bytes
+ // argument is ignored, it is added for future use.
+ public boolean startRtcEventLog(
+ int file_descriptor, long max_size_bytes) {
+ return nativeStartRtcEventLog(
+ nativePeerConnection, file_descriptor, max_size_bytes);
+ }
+
+ // Stops recording an RTC event log. If no RTC event log is currently being
+ // recorded, this call will have no effect.
+ public void stopRtcEventLog() {
+ nativeStopRtcEventLog(nativePeerConnection);
+ }
+
// TODO(fischman): add support for DTMF-related methods once that API
// stabilizes.
public native SignalingState signalingState();
@@ -307,4 +324,10 @@
private native List<RtpSender> nativeGetSenders();
private native List<RtpReceiver> nativeGetReceivers();
+
+ private static native boolean nativeStartRtcEventLog(
+ long nativePeerConnection, int file_descriptor, long max_size_bytes);
+
+ private static native void nativeStopRtcEventLog(long nativePeerConnection);
+
}
diff --git a/webrtc/api/android/java/src/org/webrtc/PeerConnectionFactory.java b/webrtc/api/android/java/src/org/webrtc/PeerConnectionFactory.java
index 0c1ef3c..2edd56e 100644
--- a/webrtc/api/android/java/src/org/webrtc/PeerConnectionFactory.java
+++ b/webrtc/api/android/java/src/org/webrtc/PeerConnectionFactory.java
@@ -148,28 +148,6 @@
nativeStopAecDump(nativeFactory);
}
- // Starts recording an RTC event log. Ownership of the file is transfered to
- // the native code. If an RTC event log is already being recorded, it will be
- // stopped and a new one will start using the provided file.
- public boolean startRtcEventLog(int file_descriptor) {
- return startRtcEventLog(file_descriptor, -1);
- }
-
- // Same as above, but allows setting an upper limit to the size of the
- // generated logfile.
- public boolean startRtcEventLog(int file_descriptor,
- int filesize_limit_bytes) {
- return nativeStartRtcEventLog(nativeFactory,
- file_descriptor,
- filesize_limit_bytes);
- }
-
- // Stops recording an RTC event log. If no RTC event log is currently being
- // recorded, this call will have no effect.
- public void stopRtcEventLog() {
- nativeStopRtcEventLog(nativeFactory);
- }
-
@Deprecated
public void setOptions(Options options) {
nativeSetOptions(nativeFactory, options);
@@ -275,12 +253,6 @@
private static native void nativeStopAecDump(long nativeFactory);
- private static native boolean nativeStartRtcEventLog(long nativeFactory,
- int file_descriptor,
- int filesize_limit_bytes);
-
- private static native void nativeStopRtcEventLog(long nativeFactory);
-
@Deprecated
public native void nativeSetOptions(long nativeFactory, Options options);
diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc
index cc33aa8..be61472 100644
--- a/webrtc/api/peerconnection.cc
+++ b/webrtc/api/peerconnection.cc
@@ -31,10 +31,12 @@
#include "webrtc/api/videocapturertracksource.h"
#include "webrtc/api/videotrack.h"
#include "webrtc/base/arraysize.h"
+#include "webrtc/base/bind.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/stringencode.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/base/trace_event.h"
+#include "webrtc/call.h"
#include "webrtc/media/sctp/sctpdataengine.h"
#include "webrtc/pc/channelmanager.h"
#include "webrtc/system_wrappers/include/field_trial.h"
@@ -1263,6 +1265,18 @@
}
}
+bool PeerConnection::StartRtcEventLog(rtc::PlatformFile file,
+ int64_t max_size_bytes) {
+ return factory_->worker_thread()->Invoke<bool>(
+ RTC_FROM_HERE, rtc::Bind(&PeerConnection::StartRtcEventLog_w, this, file,
+ max_size_bytes));
+}
+
+void PeerConnection::StopRtcEventLog() {
+ factory_->worker_thread()->Invoke<void>(
+ RTC_FROM_HERE, rtc::Bind(&PeerConnection::StopRtcEventLog_w, this));
+}
+
const SessionDescriptionInterface* PeerConnection::local_description() const {
return session_->local_description();
}
@@ -2234,4 +2248,12 @@
return true;
}
+bool PeerConnection::StartRtcEventLog_w(rtc::PlatformFile file,
+ int64_t max_size_bytes) {
+ return media_controller_->call_w()->StartEventLog(file, max_size_bytes);
+}
+
+void PeerConnection::StopRtcEventLog_w() {
+ media_controller_->call_w()->StopEventLog();
+}
} // namespace webrtc
diff --git a/webrtc/api/peerconnection.h b/webrtc/api/peerconnection.h
index fc754b9..c4a9a60 100644
--- a/webrtc/api/peerconnection.h
+++ b/webrtc/api/peerconnection.h
@@ -136,6 +136,10 @@
void RegisterUMAObserver(UMAObserver* observer) override;
+ bool StartRtcEventLog(rtc::PlatformFile file,
+ int64_t max_size_bytes) override;
+ void StopRtcEventLog() override;
+
void Close() override;
// Virtual for unit tests.
@@ -360,6 +364,13 @@
// is applied.
bool ReconfigurePortAllocator_n(const RTCConfiguration& configuration);
+ // Starts recording an Rtc EventLog using the supplied platform file.
+ // This function should only be called from the worker thread.
+ bool StartRtcEventLog_w(rtc::PlatformFile file, int64_t max_size_bytes);
+ // Starts recording an Rtc EventLog using the supplied platform file.
+ // This function should only be called from the worker thread.
+ void StopRtcEventLog_w();
+
// Storing the factory as a scoped reference pointer ensures that the memory
// in the PeerConnectionFactoryImpl remains available as long as the
// PeerConnection is running. It is passed to PeerConnection as a raw pointer.
diff --git a/webrtc/api/peerconnectionfactory.cc b/webrtc/api/peerconnectionfactory.cc
index 745de3f..b79e7a2 100644
--- a/webrtc/api/peerconnectionfactory.cc
+++ b/webrtc/api/peerconnectionfactory.cc
@@ -220,17 +220,6 @@
channel_manager_->StopAecDump();
}
-bool PeerConnectionFactory::StartRtcEventLog(rtc::PlatformFile file,
- int64_t max_size_bytes) {
- RTC_DCHECK(signaling_thread_->IsCurrent());
- return channel_manager_->StartRtcEventLog(file, max_size_bytes);
-}
-
-void PeerConnectionFactory::StopRtcEventLog() {
- RTC_DCHECK(signaling_thread_->IsCurrent());
- channel_manager_->StopRtcEventLog();
-}
-
rtc::scoped_refptr<PeerConnectionInterface>
PeerConnectionFactory::CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& configuration_in,
diff --git a/webrtc/api/peerconnectionfactory.h b/webrtc/api/peerconnectionfactory.h
index d4bc0da..39a6402 100644
--- a/webrtc/api/peerconnectionfactory.h
+++ b/webrtc/api/peerconnectionfactory.h
@@ -80,12 +80,15 @@
bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) override;
void StopAecDump() override;
- bool StartRtcEventLog(rtc::PlatformFile file) override {
- return StartRtcEventLog(file, -1);
- }
+ // TODO(ivoc) Remove after Chrome is updated.
+ bool StartRtcEventLog(rtc::PlatformFile file) override { return false; }
+ // TODO(ivoc) Remove after Chrome is updated.
bool StartRtcEventLog(rtc::PlatformFile file,
- int64_t max_size_bytes) override;
- void StopRtcEventLog() override;
+ int64_t max_size_bytes) override {
+ return false;
+ }
+ // TODO(ivoc) Remove after Chrome is updated.
+ void StopRtcEventLog() override {}
virtual webrtc::MediaControllerInterface* CreateMediaController(
const cricket::MediaConfig& config) const;
diff --git a/webrtc/api/peerconnectionfactoryproxy.h b/webrtc/api/peerconnectionfactoryproxy.h
index aad97e8..227a685 100644
--- a/webrtc/api/peerconnectionfactoryproxy.h
+++ b/webrtc/api/peerconnectionfactoryproxy.h
@@ -70,6 +70,8 @@
CreateAudioTrack, const std::string&, AudioSourceInterface*)
PROXY_METHOD2(bool, StartAecDump, rtc::PlatformFile, int64_t)
PROXY_METHOD0(void, StopAecDump)
+ // TODO(ivoc): Remove the StartRtcEventLog and StopRtcEventLog functions as
+ // soon as they are removed from PeerConnectionFactoryInterface.
PROXY_METHOD1(bool, StartRtcEventLog, rtc::PlatformFile)
PROXY_METHOD2(bool, StartRtcEventLog, rtc::PlatformFile, int64_t)
PROXY_METHOD0(void, StopRtcEventLog)
diff --git a/webrtc/api/peerconnectioninterface.h b/webrtc/api/peerconnectioninterface.h
index e28a27e..39c4856 100644
--- a/webrtc/api/peerconnectioninterface.h
+++ b/webrtc/api/peerconnectioninterface.h
@@ -493,6 +493,21 @@
virtual IceConnectionState ice_connection_state() = 0;
virtual IceGatheringState ice_gathering_state() = 0;
+ // Starts RtcEventLog using existing file. Takes ownership of |file| and
+ // passes it on to Call, which will take the ownership. If the
+ // operation fails the file will be closed. The logging will stop
+ // automatically after 10 minutes have passed, or when the StopRtcEventLog
+ // function is called.
+ // TODO(ivoc): Make this pure virtual when Chrome is updated.
+ virtual bool StartRtcEventLog(rtc::PlatformFile file,
+ int64_t max_size_bytes) {
+ return false;
+ }
+
+ // Stops logging the RtcEventLog.
+ // TODO(ivoc): Make this pure virtual when Chrome is updated.
+ virtual void StopRtcEventLog() {}
+
// Terminates all media and closes the transport.
virtual void Close() = 0;
@@ -659,25 +674,19 @@
// Stops logging the AEC dump.
virtual void StopAecDump() = 0;
- // Starts RtcEventLog using existing file. Takes ownership of |file| and
- // passes it on to VoiceEngine, which will take the ownership. If the
- // operation fails the file will be closed. The logging will stop
- // automatically after 10 minutes have passed, or when the StopRtcEventLog
- // function is called. A maximum filesize in bytes can be set, the logging
- // will be stopped before exceeding this limit. If max_size_bytes is set to a
- // value <= 0, no limit will be used.
- // This function as well as the StopRtcEventLog don't really belong on this
- // interface, this is a temporary solution until we move the logging object
- // from inside voice engine to webrtc::Call, which will happen when the VoE
- // restructuring effort is further along.
- // TODO(ivoc): Move this into being:
- // PeerConnection => MediaController => webrtc::Call.
+ // This function is deprecated and will be removed when Chrome is updated to
+ // use the equivalent function on PeerConnectionInterface.
+ // TODO(ivoc) Remove after Chrome is updated.
virtual bool StartRtcEventLog(rtc::PlatformFile file,
int64_t max_size_bytes) = 0;
- // Deprecated, use the version above.
+ // This function is deprecated and will be removed when Chrome is updated to
+ // use the equivalent function on PeerConnectionInterface.
+ // TODO(ivoc) Remove after Chrome is updated.
virtual bool StartRtcEventLog(rtc::PlatformFile file) = 0;
- // Stops logging the RtcEventLog.
+ // This function is deprecated and will be removed when Chrome is updated to
+ // use the equivalent function on PeerConnectionInterface.
+ // TODO(ivoc) Remove after Chrome is updated.
virtual void StopRtcEventLog() = 0;
protected:
diff --git a/webrtc/api/peerconnectionproxy.h b/webrtc/api/peerconnectionproxy.h
index d35d5ba..37f2e89 100644
--- a/webrtc/api/peerconnectionproxy.h
+++ b/webrtc/api/peerconnectionproxy.h
@@ -74,6 +74,8 @@
PROXY_METHOD0(IceState, ice_state)
PROXY_METHOD0(IceConnectionState, ice_connection_state)
PROXY_METHOD0(IceGatheringState, ice_gathering_state)
+ PROXY_METHOD2(bool, StartRtcEventLog, rtc::PlatformFile, int64_t)
+ PROXY_METHOD0(void, StopRtcEventLog)
PROXY_METHOD0(void, Close)
END_SIGNALING_PROXY()
diff --git a/webrtc/audio/DEPS b/webrtc/audio/DEPS
index b9605bb..82c3165 100644
--- a/webrtc/audio/DEPS
+++ b/webrtc/audio/DEPS
@@ -9,3 +9,12 @@
"+webrtc/modules/rtp_rtcp",
"+webrtc/system_wrappers",
]
+
+specific_include_rules = {
+ "audio_receive_stream_unittest\.cc": [
+ "+webrtc/call/mock",
+ ],
+ "audio_send_stream_unittest\.cc": [
+ "+webrtc/call/mock",
+ ],
+}
diff --git a/webrtc/audio/audio_receive_stream.cc b/webrtc/audio/audio_receive_stream.cc
index a684003..0a2bc2b 100644
--- a/webrtc/audio/audio_receive_stream.cc
+++ b/webrtc/audio/audio_receive_stream.cc
@@ -81,7 +81,8 @@
AudioReceiveStream::AudioReceiveStream(
CongestionController* congestion_controller,
const webrtc::AudioReceiveStream::Config& config,
- const rtc::scoped_refptr<webrtc::AudioState>& audio_state)
+ const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
+ webrtc::RtcEventLog* event_log)
: config_(config),
audio_state_(audio_state),
rtp_header_parser_(RtpHeaderParser::Create()) {
@@ -93,6 +94,7 @@
VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine());
channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id);
+ channel_proxy_->SetRtcEventLog(event_log);
channel_proxy_->SetLocalSSRC(config.rtp.local_ssrc);
// TODO(solenberg): Config NACK history window (which is a packet count),
// using the actual packet size for the configured codec.
@@ -144,6 +146,7 @@
LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString();
channel_proxy_->DeRegisterExternalTransport();
channel_proxy_->ResetCongestionControlObjects();
+ channel_proxy_->SetRtcEventLog(nullptr);
if (remote_bitrate_estimator_) {
remote_bitrate_estimator_->RemoveStream(config_.rtp.remote_ssrc);
}
diff --git a/webrtc/audio/audio_receive_stream.h b/webrtc/audio/audio_receive_stream.h
index 284f98e..24924c9a 100644
--- a/webrtc/audio/audio_receive_stream.h
+++ b/webrtc/audio/audio_receive_stream.h
@@ -22,6 +22,7 @@
namespace webrtc {
class CongestionController;
class RemoteBitrateEstimator;
+class RtcEventLog;
namespace voe {
class ChannelProxy;
@@ -33,7 +34,8 @@
public:
AudioReceiveStream(CongestionController* congestion_controller,
const webrtc::AudioReceiveStream::Config& config,
- const rtc::scoped_refptr<webrtc::AudioState>& audio_state);
+ const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
+ webrtc::RtcEventLog* event_log);
~AudioReceiveStream() override;
// webrtc::AudioReceiveStream implementation.
diff --git a/webrtc/audio/audio_receive_stream_unittest.cc b/webrtc/audio/audio_receive_stream_unittest.cc
index aed1d1a..dd66cc6 100644
--- a/webrtc/audio/audio_receive_stream_unittest.cc
+++ b/webrtc/audio/audio_receive_stream_unittest.cc
@@ -15,6 +15,7 @@
#include "webrtc/audio/audio_receive_stream.h"
#include "webrtc/audio/conversion.h"
+#include "webrtc/call/mock/mock_rtc_event_log.h"
#include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h"
#include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller.h"
#include "webrtc/modules/congestion_controller/include/mock/mock_congestion_controller.h"
@@ -70,7 +71,8 @@
decoder_factory_(new rtc::RefCountedObject<MockAudioDecoderFactory>),
congestion_controller_(&simulated_clock_,
&bitrate_observer_,
- &remote_bitrate_observer_) {
+ &remote_bitrate_observer_,
+ &event_log_) {
using testing::Invoke;
EXPECT_CALL(voice_engine_,
@@ -109,6 +111,12 @@
.Times(1);
EXPECT_CALL(*channel_proxy_, GetAudioDecoderFactory())
.WillOnce(ReturnRef(decoder_factory_));
+ testing::Expectation expect_set =
+ EXPECT_CALL(*channel_proxy_, SetRtcEventLog(&event_log_))
+ .Times(1);
+ EXPECT_CALL(*channel_proxy_, SetRtcEventLog(testing::IsNull()))
+ .Times(1)
+ .After(expect_set);
return channel_proxy_;
}));
stream_config_.voe_channel_id = kChannelId;
@@ -130,6 +138,7 @@
MockRemoteBitrateEstimator* remote_bitrate_estimator() {
return &remote_bitrate_estimator_;
}
+ MockRtcEventLog* event_log() { return &event_log_; }
AudioReceiveStream::Config& config() { return stream_config_; }
rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; }
MockVoiceEngine& voice_engine() { return voice_engine_; }
@@ -171,6 +180,7 @@
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
MockCongestionController congestion_controller_;
MockRemoteBitrateEstimator remote_bitrate_estimator_;
+ MockRtcEventLog event_log_;
testing::StrictMock<MockVoiceEngine> voice_engine_;
rtc::scoped_refptr<AudioState> audio_state_;
AudioReceiveStream::Config stream_config_;
@@ -248,7 +258,8 @@
TEST(AudioReceiveStreamTest, ConstructDestruct) {
ConfigHelper helper;
internal::AudioReceiveStream recv_stream(
- helper.congestion_controller(), helper.config(), helper.audio_state());
+ helper.congestion_controller(), helper.config(), helper.audio_state(),
+ helper.event_log());
}
MATCHER_P(VerifyHeaderExtension, expected_extension, "") {
@@ -267,7 +278,8 @@
helper.config().rtp.transport_cc = true;
helper.SetupMockForBweFeedback(true);
internal::AudioReceiveStream recv_stream(
- helper.congestion_controller(), helper.config(), helper.audio_state());
+ helper.congestion_controller(), helper.config(), helper.audio_state(),
+ helper.event_log());
const int kTransportSequenceNumberValue = 1234;
std::vector<uint8_t> rtp_packet = CreateRtpHeaderWithOneByteExtension(
kTransportSequenceNumberId, kTransportSequenceNumberValue, 2);
@@ -295,7 +307,8 @@
helper.config().rtp.transport_cc = true;
helper.SetupMockForBweFeedback(true);
internal::AudioReceiveStream recv_stream(
- helper.congestion_controller(), helper.config(), helper.audio_state());
+ helper.congestion_controller(), helper.config(), helper.audio_state(),
+ helper.event_log());
std::vector<uint8_t> rtcp_packet = CreateRtcpSenderReport();
EXPECT_CALL(*helper.channel_proxy(),
@@ -307,7 +320,8 @@
TEST(AudioReceiveStreamTest, GetStats) {
ConfigHelper helper;
internal::AudioReceiveStream recv_stream(
- helper.congestion_controller(), helper.config(), helper.audio_state());
+ helper.congestion_controller(), helper.config(), helper.audio_state(),
+ helper.event_log());
helper.SetupMockForGetStats();
AudioReceiveStream::Stats stats = recv_stream.GetStats();
EXPECT_EQ(kRemoteSsrc, stats.remote_ssrc);
@@ -349,7 +363,8 @@
TEST(AudioReceiveStreamTest, SetGain) {
ConfigHelper helper;
internal::AudioReceiveStream recv_stream(
- helper.congestion_controller(), helper.config(), helper.audio_state());
+ helper.congestion_controller(), helper.config(), helper.audio_state(),
+ helper.event_log());
EXPECT_CALL(*helper.channel_proxy(),
SetChannelOutputVolumeScaling(FloatEq(0.765f)));
recv_stream.SetGain(0.765f);
diff --git a/webrtc/audio/audio_send_stream_unittest.cc b/webrtc/audio/audio_send_stream_unittest.cc
index b953554..ea70d30 100644
--- a/webrtc/audio/audio_send_stream_unittest.cc
+++ b/webrtc/audio/audio_send_stream_unittest.cc
@@ -17,6 +17,7 @@
#include "webrtc/audio/audio_state.h"
#include "webrtc/audio/conversion.h"
#include "webrtc/modules/congestion_controller/include/mock/mock_congestion_controller.h"
+#include "webrtc/call/mock/mock_rtc_event_log.h"
#include "webrtc/modules/congestion_controller/include/congestion_controller.h"
#include "webrtc/modules/pacing/paced_sender.h"
#include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitrate_estimator.h"
@@ -55,7 +56,8 @@
stream_config_(nullptr),
congestion_controller_(&simulated_clock_,
&bitrate_observer_,
- &remote_bitrate_observer_) {
+ &remote_bitrate_observer_,
+ &event_log_) {
using testing::Invoke;
using testing::StrEq;
@@ -167,6 +169,7 @@
testing::NiceMock<MockCongestionObserver> bitrate_observer_;
testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_;
CongestionController congestion_controller_;
+ MockRtcEventLog event_log_;
};
} // namespace
diff --git a/webrtc/call.h b/webrtc/call.h
index f89af93..ff20a1e 100644
--- a/webrtc/call.h
+++ b/webrtc/call.h
@@ -18,6 +18,7 @@
#include "webrtc/audio_send_stream.h"
#include "webrtc/audio_state.h"
#include "webrtc/base/networkroute.h"
+#include "webrtc/base/platform_file.h"
#include "webrtc/base/socket.h"
#include "webrtc/video_receive_stream.h"
#include "webrtc/video_send_stream.h"
@@ -147,6 +148,10 @@
virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
+ virtual bool StartEventLog(rtc::PlatformFile log_file,
+ int64_t max_size_bytes) = 0;
+ virtual void StopEventLog() = 0;
+
virtual ~Call() {}
};
diff --git a/webrtc/call/call.cc b/webrtc/call/call.cc
index a6a7978..cbf9da7 100644
--- a/webrtc/call/call.cc
+++ b/webrtc/call/call.cc
@@ -35,6 +35,7 @@
#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
#include "webrtc/modules/rtp_rtcp/source/byte_io.h"
#include "webrtc/modules/utility/include/process_thread.h"
+#include "webrtc/system_wrappers/include/clock.h"
#include "webrtc/system_wrappers/include/cpu_info.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/metrics.h"
@@ -107,6 +108,13 @@
void OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps,
uint32_t max_padding_bitrate_bps) override;
+ bool StartEventLog(rtc::PlatformFile log_file,
+ int64_t max_size_bytes) override {
+ return event_log_->StartLogging(log_file, max_size_bytes);
+ }
+
+ void StopEventLog() override { event_log_->StopLogging(); }
+
private:
DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet,
size_t length);
@@ -162,7 +170,7 @@
VideoSendStream::RtpStateMap suspended_video_send_ssrcs_;
- RtcEventLog* event_log_ = nullptr;
+ std::unique_ptr<webrtc::RtcEventLog> event_log_;
// The following members are only accessed (exclusively) from one thread and
// from the destructor, and therefore doesn't need any explicit
@@ -210,6 +218,7 @@
video_network_state_(kNetworkUp),
receive_crit_(RWLockWrapper::CreateRWLock()),
send_crit_(RWLockWrapper::CreateRWLock()),
+ event_log_(RtcEventLog::Create(webrtc::Clock::GetRealTimeClock())),
received_video_bytes_(0),
received_audio_bytes_(0),
received_rtcp_bytes_(0),
@@ -221,7 +230,8 @@
min_allocated_send_bitrate_bps_(0),
num_bitrate_updates_(0),
remb_(clock_),
- congestion_controller_(new CongestionController(clock_, this, &remb_)),
+ congestion_controller_(
+ new CongestionController(clock_, this, &remb_, event_log_.get())),
video_send_delay_stats_(new SendDelayStats(clock_)) {
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
@@ -231,10 +241,6 @@
RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps,
config.bitrate_config.start_bitrate_bps);
}
- if (config.audio_state.get()) {
- ScopedVoEInterface<VoECodec> voe_codec(voice_engine());
- event_log_ = voe_codec->GetEventLog();
- }
Trace::CreateTrace();
call_stats_->RegisterStatsObserver(congestion_controller_.get());
@@ -243,7 +249,6 @@
config_.bitrate_config.min_bitrate_bps,
config_.bitrate_config.start_bitrate_bps,
config_.bitrate_config.max_bitrate_bps);
- congestion_controller_->GetBitrateController()->SetEventLog(event_log_);
module_process_thread_->Start();
module_process_thread_->RegisterModule(call_stats_.get());
@@ -371,8 +376,9 @@
const webrtc::AudioReceiveStream::Config& config) {
TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
- AudioReceiveStream* receive_stream = new AudioReceiveStream(
- congestion_controller_.get(), config, config_.audio_state);
+ AudioReceiveStream* receive_stream =
+ new AudioReceiveStream(congestion_controller_.get(), config,
+ config_.audio_state, event_log_.get());
{
WriteLockScoped write_lock(*receive_crit_);
RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) ==
@@ -421,8 +427,8 @@
VideoSendStream* send_stream = new VideoSendStream(
num_cpu_cores_, module_process_thread_.get(), call_stats_.get(),
congestion_controller_.get(), bitrate_allocator_.get(),
- video_send_delay_stats_.get(), &remb_, event_log_, config, encoder_config,
- suspended_video_send_ssrcs_);
+ video_send_delay_stats_.get(), &remb_, event_log_.get(), config,
+ encoder_config, suspended_video_send_ssrcs_);
{
WriteLockScoped write_lock(*send_crit_);
for (uint32_t ssrc : config.rtp.ssrcs) {
@@ -433,8 +439,7 @@
}
send_stream->SignalNetworkState(video_network_state_);
UpdateAggregateNetworkState();
- if (event_log_)
- event_log_->LogVideoSendStreamConfig(config);
+ event_log_->LogVideoSendStreamConfig(config);
return send_stream;
}
@@ -493,13 +498,11 @@
if (it != config.rtp.rtx.end())
video_receive_ssrcs_[it->second.ssrc] = receive_stream;
video_receive_streams_.insert(receive_stream);
-
ConfigureSync(config.sync_group);
}
receive_stream->SignalNetworkState(video_network_state_);
UpdateAggregateNetworkState();
- if (event_log_)
- event_log_->LogVideoReceiveStreamConfig(config);
+ event_log_->LogVideoReceiveStreamConfig(config);
return receive_stream;
}
@@ -827,7 +830,7 @@
auto status = it->second->DeliverRtp(packet, length, packet_time)
? DELIVERY_OK
: DELIVERY_PACKET_ERROR;
- if (status == DELIVERY_OK && event_log_)
+ if (status == DELIVERY_OK)
event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length);
return status;
}
@@ -839,7 +842,7 @@
auto status = it->second->DeliverRtp(packet, length, packet_time)
? DELIVERY_OK
: DELIVERY_PACKET_ERROR;
- if (status == DELIVERY_OK && event_log_)
+ if (status == DELIVERY_OK)
event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length);
return status;
}
diff --git a/webrtc/call/rtc_event_log.cc b/webrtc/call/rtc_event_log.cc
index 7ea1e16..840b210 100644
--- a/webrtc/call/rtc_event_log.cc
+++ b/webrtc/call/rtc_event_log.cc
@@ -38,9 +38,7 @@
namespace webrtc {
-#ifndef ENABLE_RTC_EVENT_LOG
-
-// No-op implementation if flag is not set.
+// No-op implementation is used if flag is not set, or in tests.
class RtcEventLogNullImpl final : public RtcEventLog {
public:
bool StartLogging(const std::string& file_name,
@@ -74,7 +72,7 @@
int32_t total_packets) override {}
};
-#else // ENABLE_RTC_EVENT_LOG is defined
+#ifdef ENABLE_RTC_EVENT_LOG
class RtcEventLogImpl final : public RtcEventLog {
public:
@@ -465,4 +463,8 @@
#endif // ENABLE_RTC_EVENT_LOG
}
+std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() {
+ return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl());
+}
+
} // namespace webrtc
diff --git a/webrtc/call/rtc_event_log.h b/webrtc/call/rtc_event_log.h
index bea57b0..7c72dd5 100644
--- a/webrtc/call/rtc_event_log.h
+++ b/webrtc/call/rtc_event_log.h
@@ -40,6 +40,9 @@
// Factory method to create an RtcEventLog object.
static std::unique_ptr<RtcEventLog> Create(const Clock* clock);
+ // Create an RtcEventLog object that does nothing.
+ static std::unique_ptr<RtcEventLog> CreateNull();
+
// Starts logging a maximum of max_size_bytes bytes to the specified file.
// If the file already exists it will be overwritten.
// If max_size_bytes <= 0, logging will be active until StopLogging is called.
diff --git a/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m b/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m
index 88431c6..43eb6f4 100644
--- a/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m
+++ b/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m
@@ -308,11 +308,13 @@
_isInitiator = NO;
_hasReceivedSdp = NO;
_messageQueue = [NSMutableArray array];
+#if defined(WEBRTC_IOS)
+ [_peerConnection stopRtcEventLog];
+#endif
_peerConnection = nil;
self.state = kARDAppClientStateDisconnected;
#if defined(WEBRTC_IOS)
RTCStopInternalCapture();
- [_factory stopRtcEventLog];
#endif
}
@@ -526,17 +528,6 @@
}
self.state = kARDAppClientStateConnected;
-#if defined(WEBRTC_IOS)
- // Start event log.
- if (kARDAppClientEnableRtcEventLog) {
- NSString *filePath = [self documentsFilePathForFileName:@"webrtc-rtceventlog"];
- if (![_factory startRtcEventLogWithFilePath:filePath
- maxSizeInBytes:kARDAppClientRtcEventLogMaxSizeInBytes]) {
- RTCLogError(@"Failed to start event logging.");
- }
- }
-#endif
-
// Create peer connection.
RTCMediaConstraints *constraints = [self defaultPeerConnectionConstraints];
RTCConfiguration *config = [[RTCConfiguration alloc] init];
@@ -562,6 +553,16 @@
// Check if we've received an offer.
[self drainMessageQueueIfReady];
}
+#if defined(WEBRTC_IOS)
+ // Start event log.
+ if (kARDAppClientEnableRtcEventLog) {
+ NSString *filePath = [self documentsFilePathForFileName:@"webrtc-rtceventlog"];
+ if (![_peerConnection startRtcEventLogWithFilePath:filePath
+ maxSizeInBytes:kARDAppClientRtcEventLogMaxSizeInBytes]) {
+ RTCLogError(@"Failed to start event logging.");
+ }
+ }
+#endif
}
// Processes the messages that we've received from the room server and the
diff --git a/webrtc/media/base/mediaengine.h b/webrtc/media/base/mediaengine.h
index 0e2b7ef..dd1f527 100644
--- a/webrtc/media/base/mediaengine.h
+++ b/webrtc/media/base/mediaengine.h
@@ -88,15 +88,6 @@
// Stops recording AEC dump.
virtual void StopAecDump() = 0;
-
- // Starts RtcEventLog using existing file. A maximum file size in bytes can be
- // specified. Logging is stopped just before the size limit is exceeded.
- // If max_size_bytes is set to a value <= 0, no limit will be used.
- virtual bool StartRtcEventLog(rtc::PlatformFile file,
- int64_t max_size_bytes) = 0;
-
- // Stops recording an RtcEventLog.
- virtual void StopRtcEventLog() = 0;
};
@@ -175,13 +166,6 @@
voice_.StopAecDump();
}
- virtual bool StartRtcEventLog(rtc::PlatformFile file,
- int64_t max_size_bytes) {
- return voice_.StartRtcEventLog(file, max_size_bytes);
- }
-
- virtual void StopRtcEventLog() { voice_.StopRtcEventLog(); }
-
protected:
VOICE voice_;
VIDEO video_;
diff --git a/webrtc/media/engine/fakewebrtccall.cc b/webrtc/media/engine/fakewebrtccall.cc
index 914a403..fdf7cf3 100644
--- a/webrtc/media/engine/fakewebrtccall.cc
+++ b/webrtc/media/engine/fakewebrtccall.cc
@@ -478,4 +478,11 @@
}
}
+bool FakeCall::StartEventLog(rtc::PlatformFile log_file,
+ int64_t max_size_bytes) {
+ return false;
+}
+
+void FakeCall::StopEventLog() {}
+
} // namespace cricket
diff --git a/webrtc/media/engine/fakewebrtccall.h b/webrtc/media/engine/fakewebrtccall.h
index f703b15..a2ac079 100644
--- a/webrtc/media/engine/fakewebrtccall.h
+++ b/webrtc/media/engine/fakewebrtccall.h
@@ -231,6 +231,10 @@
webrtc::NetworkState state) override;
void OnSentPacket(const rtc::SentPacket& sent_packet) override;
+ bool StartEventLog(rtc::PlatformFile log_file,
+ int64_t max_size_bytes) override;
+ void StopEventLog() override;
+
webrtc::Call::Config config_;
webrtc::NetworkState audio_network_state_;
webrtc::NetworkState video_network_state_;
diff --git a/webrtc/media/engine/fakewebrtcvoiceengine.h b/webrtc/media/engine/fakewebrtcvoiceengine.h
index 4e3ced6..e745f13 100644
--- a/webrtc/media/engine/fakewebrtcvoiceengine.h
+++ b/webrtc/media/engine/fakewebrtcvoiceengine.h
@@ -272,7 +272,6 @@
channels_[channel]->associate_send_channel = accociate_send_channel;
return 0;
}
- webrtc::RtcEventLog* GetEventLog() override { return nullptr; }
// webrtc::VoECodec
WEBRTC_STUB(NumOfCodecs, ());
diff --git a/webrtc/media/engine/webrtcvoiceengine.cc b/webrtc/media/engine/webrtcvoiceengine.cc
index 938daf6..469098a 100644
--- a/webrtc/media/engine/webrtcvoiceengine.cc
+++ b/webrtc/media/engine/webrtcvoiceengine.cc
@@ -28,7 +28,6 @@
#include "webrtc/base/stringencode.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/base/trace_event.h"
-#include "webrtc/call/rtc_event_log.h"
#include "webrtc/common.h"
#include "webrtc/media/base/audiosource.h"
#include "webrtc/media/base/mediaconstants.h"
@@ -1071,27 +1070,6 @@
}
}
-bool WebRtcVoiceEngine::StartRtcEventLog(rtc::PlatformFile file,
- int64_t max_size_bytes) {
- RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
- webrtc::RtcEventLog* event_log = voe_wrapper_->codec()->GetEventLog();
- if (event_log) {
- return event_log->StartLogging(file, max_size_bytes);
- }
- LOG_RTCERR0(StartRtcEventLog);
- return false;
-}
-
-void WebRtcVoiceEngine::StopRtcEventLog() {
- RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
- webrtc::RtcEventLog* event_log = voe_wrapper_->codec()->GetEventLog();
- if (event_log) {
- event_log->StopLogging();
- return;
- }
- LOG_RTCERR0(StopRtcEventLog);
-}
-
int WebRtcVoiceEngine::CreateVoEChannel() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
return voe_wrapper_->base()->CreateChannel(voe_config_);
diff --git a/webrtc/media/engine/webrtcvoiceengine.h b/webrtc/media/engine/webrtcvoiceengine.h
index d609534..64e0f5b 100644
--- a/webrtc/media/engine/webrtcvoiceengine.h
+++ b/webrtc/media/engine/webrtcvoiceengine.h
@@ -109,14 +109,6 @@
// Stops AEC dump.
void StopAecDump();
- // Starts recording an RtcEventLog using an existing file until the log file
- // reaches the maximum filesize or the StopRtcEventLog function is called.
- // If the value of max_size_bytes is <= 0, no limit is used.
- bool StartRtcEventLog(rtc::PlatformFile file, int64_t max_size_bytes);
-
- // Stops recording the RtcEventLog.
- void StopRtcEventLog();
-
private:
// Every option that is "set" will be applied. Every option not "set" will be
// ignored. This allows us to selectively turn on and off different options
diff --git a/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc b/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc
index c99bd5321..8a2464d 100644
--- a/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc
+++ b/webrtc/modules/bitrate_controller/bitrate_controller_impl.cc
@@ -79,20 +79,25 @@
BitrateController* BitrateController::CreateBitrateController(
Clock* clock,
- BitrateObserver* observer) {
- return new BitrateControllerImpl(clock, observer);
+ BitrateObserver* observer,
+ RtcEventLog* event_log) {
+ return new BitrateControllerImpl(clock, observer, event_log);
}
-BitrateController* BitrateController::CreateBitrateController(Clock* clock) {
- return new BitrateControllerImpl(clock, nullptr);
+BitrateController* BitrateController::CreateBitrateController(
+ Clock* clock,
+ RtcEventLog* event_log) {
+ return CreateBitrateController(clock, nullptr, event_log);
}
BitrateControllerImpl::BitrateControllerImpl(Clock* clock,
- BitrateObserver* observer)
+ BitrateObserver* observer,
+ RtcEventLog* event_log)
: clock_(clock),
observer_(observer),
last_bitrate_update_ms_(clock_->TimeInMilliseconds()),
- bandwidth_estimation_(),
+ event_log_(event_log),
+ bandwidth_estimation_(event_log),
reserved_bitrate_bps_(0),
last_bitrate_bps_(0),
last_fraction_loss_(0),
@@ -143,7 +148,7 @@
int max_bitrate_bps) {
{
rtc::CritScope cs(&critsect_);
- bandwidth_estimation_ = SendSideBandwidthEstimation();
+ bandwidth_estimation_ = SendSideBandwidthEstimation(event_log_);
bandwidth_estimation_.SetBitrates(bitrate_bps, min_bitrate_bps,
max_bitrate_bps);
}
@@ -158,11 +163,6 @@
MaybeTriggerOnNetworkChanged();
}
-void BitrateControllerImpl::SetEventLog(RtcEventLog* event_log) {
- rtc::CritScope cs(&critsect_);
- bandwidth_estimation_.SetEventLog(event_log);
-}
-
void BitrateControllerImpl::OnReceivedEstimatedBitrate(uint32_t bitrate) {
{
rtc::CritScope cs(&critsect_);
diff --git a/webrtc/modules/bitrate_controller/bitrate_controller_impl.h b/webrtc/modules/bitrate_controller/bitrate_controller_impl.h
index 91f0902..114e1a6 100644
--- a/webrtc/modules/bitrate_controller/bitrate_controller_impl.h
+++ b/webrtc/modules/bitrate_controller/bitrate_controller_impl.h
@@ -30,7 +30,9 @@
public:
// TODO(perkj): BitrateObserver has been deprecated and is not used in WebRTC.
// |observer| is left for project that is not yet updated.
- BitrateControllerImpl(Clock* clock, BitrateObserver* observer);
+ BitrateControllerImpl(Clock* clock,
+ BitrateObserver* observer,
+ RtcEventLog* event_log);
virtual ~BitrateControllerImpl() {}
bool AvailableBandwidth(uint32_t* bandwidth) const override;
@@ -54,8 +56,6 @@
void SetReservedBitrate(uint32_t reserved_bitrate_bps) override;
- void SetEventLog(RtcEventLog* event_log) override;
-
// Returns true if the parameters have changed since the last call.
bool GetNetworkParameters(uint32_t* bitrate,
uint8_t* fraction_loss,
@@ -86,6 +86,7 @@
Clock* const clock_;
BitrateObserver* const observer_;
int64_t last_bitrate_update_ms_;
+ RtcEventLog* const event_log_;
rtc::CriticalSection critsect_;
SendSideBandwidthEstimation bandwidth_estimation_ GUARDED_BY(critsect_);
diff --git a/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc b/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc
index 4f92a38..f2a14ea 100644
--- a/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc
+++ b/webrtc/modules/bitrate_controller/bitrate_controller_unittest.cc
@@ -13,6 +13,7 @@
#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/call/mock/mock_rtc_event_log.h"
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
#include "webrtc/modules/pacing/mock/mock_paced_sender.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
@@ -66,8 +67,8 @@
~BitrateControllerTest() {}
virtual void SetUp() {
- controller_ =
- BitrateController::CreateBitrateController(&clock_, &bitrate_observer_);
+ controller_ = BitrateController::CreateBitrateController(
+ &clock_, &bitrate_observer_, &event_log_);
controller_->SetStartBitrate(kStartBitrateBps);
EXPECT_EQ(kStartBitrateBps, bitrate_observer_.last_bitrate_);
controller_->SetMinMaxBitrate(kMinBitrateBps, kMaxBitrateBps);
@@ -91,6 +92,7 @@
TestBitrateObserver bitrate_observer_;
BitrateController* controller_;
RtcpBandwidthObserver* bandwidth_observer_;
+ webrtc::MockRtcEventLog event_log_;
};
TEST_F(BitrateControllerTest, DefaultMinMaxBitrate) {
@@ -107,6 +109,7 @@
TEST_F(BitrateControllerTest, OneBitrateObserverOneRtcpObserver) {
// First REMB applies immediately.
+ EXPECT_CALL(event_log_, LogBwePacketLossEvent(testing::Gt(0), 0, 0)).Times(8);
int64_t time_ms = 1001;
webrtc::ReportBlockList report_blocks;
report_blocks.push_back(CreateReportBlock(1, 2, 0, 1));
@@ -183,6 +186,7 @@
TEST_F(BitrateControllerTest, OneBitrateObserverTwoRtcpObservers) {
// REMBs during the first 2 seconds apply immediately.
+ EXPECT_CALL(event_log_, LogBwePacketLossEvent(testing::Gt(0), 0, 0)).Times(9);
int64_t time_ms = 1;
webrtc::ReportBlockList report_blocks;
report_blocks.push_back(CreateReportBlock(1, 2, 0, 1));
@@ -278,6 +282,13 @@
}
TEST_F(BitrateControllerTest, OneBitrateObserverMultipleReportBlocks) {
+ testing::Expectation first_calls =
+ EXPECT_CALL(event_log_, LogBwePacketLossEvent(testing::Gt(0), 0, 0))
+ .Times(7);
+ EXPECT_CALL(event_log_,
+ LogBwePacketLossEvent(testing::Gt(0), testing::Gt(0), 0))
+ .Times(2)
+ .After(first_calls);
uint32_t sequence_number[2] = {0, 0xFF00};
const int kStartBitrate = 200000;
const int kMinBitrate = 100000;
diff --git a/webrtc/modules/bitrate_controller/include/bitrate_controller.h b/webrtc/modules/bitrate_controller/include/bitrate_controller.h
index 4165f06..f06314c 100644
--- a/webrtc/modules/bitrate_controller/include/bitrate_controller.h
+++ b/webrtc/modules/bitrate_controller/include/bitrate_controller.h
@@ -55,8 +55,11 @@
// TODO(perkj): BitrateObserver has been deprecated and is not used in WebRTC.
// Remove this method once other other projects does not use it.
static BitrateController* CreateBitrateController(Clock* clock,
- BitrateObserver* observer);
- static BitrateController* CreateBitrateController(Clock* clock);
+ BitrateObserver* observer,
+ RtcEventLog* event_log);
+
+ static BitrateController* CreateBitrateController(Clock* clock,
+ RtcEventLog* event_log);
virtual ~BitrateController() {}
@@ -76,8 +79,6 @@
virtual void UpdateDelayBasedEstimate(uint32_t bitrate_bps) = 0;
- virtual void SetEventLog(RtcEventLog* event_log) = 0;
-
// Gets the available payload bandwidth in bits per second. Note that
// this bandwidth excludes packet headers.
virtual bool AvailableBandwidth(uint32_t* bandwidth) const = 0;
diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc
index a1b78a2..e47d491 100644
--- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc
+++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc
@@ -44,7 +44,7 @@
} // namespace
-SendSideBandwidthEstimation::SendSideBandwidthEstimation()
+SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log)
: lost_packets_since_last_loss_update_Q8_(0),
expected_packets_since_last_loss_update_(0),
bitrate_(0),
@@ -63,7 +63,9 @@
bitrate_at_2_seconds_kbps_(0),
uma_update_state_(kNoUpdate),
rampup_uma_stats_updated_(kNumUmaRampupMetrics, false),
- event_log_(nullptr) {}
+ event_log_(event_log) {
+ RTC_DCHECK(event_log);
+}
SendSideBandwidthEstimation::~SendSideBandwidthEstimation() {}
@@ -227,11 +229,9 @@
// rates).
bitrate_ += 1000;
- if (event_log_) {
- event_log_->LogBwePacketLossEvent(
- bitrate_, last_fraction_loss_,
- expected_packets_since_last_loss_update_);
- }
+ event_log_->LogBwePacketLossEvent(
+ bitrate_, last_fraction_loss_,
+ expected_packets_since_last_loss_update_);
} else if (last_fraction_loss_ <= 26) {
// Loss between 2% - 10%: Do nothing.
} else {
@@ -250,11 +250,9 @@
512.0);
has_decreased_since_last_fraction_loss_ = true;
}
- if (event_log_) {
- event_log_->LogBwePacketLossEvent(
- bitrate_, last_fraction_loss_,
- expected_packets_since_last_loss_update_);
- }
+ event_log_->LogBwePacketLossEvent(
+ bitrate_, last_fraction_loss_,
+ expected_packets_since_last_loss_update_);
}
}
bitrate_ = CapBitrateToThresholds(now_ms, bitrate_);
@@ -308,9 +306,4 @@
}
return bitrate;
}
-
-void SendSideBandwidthEstimation::SetEventLog(RtcEventLog* event_log) {
- event_log_ = event_log;
-}
-
} // namespace webrtc
diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h
index 402d22a..c97714f 100644
--- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h
+++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h
@@ -26,7 +26,8 @@
class SendSideBandwidthEstimation {
public:
- SendSideBandwidthEstimation();
+ SendSideBandwidthEstimation() = delete;
+ explicit SendSideBandwidthEstimation(RtcEventLog* event_log);
virtual ~SendSideBandwidthEstimation();
void CurrentEstimate(int* bitrate, uint8_t* loss, int64_t* rtt) const;
@@ -53,8 +54,6 @@
void SetMinMaxBitrate(int min_bitrate, int max_bitrate);
int GetMinBitrate() const;
- void SetEventLog(RtcEventLog* event_log);
-
private:
enum UmaState { kNoUpdate, kFirstDone, kDone };
diff --git a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc
index a6fda5b..64cb2fe 100644
--- a/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc
+++ b/webrtc/modules/bitrate_controller/send_side_bandwidth_estimation_unittest.cc
@@ -12,12 +12,14 @@
#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/call/mock/mock_rtc_event_log.h"
#include "webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h"
namespace webrtc {
void TestProbing(bool use_delay_based) {
- SendSideBandwidthEstimation bwe;
+ MockRtcEventLog event_log;
+ SendSideBandwidthEstimation bwe(&event_log);
bwe.SetMinMaxBitrate(100000, 1500000);
bwe.SetSendBitrate(200000);
@@ -62,7 +64,11 @@
}
TEST(SendSideBweTest, DoesntReapplyBitrateDecreaseWithoutFollowingRemb) {
- SendSideBandwidthEstimation bwe;
+ MockRtcEventLog event_log;
+ EXPECT_CALL(event_log,
+ LogBwePacketLossEvent(testing::Gt(0), testing::Gt(0), 0))
+ .Times(3);
+ SendSideBandwidthEstimation bwe(&event_log);
static const int kMinBitrateBps = 100000;
static const int kInitialBitrateBps = 1000000;
bwe.SetMinMaxBitrate(kMinBitrateBps, 1500000);
diff --git a/webrtc/modules/congestion_controller/DEPS b/webrtc/modules/congestion_controller/DEPS
index d72e34d..675f103 100644
--- a/webrtc/modules/congestion_controller/DEPS
+++ b/webrtc/modules/congestion_controller/DEPS
@@ -1,5 +1,6 @@
include_rules = [
"+webrtc/base",
+ "+webrtc/call/mock",
"+webrtc/system_wrappers",
"+webrtc/video",
]
diff --git a/webrtc/modules/congestion_controller/congestion_controller.cc b/webrtc/modules/congestion_controller/congestion_controller.cc
index c836f40..d42ad4a 100644
--- a/webrtc/modules/congestion_controller/congestion_controller.cc
+++ b/webrtc/modules/congestion_controller/congestion_controller.cc
@@ -153,37 +153,17 @@
CongestionController::CongestionController(
Clock* clock,
- BitrateObserver* bitrate_observer,
- RemoteBitrateObserver* remote_bitrate_observer)
- : clock_(clock),
- observer_(nullptr),
- packet_router_(new PacketRouter()),
- pacer_(new PacedSender(clock_, packet_router_.get())),
- remote_bitrate_estimator_(
- new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
- bitrate_controller_(
- BitrateController::CreateBitrateController(clock_, bitrate_observer)),
- remote_estimator_proxy_(clock_, packet_router_.get()),
- transport_feedback_adapter_(bitrate_controller_.get(), clock_),
- min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps),
- last_reported_bitrate_bps_(0),
- last_reported_fraction_loss_(0),
- last_reported_rtt_(0),
- network_state_(kNetworkUp) {
- Init();
-}
-
-CongestionController::CongestionController(
- Clock* clock,
Observer* observer,
- RemoteBitrateObserver* remote_bitrate_observer)
+ RemoteBitrateObserver* remote_bitrate_observer,
+ RtcEventLog* event_log)
: clock_(clock),
observer_(observer),
packet_router_(new PacketRouter()),
pacer_(new PacedSender(clock_, packet_router_.get())),
remote_bitrate_estimator_(
new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
- bitrate_controller_(BitrateController::CreateBitrateController(clock_)),
+ bitrate_controller_(
+ BitrateController::CreateBitrateController(clock_, event_log)),
remote_estimator_proxy_(clock_, packet_router_.get()),
transport_feedback_adapter_(bitrate_controller_.get(), clock_),
min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps),
@@ -198,6 +178,7 @@
Clock* clock,
Observer* observer,
RemoteBitrateObserver* remote_bitrate_observer,
+ RtcEventLog* event_log,
std::unique_ptr<PacketRouter> packet_router,
std::unique_ptr<PacedSender> pacer)
: clock_(clock),
@@ -208,7 +189,8 @@
new WrappingBitrateEstimator(remote_bitrate_observer, clock_)),
// Constructed last as this object calls the provided callback on
// construction.
- bitrate_controller_(BitrateController::CreateBitrateController(clock_)),
+ bitrate_controller_(
+ BitrateController::CreateBitrateController(clock_, event_log)),
remote_estimator_proxy_(clock_, packet_router_.get()),
transport_feedback_adapter_(bitrate_controller_.get(), clock_),
min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps),
diff --git a/webrtc/modules/congestion_controller/congestion_controller_unittest.cc b/webrtc/modules/congestion_controller/congestion_controller_unittest.cc
index 1a26582..aa4a5d3 100644
--- a/webrtc/modules/congestion_controller/congestion_controller_unittest.cc
+++ b/webrtc/modules/congestion_controller/congestion_controller_unittest.cc
@@ -10,6 +10,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/call/mock/mock_rtc_event_log.h"
#include "webrtc/modules/pacing/mock/mock_paced_sender.h"
#include "webrtc/modules/congestion_controller/include/congestion_controller.h"
#include "webrtc/modules/congestion_controller/include/mock/mock_congestion_controller.h"
@@ -34,9 +35,9 @@
pacer_ = new NiceMock<MockPacedSender>();
std::unique_ptr<PacedSender> pacer(pacer_); // Passes ownership.
std::unique_ptr<PacketRouter> packet_router(new PacketRouter());
- controller_.reset(
- new CongestionController(&clock_, &observer_, &remote_bitrate_observer_,
- std::move(packet_router), std::move(pacer)));
+ controller_.reset(new CongestionController(
+ &clock_, &observer_, &remote_bitrate_observer_, &event_log_,
+ std::move(packet_router), std::move(pacer)));
bandwidth_observer_.reset(
controller_->GetBitrateController()->CreateRtcpBandwidthObserver());
@@ -51,6 +52,7 @@
StrictMock<MockCongestionObserver> observer_;
NiceMock<MockPacedSender>* pacer_;
NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_;
+ MockRtcEventLog event_log_;
std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_;
std::unique_ptr<CongestionController> controller_;
const uint32_t kInitialBitrateBps = 60000;
diff --git a/webrtc/modules/congestion_controller/include/congestion_controller.h b/webrtc/modules/congestion_controller/include/congestion_controller.h
index 82906ef..a48f000 100644
--- a/webrtc/modules/congestion_controller/include/congestion_controller.h
+++ b/webrtc/modules/congestion_controller/include/congestion_controller.h
@@ -29,11 +29,11 @@
namespace webrtc {
class BitrateController;
-class BitrateObserver;
class Clock;
class ProcessThread;
class RemoteBitrateEstimator;
class RemoteBitrateObserver;
+class RtcEventLog;
class TransportFeedbackObserver;
class CongestionController : public CallStatsObserver, public Module {
@@ -52,17 +52,14 @@
protected:
virtual ~Observer() {}
};
- // Deprecated
- // TODO(perkj): Remove once no other clients use this ctor.
- CongestionController(Clock* clock,
- BitrateObserver* bitrate_observer,
- RemoteBitrateObserver* remote_bitrate_observer);
- CongestionController(Clock* clock,
- Observer* observer,
- RemoteBitrateObserver* remote_bitrate_observer);
CongestionController(Clock* clock,
Observer* observer,
RemoteBitrateObserver* remote_bitrate_observer,
+ RtcEventLog* event_log);
+ CongestionController(Clock* clock,
+ Observer* observer,
+ RemoteBitrateObserver* remote_bitrate_observer,
+ RtcEventLog* event_log,
std::unique_ptr<PacketRouter> packet_router,
std::unique_ptr<PacedSender> pacer);
virtual ~CongestionController();
diff --git a/webrtc/modules/congestion_controller/include/mock/mock_congestion_controller.h b/webrtc/modules/congestion_controller/include/mock/mock_congestion_controller.h
index 20955ea..f7d4aaa 100644
--- a/webrtc/modules/congestion_controller/include/mock/mock_congestion_controller.h
+++ b/webrtc/modules/congestion_controller/include/mock/mock_congestion_controller.h
@@ -31,8 +31,12 @@
public:
MockCongestionController(Clock* clock,
Observer* observer,
- RemoteBitrateObserver* remote_bitrate_observer)
- : CongestionController(clock, observer, remote_bitrate_observer) {}
+ RemoteBitrateObserver* remote_bitrate_observer,
+ RtcEventLog* event_log)
+ : CongestionController(clock,
+ observer,
+ remote_bitrate_observer,
+ event_log) {}
MOCK_METHOD3(SetBweBitrates,
void(int min_bitrate_bps,
int start_bitrate_bps,
diff --git a/webrtc/modules/remote_bitrate_estimator/DEPS b/webrtc/modules/remote_bitrate_estimator/DEPS
index 9a863d9..fc31fa7 100644
--- a/webrtc/modules/remote_bitrate_estimator/DEPS
+++ b/webrtc/modules/remote_bitrate_estimator/DEPS
@@ -7,4 +7,10 @@
"nada\.h": [
"+webrtc/voice_engine",
],
+ "remb\.h": [
+ "+webrtc/call/mock",
+ ],
+ "send_side\.h": [
+ "+webrtc/call/mock",
+ ],
}
diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.cc b/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.cc
index e2d3da9..1c878b9 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.cc
+++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.cc
@@ -25,7 +25,9 @@
RembBweSender::RembBweSender(int kbps, BitrateObserver* observer, Clock* clock)
: bitrate_controller_(
- BitrateController::CreateBitrateController(clock, observer)),
+ BitrateController::CreateBitrateController(clock,
+ observer,
+ &event_log_)),
feedback_observer_(bitrate_controller_->CreateRtcpBandwidthObserver()),
clock_(clock) {
assert(kbps >= kMinBitrateKbps);
diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.h b/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.h
index 3dc4f38..5840aef 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.h
+++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.h
@@ -16,6 +16,7 @@
#include <vector>
#include "webrtc/base/constructormagic.h"
+#include "webrtc/call/mock/mock_rtc_event_log.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe.h"
namespace webrtc {
@@ -45,6 +46,7 @@
private:
Clock* clock_;
+ MockRtcEventLog event_log_;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RembBweSender);
};
diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.cc b/webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.cc
index 7a31b54..6d79e09 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.cc
+++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.cc
@@ -22,7 +22,9 @@
FullBweSender::FullBweSender(int kbps, BitrateObserver* observer, Clock* clock)
: bitrate_controller_(
- BitrateController::CreateBitrateController(clock, observer)),
+ BitrateController::CreateBitrateController(clock,
+ observer,
+ &event_log_)),
rbe_(new RemoteBitrateEstimatorAbsSendTime(this)),
feedback_observer_(bitrate_controller_->CreateRtcpBandwidthObserver()),
clock_(clock),
diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.h b/webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.h
index ca7f6db..9eb0c1a 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.h
+++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.h
@@ -14,6 +14,7 @@
#include <memory>
#include <vector>
+#include "webrtc/call/mock/mock_rtc_event_log.h"
#include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe.h"
@@ -46,6 +47,7 @@
bool has_received_ack_;
uint16_t last_acked_seq_num_;
int64_t last_log_time_ms_;
+ MockRtcEventLog event_log_;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(FullBweSender);
};
diff --git a/webrtc/pc/channelmanager.cc b/webrtc/pc/channelmanager.cc
index fba1040..c2ce1cc 100644
--- a/webrtc/pc/channelmanager.cc
+++ b/webrtc/pc/channelmanager.cc
@@ -389,17 +389,4 @@
Bind(&MediaEngineInterface::StopAecDump, media_engine_.get()));
}
-bool ChannelManager::StartRtcEventLog(rtc::PlatformFile file,
- int64_t max_size_bytes) {
- return worker_thread_->Invoke<bool>(
- RTC_FROM_HERE, Bind(&MediaEngineInterface::StartRtcEventLog,
- media_engine_.get(), file, max_size_bytes));
-}
-
-void ChannelManager::StopRtcEventLog() {
- worker_thread_->Invoke<void>(
- RTC_FROM_HERE,
- Bind(&MediaEngineInterface::StopRtcEventLog, media_engine_.get()));
-}
-
} // namespace cricket
diff --git a/webrtc/pc/channelmanager.h b/webrtc/pc/channelmanager.h
index 34188e6..c6a67df 100644
--- a/webrtc/pc/channelmanager.h
+++ b/webrtc/pc/channelmanager.h
@@ -138,12 +138,6 @@
// Stops recording AEC dump.
void StopAecDump();
- // Starts RtcEventLog using existing file.
- bool StartRtcEventLog(rtc::PlatformFile file, int64_t max_size_bytes);
-
- // Stops logging RtcEventLog.
- void StopRtcEventLog();
-
private:
typedef std::vector<VoiceChannel*> VoiceChannels;
typedef std::vector<VideoChannel*> VideoChannels;
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCPeerConnection.mm b/webrtc/sdk/objc/Framework/Classes/RTCPeerConnection.mm
index 68d2387..99a0db3 100644
--- a/webrtc/sdk/objc/Framework/Classes/RTCPeerConnection.mm
+++ b/webrtc/sdk/objc/Framework/Classes/RTCPeerConnection.mm
@@ -207,6 +207,7 @@
NSMutableArray *_localStreams;
std::unique_ptr<webrtc::PeerConnectionDelegateAdapter> _observer;
rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection;
+ BOOL _hasStartedRtcEventLog;
}
@synthesize delegate = _delegate;
@@ -356,6 +357,31 @@
_peerConnection->SetRemoteDescription(observer, sdp.nativeDescription);
}
+- (BOOL)startRtcEventLogWithFilePath:(NSString *)filePath
+ maxSizeInBytes:(int64_t)maxSizeInBytes {
+ RTC_DCHECK(filePath.length);
+ RTC_DCHECK_GT(maxSizeInBytes, 0);
+ RTC_DCHECK(!_hasStartedRtcEventLog);
+ if (_hasStartedRtcEventLog) {
+ RTCLogError(@"Event logging already started.");
+ return NO;
+ }
+ int fd = open(filePath.UTF8String, O_WRONLY | O_CREAT | O_TRUNC,
+ S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ RTCLogError(@"Error opening file: %@. Error: %d", filePath, errno);
+ return NO;
+ }
+ _hasStartedRtcEventLog =
+ _peerConnection->StartRtcEventLog(fd, maxSizeInBytes);
+ return _hasStartedRtcEventLog;
+}
+
+- (void)stopRtcEventLog {
+ _peerConnection->StopRtcEventLog();
+ _hasStartedRtcEventLog = NO;
+}
+
- (RTCRtpSender *)senderWithKind:(NSString *)kind
streamId:(NSString *)streamId {
std::string nativeKind = [NSString stdStringForString:kind];
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCPeerConnectionFactory.mm b/webrtc/sdk/objc/Framework/Classes/RTCPeerConnectionFactory.mm
index a1e701b..9c9fd75 100644
--- a/webrtc/sdk/objc/Framework/Classes/RTCPeerConnectionFactory.mm
+++ b/webrtc/sdk/objc/Framework/Classes/RTCPeerConnectionFactory.mm
@@ -10,8 +10,6 @@
#import "RTCPeerConnectionFactory+Private.h"
-#include <memory>
-
#import "NSString+StdString.h"
#import "RTCAVFoundationVideoSource+Private.h"
#import "RTCAudioTrack+Private.h"
@@ -19,15 +17,11 @@
#import "RTCPeerConnection+Private.h"
#import "RTCVideoSource+Private.h"
#import "RTCVideoTrack+Private.h"
-#import "WebRTC/RTCLogging.h"
-
-#include "webrtc/base/checks.h"
@implementation RTCPeerConnectionFactory {
std::unique_ptr<rtc::Thread> _networkThread;
std::unique_ptr<rtc::Thread> _workerThread;
std::unique_ptr<rtc::Thread> _signalingThread;
- BOOL _hasStartedRtcEventLog;
}
@synthesize nativeFactory = _nativeFactory;
@@ -54,29 +48,6 @@
return self;
}
-- (BOOL)startRtcEventLogWithFilePath:(NSString *)filePath
- maxSizeInBytes:(int64_t)maxSizeInBytes {
- RTC_DCHECK(filePath.length);
- RTC_DCHECK_GT(maxSizeInBytes, 0);
- RTC_DCHECK(!_hasStartedRtcEventLog);
- if (_hasStartedRtcEventLog) {
- RTCLogError(@"Event logging already started.");
- return NO;
- }
- int fd = open(filePath.UTF8String, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
- if (fd < 0) {
- RTCLogError(@"Error opening file: %@. Error: %d", filePath, errno);
- return NO;
- }
- _hasStartedRtcEventLog = _nativeFactory->StartRtcEventLog(fd, maxSizeInBytes);
- return _hasStartedRtcEventLog;
-}
-
-- (void)stopRtcEventLog {
- _nativeFactory->StopRtcEventLog();
- _hasStartedRtcEventLog = NO;
-}
-
- (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints:
(nullable RTCMediaConstraints *)constraints {
return [[RTCAVFoundationVideoSource alloc] initWithFactory:self
diff --git a/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnection.h b/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnection.h
index 922ccfa..87d643d 100644
--- a/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnection.h
+++ b/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnection.h
@@ -183,6 +183,11 @@
completionHandler:
(nullable void (^)(NSError * _Nullable error))completionHandler;
+/** Start or stop recording an Rtc EventLog. */
+- (BOOL)startRtcEventLogWithFilePath:(NSString *)filePath
+ maxSizeInBytes:(int64_t)maxSizeInBytes;
+- (void)stopRtcEventLog;
+
@end
@interface RTCPeerConnection (Media)
diff --git a/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h b/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h
index f968ab7..f21c107 100644
--- a/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h
+++ b/webrtc/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h
@@ -53,11 +53,6 @@
delegate:
(nullable id<RTCPeerConnectionDelegate>)delegate;
-/** Temporary interface. Use at your own risk. See peerconnectioninterface.h for details. */
-- (BOOL)startRtcEventLogWithFilePath:(NSString *)filePath
- maxSizeInBytes:(int64_t)maxSizeInBytes;
-- (void)stopRtcEventLog;
-
@end
NS_ASSUME_NONNULL_END
diff --git a/webrtc/test/mock_voe_channel_proxy.h b/webrtc/test/mock_voe_channel_proxy.h
index dc2a961..fef8b7d 100644
--- a/webrtc/test/mock_voe_channel_proxy.h
+++ b/webrtc/test/mock_voe_channel_proxy.h
@@ -57,6 +57,7 @@
MOCK_CONST_METHOD0(GetAudioDecoderFactory,
const rtc::scoped_refptr<AudioDecoderFactory>&());
MOCK_METHOD1(SetChannelOutputVolumeScaling, void(float scaling));
+ MOCK_METHOD1(SetRtcEventLog, void(RtcEventLog* event_log));
};
} // namespace test
} // namespace webrtc
diff --git a/webrtc/test/mock_voice_engine.h b/webrtc/test/mock_voice_engine.h
index be72e0d..469028d 100644
--- a/webrtc/test/mock_voice_engine.h
+++ b/webrtc/test/mock_voice_engine.h
@@ -157,7 +157,6 @@
int(int channel, bool& enabled, VadModes& mode, bool& disabledDTX));
MOCK_METHOD2(SetOpusMaxPlaybackRate, int(int channel, int frequency_hz));
MOCK_METHOD2(SetOpusDtx, int(int channel, bool enable_dtx));
- MOCK_METHOD0(GetEventLog, RtcEventLog*());
// VoEExternalMedia
MOCK_METHOD3(RegisterExternalMediaProcessing,
diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc
index 943a045..8287668 100644
--- a/webrtc/voice_engine/channel.cc
+++ b/webrtc/voice_engine/channel.cc
@@ -19,6 +19,7 @@
#include "webrtc/base/logging.h"
#include "webrtc/base/thread_checker.h"
#include "webrtc/base/timeutils.h"
+#include "webrtc/call/rtc_event_log.h"
#include "webrtc/common.h"
#include "webrtc/config.h"
#include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
@@ -58,6 +59,87 @@
const int kTelephoneEventAttenuationdB = 10;
+class RtcEventLogProxy final : public webrtc::RtcEventLog {
+ public:
+ RtcEventLogProxy() : event_log_(nullptr) {}
+
+ bool StartLogging(const std::string& file_name,
+ int64_t max_size_bytes) override {
+ RTC_NOTREACHED();
+ return false;
+ }
+
+ bool StartLogging(rtc::PlatformFile log_file,
+ int64_t max_size_bytes) override {
+ RTC_NOTREACHED();
+ return false;
+ }
+
+ void StopLogging() override { RTC_NOTREACHED(); }
+
+ void LogVideoReceiveStreamConfig(
+ const webrtc::VideoReceiveStream::Config& config) override {
+ rtc::CritScope lock(&crit_);
+ if (event_log_) {
+ event_log_->LogVideoReceiveStreamConfig(config);
+ }
+ }
+
+ void LogVideoSendStreamConfig(
+ const webrtc::VideoSendStream::Config& config) override {
+ rtc::CritScope lock(&crit_);
+ if (event_log_) {
+ event_log_->LogVideoSendStreamConfig(config);
+ }
+ }
+
+ void LogRtpHeader(webrtc::PacketDirection direction,
+ webrtc::MediaType media_type,
+ const uint8_t* header,
+ size_t packet_length) override {
+ rtc::CritScope lock(&crit_);
+ if (event_log_) {
+ event_log_->LogRtpHeader(direction, media_type, header, packet_length);
+ }
+ }
+
+ void LogRtcpPacket(webrtc::PacketDirection direction,
+ webrtc::MediaType media_type,
+ const uint8_t* packet,
+ size_t length) override {
+ rtc::CritScope lock(&crit_);
+ if (event_log_) {
+ event_log_->LogRtcpPacket(direction, media_type, packet, length);
+ }
+ }
+
+ void LogAudioPlayout(uint32_t ssrc) override {
+ rtc::CritScope lock(&crit_);
+ if (event_log_) {
+ event_log_->LogAudioPlayout(ssrc);
+ }
+ }
+
+ void LogBwePacketLossEvent(int32_t bitrate,
+ uint8_t fraction_loss,
+ int32_t total_packets) override {
+ rtc::CritScope lock(&crit_);
+ if (event_log_) {
+ event_log_->LogBwePacketLossEvent(bitrate, fraction_loss, total_packets);
+ }
+ }
+
+ void SetEventLog(RtcEventLog* event_log) {
+ rtc::CritScope lock(&crit_);
+ event_log_ = event_log;
+ }
+
+ private:
+ rtc::CriticalSection crit_;
+ RtcEventLog* event_log_ GUARDED_BY(crit_);
+ RTC_DISALLOW_COPY_AND_ASSIGN(RtcEventLogProxy);
+};
+
class TransportFeedbackProxy : public TransportFeedbackObserver {
public:
TransportFeedbackProxy() : feedback_observer_(nullptr) {
@@ -480,11 +562,9 @@
MixerParticipant::AudioFrameInfo Channel::GetAudioFrameWithMuted(
int32_t id,
AudioFrame* audioFrame) {
- if (event_log_) {
- unsigned int ssrc;
- RTC_CHECK_EQ(GetLocalSSRC(ssrc), 0);
- event_log_->LogAudioPlayout(ssrc);
- }
+ unsigned int ssrc;
+ RTC_CHECK_EQ(GetLocalSSRC(ssrc), 0);
+ event_log_proxy_->LogAudioPlayout(ssrc);
// Get 10ms raw PCM data from the ACM (mixer limits output frequency)
bool muted;
if (audio_coding_->PlayoutData10Ms(audioFrame->sample_rate_hz_, audioFrame,
@@ -671,9 +751,8 @@
int32_t Channel::CreateChannel(Channel*& channel,
int32_t channelId,
uint32_t instanceId,
- RtcEventLog* const event_log,
const Config& config) {
- return CreateChannel(channel, channelId, instanceId, event_log, config,
+ return CreateChannel(channel, channelId, instanceId, config,
CreateBuiltinAudioDecoderFactory());
}
@@ -681,15 +760,13 @@
Channel*& channel,
int32_t channelId,
uint32_t instanceId,
- RtcEventLog* const event_log,
const Config& config,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId),
"Channel::CreateChannel(channelId=%d, instanceId=%d)", channelId,
instanceId);
- channel =
- new Channel(channelId, instanceId, event_log, config, decoder_factory);
+ channel = new Channel(channelId, instanceId, config, decoder_factory);
if (channel == NULL) {
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(instanceId, channelId),
"Channel::CreateChannel() unable to allocate memory for"
@@ -748,12 +825,11 @@
Channel::Channel(int32_t channelId,
uint32_t instanceId,
- RtcEventLog* const event_log,
const Config& config,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory)
: _instanceId(instanceId),
_channelId(channelId),
- event_log_(event_log),
+ event_log_proxy_(new RtcEventLogProxy()),
rtp_header_parser_(RtpHeaderParser::Create()),
rtp_payload_registry_(
new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))),
@@ -856,7 +932,7 @@
seq_num_allocator_proxy_.get();
configuration.transport_feedback_callback = feedback_observer_proxy_.get();
}
- configuration.event_log = event_log;
+ configuration.event_log = &(*event_log_proxy_);
_rtpRtcpModule.reset(RtpRtcp::CreateRtpRtcp(configuration));
_rtpRtcpModule->SetSendingMediaStatus(false);
@@ -3008,6 +3084,10 @@
}
}
+void Channel::SetRtcEventLog(RtcEventLog* event_log) {
+ event_log_proxy_->SetEventLog(event_log);
+}
+
int Channel::RegisterExternalMediaProcessing(ProcessingTypes type,
VoEMediaProcess& processObject) {
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId),
diff --git a/webrtc/voice_engine/channel.h b/webrtc/voice_engine/channel.h
index 9b6a2a1..68211a6 100644
--- a/webrtc/voice_engine/channel.h
+++ b/webrtc/voice_engine/channel.h
@@ -66,6 +66,7 @@
namespace voe {
class OutputMixer;
+class RtcEventLogProxy;
class RtpPacketSenderProxy;
class Statistics;
class StatisticsProxy;
@@ -173,18 +174,15 @@
static int32_t CreateChannel(Channel*& channel,
int32_t channelId,
uint32_t instanceId,
- RtcEventLog* const event_log,
const Config& config);
static int32_t CreateChannel(
Channel*& channel,
int32_t channelId,
uint32_t instanceId,
- RtcEventLog* const event_log,
const Config& config,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory);
Channel(int32_t channelId,
uint32_t instanceId,
- RtcEventLog* const event_log,
const Config& config,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory);
int32_t Init();
@@ -451,6 +449,9 @@
// Disassociate a send channel if it was associated.
void DisassociateSendChannel(int channel_id);
+ // Set a RtcEventLog logging object.
+ void SetRtcEventLog(RtcEventLog* event_log);
+
protected:
void OnIncomingFractionLoss(int fraction_lost);
@@ -486,7 +487,7 @@
ChannelState channel_state_;
- RtcEventLog* const event_log_;
+ std::unique_ptr<voe::RtcEventLogProxy> event_log_proxy_;
std::unique_ptr<RtpHeaderParser> rtp_header_parser_;
std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry_;
diff --git a/webrtc/voice_engine/channel_manager.cc b/webrtc/voice_engine/channel_manager.cc
index 47350b5..5f20b2e 100644
--- a/webrtc/voice_engine/channel_manager.cc
+++ b/webrtc/voice_engine/channel_manager.cc
@@ -47,10 +47,7 @@
: channel(channel), ref_count(1) {}
ChannelManager::ChannelManager(uint32_t instance_id, const Config& config)
- : instance_id_(instance_id),
- last_channel_id_(-1),
- config_(config),
- event_log_(RtcEventLog::Create(Clock::GetRealTimeClock())) {}
+ : instance_id_(instance_id), last_channel_id_(-1), config_(config) {}
ChannelOwner ChannelManager::CreateChannel() {
return CreateChannel(CreateBuiltinAudioDecoderFactory());
@@ -75,8 +72,8 @@
const Config& config,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) {
Channel* channel;
- Channel::CreateChannel(channel, ++last_channel_id_, instance_id_,
- event_log_.get(), config, decoder_factory);
+ Channel::CreateChannel(channel, ++last_channel_id_, instance_id_, config,
+ decoder_factory);
ChannelOwner channel_owner(channel);
rtc::CritScope crit(&lock_);
@@ -143,10 +140,6 @@
return channels_.size();
}
-RtcEventLog* ChannelManager::GetEventLog() const {
- return event_log_.get();
-}
-
ChannelManager::Iterator::Iterator(ChannelManager* channel_manager)
: iterator_pos_(0) {
channel_manager->GetAllChannels(&channels_);
diff --git a/webrtc/voice_engine/channel_manager.h b/webrtc/voice_engine/channel_manager.h
index 213a48f..c59ee5d 100644
--- a/webrtc/voice_engine/channel_manager.h
+++ b/webrtc/voice_engine/channel_manager.h
@@ -17,7 +17,6 @@
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/scoped_ref_ptr.h"
-#include "webrtc/call/rtc_event_log.h"
#include "webrtc/system_wrappers/include/atomic32.h"
#include "webrtc/typedefs.h"
@@ -119,9 +118,6 @@
size_t NumOfChannels() const;
- // Returns a pointer to the event log object stored within the ChannelManager.
- RtcEventLog* GetEventLog() const;
-
private:
// Create a channel given a configuration, |config|.
ChannelOwner CreateChannelInternal(
@@ -136,7 +132,6 @@
std::vector<ChannelOwner> channels_;
const Config& config_;
- std::unique_ptr<RtcEventLog> event_log_;
RTC_DISALLOW_COPY_AND_ASSIGN(ChannelManager);
};
diff --git a/webrtc/voice_engine/channel_proxy.cc b/webrtc/voice_engine/channel_proxy.cc
index f60728a..215d931 100644
--- a/webrtc/voice_engine/channel_proxy.cc
+++ b/webrtc/voice_engine/channel_proxy.cc
@@ -204,6 +204,11 @@
RTC_DCHECK_EQ(0, error);
}
+void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) {
+ RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ channel()->SetRtcEventLog(event_log);
+}
+
Channel* ChannelProxy::channel() const {
RTC_DCHECK(channel_owner_.channel());
return channel_owner_.channel();
diff --git a/webrtc/voice_engine/channel_proxy.h b/webrtc/voice_engine/channel_proxy.h
index 39eed67..0c26b00 100644
--- a/webrtc/voice_engine/channel_proxy.h
+++ b/webrtc/voice_engine/channel_proxy.h
@@ -24,6 +24,7 @@
class AudioSinkInterface;
class PacketRouter;
+class RtcEventLog;
class RtpPacketSender;
class Transport;
class TransportFeedbackObserver;
@@ -87,6 +88,8 @@
virtual void SetChannelOutputVolumeScaling(float scaling);
+ virtual void SetRtcEventLog(RtcEventLog* event_log);
+
private:
Channel* channel() const;
diff --git a/webrtc/voice_engine/include/voe_codec.h b/webrtc/voice_engine/include/voe_codec.h
index 6c4fb38..5d94ac2 100644
--- a/webrtc/voice_engine/include/voe_codec.h
+++ b/webrtc/voice_engine/include/voe_codec.h
@@ -35,7 +35,6 @@
namespace webrtc {
-class RtcEventLog;
class VoiceEngine;
class WEBRTC_DLLEXPORT VoECodec {
@@ -132,10 +131,6 @@
// success, and -1 if failed.
virtual int SetOpusDtx(int channel, bool enable_dtx) = 0;
- // Get a pointer to the event logging object associated with this Voice
- // Engine. This pointer will remain valid until VoiceEngine is destroyed.
- virtual RtcEventLog* GetEventLog() = 0;
-
protected:
VoECodec() {}
virtual ~VoECodec() {}
diff --git a/webrtc/voice_engine/test/auto_test/standard/codec_test.cc b/webrtc/voice_engine/test/auto_test/standard/codec_test.cc
index 3a3d830..5a500af 100644
--- a/webrtc/voice_engine/test/auto_test/standard/codec_test.cc
+++ b/webrtc/voice_engine/test/auto_test/standard/codec_test.cc
@@ -176,30 +176,6 @@
}
}
-#ifdef ENABLE_RTC_EVENT_LOG
-TEST_F(CodecTest, RtcEventLogIntegrationTest) {
- webrtc::RtcEventLog* event_log = voe_codec_->GetEventLog();
- ASSERT_TRUE(event_log);
-
- // Find the name of the current test, in order to use it as a temporary
- // filename.
- auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
- const std::string temp_filename = webrtc::test::OutputPath() +
- test_info->test_case_name() +
- test_info->name();
- // Create a log file.
- event_log->StartLogging(temp_filename, 1000);
- event_log->StopLogging();
-
- // Check if the file has been created.
- FILE* event_file = fopen(temp_filename.c_str(), "r");
- ASSERT_TRUE(event_file);
- fclose(event_file);
- // Remove the temporary file.
- remove(temp_filename.c_str());
-}
-#endif // ENABLE_RTC_EVENT_LOG
-
// TODO(xians, phoglund): Re-enable when issue 372 is resolved.
TEST_F(CodecTest, DISABLED_ManualVerifySendCodecsForAllPacketSizes) {
for (int i = 0; i < voe_codec_->NumOfCodecs(); ++i) {
diff --git a/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc b/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc
index d3d2a2d..674a05c 100644
--- a/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc
+++ b/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc
@@ -21,7 +21,6 @@
#include "gflags/gflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/format_macros.h"
-#include "webrtc/call/rtc_event_log.h"
#include "webrtc/engine_configurations.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/test/channel_transport/channel_transport.h"
@@ -448,7 +447,6 @@
printf("%i. Set bit rate (only take effect on codecs that allow the "
"change) \n", option_index++);
printf("%i. Toggle AECdump recording \n", option_index++);
- printf("%i. Record RtcEventLog file of 30 seconds \n", option_index++);
printf("Select action or %i to stop the call: ", option_index);
int option_selection;
@@ -795,9 +793,6 @@
printf("Debug recording named %s started\n", kDebugFileName);
}
debug_recording_started = !debug_recording_started;
- } else if (option_selection == option_index++) {
- const char* kDebugFileName = "eventlog.rel";
- codec->GetEventLog()->StartLogging(kDebugFileName, 30000);
} else {
break;
}
diff --git a/webrtc/voice_engine/voe_codec_impl.cc b/webrtc/voice_engine/voe_codec_impl.cc
index 5a16592..19891bc 100644
--- a/webrtc/voice_engine/voe_codec_impl.cc
+++ b/webrtc/voice_engine/voe_codec_impl.cc
@@ -376,10 +376,6 @@
return channelPtr->SetOpusDtx(enable_dtx);
}
-RtcEventLog* VoECodecImpl::GetEventLog() {
- return _shared->channel_manager().GetEventLog();
-}
-
#endif // WEBRTC_VOICE_ENGINE_CODEC_API
} // namespace webrtc
diff --git a/webrtc/voice_engine/voe_codec_impl.h b/webrtc/voice_engine/voe_codec_impl.h
index 5095f6e..5519232 100644
--- a/webrtc/voice_engine/voe_codec_impl.h
+++ b/webrtc/voice_engine/voe_codec_impl.h
@@ -58,8 +58,6 @@
int SetOpusDtx(int channel, bool enable_dtx) override;
- RtcEventLog* GetEventLog() override;
-
protected:
VoECodecImpl(voe::SharedData* shared);
~VoECodecImpl() override;