Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 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/api/statscollector.h" | 11 #include "webrtc/api/statscollector.h" |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <utility> | 14 #include <utility> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 // StatsCollector::GetTimeNow | |
| 18 #if defined(WEBRTC_POSIX) | |
| 19 #include <sys/time.h> | |
| 20 #elif defined(WEBRTC_WIN) | |
| 21 #include <sys/timeb.h> | |
| 22 #endif | |
| 23 | |
| 17 #include "webrtc/api/peerconnection.h" | 24 #include "webrtc/api/peerconnection.h" |
| 18 #include "webrtc/base/base64.h" | 25 #include "webrtc/base/base64.h" |
| 19 #include "webrtc/base/checks.h" | 26 #include "webrtc/base/checks.h" |
| 20 #include "webrtc/base/timing.h" | |
| 21 #include "webrtc/pc/channel.h" | 27 #include "webrtc/pc/channel.h" |
| 22 | 28 |
| 23 namespace webrtc { | 29 namespace webrtc { |
| 24 namespace { | 30 namespace { |
| 25 | 31 |
| 26 // The following is the enum RTCStatsIceCandidateType from | 32 // The following is the enum RTCStatsIceCandidateType from |
| 27 // http://w3c.github.io/webrtc-stats/#rtcstatsicecandidatetype-enum such that | 33 // http://w3c.github.io/webrtc-stats/#rtcstatsicecandidatetype-enum such that |
| 28 // our stats report for ice candidate type could conform to that. | 34 // our stats report for ice candidate type could conform to that. |
| 29 const char STATSREPORT_LOCAL_PORT_TYPE[] = "host"; | 35 const char STATSREPORT_LOCAL_PORT_TYPE[] = "host"; |
| 30 const char STATSREPORT_STUN_PORT_TYPE[] = "serverreflexive"; | 36 const char STATSREPORT_STUN_PORT_TYPE[] = "serverreflexive"; |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 StatsCollector::StatsCollector(PeerConnection* pc) | 375 StatsCollector::StatsCollector(PeerConnection* pc) |
| 370 : pc_(pc), stats_gathering_started_(0) { | 376 : pc_(pc), stats_gathering_started_(0) { |
| 371 RTC_DCHECK(pc_); | 377 RTC_DCHECK(pc_); |
| 372 } | 378 } |
| 373 | 379 |
| 374 StatsCollector::~StatsCollector() { | 380 StatsCollector::~StatsCollector() { |
| 375 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); | 381 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
| 376 } | 382 } |
| 377 | 383 |
| 378 double StatsCollector::GetTimeNow() { | 384 double StatsCollector::GetTimeNow() { |
| 379 return rtc::Timing::WallTimeNow() * rtc::kNumMillisecsPerSec; | 385 // TODO(nisse): Helper function belongs in timeutils.h. |
|
hbos
2016/08/30 12:56:40
I think this TODO should be fixed in this CL befor
nisse-webrtc
2016/08/30 13:20:25
Agreed. We only have to settle on a name.
| |
| 386 #if defined(WEBRTC_POSIX) | |
| 387 struct timeval time; | |
| 388 gettimeofday(&time, NULL); | |
| 389 // Convert from second (1.0) and microsecond (1e-6). | |
| 390 return (static_cast<double>(time.tv_sec) + | |
| 391 static_cast<double>(time.tv_usec) * 1.0e-6); | |
| 392 | |
| 393 #elif defined(WEBRTC_WIN) | |
| 394 struct _timeb time; | |
| 395 _ftime(&time); | |
| 396 // Convert from second (1.0) and milliseconds (1e-3). | |
| 397 return (static_cast<double>(time.time) + | |
| 398 static_cast<double>(time.millitm) * 1.0e-3); | |
| 399 #endif | |
| 380 } | 400 } |
| 381 | 401 |
| 382 // Adds a MediaStream with tracks that can be used as a |selector| in a call | 402 // Adds a MediaStream with tracks that can be used as a |selector| in a call |
| 383 // to GetStats. | 403 // to GetStats. |
| 384 void StatsCollector::AddStream(MediaStreamInterface* stream) { | 404 void StatsCollector::AddStream(MediaStreamInterface* stream) { |
| 385 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); | 405 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
| 386 RTC_DCHECK(stream != NULL); | 406 RTC_DCHECK(stream != NULL); |
| 387 | 407 |
| 388 CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(), | 408 CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(), |
| 389 &reports_, track_ids_); | 409 &reports_, track_ids_); |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 961 StatsReport* report = entry.second; | 981 StatsReport* report = entry.second; |
| 962 report->set_timestamp(stats_gathering_started_); | 982 report->set_timestamp(stats_gathering_started_); |
| 963 } | 983 } |
| 964 } | 984 } |
| 965 | 985 |
| 966 void StatsCollector::ClearUpdateStatsCacheForTest() { | 986 void StatsCollector::ClearUpdateStatsCacheForTest() { |
| 967 stats_gathering_started_ = 0; | 987 stats_gathering_started_ = 0; |
| 968 } | 988 } |
| 969 | 989 |
| 970 } // namespace webrtc | 990 } // namespace webrtc |
| OLD | NEW |