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 |
| 11 #include "webrtc/pc/rtcstatscollector.h" | 11 #include "webrtc/pc/rtcstatscollector.h" |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <sstream> | 14 #include <sstream> |
| 15 #include <utility> | 15 #include <utility> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "webrtc/api/mediastreaminterface.h" | 18 #include "webrtc/api/mediastreaminterface.h" |
| 19 #include "webrtc/api/peerconnectioninterface.h" | 19 #include "webrtc/api/peerconnectioninterface.h" |
| 20 #include "webrtc/media/base/mediachannel.h" | 20 #include "webrtc/media/base/mediachannel.h" |
| 21 #include "webrtc/p2p/base/candidate.h" | 21 #include "webrtc/p2p/base/candidate.h" |
| 22 #include "webrtc/p2p/base/p2pconstants.h" | 22 #include "webrtc/p2p/base/p2pconstants.h" |
| 23 #include "webrtc/p2p/base/port.h" | 23 #include "webrtc/p2p/base/port.h" |
| 24 #include "webrtc/pc/peerconnection.h" | 24 #include "webrtc/pc/peerconnection.h" |
| 25 #include "webrtc/pc/webrtcsession.h" | 25 #include "webrtc/pc/webrtcsession.h" |
| 26 #include "webrtc/rtc_base/checks.h" | 26 #include "webrtc/rtc_base/checks.h" |
| 27 #include "webrtc/rtc_base/timeutils.h" | 27 #include "webrtc/rtc_base/timeutils.h" |
| 28 #include "webrtc/rtc_base/trace_event.h" | |
| 28 | 29 |
| 29 namespace webrtc { | 30 namespace webrtc { |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 std::string RTCCertificateIDFromFingerprint(const std::string& fingerprint) { | 34 std::string RTCCertificateIDFromFingerprint(const std::string& fingerprint) { |
| 34 return "RTCCertificate_" + fingerprint; | 35 return "RTCCertificate_" + fingerprint; |
| 35 } | 36 } |
| 36 | 37 |
| 37 std::string RTCCodecStatsIDFromDirectionMediaAndPayload( | 38 std::string RTCCodecStatsIDFromDirectionMediaAndPayload( |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 video_track, video_track_stats.get()); | 425 video_track, video_track_stats.get()); |
| 425 video_track_stats->remote_source = false; | 426 video_track_stats->remote_source = false; |
| 426 video_track_stats->detached = false; | 427 video_track_stats->detached = false; |
| 427 video_track_stats->frame_width = static_cast<uint32_t>( | 428 video_track_stats->frame_width = static_cast<uint32_t>( |
| 428 video_sender_info.send_frame_width); | 429 video_sender_info.send_frame_width); |
| 429 video_track_stats->frame_height = static_cast<uint32_t>( | 430 video_track_stats->frame_height = static_cast<uint32_t>( |
| 430 video_sender_info.send_frame_height); | 431 video_sender_info.send_frame_height); |
| 431 // TODO(hbos): Will reduce this by frames dropped due to congestion control | 432 // TODO(hbos): Will reduce this by frames dropped due to congestion control |
| 432 // when available. crbug.com/659137 | 433 // when available. crbug.com/659137 |
| 433 video_track_stats->frames_sent = video_sender_info.frames_encoded; | 434 video_track_stats->frames_sent = video_sender_info.frames_encoded; |
| 435 TRACE_EVENT2("webrtc_stats", "sent_frame_width", | |
|
tommi
2017/07/10 20:43:23
It would be good to add some context for why these
| |
| 436 "value", video_track_stats->frame_width.ValueToString(), | |
| 437 "ssrc", video_sender_info.ssrc()); | |
| 438 TRACE_EVENT2("webrtc_stats", "sent_frame_height", | |
| 439 "value", video_track_stats->frame_height.ValueToString(), | |
| 440 "ssrc", video_sender_info.ssrc()); | |
| 441 TRACE_EVENT2("webrtc_stats", "frames_sent", | |
| 442 "value", video_track_stats->frames_sent.ValueToString(), | |
| 443 "ssrc", video_sender_info.ssrc()); | |
| 434 return video_track_stats; | 444 return video_track_stats; |
| 435 } | 445 } |
| 436 | 446 |
| 437 std::unique_ptr<RTCMediaStreamTrackStats> | 447 std::unique_ptr<RTCMediaStreamTrackStats> |
| 438 ProduceMediaStreamTrackStatsFromVideoReceiverInfo( | 448 ProduceMediaStreamTrackStatsFromVideoReceiverInfo( |
| 439 int64_t timestamp_us, | 449 int64_t timestamp_us, |
| 440 const VideoTrackInterface& video_track, | 450 const VideoTrackInterface& video_track, |
| 441 const cricket::VideoReceiverInfo& video_receiver_info) { | 451 const cricket::VideoReceiverInfo& video_receiver_info) { |
| 442 std::unique_ptr<RTCMediaStreamTrackStats> video_track_stats( | 452 std::unique_ptr<RTCMediaStreamTrackStats> video_track_stats( |
| 443 new RTCMediaStreamTrackStats( | 453 new RTCMediaStreamTrackStats( |
| 444 RTCMediaStreamTrackStatsIDFromTrackKindIDAndSsrc( | 454 RTCMediaStreamTrackStatsIDFromTrackKindIDAndSsrc( |
| 445 false, MediaStreamTrackInterface::kVideoKind, video_track.id(), | 455 false, MediaStreamTrackInterface::kVideoKind, video_track.id(), |
| 446 video_receiver_info.ssrc()), | 456 video_receiver_info.ssrc()), |
| 447 timestamp_us, | 457 timestamp_us, |
| 448 RTCMediaStreamTrackKind::kVideo)); | 458 RTCMediaStreamTrackKind::kVideo)); |
| 449 SetMediaStreamTrackStatsFromMediaStreamTrackInterface( | 459 SetMediaStreamTrackStatsFromMediaStreamTrackInterface( |
| 450 video_track, video_track_stats.get()); | 460 video_track, video_track_stats.get()); |
| 451 video_track_stats->remote_source = true; | 461 video_track_stats->remote_source = true; |
| 452 video_track_stats->detached = false; | 462 video_track_stats->detached = false; |
| 453 if (video_receiver_info.frame_width > 0 && | 463 if (video_receiver_info.frame_width > 0 && |
| 454 video_receiver_info.frame_height > 0) { | 464 video_receiver_info.frame_height > 0) { |
| 455 video_track_stats->frame_width = static_cast<uint32_t>( | 465 video_track_stats->frame_width = static_cast<uint32_t>( |
| 456 video_receiver_info.frame_width); | 466 video_receiver_info.frame_width); |
| 457 video_track_stats->frame_height = static_cast<uint32_t>( | 467 video_track_stats->frame_height = static_cast<uint32_t>( |
| 458 video_receiver_info.frame_height); | 468 video_receiver_info.frame_height); |
| 469 TRACE_EVENT2("webrtc_stats", "received_frame_width", | |
| 470 "value", video_track_stats->frame_width.ValueToString(), | |
| 471 "ssrc", video_receiver_info.ssrc()); | |
| 472 TRACE_EVENT2("webrtc_stats", "received_frame_height", | |
| 473 "value", video_track_stats->frame_width.ValueToString(), | |
| 474 "ssrc", video_receiver_info.ssrc()); | |
| 459 } | 475 } |
| 460 video_track_stats->frames_received = video_receiver_info.frames_received; | 476 video_track_stats->frames_received = video_receiver_info.frames_received; |
| 461 // TODO(hbos): When we support receiving simulcast, this should be the total | 477 // TODO(hbos): When we support receiving simulcast, this should be the total |
| 462 // number of frames correctly decoded, independent of which SSRC it was | 478 // number of frames correctly decoded, independent of which SSRC it was |
| 463 // received from. Since we don't support that, this is correct and is the same | 479 // received from. Since we don't support that, this is correct and is the same |
| 464 // value as "RTCInboundRTPStreamStats.framesDecoded". crbug.com/659137 | 480 // value as "RTCInboundRTPStreamStats.framesDecoded". crbug.com/659137 |
| 465 video_track_stats->frames_decoded = video_receiver_info.frames_decoded; | 481 video_track_stats->frames_decoded = video_receiver_info.frames_decoded; |
| 466 RTC_DCHECK_GE(video_receiver_info.frames_received, | 482 RTC_DCHECK_GE(video_receiver_info.frames_received, |
| 467 video_receiver_info.frames_rendered); | 483 video_receiver_info.frames_rendered); |
| 468 video_track_stats->frames_dropped = video_receiver_info.frames_received - | 484 video_track_stats->frames_dropped = video_receiver_info.frames_received - |
| 469 video_receiver_info.frames_rendered; | 485 video_receiver_info.frames_rendered; |
| 486 TRACE_EVENT2("webrtc_stats", "frames_received", | |
| 487 "value", video_track_stats->frames_received.ValueToString(), | |
| 488 "ssrc", video_receiver_info.ssrc()); | |
| 489 TRACE_EVENT2("webrtc_stats", "frames_decoded", | |
| 490 "value", video_track_stats->frames_decoded.ValueToString(), | |
| 491 "ssrc", video_receiver_info.ssrc()); | |
| 492 TRACE_EVENT2("webrtc_stats", "frames_dropped", | |
| 493 "value", video_track_stats->frames_dropped.ValueToString(), | |
| 494 "ssrc", video_receiver_info.ssrc()); | |
|
hbos
2017/07/11 13:37:13
The "ssrc" is not a identifier of this report, you
| |
| 470 return video_track_stats; | 495 return video_track_stats; |
| 471 } | 496 } |
| 472 | 497 |
| 473 void ProduceMediaStreamAndTrackStats( | 498 void ProduceMediaStreamAndTrackStats( |
| 474 int64_t timestamp_us, | 499 int64_t timestamp_us, |
| 475 const TrackMediaInfoMap& track_media_info_map, | 500 const TrackMediaInfoMap& track_media_info_map, |
| 476 rtc::scoped_refptr<StreamCollectionInterface> streams, | 501 rtc::scoped_refptr<StreamCollectionInterface> streams, |
| 477 bool is_local, | 502 bool is_local, |
| 478 RTCStatsReport* report) { | 503 RTCStatsReport* report) { |
| 479 // TODO(hbos): When "AddTrack" is implemented we should iterate tracks to | 504 // TODO(hbos): When "AddTrack" is implemented we should iterate tracks to |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 743 partial_report_ = partial_report; | 768 partial_report_ = partial_report; |
| 744 else | 769 else |
| 745 partial_report_->TakeMembersFrom(partial_report); | 770 partial_report_->TakeMembersFrom(partial_report); |
| 746 --num_pending_partial_reports_; | 771 --num_pending_partial_reports_; |
| 747 if (!num_pending_partial_reports_) { | 772 if (!num_pending_partial_reports_) { |
| 748 cache_timestamp_us_ = partial_report_timestamp_us_; | 773 cache_timestamp_us_ = partial_report_timestamp_us_; |
| 749 cached_report_ = partial_report_; | 774 cached_report_ = partial_report_; |
| 750 partial_report_ = nullptr; | 775 partial_report_ = nullptr; |
| 751 channel_name_pairs_.reset(); | 776 channel_name_pairs_.reset(); |
| 752 track_media_info_map_.reset(); | 777 track_media_info_map_.reset(); |
| 753 track_to_id_.clear(); | 778 track_to_id_.clear(); |
|
hbos
2017/07/11 13:37:13
Reports are produced asynchronously on different t
| |
| 754 DeliverCachedReport(); | 779 DeliverCachedReport(); |
| 755 } | 780 } |
| 756 } | 781 } |
| 757 | 782 |
| 758 void RTCStatsCollector::DeliverCachedReport() { | 783 void RTCStatsCollector::DeliverCachedReport() { |
| 759 RTC_DCHECK(signaling_thread_->IsCurrent()); | 784 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 760 RTC_DCHECK(!callbacks_.empty()); | 785 RTC_DCHECK(!callbacks_.empty()); |
| 761 RTC_DCHECK(cached_report_); | 786 RTC_DCHECK(cached_report_); |
| 762 for (const rtc::scoped_refptr<RTCStatsCollectorCallback>& callback : | 787 for (const rtc::scoped_refptr<RTCStatsCollectorCallback>& callback : |
| 763 callbacks_) { | 788 callbacks_) { |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1248 const std::string& type) { | 1273 const std::string& type) { |
| 1249 return CandidateTypeToRTCIceCandidateType(type); | 1274 return CandidateTypeToRTCIceCandidateType(type); |
| 1250 } | 1275 } |
| 1251 | 1276 |
| 1252 const char* DataStateToRTCDataChannelStateForTesting( | 1277 const char* DataStateToRTCDataChannelStateForTesting( |
| 1253 DataChannelInterface::DataState state) { | 1278 DataChannelInterface::DataState state) { |
| 1254 return DataStateToRTCDataChannelState(state); | 1279 return DataStateToRTCDataChannelState(state); |
| 1255 } | 1280 } |
| 1256 | 1281 |
| 1257 } // namespace webrtc | 1282 } // namespace webrtc |
| OLD | NEW |