OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 12 matching lines...) Expand all Loading... |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include "talk/app/webrtc/statscollector.h" | 28 #include "talk/app/webrtc/statscollector.h" |
29 | 29 |
30 #include <utility> | 30 #include <utility> |
31 #include <vector> | 31 #include <vector> |
32 | 32 |
| 33 #include "talk/app/webrtc/peerconnection.h" |
33 #include "talk/session/media/channel.h" | 34 #include "talk/session/media/channel.h" |
34 #include "webrtc/base/base64.h" | 35 #include "webrtc/base/base64.h" |
35 #include "webrtc/base/checks.h" | 36 #include "webrtc/base/checks.h" |
36 #include "webrtc/base/scoped_ptr.h" | 37 #include "webrtc/base/scoped_ptr.h" |
37 #include "webrtc/base/timing.h" | 38 #include "webrtc/base/timing.h" |
38 | 39 |
39 using rtc::scoped_ptr; | 40 using rtc::scoped_ptr; |
40 | 41 |
41 namespace webrtc { | 42 namespace webrtc { |
42 namespace { | 43 namespace { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 case rtc::ADAPTER_TYPE_VPN: | 350 case rtc::ADAPTER_TYPE_VPN: |
350 return STATSREPORT_ADAPTER_TYPE_VPN; | 351 return STATSREPORT_ADAPTER_TYPE_VPN; |
351 case rtc::ADAPTER_TYPE_LOOPBACK: | 352 case rtc::ADAPTER_TYPE_LOOPBACK: |
352 return STATSREPORT_ADAPTER_TYPE_LOOPBACK; | 353 return STATSREPORT_ADAPTER_TYPE_LOOPBACK; |
353 default: | 354 default: |
354 RTC_DCHECK(false); | 355 RTC_DCHECK(false); |
355 return ""; | 356 return ""; |
356 } | 357 } |
357 } | 358 } |
358 | 359 |
359 StatsCollector::StatsCollector(WebRtcSession* session) | 360 StatsCollector::StatsCollector(PeerConnection* pc, WebRtcSession* session) |
360 : session_(session), | 361 : pc_(pc), session_(session), stats_gathering_started_(0) { |
361 stats_gathering_started_(0) { | 362 RTC_DCHECK(pc_); |
362 RTC_DCHECK(session_); | 363 RTC_DCHECK(session_); |
363 } | 364 } |
364 | 365 |
365 StatsCollector::~StatsCollector() { | 366 StatsCollector::~StatsCollector() { |
366 RTC_DCHECK(session_->signaling_thread()->IsCurrent()); | 367 RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
367 } | 368 } |
368 | 369 |
369 double StatsCollector::GetTimeNow() { | 370 double StatsCollector::GetTimeNow() { |
370 return rtc::Timing::WallTimeNow() * rtc::kNumMillisecsPerSec; | 371 return rtc::Timing::WallTimeNow() * rtc::kNumMillisecsPerSec; |
371 } | 372 } |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 ExtractStats( | 825 ExtractStats( |
825 video_info.bw_estimations[0], stats_gathering_started_, level, report); | 826 video_info.bw_estimations[0], stats_gathering_started_, level, report); |
826 } | 827 } |
827 } | 828 } |
828 | 829 |
829 void StatsCollector::ExtractDataInfo() { | 830 void StatsCollector::ExtractDataInfo() { |
830 RTC_DCHECK(session_->signaling_thread()->IsCurrent()); | 831 RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
831 | 832 |
832 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; | 833 rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; |
833 | 834 |
834 for (const auto& dc : | 835 for (const auto& dc : pc_->sctp_data_channels()) { |
835 session_->mediastream_signaling()->sctp_data_channels()) { | |
836 StatsReport::Id id(StatsReport::NewTypedIntId( | 836 StatsReport::Id id(StatsReport::NewTypedIntId( |
837 StatsReport::kStatsReportTypeDataChannel, dc->id())); | 837 StatsReport::kStatsReportTypeDataChannel, dc->id())); |
838 StatsReport* report = reports_.ReplaceOrAddNew(id); | 838 StatsReport* report = reports_.ReplaceOrAddNew(id); |
839 report->set_timestamp(stats_gathering_started_); | 839 report->set_timestamp(stats_gathering_started_); |
840 report->AddString(StatsReport::kStatsValueNameLabel, dc->label()); | 840 report->AddString(StatsReport::kStatsValueNameLabel, dc->label()); |
841 report->AddInt(StatsReport::kStatsValueNameDataChannelId, dc->id()); | 841 report->AddInt(StatsReport::kStatsValueNameDataChannelId, dc->id()); |
842 report->AddString(StatsReport::kStatsValueNameProtocol, dc->protocol()); | 842 report->AddString(StatsReport::kStatsValueNameProtocol, dc->protocol()); |
843 report->AddString(StatsReport::kStatsValueNameState, | 843 report->AddString(StatsReport::kStatsValueNameState, |
844 DataChannelInterface::DataStateString(dc->state())); | 844 DataChannelInterface::DataStateString(dc->state())); |
845 } | 845 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 StatsReport* report = entry.second; | 933 StatsReport* report = entry.second; |
934 report->set_timestamp(stats_gathering_started_); | 934 report->set_timestamp(stats_gathering_started_); |
935 } | 935 } |
936 } | 936 } |
937 | 937 |
938 void StatsCollector::ClearUpdateStatsCacheForTest() { | 938 void StatsCollector::ClearUpdateStatsCacheForTest() { |
939 stats_gathering_started_ = 0; | 939 stats_gathering_started_ = 0; |
940 } | 940 } |
941 | 941 |
942 } // namespace webrtc | 942 } // namespace webrtc |
OLD | NEW |