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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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; |
65 void LogAudioReceiveStreamConfig( | 65 void LogAudioReceiveStreamConfig( |
66 const AudioReceiveStream::Config& config) override; | 66 const AudioReceiveStream::Config& config) override; |
67 void LogAudioSendStreamConfig(const AudioSendStream::Config& config) override; | 67 void LogAudioSendStreamConfig(const AudioSendStream::Config& config) override; |
68 void LogRtpHeader(PacketDirection direction, | 68 void LogRtpHeader(PacketDirection direction, |
69 MediaType media_type, | 69 MediaType media_type, |
70 const uint8_t* header, | 70 const uint8_t* header, |
71 size_t packet_length) override; | 71 size_t packet_length) override; |
72 void LogRtpHeader(PacketDirection direction, | |
terelius
2017/02/01 13:38:19
Assuming we always log outgoing packets by calling
philipel
2017/02/17 15:15:02
We could do that, but we will still log outgoing p
terelius
2017/02/17 15:50:43
As far as I can tell, all outgoing packets will ha
philipel
2017/02/20 09:46:47
If we want to do this change I think we should do
| |
73 MediaType media_type, | |
74 const uint8_t* header, | |
75 size_t packet_length, | |
76 int probe_cluster_id) override; | |
72 void LogRtcpPacket(PacketDirection direction, | 77 void LogRtcpPacket(PacketDirection direction, |
73 MediaType media_type, | 78 MediaType media_type, |
74 const uint8_t* packet, | 79 const uint8_t* packet, |
75 size_t length) override; | 80 size_t length) override; |
76 void LogAudioPlayout(uint32_t ssrc) override; | 81 void LogAudioPlayout(uint32_t ssrc) override; |
77 void LogBwePacketLossEvent(int32_t bitrate, | 82 void LogBwePacketLossEvent(int32_t bitrate, |
78 uint8_t fraction_loss, | 83 uint8_t fraction_loss, |
79 int32_t total_packets) override; | 84 int32_t total_packets) override; |
80 void LogAudioNetworkAdaptation( | 85 void LogAudioNetworkAdaptation( |
81 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) override; | 86 const AudioNetworkAdaptor::EncoderRuntimeConfig& config) override; |
87 void LogProbeClusterCreated(int id, | |
88 int bitrate_bps, | |
89 int min_probes, | |
90 int min_bytes) override; | |
91 void LogProbeResultSuccess(int id, int bitrate_bps) override; | |
92 void LogProbeResultFailure(int id, | |
93 ProbeFailureReason failure_reason) override; | |
82 | 94 |
83 private: | 95 private: |
84 void StoreEvent(std::unique_ptr<rtclog::Event>* event); | 96 void StoreEvent(std::unique_ptr<rtclog::Event>* event); |
97 void LogProbeResult(int id, | |
98 rtclog::BweProbeResult::ResultType result, | |
99 int bitrate_bps); | |
85 | 100 |
86 // Message queue for passing control messages to the logging thread. | 101 // Message queue for passing control messages to the logging thread. |
87 SwapQueue<RtcEventLogHelperThread::ControlMessage> message_queue_; | 102 SwapQueue<RtcEventLogHelperThread::ControlMessage> message_queue_; |
88 | 103 |
89 // Message queue for passing events to the logging thread. | 104 // Message queue for passing events to the logging thread. |
90 SwapQueue<std::unique_ptr<rtclog::Event> > event_queue_; | 105 SwapQueue<std::unique_ptr<rtclog::Event> > event_queue_; |
91 | 106 |
92 RtcEventLogHelperThread helper_thread_; | 107 RtcEventLogHelperThread helper_thread_; |
93 rtc::ThreadChecker thread_checker_; | 108 rtc::ThreadChecker thread_checker_; |
94 | 109 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 extension->set_id(e.id); | 346 extension->set_id(e.id); |
332 } | 347 } |
333 | 348 |
334 StoreEvent(&event); | 349 StoreEvent(&event); |
335 } | 350 } |
336 | 351 |
337 void RtcEventLogImpl::LogRtpHeader(PacketDirection direction, | 352 void RtcEventLogImpl::LogRtpHeader(PacketDirection direction, |
338 MediaType media_type, | 353 MediaType media_type, |
339 const uint8_t* header, | 354 const uint8_t* header, |
340 size_t packet_length) { | 355 size_t packet_length) { |
356 LogRtpHeader(direction, media_type, header, packet_length, | |
357 PacketInfo::kNotAProbe); | |
358 } | |
359 | |
360 void RtcEventLogImpl::LogRtpHeader(PacketDirection direction, | |
361 MediaType media_type, | |
362 const uint8_t* header, | |
363 size_t packet_length, | |
364 int probe_cluster_id) { | |
341 // Read header length (in bytes) from packet data. | 365 // Read header length (in bytes) from packet data. |
342 if (packet_length < 12u) { | 366 if (packet_length < 12u) { |
343 return; // Don't read outside the packet. | 367 return; // Don't read outside the packet. |
344 } | 368 } |
345 const bool x = (header[0] & 0x10) != 0; | 369 const bool x = (header[0] & 0x10) != 0; |
346 const uint8_t cc = header[0] & 0x0f; | 370 const uint8_t cc = header[0] & 0x0f; |
347 size_t header_length = 12u + cc * 4u; | 371 size_t header_length = 12u + cc * 4u; |
348 | 372 |
349 if (x) { | 373 if (x) { |
350 if (packet_length < 12u + cc * 4u + 4u) { | 374 if (packet_length < 12u + cc * 4u + 4u) { |
351 return; // Don't read outside the packet. | 375 return; // Don't read outside the packet. |
352 } | 376 } |
353 size_t x_len = ByteReader<uint16_t>::ReadBigEndian(header + 14 + cc * 4); | 377 size_t x_len = ByteReader<uint16_t>::ReadBigEndian(header + 14 + cc * 4); |
354 header_length += (x_len + 1) * 4; | 378 header_length += (x_len + 1) * 4; |
355 } | 379 } |
356 | 380 |
357 std::unique_ptr<rtclog::Event> rtp_event(new rtclog::Event()); | 381 std::unique_ptr<rtclog::Event> rtp_event(new rtclog::Event()); |
358 rtp_event->set_timestamp_us(rtc::TimeMicros()); | 382 rtp_event->set_timestamp_us(rtc::TimeMicros()); |
359 rtp_event->set_type(rtclog::Event::RTP_EVENT); | 383 rtp_event->set_type(rtclog::Event::RTP_EVENT); |
360 rtp_event->mutable_rtp_packet()->set_incoming(direction == kIncomingPacket); | 384 rtp_event->mutable_rtp_packet()->set_incoming(direction == kIncomingPacket); |
361 rtp_event->mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); | 385 rtp_event->mutable_rtp_packet()->set_type(ConvertMediaType(media_type)); |
362 rtp_event->mutable_rtp_packet()->set_packet_length(packet_length); | 386 rtp_event->mutable_rtp_packet()->set_packet_length(packet_length); |
363 rtp_event->mutable_rtp_packet()->set_header(header, header_length); | 387 rtp_event->mutable_rtp_packet()->set_header(header, header_length); |
388 if (probe_cluster_id != PacketInfo::kNotAProbe) | |
389 rtp_event->mutable_rtp_packet()->set_probe_cluster_id(probe_cluster_id); | |
364 StoreEvent(&rtp_event); | 390 StoreEvent(&rtp_event); |
365 } | 391 } |
366 | 392 |
367 void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, | 393 void RtcEventLogImpl::LogRtcpPacket(PacketDirection direction, |
368 MediaType media_type, | 394 MediaType media_type, |
369 const uint8_t* packet, | 395 const uint8_t* packet, |
370 size_t length) { | 396 size_t length) { |
371 std::unique_ptr<rtclog::Event> rtcp_event(new rtclog::Event()); | 397 std::unique_ptr<rtclog::Event> rtcp_event(new rtclog::Event()); |
372 rtcp_event->set_timestamp_us(rtc::TimeMicros()); | 398 rtcp_event->set_timestamp_us(rtc::TimeMicros()); |
373 rtcp_event->set_type(rtclog::Event::RTCP_EVENT); | 399 rtcp_event->set_type(rtclog::Event::RTCP_EVENT); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 } | 478 } |
453 if (config.enable_fec) | 479 if (config.enable_fec) |
454 audio_network_adaptation->set_enable_fec(*config.enable_fec); | 480 audio_network_adaptation->set_enable_fec(*config.enable_fec); |
455 if (config.enable_dtx) | 481 if (config.enable_dtx) |
456 audio_network_adaptation->set_enable_dtx(*config.enable_dtx); | 482 audio_network_adaptation->set_enable_dtx(*config.enable_dtx); |
457 if (config.num_channels) | 483 if (config.num_channels) |
458 audio_network_adaptation->set_num_channels(*config.num_channels); | 484 audio_network_adaptation->set_num_channels(*config.num_channels); |
459 StoreEvent(&event); | 485 StoreEvent(&event); |
460 } | 486 } |
461 | 487 |
488 void RtcEventLogImpl::LogProbeClusterCreated(int id, | |
terelius
2017/02/01 13:38:19
Please add unit test.
philipel
2017/02/17 15:15:02
Done.
| |
489 int bitrate_bps, | |
490 int min_probes, | |
491 int min_bytes) { | |
492 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | |
493 event->set_timestamp_us(rtc::TimeMicros()); | |
494 event->set_type(rtclog::Event::BWE_PROBE_CLUSTER_CREATED_EVENT); | |
495 | |
496 auto probe_cluster = event->mutable_probe_cluster(); | |
497 probe_cluster->set_id(id); | |
498 probe_cluster->set_bitrate_bps(bitrate_bps); | |
499 probe_cluster->set_min_probes(min_probes); | |
500 probe_cluster->set_min_bytes(min_bytes); | |
501 StoreEvent(&event); | |
502 } | |
503 | |
504 void RtcEventLogImpl::LogProbeResultSuccess(int id, int bitrate_bps) { | |
terelius
2017/02/01 13:38:19
Please add unit test.
philipel
2017/02/17 15:15:02
Done.
| |
505 LogProbeResult(id, rtclog::BweProbeResult::SUCCESS, bitrate_bps); | |
506 } | |
507 | |
508 void RtcEventLogImpl::LogProbeResultFailure(int id, | |
terelius
2017/02/01 13:38:19
Please add unit test.
philipel
2017/02/17 15:15:02
Done.
| |
509 ProbeFailureReason failure_reason) { | |
510 rtclog::BweProbeResult::ResultType result; | |
511 switch (failure_reason) { | |
512 case kInvalidSendReceiveInterval: | |
513 result = rtclog::BweProbeResult::INVALID_SEND_RECEIVE_INTERVAL; | |
514 break; | |
515 case kInvalidSendReceiveRatio: | |
516 result = rtclog::BweProbeResult::INVALID_SEND_RECEIVE_RATIO; | |
517 break; | |
518 case kTimeout: | |
519 result = rtclog::BweProbeResult::TIMEOUT; | |
520 break; | |
521 } | |
522 LogProbeResult(id, result, -1); | |
523 } | |
524 | |
525 void RtcEventLogImpl::LogProbeResult(int id, | |
526 rtclog::BweProbeResult::ResultType result, | |
527 int bitrate_bps) { | |
528 std::unique_ptr<rtclog::Event> event(new rtclog::Event()); | |
529 event->set_timestamp_us(rtc::TimeMicros()); | |
530 event->set_type(rtclog::Event::BWE_PROBE_RESULT_EVENT); | |
531 | |
532 auto probe_result = event->mutable_probe_result(); | |
533 probe_result->set_id(id); | |
534 probe_result->set_result(result); | |
535 if (result == rtclog::BweProbeResult::SUCCESS) | |
536 probe_result->set_bitrate_bps(bitrate_bps); | |
537 StoreEvent(&event); | |
538 } | |
539 | |
462 void RtcEventLogImpl::StoreEvent(std::unique_ptr<rtclog::Event>* event) { | 540 void RtcEventLogImpl::StoreEvent(std::unique_ptr<rtclog::Event>* event) { |
463 if (!event_queue_.Insert(event)) { | 541 if (!event_queue_.Insert(event)) { |
464 LOG(LS_ERROR) << "WebRTC event log queue full. Dropping event."; | 542 LOG(LS_ERROR) << "WebRTC event log queue full. Dropping event."; |
465 } | 543 } |
466 helper_thread_.SignalNewEvent(); | 544 helper_thread_.SignalNewEvent(); |
467 } | 545 } |
468 | 546 |
469 bool RtcEventLog::ParseRtcEventLog(const std::string& file_name, | 547 bool RtcEventLog::ParseRtcEventLog(const std::string& file_name, |
470 rtclog::EventStream* result) { | 548 rtclog::EventStream* result) { |
471 char tmp_buffer[1024]; | 549 char tmp_buffer[1024]; |
(...skipping 28 matching lines...) Expand all Loading... | |
500 #else | 578 #else |
501 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); | 579 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); |
502 #endif // ENABLE_RTC_EVENT_LOG | 580 #endif // ENABLE_RTC_EVENT_LOG |
503 } | 581 } |
504 | 582 |
505 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() { | 583 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() { |
506 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); | 584 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); |
507 } | 585 } |
508 | 586 |
509 } // namespace webrtc | 587 } // namespace webrtc |
OLD | NEW |