OLD | NEW |
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/logging/rtc_event_log/rtc_event_log.h" | 11 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
12 | 12 |
13 #include <limits> | 13 #include <limits> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/constructormagic.h" | 17 #include "webrtc/base/constructormagic.h" |
18 #include "webrtc/base/event.h" | 18 #include "webrtc/base/event.h" |
19 #include "webrtc/base/swap_queue.h" | 19 #include "webrtc/base/swap_queue.h" |
20 #include "webrtc/base/thread_checker.h" | 20 #include "webrtc/base/thread_checker.h" |
| 21 #include "webrtc/base/timeutils.h" |
21 #include "webrtc/call/call.h" | 22 #include "webrtc/call/call.h" |
22 #include "webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h" | 23 #include "webrtc/logging/rtc_event_log/rtc_event_log_helper_thread.h" |
23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
24 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 25 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" | 26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" |
26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" | 27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" |
27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" | 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" |
28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h" | 29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h" |
29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" | 30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" |
30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" | 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" |
31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h" | 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h" |
32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" | 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" |
33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" | 34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" |
34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" | 35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" |
35 #include "webrtc/system_wrappers/include/clock.h" | |
36 #include "webrtc/system_wrappers/include/file_wrapper.h" | 36 #include "webrtc/system_wrappers/include/file_wrapper.h" |
37 #include "webrtc/system_wrappers/include/logging.h" | 37 #include "webrtc/system_wrappers/include/logging.h" |
38 | 38 |
39 #ifdef ENABLE_RTC_EVENT_LOG | 39 #ifdef ENABLE_RTC_EVENT_LOG |
40 // Files generated at build-time by the protobuf compiler. | 40 // Files generated at build-time by the protobuf compiler. |
41 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 41 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
42 #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log.pb.h" | 42 #include "external/webrtc/webrtc/logging/rtc_event_log/rtc_event_log.pb.h" |
43 #else | 43 #else |
44 #include "webrtc/logging/rtc_event_log/rtc_event_log.pb.h" | 44 #include "webrtc/logging/rtc_event_log/rtc_event_log.pb.h" |
45 #endif | 45 #endif |
46 #endif | 46 #endif |
47 | 47 |
48 namespace webrtc { | 48 namespace webrtc { |
49 | 49 |
50 #ifdef ENABLE_RTC_EVENT_LOG | 50 #ifdef ENABLE_RTC_EVENT_LOG |
51 | 51 |
52 class RtcEventLogImpl final : public RtcEventLog { | 52 class RtcEventLogImpl final : public RtcEventLog { |
53 public: | 53 public: |
54 explicit RtcEventLogImpl(const Clock* clock); | 54 RtcEventLogImpl(); |
55 ~RtcEventLogImpl() override; | 55 ~RtcEventLogImpl() override; |
56 | 56 |
57 bool StartLogging(const std::string& file_name, | 57 bool StartLogging(const std::string& file_name, |
58 int64_t max_size_bytes) override; | 58 int64_t max_size_bytes) override; |
59 bool StartLogging(rtc::PlatformFile platform_file, | 59 bool StartLogging(rtc::PlatformFile platform_file, |
60 int64_t max_size_bytes) override; | 60 int64_t max_size_bytes) override; |
61 void StopLogging() override; | 61 void StopLogging() override; |
62 void LogVideoReceiveStreamConfig( | 62 void LogVideoReceiveStreamConfig( |
63 const VideoReceiveStream::Config& config) override; | 63 const VideoReceiveStream::Config& config) override; |
64 void LogVideoSendStreamConfig(const VideoSendStream::Config& config) override; | 64 void LogVideoSendStreamConfig(const VideoSendStream::Config& config) override; |
(...skipping 15 matching lines...) Expand all Loading... |
80 | 80 |
81 private: | 81 private: |
82 void StoreEvent(std::unique_ptr<rtclog::Event>* event); | 82 void StoreEvent(std::unique_ptr<rtclog::Event>* event); |
83 | 83 |
84 // Message queue for passing control messages to the logging thread. | 84 // Message queue for passing control messages to the logging thread. |
85 SwapQueue<RtcEventLogHelperThread::ControlMessage> message_queue_; | 85 SwapQueue<RtcEventLogHelperThread::ControlMessage> message_queue_; |
86 | 86 |
87 // Message queue for passing events to the logging thread. | 87 // Message queue for passing events to the logging thread. |
88 SwapQueue<std::unique_ptr<rtclog::Event> > event_queue_; | 88 SwapQueue<std::unique_ptr<rtclog::Event> > event_queue_; |
89 | 89 |
90 const Clock* const clock_; | |
91 | |
92 RtcEventLogHelperThread helper_thread_; | 90 RtcEventLogHelperThread helper_thread_; |
93 rtc::ThreadChecker thread_checker_; | 91 rtc::ThreadChecker thread_checker_; |
94 | 92 |
95 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtcEventLogImpl); | 93 RTC_DISALLOW_COPY_AND_ASSIGN(RtcEventLogImpl); |
96 }; | 94 }; |
97 | 95 |
98 namespace { | 96 namespace { |
99 // The functions in this namespace convert enums from the runtime format | 97 // The functions in this namespace convert enums from the runtime format |
100 // that the rest of the WebRtc project can use, to the corresponding | 98 // that the rest of the WebRtc project can use, to the corresponding |
101 // serialized enum which is defined by the protobuf. | 99 // serialized enum which is defined by the protobuf. |
102 | 100 |
103 rtclog::VideoReceiveConfig_RtcpMode ConvertRtcpMode(RtcpMode rtcp_mode) { | 101 rtclog::VideoReceiveConfig_RtcpMode ConvertRtcpMode(RtcpMode rtcp_mode) { |
104 switch (rtcp_mode) { | 102 switch (rtcp_mode) { |
105 case RtcpMode::kCompound: | 103 case RtcpMode::kCompound: |
(...skipping 23 matching lines...) Expand all Loading... |
129 return rtclog::ANY; | 127 return rtclog::ANY; |
130 } | 128 } |
131 | 129 |
132 // The RTP and RTCP buffers reserve space for twice the expected number of | 130 // The RTP and RTCP buffers reserve space for twice the expected number of |
133 // sent packets because they also contain received packets. | 131 // sent packets because they also contain received packets. |
134 static const int kEventsPerSecond = 1000; | 132 static const int kEventsPerSecond = 1000; |
135 static const int kControlMessagesPerSecond = 10; | 133 static const int kControlMessagesPerSecond = 10; |
136 } // namespace | 134 } // namespace |
137 | 135 |
138 // RtcEventLogImpl member functions. | 136 // RtcEventLogImpl member functions. |
139 RtcEventLogImpl::RtcEventLogImpl(const Clock* clock) | 137 RtcEventLogImpl::RtcEventLogImpl() |
140 // Allocate buffers for roughly one second of history. | 138 // Allocate buffers for roughly one second of history. |
141 : message_queue_(kControlMessagesPerSecond), | 139 : message_queue_(kControlMessagesPerSecond), |
142 event_queue_(kEventsPerSecond), | 140 event_queue_(kEventsPerSecond), |
143 clock_(clock), | 141 helper_thread_(&message_queue_, &event_queue_), |
144 helper_thread_(&message_queue_, &event_queue_, clock), | |
145 thread_checker_() { | 142 thread_checker_() { |
146 thread_checker_.DetachFromThread(); | 143 thread_checker_.DetachFromThread(); |
147 } | 144 } |
148 | 145 |
149 RtcEventLogImpl::~RtcEventLogImpl() { | 146 RtcEventLogImpl::~RtcEventLogImpl() { |
150 // The RtcEventLogHelperThread destructor closes the file | 147 // The RtcEventLogHelperThread destructor closes the file |
151 // and waits for the thread to terminate. | 148 // and waits for the thread to terminate. |
152 } | 149 } |
153 | 150 |
154 bool RtcEventLogImpl::StartLogging(const std::string& file_name, | 151 bool RtcEventLogImpl::StartLogging(const std::string& file_name, |
155 int64_t max_size_bytes) { | 152 int64_t max_size_bytes) { |
156 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 153 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
157 RtcEventLogHelperThread::ControlMessage message; | 154 RtcEventLogHelperThread::ControlMessage message; |
158 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; | 155 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; |
159 message.max_size_bytes = max_size_bytes <= 0 | 156 message.max_size_bytes = max_size_bytes <= 0 |
160 ? std::numeric_limits<int64_t>::max() | 157 ? std::numeric_limits<int64_t>::max() |
161 : max_size_bytes; | 158 : max_size_bytes; |
162 message.start_time = clock_->TimeInMicroseconds(); | 159 message.start_time = rtc::TimeMicros(); |
163 message.stop_time = std::numeric_limits<int64_t>::max(); | 160 message.stop_time = std::numeric_limits<int64_t>::max(); |
164 message.file.reset(FileWrapper::Create()); | 161 message.file.reset(FileWrapper::Create()); |
165 if (!message.file->OpenFile(file_name.c_str(), false)) { | 162 if (!message.file->OpenFile(file_name.c_str(), false)) { |
166 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; | 163 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; |
167 return false; | 164 return false; |
168 } | 165 } |
169 if (!message_queue_.Insert(&message)) { | 166 if (!message_queue_.Insert(&message)) { |
170 LOG(LS_ERROR) << "Message queue full. Can't start logging."; | 167 LOG(LS_ERROR) << "Message queue full. Can't start logging."; |
171 return false; | 168 return false; |
172 } | 169 } |
173 helper_thread_.SignalNewEvent(); | 170 helper_thread_.SignalNewEvent(); |
174 LOG(LS_INFO) << "Starting WebRTC event log."; | 171 LOG(LS_INFO) << "Starting WebRTC event log."; |
175 return true; | 172 return true; |
176 } | 173 } |
177 | 174 |
178 bool RtcEventLogImpl::StartLogging(rtc::PlatformFile platform_file, | 175 bool RtcEventLogImpl::StartLogging(rtc::PlatformFile platform_file, |
179 int64_t max_size_bytes) { | 176 int64_t max_size_bytes) { |
180 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 177 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
181 RtcEventLogHelperThread::ControlMessage message; | 178 RtcEventLogHelperThread::ControlMessage message; |
182 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; | 179 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; |
183 message.max_size_bytes = max_size_bytes <= 0 | 180 message.max_size_bytes = max_size_bytes <= 0 |
184 ? std::numeric_limits<int64_t>::max() | 181 ? std::numeric_limits<int64_t>::max() |
185 : max_size_bytes; | 182 : max_size_bytes; |
186 message.start_time = clock_->TimeInMicroseconds(); | 183 message.start_time = rtc::TimeMicros(); |
187 message.stop_time = std::numeric_limits<int64_t>::max(); | 184 message.stop_time = std::numeric_limits<int64_t>::max(); |
188 message.file.reset(FileWrapper::Create()); | 185 message.file.reset(FileWrapper::Create()); |
189 FILE* file_handle = rtc::FdopenPlatformFileForWriting(platform_file); | 186 FILE* file_handle = rtc::FdopenPlatformFileForWriting(platform_file); |
190 if (!file_handle) { | 187 if (!file_handle) { |
191 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; | 188 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; |
192 // Even though we failed to open a FILE*, the platform_file is still open | 189 // Even though we failed to open a FILE*, the platform_file is still open |
193 // and needs to be closed. | 190 // and needs to be closed. |
194 if (!rtc::ClosePlatformFile(platform_file)) { | 191 if (!rtc::ClosePlatformFile(platform_file)) { |
195 LOG(LS_ERROR) << "Can't close file."; | 192 LOG(LS_ERROR) << "Can't close file."; |
196 } | 193 } |
197 return false; | 194 return false; |
198 } | 195 } |
199 if (!message.file->OpenFromFileHandle(file_handle)) { | 196 if (!message.file->OpenFromFileHandle(file_handle)) { |
200 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; | 197 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; |
201 return false; | 198 return false; |
202 } | 199 } |
203 if (!message_queue_.Insert(&message)) { | 200 if (!message_queue_.Insert(&message)) { |
204 LOG(LS_ERROR) << "Message queue full. Can't start logging."; | 201 LOG(LS_ERROR) << "Message queue full. Can't start logging."; |
205 return false; | 202 return false; |
206 } | 203 } |
207 helper_thread_.SignalNewEvent(); | 204 helper_thread_.SignalNewEvent(); |
208 LOG(LS_INFO) << "Starting WebRTC event log."; | 205 LOG(LS_INFO) << "Starting WebRTC event log."; |
209 return true; | 206 return true; |
210 } | 207 } |
211 | 208 |
212 void RtcEventLogImpl::StopLogging() { | 209 void RtcEventLogImpl::StopLogging() { |
213 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 210 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
214 RtcEventLogHelperThread::ControlMessage message; | 211 RtcEventLogHelperThread::ControlMessage message; |
215 message.message_type = RtcEventLogHelperThread::ControlMessage::STOP_FILE; | 212 message.message_type = RtcEventLogHelperThread::ControlMessage::STOP_FILE; |
216 message.stop_time = clock_->TimeInMicroseconds(); | 213 message.stop_time = rtc::TimeMicros(); |
217 while (!message_queue_.Insert(&message)) { | 214 while (!message_queue_.Insert(&message)) { |
218 // TODO(terelius): We would like to have a blocking Insert function in the | 215 // TODO(terelius): We would like to have a blocking Insert function in the |
219 // SwapQueue, but for the time being we will just clear any previous | 216 // SwapQueue, but for the time being we will just clear any previous |
220 // messages. | 217 // messages. |
221 // Since StopLogging waits for the thread, it is essential that we don't | 218 // Since StopLogging waits for the thread, it is essential that we don't |
222 // clear any STOP_FILE messages. To ensure that there is only one call at a | 219 // clear any STOP_FILE messages. To ensure that there is only one call at a |
223 // time, we require that all calls to StopLogging are made on the same | 220 // time, we require that all calls to StopLogging are made on the same |
224 // thread. | 221 // thread. |
225 LOG(LS_ERROR) << "Message queue full. Clearing queue to stop logging."; | 222 LOG(LS_ERROR) << "Message queue full. Clearing queue to stop logging."; |
226 message_queue_.Clear(); | 223 message_queue_.Clear(); |
227 } | 224 } |
228 LOG(LS_INFO) << "Stopping WebRTC event log."; | 225 LOG(LS_INFO) << "Stopping WebRTC event log."; |
229 helper_thread_.WaitForFileFinished(); | 226 helper_thread_.WaitForFileFinished(); |
230 } | 227 } |
231 | 228 |
232 void RtcEventLogImpl::LogVideoReceiveStreamConfig( | 229 void RtcEventLogImpl::LogVideoReceiveStreamConfig( |
233 const VideoReceiveStream::Config& config) { | 230 const VideoReceiveStream::Config& config) { |
234 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 231 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
235 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 232 event->set_timestamp_us(rtc::TimeMicros()); |
236 event->set_type(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT); | 233 event->set_type(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT); |
237 | 234 |
238 rtclog::VideoReceiveConfig* receiver_config = | 235 rtclog::VideoReceiveConfig* receiver_config = |
239 event->mutable_video_receiver_config(); | 236 event->mutable_video_receiver_config(); |
240 receiver_config->set_remote_ssrc(config.rtp.remote_ssrc); | 237 receiver_config->set_remote_ssrc(config.rtp.remote_ssrc); |
241 receiver_config->set_local_ssrc(config.rtp.local_ssrc); | 238 receiver_config->set_local_ssrc(config.rtp.local_ssrc); |
242 | 239 |
243 receiver_config->set_rtcp_mode(ConvertRtcpMode(config.rtp.rtcp_mode)); | 240 receiver_config->set_rtcp_mode(ConvertRtcpMode(config.rtp.rtcp_mode)); |
244 receiver_config->set_remb(config.rtp.remb); | 241 receiver_config->set_remb(config.rtp.remb); |
245 | 242 |
(...skipping 15 matching lines...) Expand all Loading... |
261 rtclog::DecoderConfig* decoder = receiver_config->add_decoders(); | 258 rtclog::DecoderConfig* decoder = receiver_config->add_decoders(); |
262 decoder->set_name(d.payload_name); | 259 decoder->set_name(d.payload_name); |
263 decoder->set_payload_type(d.payload_type); | 260 decoder->set_payload_type(d.payload_type); |
264 } | 261 } |
265 StoreEvent(&event); | 262 StoreEvent(&event); |
266 } | 263 } |
267 | 264 |
268 void RtcEventLogImpl::LogVideoSendStreamConfig( | 265 void RtcEventLogImpl::LogVideoSendStreamConfig( |
269 const VideoSendStream::Config& config) { | 266 const VideoSendStream::Config& config) { |
270 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 267 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
271 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 268 event->set_timestamp_us(rtc::TimeMicros()); |
272 event->set_type(rtclog::Event::VIDEO_SENDER_CONFIG_EVENT); | 269 event->set_type(rtclog::Event::VIDEO_SENDER_CONFIG_EVENT); |
273 | 270 |
274 rtclog::VideoSendConfig* sender_config = event->mutable_video_sender_config(); | 271 rtclog::VideoSendConfig* sender_config = event->mutable_video_sender_config(); |
275 | 272 |
276 for (const auto& ssrc : config.rtp.ssrcs) { | 273 for (const auto& ssrc : config.rtp.ssrcs) { |
277 sender_config->add_ssrcs(ssrc); | 274 sender_config->add_ssrcs(ssrc); |
278 } | 275 } |
279 | 276 |
280 for (const auto& e : config.rtp.extensions) { | 277 for (const auto& e : config.rtp.extensions) { |
281 rtclog::RtpHeaderExtension* extension = | 278 rtclog::RtpHeaderExtension* extension = |
282 sender_config->add_header_extensions(); | 279 sender_config->add_header_extensions(); |
283 extension->set_name(e.uri); | 280 extension->set_name(e.uri); |
284 extension->set_id(e.id); | 281 extension->set_id(e.id); |
285 } | 282 } |
286 | 283 |
287 for (const auto& rtx_ssrc : config.rtp.rtx.ssrcs) { | 284 for (const auto& rtx_ssrc : config.rtp.rtx.ssrcs) { |
288 sender_config->add_rtx_ssrcs(rtx_ssrc); | 285 sender_config->add_rtx_ssrcs(rtx_ssrc); |
289 } | 286 } |
290 sender_config->set_rtx_payload_type(config.rtp.rtx.payload_type); | 287 sender_config->set_rtx_payload_type(config.rtp.rtx.payload_type); |
291 | 288 |
292 rtclog::EncoderConfig* encoder = sender_config->mutable_encoder(); | 289 rtclog::EncoderConfig* encoder = sender_config->mutable_encoder(); |
293 encoder->set_name(config.encoder_settings.payload_name); | 290 encoder->set_name(config.encoder_settings.payload_name); |
294 encoder->set_payload_type(config.encoder_settings.payload_type); | 291 encoder->set_payload_type(config.encoder_settings.payload_type); |
295 StoreEvent(&event); | 292 StoreEvent(&event); |
296 } | 293 } |
297 | 294 |
298 void RtcEventLogImpl::LogAudioReceiveStreamConfig( | 295 void RtcEventLogImpl::LogAudioReceiveStreamConfig( |
299 const AudioReceiveStream::Config& config) { | 296 const AudioReceiveStream::Config& config) { |
300 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 297 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
301 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 298 event->set_timestamp_us(rtc::TimeMicros()); |
302 event->set_type(rtclog::Event::AUDIO_RECEIVER_CONFIG_EVENT); | 299 event->set_type(rtclog::Event::AUDIO_RECEIVER_CONFIG_EVENT); |
303 | 300 |
304 rtclog::AudioReceiveConfig* receiver_config = | 301 rtclog::AudioReceiveConfig* receiver_config = |
305 event->mutable_audio_receiver_config(); | 302 event->mutable_audio_receiver_config(); |
306 receiver_config->set_remote_ssrc(config.rtp.remote_ssrc); | 303 receiver_config->set_remote_ssrc(config.rtp.remote_ssrc); |
307 receiver_config->set_local_ssrc(config.rtp.local_ssrc); | 304 receiver_config->set_local_ssrc(config.rtp.local_ssrc); |
308 | 305 |
309 for (const auto& e : config.rtp.extensions) { | 306 for (const auto& e : config.rtp.extensions) { |
310 rtclog::RtpHeaderExtension* extension = | 307 rtclog::RtpHeaderExtension* extension = |
311 receiver_config->add_header_extensions(); | 308 receiver_config->add_header_extensions(); |
312 extension->set_name(e.uri); | 309 extension->set_name(e.uri); |
313 extension->set_id(e.id); | 310 extension->set_id(e.id); |
314 } | 311 } |
315 StoreEvent(&event); | 312 StoreEvent(&event); |
316 } | 313 } |
317 | 314 |
318 void RtcEventLogImpl::LogAudioSendStreamConfig( | 315 void RtcEventLogImpl::LogAudioSendStreamConfig( |
319 const AudioSendStream::Config& config) { | 316 const AudioSendStream::Config& config) { |
320 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 317 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
321 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 318 event->set_timestamp_us(rtc::TimeMicros()); |
322 event->set_type(rtclog::Event::AUDIO_SENDER_CONFIG_EVENT); | 319 event->set_type(rtclog::Event::AUDIO_SENDER_CONFIG_EVENT); |
323 | 320 |
324 rtclog::AudioSendConfig* sender_config = event->mutable_audio_sender_config(); | 321 rtclog::AudioSendConfig* sender_config = event->mutable_audio_sender_config(); |
325 | 322 |
326 sender_config->set_ssrc(config.rtp.ssrc); | 323 sender_config->set_ssrc(config.rtp.ssrc); |
327 | 324 |
328 for (const auto& e : config.rtp.extensions) { | 325 for (const auto& e : config.rtp.extensions) { |
329 rtclog::RtpHeaderExtension* extension = | 326 rtclog::RtpHeaderExtension* extension = |
330 sender_config->add_header_extensions(); | 327 sender_config->add_header_extensions(); |
331 extension->set_name(e.uri); | 328 extension->set_name(e.uri); |
(...skipping 17 matching lines...) Expand all Loading... |
349 | 346 |
350 if (x) { | 347 if (x) { |
351 if (packet_length < 12u + cc * 4u + 4u) { | 348 if (packet_length < 12u + cc * 4u + 4u) { |
352 return; // Don't read outside the packet. | 349 return; // Don't read outside the packet. |
353 } | 350 } |
354 size_t x_len = ByteReader<uint16_t>::ReadBigEndian(header + 14 + cc * 4); | 351 size_t x_len = ByteReader<uint16_t>::ReadBigEndian(header + 14 + cc * 4); |
355 header_length += (x_len + 1) * 4; | 352 header_length += (x_len + 1) * 4; |
356 } | 353 } |
357 | 354 |
358 std::unique_ptr<rtclog::Event> rtp_event(new rtclog::Event()); | 355 std::unique_ptr<rtclog::Event> rtp_event(new rtclog::Event()); |
359 rtp_event->set_timestamp_us(clock_->TimeInMicroseconds()); | 356 rtp_event->set_timestamp_us(rtc::TimeMicros()); |
360 rtp_event->set_type(rtclog::Event::RTP_EVENT); | 357 rtp_event->set_type(rtclog::Event::RTP_EVENT); |
361 rtp_event->mutable_rtp_packet()->set_incoming(direction == kIncomingPacket); | 358 rtp_event->mutable_rtp_packet()->set_incoming(direction == kIncomingPacket); |
362 rtp_event->mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); | 359 rtp_event->mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); |
363 rtp_event->mutable_rtp_packet()->set_packet_length(packet_length); | 360 rtp_event->mutable_rtp_packet()->set_packet_length(packet_length); |
364 rtp_event->mutable_rtp_packet()->set_header(header, header_length); | 361 rtp_event->mutable_rtp_packet()->set_header(header, header_length); |
365 StoreEvent(&rtp_event); | 362 StoreEvent(&rtp_event); |
366 } | 363 } |
367 | 364 |
368 void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, | 365 void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, |
369 MediaType media_type, | 366 MediaType media_type, |
370 const uint8_t* packet, | 367 const uint8_t* packet, |
371 size_t length) { | 368 size_t length) { |
372 std::unique_ptr<rtclog::Event> rtcp_event(new rtclog::Event()); | 369 std::unique_ptr<rtclog::Event> rtcp_event(new rtclog::Event()); |
373 rtcp_event->set_timestamp_us(clock_->TimeInMicroseconds()); | 370 rtcp_event->set_timestamp_us(rtc::TimeMicros()); |
374 rtcp_event->set_type(rtclog::Event::RTCP_EVENT); | 371 rtcp_event->set_type(rtclog::Event::RTCP_EVENT); |
375 rtcp_event->mutable_rtcp_packet()->set_incoming(direction == kIncomingPacket); | 372 rtcp_event->mutable_rtcp_packet()->set_incoming(direction == kIncomingPacket); |
376 rtcp_event->mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); | 373 rtcp_event->mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); |
377 | 374 |
378 rtcp::CommonHeader header; | 375 rtcp::CommonHeader header; |
379 const uint8_t* block_begin = packet; | 376 const uint8_t* block_begin = packet; |
380 const uint8_t* packet_end = packet + length; | 377 const uint8_t* packet_end = packet + length; |
381 RTC_DCHECK(length <= IP_PACKET_SIZE); | 378 RTC_DCHECK(length <= IP_PACKET_SIZE); |
382 uint8_t buffer[IP_PACKET_SIZE]; | 379 uint8_t buffer[IP_PACKET_SIZE]; |
383 uint32_t buffer_length = 0; | 380 uint32_t buffer_length = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
410 } | 407 } |
411 | 408 |
412 block_begin += block_size; | 409 block_begin += block_size; |
413 } | 410 } |
414 rtcp_event->mutable_rtcp_packet()->set_packet_data(buffer, buffer_length); | 411 rtcp_event->mutable_rtcp_packet()->set_packet_data(buffer, buffer_length); |
415 StoreEvent(&rtcp_event); | 412 StoreEvent(&rtcp_event); |
416 } | 413 } |
417 | 414 |
418 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { | 415 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { |
419 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 416 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
420 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 417 event->set_timestamp_us(rtc::TimeMicros()); |
421 event->set_type(rtclog::Event::AUDIO_PLAYOUT_EVENT); | 418 event->set_type(rtclog::Event::AUDIO_PLAYOUT_EVENT); |
422 auto playout_event = event->mutable_audio_playout_event(); | 419 auto playout_event = event->mutable_audio_playout_event(); |
423 playout_event->set_local_ssrc(ssrc); | 420 playout_event->set_local_ssrc(ssrc); |
424 StoreEvent(&event); | 421 StoreEvent(&event); |
425 } | 422 } |
426 | 423 |
427 void RtcEventLogImpl::LogBwePacketLossEvent(int32_t bitrate, | 424 void RtcEventLogImpl::LogBwePacketLossEvent(int32_t bitrate, |
428 uint8_t fraction_loss, | 425 uint8_t fraction_loss, |
429 int32_t total_packets) { | 426 int32_t total_packets) { |
430 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | 427 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); |
431 event->set_timestamp_us(clock_->TimeInMicroseconds()); | 428 event->set_timestamp_us(rtc::TimeMicros()); |
432 event->set_type(rtclog::Event::BWE_PACKET_LOSS_EVENT); | 429 event->set_type(rtclog::Event::BWE_PACKET_LOSS_EVENT); |
433 auto bwe_event = event->mutable_bwe_packet_loss_event(); | 430 auto bwe_event = event->mutable_bwe_packet_loss_event(); |
434 bwe_event->set_bitrate(bitrate); | 431 bwe_event->set_bitrate(bitrate); |
435 bwe_event->set_fraction_loss(fraction_loss); | 432 bwe_event->set_fraction_loss(fraction_loss); |
436 bwe_event->set_total_packets(total_packets); | 433 bwe_event->set_total_packets(total_packets); |
437 StoreEvent(&event); | 434 StoreEvent(&event); |
438 } | 435 } |
439 | 436 |
440 void RtcEventLogImpl::StoreEvent(std::unique_ptr<rtclog::Event>* event) { | 437 void RtcEventLogImpl::StoreEvent(std::unique_ptr<rtclog::Event>* event) { |
441 if (!event_queue_.Insert(event)) { | 438 if (!event_queue_.Insert(event)) { |
(...skipping 23 matching lines...) Expand all Loading... |
465 bool RtcEventLogNullImpl::StartLogging(rtc::PlatformFile platform_file, | 462 bool RtcEventLogNullImpl::StartLogging(rtc::PlatformFile platform_file, |
466 int64_t max_size_bytes) { | 463 int64_t max_size_bytes) { |
467 // The platform_file is open and needs to be closed. | 464 // The platform_file is open and needs to be closed. |
468 if (!rtc::ClosePlatformFile(platform_file)) { | 465 if (!rtc::ClosePlatformFile(platform_file)) { |
469 LOG(LS_ERROR) << "Can't close file."; | 466 LOG(LS_ERROR) << "Can't close file."; |
470 } | 467 } |
471 return false; | 468 return false; |
472 } | 469 } |
473 | 470 |
474 // RtcEventLog member functions. | 471 // RtcEventLog member functions. |
475 std::unique_ptr<RtcEventLog> RtcEventLog::Create(const Clock* clock) { | 472 std::unique_ptr<RtcEventLog> RtcEventLog::Create() { |
476 #ifdef ENABLE_RTC_EVENT_LOG | 473 #ifdef ENABLE_RTC_EVENT_LOG |
477 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl(clock)); | 474 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl()); |
478 #else | 475 #else |
479 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); | 476 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); |
480 #endif // ENABLE_RTC_EVENT_LOG | 477 #endif // ENABLE_RTC_EVENT_LOG |
481 } | 478 } |
482 | 479 |
483 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() { | 480 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() { |
484 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); | 481 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); |
485 } | 482 } |
486 | 483 |
487 } // namespace webrtc | 484 } // namespace webrtc |
OLD | NEW |