Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 std::string RTCTransportStatsIDFromBaseChannel( | 46 std::string RTCTransportStatsIDFromBaseChannel( |
| 47 const ProxyTransportMap& proxy_to_transport, | 47 const ProxyTransportMap& proxy_to_transport, |
| 48 const cricket::BaseChannel& base_channel) { | 48 const cricket::BaseChannel& base_channel) { |
| 49 auto proxy_it = proxy_to_transport.find(base_channel.content_name()); | 49 auto proxy_it = proxy_to_transport.find(base_channel.content_name()); |
| 50 if (proxy_it == proxy_to_transport.cend()) | 50 if (proxy_it == proxy_to_transport.cend()) |
| 51 return ""; | 51 return ""; |
| 52 return RTCTransportStatsIDFromTransportChannel( | 52 return RTCTransportStatsIDFromTransportChannel( |
| 53 proxy_it->second, cricket::ICE_CANDIDATE_COMPONENT_RTP); | 53 proxy_it->second, cricket::ICE_CANDIDATE_COMPONENT_RTP); |
| 54 } | 54 } |
| 55 | 55 |
| 56 std::string RTCInboundRTPStreamStatsIDFromSSRC(bool audio, uint32_t ssrc) { | |
| 57 return audio ? "RTCInboundRTPAudioStream_" + rtc::ToString<>(ssrc) | |
| 58 : "RTCInboundRTPVideoStream_" + rtc::ToString<>(ssrc); | |
| 59 } | |
| 60 | |
| 56 std::string RTCOutboundRTPStreamStatsIDFromSSRC(bool audio, uint32_t ssrc) { | 61 std::string RTCOutboundRTPStreamStatsIDFromSSRC(bool audio, uint32_t ssrc) { |
| 57 return audio ? "RTCOutboundRTPAudioStream_" + rtc::ToString<>(ssrc) | 62 return audio ? "RTCOutboundRTPAudioStream_" + rtc::ToString<>(ssrc) |
| 58 : "RTCOutboundRTPVideoStream_" + rtc::ToString<>(ssrc); | 63 : "RTCOutboundRTPVideoStream_" + rtc::ToString<>(ssrc); |
| 59 } | 64 } |
| 60 | 65 |
| 61 const char* CandidateTypeToRTCIceCandidateType(const std::string& type) { | 66 const char* CandidateTypeToRTCIceCandidateType(const std::string& type) { |
| 62 if (type == cricket::LOCAL_PORT_TYPE) | 67 if (type == cricket::LOCAL_PORT_TYPE) |
| 63 return RTCIceCandidateType::kHost; | 68 return RTCIceCandidateType::kHost; |
| 64 if (type == cricket::STUN_PORT_TYPE) | 69 if (type == cricket::STUN_PORT_TYPE) |
| 65 return RTCIceCandidateType::kSrflx; | 70 return RTCIceCandidateType::kSrflx; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 81 case DataChannelInterface::kClosing: | 86 case DataChannelInterface::kClosing: |
| 82 return RTCDataChannelState::kClosing; | 87 return RTCDataChannelState::kClosing; |
| 83 case DataChannelInterface::kClosed: | 88 case DataChannelInterface::kClosed: |
| 84 return RTCDataChannelState::kClosed; | 89 return RTCDataChannelState::kClosed; |
| 85 default: | 90 default: |
| 86 RTC_NOTREACHED(); | 91 RTC_NOTREACHED(); |
| 87 return nullptr; | 92 return nullptr; |
| 88 } | 93 } |
| 89 } | 94 } |
| 90 | 95 |
| 96 void SetInboundRTPStreamStatsFromMediaReceiverInfo( | |
| 97 const cricket::MediaReceiverInfo& media_receiver_info, | |
| 98 RTCInboundRTPStreamStats* inbound_stats) { | |
| 99 RTC_DCHECK(inbound_stats); | |
| 100 inbound_stats->ssrc = rtc::ToString<>(media_receiver_info.ssrc()); | |
| 101 // TODO(hbos): Support the remote case. crbug.com/657855 | |
| 102 inbound_stats->is_remote = false; | |
| 103 // TODO(hbos): Set |codec_id| when we have |RTCCodecStats|. Maybe relevant: | |
| 104 // |media_receiver_info.codec_name|. crbug.com/657854, 657855, 659117 | |
| 105 inbound_stats->packets_received = | |
| 106 static_cast<uint32_t>(media_receiver_info.packets_rcvd); | |
| 107 inbound_stats->bytes_received = | |
| 108 static_cast<uint64_t>(media_receiver_info.bytes_rcvd); | |
| 109 inbound_stats->fraction_lost = | |
| 110 static_cast<double>(media_receiver_info.fraction_lost); | |
| 111 } | |
| 112 | |
| 113 void SetInboundRTPStreamStatsFromVoiceReceiverInfo( | |
| 114 const cricket::VoiceReceiverInfo& voice_receiver_info, | |
| 115 RTCInboundRTPStreamStats* inbound_stats) { | |
| 116 SetInboundRTPStreamStatsFromMediaReceiverInfo( | |
| 117 voice_receiver_info, inbound_stats); | |
| 118 inbound_stats->media_type = "audio"; | |
| 119 inbound_stats->jitter = | |
| 120 static_cast<double>(voice_receiver_info.jitter_buffer_ms) / | |
|
Taylor Brandstetter
2016/10/27 21:26:03
I don't think this is right; it looks like jitter_
hbos
2016/10/28 10:03:48
Done. The audio case has jitter_ms, jitter_buffer_
| |
| 121 rtc::kNumMillisecsPerSec; | |
| 122 } | |
| 123 | |
| 124 void SetInboundRTPStreamStatsFromVideoReceiverInfo( | |
| 125 const cricket::VideoReceiverInfo& video_receiver_info, | |
| 126 RTCInboundRTPStreamStats* inbound_stats) { | |
| 127 SetInboundRTPStreamStatsFromMediaReceiverInfo( | |
| 128 video_receiver_info, inbound_stats); | |
| 129 inbound_stats->media_type = "video"; | |
| 130 inbound_stats->jitter = | |
| 131 static_cast<double>(video_receiver_info.jitter_buffer_ms) / | |
| 132 rtc::kNumMillisecsPerSec; | |
| 133 } | |
| 134 | |
| 91 void SetOutboundRTPStreamStatsFromMediaSenderInfo( | 135 void SetOutboundRTPStreamStatsFromMediaSenderInfo( |
| 92 const cricket::MediaSenderInfo& media_sender_info, | 136 const cricket::MediaSenderInfo& media_sender_info, |
| 93 RTCOutboundRTPStreamStats* outbound_stats) { | 137 RTCOutboundRTPStreamStats* outbound_stats) { |
| 94 RTC_DCHECK(outbound_stats); | 138 RTC_DCHECK(outbound_stats); |
| 95 outbound_stats->ssrc = rtc::ToString<>(media_sender_info.ssrc()); | 139 outbound_stats->ssrc = rtc::ToString<>(media_sender_info.ssrc()); |
| 96 // TODO(hbos): Support the remote case. crbug.com/657856 | 140 // TODO(hbos): Support the remote case. crbug.com/657856 |
| 97 outbound_stats->is_remote = false; | 141 outbound_stats->is_remote = false; |
| 98 // TODO(hbos): Set |codec_id| when we have |RTCCodecStats|. Maybe relevant: | 142 // TODO(hbos): Set |codec_id| when we have |RTCCodecStats|. Maybe relevant: |
| 99 // |media_sender_info.codec_name|. crbug.com/657854, 657856, 659117 | 143 // |media_sender_info.codec_name|. crbug.com/657854, 657856, 659117 |
| 100 outbound_stats->packets_sent = | 144 outbound_stats->packets_sent = |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 int64_t timestamp_us, const SessionStats& session_stats, | 501 int64_t timestamp_us, const SessionStats& session_stats, |
| 458 RTCStatsReport* report) const { | 502 RTCStatsReport* report) const { |
| 459 RTC_DCHECK(signaling_thread_->IsCurrent()); | 503 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 460 | 504 |
| 461 // Audio | 505 // Audio |
| 462 if (pc_->session()->voice_channel()) { | 506 if (pc_->session()->voice_channel()) { |
| 463 cricket::VoiceMediaInfo voice_media_info; | 507 cricket::VoiceMediaInfo voice_media_info; |
| 464 if (pc_->session()->voice_channel()->GetStats(&voice_media_info)) { | 508 if (pc_->session()->voice_channel()->GetStats(&voice_media_info)) { |
| 465 std::string transport_id = RTCTransportStatsIDFromBaseChannel( | 509 std::string transport_id = RTCTransportStatsIDFromBaseChannel( |
| 466 session_stats.proxy_to_transport, *pc_->session()->voice_channel()); | 510 session_stats.proxy_to_transport, *pc_->session()->voice_channel()); |
| 511 // Inbound | |
| 512 for (const cricket::VoiceReceiverInfo& voice_receiver_info : | |
| 513 voice_media_info.receivers) { | |
| 514 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | |
| 515 // is fixed. | |
| 516 if (voice_receiver_info.ssrc() == 0) | |
| 517 continue; | |
| 518 std::unique_ptr<RTCInboundRTPStreamStats> inbound_audio( | |
| 519 new RTCInboundRTPStreamStats( | |
| 520 RTCInboundRTPStreamStatsIDFromSSRC( | |
| 521 true, voice_receiver_info.ssrc()), | |
| 522 timestamp_us)); | |
| 523 SetInboundRTPStreamStatsFromVoiceReceiverInfo( | |
| 524 voice_receiver_info, inbound_audio.get()); | |
| 525 if (!transport_id.empty()) | |
|
Taylor Brandstetter
2016/10/27 21:26:03
Is it ever possible for transport_id to be empty h
Taylor Brandstetter
2016/10/27 21:28:30
Oh, I see now. It's possible given how "proxy_to_t
hbos
2016/10/28 10:03:48
Done.
| |
| 526 inbound_audio->transport_id = transport_id; | |
| 527 report->AddStats(std::move(inbound_audio)); | |
| 528 } | |
| 529 // Outbound | |
| 467 for (const cricket::VoiceSenderInfo& voice_sender_info : | 530 for (const cricket::VoiceSenderInfo& voice_sender_info : |
| 468 voice_media_info.senders) { | 531 voice_media_info.senders) { |
| 469 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 532 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
| 470 // is fixed. | 533 // is fixed. |
| 471 if (voice_sender_info.ssrc() == 0) | 534 if (voice_sender_info.ssrc() == 0) |
| 472 continue; | 535 continue; |
| 473 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_audio( | 536 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_audio( |
| 474 new RTCOutboundRTPStreamStats( | 537 new RTCOutboundRTPStreamStats( |
| 475 RTCOutboundRTPStreamStatsIDFromSSRC( | 538 RTCOutboundRTPStreamStatsIDFromSSRC( |
| 476 true, voice_sender_info.ssrc()), | 539 true, voice_sender_info.ssrc()), |
| 477 timestamp_us)); | 540 timestamp_us)); |
| 478 SetOutboundRTPStreamStatsFromVoiceSenderInfo( | 541 SetOutboundRTPStreamStatsFromVoiceSenderInfo( |
| 479 voice_sender_info, outbound_audio.get()); | 542 voice_sender_info, outbound_audio.get()); |
| 480 if (!transport_id.empty()) | 543 if (!transport_id.empty()) |
| 481 outbound_audio->transport_id = transport_id; | 544 outbound_audio->transport_id = transport_id; |
| 482 report->AddStats(std::move(outbound_audio)); | 545 report->AddStats(std::move(outbound_audio)); |
| 483 } | 546 } |
| 484 } | 547 } |
| 485 } | 548 } |
| 486 // Video | 549 // Video |
| 487 if (pc_->session()->video_channel()) { | 550 if (pc_->session()->video_channel()) { |
| 488 cricket::VideoMediaInfo video_media_info; | 551 cricket::VideoMediaInfo video_media_info; |
| 489 if (pc_->session()->video_channel()->GetStats(&video_media_info)) { | 552 if (pc_->session()->video_channel()->GetStats(&video_media_info)) { |
| 490 std::string transport_id = RTCTransportStatsIDFromBaseChannel( | 553 std::string transport_id = RTCTransportStatsIDFromBaseChannel( |
| 491 session_stats.proxy_to_transport, *pc_->session()->video_channel()); | 554 session_stats.proxy_to_transport, *pc_->session()->video_channel()); |
| 555 // Inbound | |
| 556 for (const cricket::VideoReceiverInfo& video_receiver_info : | |
| 557 video_media_info.receivers) { | |
| 558 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | |
| 559 // is fixed. | |
| 560 if (video_receiver_info.ssrc() == 0) | |
| 561 continue; | |
| 562 std::unique_ptr<RTCInboundRTPStreamStats> inbound_video( | |
| 563 new RTCInboundRTPStreamStats( | |
| 564 RTCInboundRTPStreamStatsIDFromSSRC( | |
| 565 false, video_receiver_info.ssrc()), | |
| 566 timestamp_us)); | |
| 567 SetInboundRTPStreamStatsFromVideoReceiverInfo( | |
| 568 video_receiver_info, inbound_video.get()); | |
| 569 if (!transport_id.empty()) | |
| 570 inbound_video->transport_id = transport_id; | |
| 571 report->AddStats(std::move(inbound_video)); | |
| 572 } | |
| 573 // Outbound | |
| 492 for (const cricket::VideoSenderInfo& video_sender_info : | 574 for (const cricket::VideoSenderInfo& video_sender_info : |
| 493 video_media_info.senders) { | 575 video_media_info.senders) { |
| 494 // TODO(nisse): SSRC == 0 currently means none. Delete check when that | 576 // TODO(nisse): SSRC == 0 currently means none. Delete check when that |
| 495 // is fixed. | 577 // is fixed. |
| 496 if (video_sender_info.ssrc() == 0) | 578 if (video_sender_info.ssrc() == 0) |
| 497 continue; | 579 continue; |
| 498 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_video( | 580 std::unique_ptr<RTCOutboundRTPStreamStats> outbound_video( |
| 499 new RTCOutboundRTPStreamStats( | 581 new RTCOutboundRTPStreamStats( |
| 500 RTCOutboundRTPStreamStatsIDFromSSRC( | 582 RTCOutboundRTPStreamStatsIDFromSSRC( |
| 501 false, video_sender_info.ssrc()), | 583 false, video_sender_info.ssrc()), |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 606 const std::string& type) { | 688 const std::string& type) { |
| 607 return CandidateTypeToRTCIceCandidateType(type); | 689 return CandidateTypeToRTCIceCandidateType(type); |
| 608 } | 690 } |
| 609 | 691 |
| 610 const char* DataStateToRTCDataChannelStateForTesting( | 692 const char* DataStateToRTCDataChannelStateForTesting( |
| 611 DataChannelInterface::DataState state) { | 693 DataChannelInterface::DataState state) { |
| 612 return DataStateToRTCDataChannelState(state); | 694 return DataStateToRTCDataChannelState(state); |
| 613 } | 695 } |
| 614 | 696 |
| 615 } // namespace webrtc | 697 } // namespace webrtc |
| OLD | NEW |