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

Side by Side Diff: webrtc/call/rtc_event_log.cc

Issue 1748403002: Move RtcEventLog object from inside VoiceEngine to Call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: More fixes for bots. Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/call/rtc_event_log.h" 11 #include "webrtc/call/rtc_event_log.h"
12 12
13 #include <deque> 13 #include <deque>
14 #include <vector> 14 #include <vector>
15 15
16 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 #include "webrtc/base/criticalsection.h" 17 #include "webrtc/base/criticalsection.h"
18 #include "webrtc/base/thread_annotations.h" 18 #include "webrtc/base/thread_annotations.h"
19 #include "webrtc/base/thread_checker.h"
19 #include "webrtc/call.h" 20 #include "webrtc/call.h"
20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
21 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 22 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
23 #include "webrtc/system_wrappers/include/clock.h" 24 #include "webrtc/system_wrappers/include/clock.h"
24 #include "webrtc/system_wrappers/include/file_wrapper.h" 25 #include "webrtc/system_wrappers/include/file_wrapper.h"
25 26
26 #ifdef ENABLE_RTC_EVENT_LOG 27 #ifdef ENABLE_RTC_EVENT_LOG
27 // Files generated at build-time by the protobuf compiler. 28 // Files generated at build-time by the protobuf compiler.
28 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD 29 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
29 #include "external/webrtc/webrtc/call/rtc_event_log.pb.h" 30 #include "external/webrtc/webrtc/call/rtc_event_log.pb.h"
30 #else 31 #else
31 #include "webrtc/call/rtc_event_log.pb.h" 32 #include "webrtc/call/rtc_event_log.pb.h"
32 #endif 33 #endif
33 #endif 34 #endif
34 35
35 namespace webrtc { 36 namespace webrtc {
36 37
37 #ifndef ENABLE_RTC_EVENT_LOG 38 #ifndef ENABLE_RTC_EVENT_LOG
38 39
39 // No-op implementation if flag is not set. 40 // No-op implementation if flag is not set.
40 class RtcEventLogImpl final : public RtcEventLog { 41 class RtcEventLogImpl final : public RtcEventLog {
41 public: 42 public:
42 void SetBufferDuration(int64_t buffer_duration_us) override {} 43 void SetBufferDuration(int64_t buffer_duration_us) override {}
43 void StartLogging(const std::string& file_name, int duration_ms) override {} 44 void StartLogging(const std::string& file_name, int duration_ms) override {}
44 bool StartLogging(rtc::PlatformFile log_file) override { return false; } 45 bool StartLogging(rtc::PlatformFile log_file,
46 int64_t max_size_bytes) override {
47 return false;
48 }
45 void StopLogging(void) override {} 49 void StopLogging(void) override {}
46 void LogVideoReceiveStreamConfig( 50 void LogVideoReceiveStreamConfig(
47 const VideoReceiveStream::Config& config) override {} 51 const VideoReceiveStream::Config& config) override {}
48 void LogVideoSendStreamConfig( 52 void LogVideoSendStreamConfig(
49 const VideoSendStream::Config& config) override {} 53 const VideoSendStream::Config& config) override {}
50 void LogRtpHeader(PacketDirection direction, 54 void LogRtpHeader(PacketDirection direction,
51 MediaType media_type, 55 MediaType media_type,
52 const uint8_t* header, 56 const uint8_t* header,
53 size_t packet_length) override {} 57 size_t packet_length) override {}
54 void LogRtcpPacket(PacketDirection direction, 58 void LogRtcpPacket(PacketDirection direction,
55 MediaType media_type, 59 MediaType media_type,
56 const uint8_t* packet, 60 const uint8_t* packet,
57 size_t length) override {} 61 size_t length) override {}
58 void LogAudioPlayout(uint32_t ssrc) override {} 62 void LogAudioPlayout(uint32_t ssrc) override {}
59 void LogBwePacketLossEvent(int32_t bitrate, 63 void LogBwePacketLossEvent(int32_t bitrate,
60 uint8_t fraction_loss, 64 uint8_t fraction_loss,
61 int32_t total_packets) override {} 65 int32_t total_packets) override {}
62 }; 66 };
63 67
64 #else // ENABLE_RTC_EVENT_LOG is defined 68 #else // ENABLE_RTC_EVENT_LOG is defined
65 69
66 class RtcEventLogImpl final : public RtcEventLog { 70 class RtcEventLogImpl final : public RtcEventLog {
67 public: 71 public:
68 RtcEventLogImpl(); 72 RtcEventLogImpl();
73 ~RtcEventLogImpl() override;
69 74
70 void SetBufferDuration(int64_t buffer_duration_us) override; 75 void SetBufferDuration(int64_t buffer_duration_us) override;
71 void StartLogging(const std::string& file_name, int duration_ms) override; 76 void StartLogging(const std::string& file_name, int duration_ms) override;
72 bool StartLogging(rtc::PlatformFile log_file) override; 77 bool StartLogging(rtc::PlatformFile log_file,
78 int64_t max_size_bytes) override {
79 return StartLogging(log_file);
80 }
73 void StopLogging() override; 81 void StopLogging() override;
74 void LogVideoReceiveStreamConfig( 82 void LogVideoReceiveStreamConfig(
75 const VideoReceiveStream::Config& config) override; 83 const VideoReceiveStream::Config& config) override;
76 void LogVideoSendStreamConfig(const VideoSendStream::Config& config) override; 84 void LogVideoSendStreamConfig(const VideoSendStream::Config& config) override;
77 void LogRtpHeader(PacketDirection direction, 85 void LogRtpHeader(PacketDirection direction,
78 MediaType media_type, 86 MediaType media_type,
79 const uint8_t* header, 87 const uint8_t* header,
80 size_t packet_length) override; 88 size_t packet_length) override;
81 void LogRtcpPacket(PacketDirection direction, 89 void LogRtcpPacket(PacketDirection direction,
82 MediaType media_type, 90 MediaType media_type,
83 const uint8_t* packet, 91 const uint8_t* packet,
84 size_t length) override; 92 size_t length) override;
85 void LogAudioPlayout(uint32_t ssrc) override; 93 void LogAudioPlayout(uint32_t ssrc) override;
86 void LogBwePacketLossEvent(int32_t bitrate, 94 void LogBwePacketLossEvent(int32_t bitrate,
87 uint8_t fraction_loss, 95 uint8_t fraction_loss,
88 int32_t total_packets) override; 96 int32_t total_packets) override;
89 97
90 private: 98 private:
99 bool StartLogging(rtc::PlatformFile log_file);
91 // Starts logging. This function assumes the file_ has been opened succesfully 100 // Starts logging. This function assumes the file_ has been opened succesfully
92 // and that the start_time_us_ and _duration_us_ have been set. 101 // and that the start_time_us_ and _duration_us_ have been set.
93 void StartLoggingLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); 102 void StartLoggingLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_);
94 // Stops logging and clears the stored data and buffers. 103 // Stops logging and clears the stored data and buffers.
95 void StopLoggingLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); 104 void StopLoggingLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_);
96 // Adds a new event to the logfile if logging is active, or adds it to the 105 // Adds a new event to the logfile if logging is active, or adds it to the
97 // list of recent log events otherwise. 106 // list of recent log events otherwise.
98 void HandleEvent(rtclog::Event* event) EXCLUSIVE_LOCKS_REQUIRED(crit_); 107 void HandleEvent(rtclog::Event* event) EXCLUSIVE_LOCKS_REQUIRED(crit_);
99 // Writes the event to the file. Note that this will destroy the state of the 108 // Writes the event to the file. Note that this will destroy the state of the
100 // input argument. 109 // input argument.
101 void StoreToFile(rtclog::Event* event) EXCLUSIVE_LOCKS_REQUIRED(crit_); 110 void StoreToFile(rtclog::Event* event) EXCLUSIVE_LOCKS_REQUIRED(crit_);
102 // Adds the event to the list of recent events, and removes any events that 111 // Adds the event to the list of recent events, and removes any events that
103 // are too old and no longer fall in the time window. 112 // are too old and no longer fall in the time window.
104 void AddRecentEvent(const rtclog::Event& event) 113 void AddRecentEvent(const rtclog::Event& event)
105 EXCLUSIVE_LOCKS_REQUIRED(crit_); 114 EXCLUSIVE_LOCKS_REQUIRED(crit_);
106 115
116 rtc::ThreadChecker thread_checker_;
107 rtc::CriticalSection crit_; 117 rtc::CriticalSection crit_;
108 std::unique_ptr<FileWrapper> file_ GUARDED_BY(crit_) = 118 std::unique_ptr<FileWrapper> file_ GUARDED_BY(crit_) =
109 std::unique_ptr<FileWrapper>(FileWrapper::Create()); 119 std::unique_ptr<FileWrapper>(FileWrapper::Create());
110 rtc::PlatformFile platform_file_ GUARDED_BY(crit_) = 120 rtc::PlatformFile platform_file_ GUARDED_BY(crit_) =
111 rtc::kInvalidPlatformFileValue; 121 rtc::kInvalidPlatformFileValue;
112 rtclog::EventStream stream_ GUARDED_BY(crit_); 122 rtclog::EventStream stream_ GUARDED_BY(crit_);
113 std::deque<rtclog::Event> recent_log_events_ GUARDED_BY(crit_); 123 std::deque<rtclog::Event> recent_log_events_ GUARDED_BY(crit_);
114 std::vector<rtclog::Event> config_events_ GUARDED_BY(crit_); 124 std::vector<rtclog::Event> config_events_ GUARDED_BY(crit_);
115 125
116 // Microseconds to record log events, before starting the actual log. 126 // Microseconds to record log events, before starting the actual log.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 183
174 // RtcEventLogImpl member functions. 184 // RtcEventLogImpl member functions.
175 RtcEventLogImpl::RtcEventLogImpl() 185 RtcEventLogImpl::RtcEventLogImpl()
176 : file_(FileWrapper::Create()), 186 : file_(FileWrapper::Create()),
177 stream_(), 187 stream_(),
178 buffer_duration_us_(10000000), 188 buffer_duration_us_(10000000),
179 currently_logging_(false), 189 currently_logging_(false),
180 start_time_us_(0), 190 start_time_us_(0),
181 duration_us_(0), 191 duration_us_(0),
182 clock_(Clock::GetRealTimeClock()) { 192 clock_(Clock::GetRealTimeClock()) {
193 RTC_DCHECK(thread_checker_.CalledOnValidThread());
194 }
195
196 RtcEventLogImpl::~RtcEventLogImpl() {
197 RTC_DCHECK(thread_checker_.CalledOnValidThread());
183 } 198 }
184 199
185 void RtcEventLogImpl::SetBufferDuration(int64_t buffer_duration_us) { 200 void RtcEventLogImpl::SetBufferDuration(int64_t buffer_duration_us) {
186 rtc::CritScope lock(&crit_); 201 rtc::CritScope lock(&crit_);
187 buffer_duration_us_ = buffer_duration_us; 202 buffer_duration_us_ = buffer_duration_us;
188 } 203 }
189 204
190 void RtcEventLogImpl::StartLogging(const std::string& file_name, 205 void RtcEventLogImpl::StartLogging(const std::string& file_name,
191 int duration_ms) { 206 int duration_ms) {
192 rtc::CritScope lock(&crit_); 207 rtc::CritScope lock(&crit_);
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 } 529 }
515 530
516 #endif // ENABLE_RTC_EVENT_LOG 531 #endif // ENABLE_RTC_EVENT_LOG
517 532
518 // RtcEventLog member functions. 533 // RtcEventLog member functions.
519 std::unique_ptr<RtcEventLog> RtcEventLog::Create() { 534 std::unique_ptr<RtcEventLog> RtcEventLog::Create() {
520 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl()); 535 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl());
521 } 536 }
522 537
523 } // namespace webrtc 538 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698