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 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 const VideoSendStream::Config& config) override {} | 47 const VideoSendStream::Config& config) override {} |
48 void LogRtpHeader(bool incoming, | 48 void LogRtpHeader(bool incoming, |
49 MediaType media_type, | 49 MediaType media_type, |
50 const uint8_t* header, | 50 const uint8_t* header, |
51 size_t packet_length) override {} | 51 size_t packet_length) override {} |
52 void LogRtcpPacket(bool incoming, | 52 void LogRtcpPacket(bool incoming, |
53 MediaType media_type, | 53 MediaType media_type, |
54 const uint8_t* packet, | 54 const uint8_t* packet, |
55 size_t length) override {} | 55 size_t length) override {} |
56 void LogAudioPlayout(uint32_t ssrc) override {} | 56 void LogAudioPlayout(uint32_t ssrc) override {} |
| 57 void LogBwePacketLossEvent(int32_t bitrate, |
| 58 uint8_t fraction_loss, |
| 59 int32_t total_packets) override {} |
57 }; | 60 }; |
58 | 61 |
59 #else // ENABLE_RTC_EVENT_LOG is defined | 62 #else // ENABLE_RTC_EVENT_LOG is defined |
60 | 63 |
61 class RtcEventLogImpl final : public RtcEventLog { | 64 class RtcEventLogImpl final : public RtcEventLog { |
62 public: | 65 public: |
63 RtcEventLogImpl(); | 66 RtcEventLogImpl(); |
64 | 67 |
65 void SetBufferDuration(int64_t buffer_duration_us) override; | 68 void SetBufferDuration(int64_t buffer_duration_us) override; |
66 void StartLogging(const std::string& file_name, int duration_ms) override; | 69 void StartLogging(const std::string& file_name, int duration_ms) override; |
67 bool StartLogging(rtc::PlatformFile log_file) override; | 70 bool StartLogging(rtc::PlatformFile log_file) override; |
68 void StopLogging() override; | 71 void StopLogging() override; |
69 void LogVideoReceiveStreamConfig( | 72 void LogVideoReceiveStreamConfig( |
70 const VideoReceiveStream::Config& config) override; | 73 const VideoReceiveStream::Config& config) override; |
71 void LogVideoSendStreamConfig(const VideoSendStream::Config& config) override; | 74 void LogVideoSendStreamConfig(const VideoSendStream::Config& config) override; |
72 void LogRtpHeader(bool incoming, | 75 void LogRtpHeader(bool incoming, |
73 MediaType media_type, | 76 MediaType media_type, |
74 const uint8_t* header, | 77 const uint8_t* header, |
75 size_t packet_length) override; | 78 size_t packet_length) override; |
76 void LogRtcpPacket(bool incoming, | 79 void LogRtcpPacket(bool incoming, |
77 MediaType media_type, | 80 MediaType media_type, |
78 const uint8_t* packet, | 81 const uint8_t* packet, |
79 size_t length) override; | 82 size_t length) override; |
80 void LogAudioPlayout(uint32_t ssrc) override; | 83 void LogAudioPlayout(uint32_t ssrc) override; |
| 84 void LogBwePacketLossEvent(int32_t bitrate, |
| 85 uint8_t fraction_loss, |
| 86 int32_t total_packets) override; |
81 | 87 |
82 private: | 88 private: |
83 // Starts logging. This function assumes the file_ has been opened succesfully | 89 // Starts logging. This function assumes the file_ has been opened succesfully |
84 // and that the start_time_us_ and _duration_us_ have been set. | 90 // and that the start_time_us_ and _duration_us_ have been set. |
85 void StartLoggingLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 91 void StartLoggingLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
86 // Stops logging and clears the stored data and buffers. | 92 // Stops logging and clears the stored data and buffers. |
87 void StopLoggingLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); | 93 void StopLoggingLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_); |
88 // Adds a new event to the logfile if logging is active, or adds it to the | 94 // Adds a new event to the logfile if logging is active, or adds it to the |
89 // list of recent log events otherwise. | 95 // list of recent log events otherwise. |
90 void HandleEvent(rtclog::Event* event) EXCLUSIVE_LOCKS_REQUIRED(crit_); | 96 void HandleEvent(rtclog::Event* event) EXCLUSIVE_LOCKS_REQUIRED(crit_); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 void RtcEventLogImpl::StopLogging() { | 253 void RtcEventLogImpl::StopLogging() { |
248 rtc::CritScope lock(&crit_); | 254 rtc::CritScope lock(&crit_); |
249 StopLoggingLocked(); | 255 StopLoggingLocked(); |
250 } | 256 } |
251 | 257 |
252 void RtcEventLogImpl::LogVideoReceiveStreamConfig( | 258 void RtcEventLogImpl::LogVideoReceiveStreamConfig( |
253 const VideoReceiveStream::Config& config) { | 259 const VideoReceiveStream::Config& config) { |
254 rtc::CritScope lock(&crit_); | 260 rtc::CritScope lock(&crit_); |
255 | 261 |
256 rtclog::Event event; | 262 rtclog::Event event; |
257 const int64_t timestamp = clock_->TimeInMicroseconds(); | 263 event.set_timestamp_us(clock_->TimeInMicroseconds()); |
258 event.set_timestamp_us(timestamp); | |
259 event.set_type(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT); | 264 event.set_type(rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT); |
260 | 265 |
261 rtclog::VideoReceiveConfig* receiver_config = | 266 rtclog::VideoReceiveConfig* receiver_config = |
262 event.mutable_video_receiver_config(); | 267 event.mutable_video_receiver_config(); |
263 receiver_config->set_remote_ssrc(config.rtp.remote_ssrc); | 268 receiver_config->set_remote_ssrc(config.rtp.remote_ssrc); |
264 receiver_config->set_local_ssrc(config.rtp.local_ssrc); | 269 receiver_config->set_local_ssrc(config.rtp.local_ssrc); |
265 | 270 |
266 receiver_config->set_rtcp_mode(ConvertRtcpMode(config.rtp.rtcp_mode)); | 271 receiver_config->set_rtcp_mode(ConvertRtcpMode(config.rtp.rtcp_mode)); |
267 | 272 |
268 receiver_config->set_receiver_reference_time_report( | 273 receiver_config->set_receiver_reference_time_report( |
(...skipping 20 matching lines...) Expand all Loading... |
289 decoder->set_payload_type(d.payload_type); | 294 decoder->set_payload_type(d.payload_type); |
290 } | 295 } |
291 HandleEvent(&event); | 296 HandleEvent(&event); |
292 } | 297 } |
293 | 298 |
294 void RtcEventLogImpl::LogVideoSendStreamConfig( | 299 void RtcEventLogImpl::LogVideoSendStreamConfig( |
295 const VideoSendStream::Config& config) { | 300 const VideoSendStream::Config& config) { |
296 rtc::CritScope lock(&crit_); | 301 rtc::CritScope lock(&crit_); |
297 | 302 |
298 rtclog::Event event; | 303 rtclog::Event event; |
299 const int64_t timestamp = clock_->TimeInMicroseconds(); | 304 event.set_timestamp_us(clock_->TimeInMicroseconds()); |
300 event.set_timestamp_us(timestamp); | |
301 event.set_type(rtclog::Event::VIDEO_SENDER_CONFIG_EVENT); | 305 event.set_type(rtclog::Event::VIDEO_SENDER_CONFIG_EVENT); |
302 | 306 |
303 rtclog::VideoSendConfig* sender_config = event.mutable_video_sender_config(); | 307 rtclog::VideoSendConfig* sender_config = event.mutable_video_sender_config(); |
304 | 308 |
305 for (const auto& ssrc : config.rtp.ssrcs) { | 309 for (const auto& ssrc : config.rtp.ssrcs) { |
306 sender_config->add_ssrcs(ssrc); | 310 sender_config->add_ssrcs(ssrc); |
307 } | 311 } |
308 | 312 |
309 for (const auto& e : config.rtp.extensions) { | 313 for (const auto& e : config.rtp.extensions) { |
310 rtclog::RtpHeaderExtension* extension = | 314 rtclog::RtpHeaderExtension* extension = |
(...skipping 30 matching lines...) Expand all Loading... |
341 if (x) { | 345 if (x) { |
342 if (packet_length < 12u + cc * 4u + 4u) { | 346 if (packet_length < 12u + cc * 4u + 4u) { |
343 return; // Don't read outside the packet. | 347 return; // Don't read outside the packet. |
344 } | 348 } |
345 size_t x_len = ByteReader<uint16_t>::ReadBigEndian(header + 14 + cc * 4); | 349 size_t x_len = ByteReader<uint16_t>::ReadBigEndian(header + 14 + cc * 4); |
346 header_length += (x_len + 1) * 4; | 350 header_length += (x_len + 1) * 4; |
347 } | 351 } |
348 | 352 |
349 rtc::CritScope lock(&crit_); | 353 rtc::CritScope lock(&crit_); |
350 rtclog::Event rtp_event; | 354 rtclog::Event rtp_event; |
351 const int64_t timestamp = clock_->TimeInMicroseconds(); | 355 rtp_event.set_timestamp_us(clock_->TimeInMicroseconds()); |
352 rtp_event.set_timestamp_us(timestamp); | |
353 rtp_event.set_type(rtclog::Event::RTP_EVENT); | 356 rtp_event.set_type(rtclog::Event::RTP_EVENT); |
354 rtp_event.mutable_rtp_packet()->set_incoming(incoming); | 357 rtp_event.mutable_rtp_packet()->set_incoming(incoming); |
355 rtp_event.mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); | 358 rtp_event.mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); |
356 rtp_event.mutable_rtp_packet()->set_packet_length(packet_length); | 359 rtp_event.mutable_rtp_packet()->set_packet_length(packet_length); |
357 rtp_event.mutable_rtp_packet()->set_header(header, header_length); | 360 rtp_event.mutable_rtp_packet()->set_header(header, header_length); |
358 HandleEvent(&rtp_event); | 361 HandleEvent(&rtp_event); |
359 } | 362 } |
360 | 363 |
361 void RtcEventLogImpl::LogRtcpPacket(bool incoming, | 364 void RtcEventLogImpl::LogRtcpPacket(bool incoming, |
362 MediaType media_type, | 365 MediaType media_type, |
363 const uint8_t* packet, | 366 const uint8_t* packet, |
364 size_t length) { | 367 size_t length) { |
365 rtc::CritScope lock(&crit_); | 368 rtc::CritScope lock(&crit_); |
366 rtclog::Event rtcp_event; | 369 rtclog::Event rtcp_event; |
367 const int64_t timestamp = clock_->TimeInMicroseconds(); | 370 rtcp_event.set_timestamp_us(clock_->TimeInMicroseconds()); |
368 rtcp_event.set_timestamp_us(timestamp); | |
369 rtcp_event.set_type(rtclog::Event::RTCP_EVENT); | 371 rtcp_event.set_type(rtclog::Event::RTCP_EVENT); |
370 rtcp_event.mutable_rtcp_packet()->set_incoming(incoming); | 372 rtcp_event.mutable_rtcp_packet()->set_incoming(incoming); |
371 rtcp_event.mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); | 373 rtcp_event.mutable_rtcp_packet()->set_type(ConvertMediaType(media_type)); |
372 rtcp_event.mutable_rtcp_packet()->set_packet_data(packet, length); | 374 rtcp_event.mutable_rtcp_packet()->set_packet_data(packet, length); |
373 HandleEvent(&rtcp_event); | 375 HandleEvent(&rtcp_event); |
374 } | 376 } |
375 | 377 |
376 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { | 378 void RtcEventLogImpl::LogAudioPlayout(uint32_t ssrc) { |
377 rtc::CritScope lock(&crit_); | 379 rtc::CritScope lock(&crit_); |
378 rtclog::Event event; | 380 rtclog::Event event; |
379 const int64_t timestamp = clock_->TimeInMicroseconds(); | 381 event.set_timestamp_us(clock_->TimeInMicroseconds()); |
380 event.set_timestamp_us(timestamp); | |
381 event.set_type(rtclog::Event::AUDIO_PLAYOUT_EVENT); | 382 event.set_type(rtclog::Event::AUDIO_PLAYOUT_EVENT); |
382 auto playout_event = event.mutable_audio_playout_event(); | 383 auto playout_event = event.mutable_audio_playout_event(); |
383 playout_event->set_local_ssrc(ssrc); | 384 playout_event->set_local_ssrc(ssrc); |
384 HandleEvent(&event); | 385 HandleEvent(&event); |
385 } | 386 } |
386 | 387 |
| 388 void RtcEventLogImpl::LogBwePacketLossEvent(int32_t bitrate, |
| 389 uint8_t fraction_loss, |
| 390 int32_t total_packets) { |
| 391 rtc::CritScope lock(&crit_); |
| 392 rtclog::Event event; |
| 393 event.set_timestamp_us(clock_->TimeInMicroseconds()); |
| 394 event.set_type(rtclog::Event::BWE_PACKET_LOSS_EVENT); |
| 395 auto bwe_event = event.mutable_bwe_packet_loss_event(); |
| 396 bwe_event->set_bitrate(bitrate); |
| 397 bwe_event->set_fraction_loss(fraction_loss); |
| 398 bwe_event->set_total_packets(total_packets); |
| 399 HandleEvent(&event); |
| 400 } |
| 401 |
387 void RtcEventLogImpl::StopLoggingLocked() { | 402 void RtcEventLogImpl::StopLoggingLocked() { |
388 if (currently_logging_) { | 403 if (currently_logging_) { |
389 currently_logging_ = false; | 404 currently_logging_ = false; |
390 // Create a LogEnd event | 405 // Create a LogEnd event |
391 rtclog::Event event; | 406 rtclog::Event event; |
392 int64_t timestamp = clock_->TimeInMicroseconds(); | 407 event.set_timestamp_us(clock_->TimeInMicroseconds()); |
393 event.set_timestamp_us(timestamp); | |
394 event.set_type(rtclog::Event::LOG_END); | 408 event.set_type(rtclog::Event::LOG_END); |
395 // Store the event and close the file | 409 // Store the event and close the file |
396 RTC_DCHECK(file_->Open()); | 410 RTC_DCHECK(file_->Open()); |
397 StoreToFile(&event); | 411 StoreToFile(&event); |
398 file_->CloseFile(); | 412 file_->CloseFile(); |
399 if (platform_file_ != rtc::kInvalidPlatformFileValue) { | 413 if (platform_file_ != rtc::kInvalidPlatformFileValue) { |
400 rtc::ClosePlatformFile(platform_file_); | 414 rtc::ClosePlatformFile(platform_file_); |
401 platform_file_ = rtc::kInvalidPlatformFileValue; | 415 platform_file_ = rtc::kInvalidPlatformFileValue; |
402 } | 416 } |
403 } | 417 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 } | 472 } |
459 | 473 |
460 #endif // ENABLE_RTC_EVENT_LOG | 474 #endif // ENABLE_RTC_EVENT_LOG |
461 | 475 |
462 // RtcEventLog member functions. | 476 // RtcEventLog member functions. |
463 rtc::scoped_ptr<RtcEventLog> RtcEventLog::Create() { | 477 rtc::scoped_ptr<RtcEventLog> RtcEventLog::Create() { |
464 return rtc::scoped_ptr<RtcEventLog>(new RtcEventLogImpl()); | 478 return rtc::scoped_ptr<RtcEventLog>(new RtcEventLogImpl()); |
465 } | 479 } |
466 | 480 |
467 } // namespace webrtc | 481 } // namespace webrtc |
OLD | NEW |