Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(963)

Unified Diff: webrtc/logging/rtc_event_log/rtc_event_log.cc

Issue 3006233002: Modularize RtcEventLog
Patch Set: Backup Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/logging/rtc_event_log/rtc_event_log.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/logging/rtc_event_log/rtc_event_log.cc
diff --git a/webrtc/logging/rtc_event_log/rtc_event_log.cc b/webrtc/logging/rtc_event_log/rtc_event_log.cc
index ae2052cac7ca0dec0952ed0777aaafe1d9e5fe26..f7812a7d9fe435e87bf17be283eb7e5bc7578479 100644
--- a/webrtc/logging/rtc_event_log/rtc_event_log.cc
+++ b/webrtc/logging/rtc_event_log/rtc_event_log.cc
@@ -18,6 +18,7 @@
#include <utility>
#include <vector>
+#include "webrtc/logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.h"
#include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h"
#include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
@@ -96,7 +97,7 @@ class ResourceOwningTask final : public rtc::QueuedTask {
} // namespace
class RtcEventLogImpl final : public RtcEventLog {
- friend std::unique_ptr<RtcEventLog> RtcEventLog::Create();
+ friend std::unique_ptr<RtcEventLog> RtcEventLog::Create(EncodingType);
public:
~RtcEventLogImpl() override;
@@ -148,11 +149,12 @@ class RtcEventLogImpl final : public RtcEventLog {
ProbeFailureReason failure_reason) override;
private:
+ // Creation is done by RtcEventLog::Create.
+ explicit RtcEventLogImpl(std::unique_ptr<RtcEventLogEncoder> event_encoder);
+
void StartLoggingInternal(std::unique_ptr<FileWrapper> file,
int64_t max_size_bytes);
- RtcEventLogImpl(); // Creation is done by RtcEventLog::Create.
-
void StoreEvent(std::unique_ptr<rtclog::Event> event);
void LogProbeResult(int id,
rtclog::BweProbeResult::ResultType result,
@@ -191,6 +193,8 @@ class RtcEventLogImpl final : public RtcEventLog {
size_t max_size_bytes_ ACCESS_ON(task_queue_);
size_t written_bytes_ ACCESS_ON(task_queue_);
+ std::unique_ptr<RtcEventLogEncoder> event_encoder_ ACCESS_ON(task_queue_);
+
// Keep this last to ensure it destructs first, or else tasks living on the
// queue might access other members after they've been torn down.
rtc::TaskQueue task_queue_;
@@ -249,10 +253,12 @@ rtclog::BweProbeResult::ResultType ConvertProbeResultType(
std::atomic<int> RtcEventLogImpl::log_count_(0);
-RtcEventLogImpl::RtcEventLogImpl()
+RtcEventLogImpl::RtcEventLogImpl(
+ std::unique_ptr<RtcEventLogEncoder> event_encoder)
: file_(FileWrapper::Create()),
max_size_bytes_(std::numeric_limits<decltype(max_size_bytes_)>::max()),
written_bytes_(0),
+ event_encoder_(std::move(event_encoder)),
task_queue_("rtc_event_log") {}
RtcEventLogImpl::~RtcEventLogImpl() {
@@ -857,7 +863,7 @@ bool RtcEventLog::ParseRtcEventLog(const std::string& file_name,
#endif // ENABLE_RTC_EVENT_LOG
// RtcEventLog member functions.
-std::unique_ptr<RtcEventLog> RtcEventLog::Create() {
+std::unique_ptr<RtcEventLog> RtcEventLog::Create(EncodingType encoding_type) {
#ifdef ENABLE_RTC_EVENT_LOG
// TODO(eladalon): Known issue - there's a race over |log_count_| here.
constexpr int kMaxLogCount = 5;
@@ -866,9 +872,10 @@ std::unique_ptr<RtcEventLog> RtcEventLog::Create() {
LOG(LS_WARNING) << "Denied creation of additional WebRTC event logs. "
<< count - 1 << " logs open already.";
std::atomic_fetch_sub(&RtcEventLogImpl::log_count_, 1);
- return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl());
+ return CreateNull();
}
- return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl());
+ auto encoder = CreateEncoder(encoding_type);
+ return rtc::WrapUnique<RtcEventLog>(new RtcEventLogImpl(std::move(encoder)));
#else
return CreateNull();
#endif // ENABLE_RTC_EVENT_LOG
@@ -878,4 +885,15 @@ std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() {
return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl());
}
+std::unique_ptr<RtcEventLogEncoder> RtcEventLog::CreateEncoder(
+ EncodingType type) {
+ switch (type) {
+ case EncodingType::Legacy:
+ return rtc::MakeUnique<RtcEventLogEncoderLegacy>();
+ default:
+ LOG(LS_ERROR) << "Unknown RtcEventLog encoder type (" << int(type) << ")";
+ RTC_NOTREACHED();
+ }
+}
+
} // namespace webrtc
« no previous file with comments | « webrtc/logging/rtc_event_log/rtc_event_log.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698