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/api/rtcstatscollector.h" | 11 #include "webrtc/api/rtcstatscollector.h" |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <ostream> | 14 #include <ostream> |
| 15 #include <string> | 15 #include <string> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "webrtc/api/mediastream.h" | |
| 19 #include "webrtc/api/mediastreamtrack.h" | |
| 18 #include "webrtc/api/jsepsessiondescription.h" | 20 #include "webrtc/api/jsepsessiondescription.h" |
| 19 #include "webrtc/api/stats/rtcstats_objects.h" | 21 #include "webrtc/api/stats/rtcstats_objects.h" |
| 20 #include "webrtc/api/stats/rtcstatsreport.h" | 22 #include "webrtc/api/stats/rtcstatsreport.h" |
| 21 #include "webrtc/api/test/mock_datachannel.h" | 23 #include "webrtc/api/test/mock_datachannel.h" |
| 22 #include "webrtc/api/test/mock_peerconnection.h" | 24 #include "webrtc/api/test/mock_peerconnection.h" |
| 23 #include "webrtc/api/test/mock_webrtcsession.h" | 25 #include "webrtc/api/test/mock_webrtcsession.h" |
| 24 #include "webrtc/base/checks.h" | 26 #include "webrtc/base/checks.h" |
| 25 #include "webrtc/base/fakeclock.h" | 27 #include "webrtc/base/fakeclock.h" |
| 26 #include "webrtc/base/fakesslidentity.h" | 28 #include "webrtc/base/fakesslidentity.h" |
| 27 #include "webrtc/base/gunit.h" | 29 #include "webrtc/base/gunit.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 } | 65 } |
| 64 | 66 |
| 65 void PrintTo(const RTCRemoteIceCandidateStats& stats, ::std::ostream* os) { | 67 void PrintTo(const RTCRemoteIceCandidateStats& stats, ::std::ostream* os) { |
| 66 *os << stats.ToString(); | 68 *os << stats.ToString(); |
| 67 } | 69 } |
| 68 | 70 |
| 69 void PrintTo(const RTCPeerConnectionStats& stats, ::std::ostream* os) { | 71 void PrintTo(const RTCPeerConnectionStats& stats, ::std::ostream* os) { |
| 70 *os << stats.ToString(); | 72 *os << stats.ToString(); |
| 71 } | 73 } |
| 72 | 74 |
| 75 void PrintTo(const RTCMediaStreamStats& stats, ::std::ostream* os) { | |
| 76 *os << stats.ToString(); | |
| 77 } | |
| 78 | |
| 79 void PrintTo(const RTCMediaStreamTrackStats& stats, ::std::ostream* os) { | |
| 80 *os << stats.ToString(); | |
| 81 } | |
| 82 | |
| 73 void PrintTo(const RTCInboundRTPStreamStats& stats, ::std::ostream* os) { | 83 void PrintTo(const RTCInboundRTPStreamStats& stats, ::std::ostream* os) { |
| 74 *os << stats.ToString(); | 84 *os << stats.ToString(); |
| 75 } | 85 } |
| 76 | 86 |
| 77 void PrintTo(const RTCOutboundRTPStreamStats& stats, ::std::ostream* os) { | 87 void PrintTo(const RTCOutboundRTPStreamStats& stats, ::std::ostream* os) { |
| 78 *os << stats.ToString(); | 88 *os << stats.ToString(); |
| 79 } | 89 } |
| 80 | 90 |
| 81 void PrintTo(const RTCTransportStats& stats, ::std::ostream* os) { | 91 void PrintTo(const RTCTransportStats& stats, ::std::ostream* os) { |
| 82 *os << stats.ToString(); | 92 *os << stats.ToString(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 const std::string& candidate_type, | 153 const std::string& candidate_type, |
| 144 uint32_t priority) { | 154 uint32_t priority) { |
| 145 std::unique_ptr<cricket::Candidate> candidate(new cricket::Candidate()); | 155 std::unique_ptr<cricket::Candidate> candidate(new cricket::Candidate()); |
| 146 candidate->set_address(rtc::SocketAddress(hostname, port)); | 156 candidate->set_address(rtc::SocketAddress(hostname, port)); |
| 147 candidate->set_protocol(protocol); | 157 candidate->set_protocol(protocol); |
| 148 candidate->set_type(candidate_type); | 158 candidate->set_type(candidate_type); |
| 149 candidate->set_priority(priority); | 159 candidate->set_priority(priority); |
| 150 return candidate; | 160 return candidate; |
| 151 } | 161 } |
| 152 | 162 |
| 163 class FakeAudioProcessorForStats : public AudioProcessorInterface { | |
|
Taylor Brandstetter
2016/11/04 18:19:14
nit: Since these fake objects only exist to return
hbos
2016/11/08 13:43:37
Acknowledged. Leaving as-is.
| |
| 164 public: | |
| 165 static rtc::scoped_refptr<FakeAudioProcessorForStats> Create( | |
| 166 AudioProcessorInterface::AudioProcessorStats stats) { | |
| 167 return rtc::scoped_refptr<FakeAudioProcessorForStats>( | |
| 168 new rtc::RefCountedObject<FakeAudioProcessorForStats>(stats)); | |
| 169 } | |
|
Taylor Brandstetter
2016/11/04 18:19:14
nit: The Create methods here seem redundant. Could
hbos
2016/11/08 13:43:37
Done. Did it for FakeVideoTrackSourceForStats too.
| |
| 170 | |
| 171 FakeAudioProcessorForStats( | |
| 172 AudioProcessorInterface::AudioProcessorStats stats) | |
| 173 : stats_(stats) { | |
| 174 } | |
| 175 | |
| 176 void GetStats(AudioProcessorInterface::AudioProcessorStats* stats) override { | |
| 177 *stats = stats_; | |
| 178 } | |
| 179 | |
| 180 private: | |
| 181 AudioProcessorInterface::AudioProcessorStats stats_; | |
| 182 }; | |
| 183 | |
| 184 class FakeAudioTrackForStats | |
| 185 : public MediaStreamTrack<AudioTrackInterface> { | |
| 186 public: | |
| 187 static rtc::scoped_refptr<FakeAudioTrackForStats> Create( | |
| 188 const std::string& id, | |
| 189 MediaStreamTrackInterface::TrackState state, | |
| 190 int signal_level, | |
| 191 rtc::scoped_refptr<FakeAudioProcessorForStats> processor) { | |
| 192 rtc::scoped_refptr<FakeAudioTrackForStats> audio_track_stats( | |
| 193 new rtc::RefCountedObject<FakeAudioTrackForStats>( | |
| 194 id, signal_level, processor)); | |
| 195 audio_track_stats->set_state(state); | |
| 196 return audio_track_stats; | |
| 197 } | |
| 198 | |
| 199 FakeAudioTrackForStats( | |
| 200 const std::string& id, | |
| 201 int signal_level, | |
| 202 rtc::scoped_refptr<FakeAudioProcessorForStats> processor) | |
| 203 : MediaStreamTrack<AudioTrackInterface>(id), | |
| 204 signal_level_(signal_level), | |
| 205 processor_(processor) { | |
| 206 } | |
| 207 | |
| 208 std::string kind() const override { | |
| 209 return MediaStreamTrackInterface::kAudioKind; | |
| 210 } | |
| 211 webrtc::AudioSourceInterface* GetSource() const override { return nullptr; } | |
| 212 void AddSink(webrtc::AudioTrackSinkInterface* sink) override {} | |
| 213 void RemoveSink(webrtc::AudioTrackSinkInterface* sink) override {} | |
| 214 bool GetSignalLevel(int* level) override { | |
| 215 *level = signal_level_; | |
| 216 return true; | |
| 217 } | |
| 218 rtc::scoped_refptr<AudioProcessorInterface> GetAudioProcessor() override { | |
| 219 return processor_; | |
| 220 } | |
| 221 | |
| 222 private: | |
| 223 int signal_level_; | |
| 224 rtc::scoped_refptr<FakeAudioProcessorForStats> processor_; | |
| 225 }; | |
| 226 | |
| 227 class FakeVideoTrackSourceForStats : public VideoTrackSourceInterface { | |
| 228 public: | |
| 229 static rtc::scoped_refptr<FakeVideoTrackSourceForStats> Create( | |
| 230 VideoTrackSourceInterface::Stats stats) { | |
| 231 return rtc::scoped_refptr<FakeVideoTrackSourceForStats>( | |
| 232 new rtc::RefCountedObject<FakeVideoTrackSourceForStats>(stats)); | |
| 233 } | |
| 234 | |
| 235 FakeVideoTrackSourceForStats(VideoTrackSourceInterface::Stats stats) | |
| 236 : stats_(stats) { | |
| 237 } | |
| 238 | |
| 239 MediaSourceInterface::SourceState state() const override { | |
| 240 return MediaSourceInterface::kLive; | |
| 241 } | |
| 242 bool remote() const override { return false; } | |
| 243 void RegisterObserver(ObserverInterface* observer) override {} | |
| 244 void UnregisterObserver(ObserverInterface* observer) override {} | |
| 245 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink, | |
| 246 const rtc::VideoSinkWants& wants) override {} | |
| 247 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override { | |
| 248 } | |
| 249 bool is_screencast() const override { return false; } | |
| 250 rtc::Optional<bool> needs_denoising() const override { | |
| 251 return rtc::Optional<bool>(); | |
| 252 } | |
| 253 bool GetStats(VideoTrackSourceInterface::Stats* stats) override { | |
| 254 *stats = stats_; | |
| 255 return true; | |
| 256 } | |
| 257 | |
| 258 private: | |
| 259 VideoTrackSourceInterface::Stats stats_; | |
| 260 }; | |
| 261 | |
| 262 class FakeVideoTrackForStats | |
| 263 : public MediaStreamTrack<VideoTrackInterface> { | |
| 264 public: | |
| 265 static rtc::scoped_refptr<FakeVideoTrackForStats> Create( | |
| 266 const std::string& id, | |
| 267 MediaStreamTrackInterface::TrackState state, | |
| 268 rtc::scoped_refptr<VideoTrackSourceInterface> source) { | |
| 269 rtc::scoped_refptr<FakeVideoTrackForStats> video_track( | |
| 270 new rtc::RefCountedObject<FakeVideoTrackForStats>(id, source)); | |
| 271 video_track->set_state(state); | |
| 272 return video_track; | |
| 273 } | |
| 274 | |
| 275 FakeVideoTrackForStats( | |
| 276 const std::string& id, | |
| 277 rtc::scoped_refptr<VideoTrackSourceInterface> source) | |
| 278 : MediaStreamTrack<VideoTrackInterface>(id), | |
| 279 source_(source) { | |
| 280 } | |
| 281 | |
| 282 std::string kind() const override { | |
| 283 return MediaStreamTrackInterface::kVideoKind; | |
| 284 } | |
| 285 VideoTrackSourceInterface* GetSource() const override { | |
| 286 return source_; | |
| 287 } | |
| 288 | |
| 289 private: | |
| 290 rtc::scoped_refptr<VideoTrackSourceInterface> source_; | |
| 291 }; | |
| 292 | |
| 153 class RTCStatsCollectorTestHelper : public SetSessionDescriptionObserver { | 293 class RTCStatsCollectorTestHelper : public SetSessionDescriptionObserver { |
| 154 public: | 294 public: |
| 155 RTCStatsCollectorTestHelper() | 295 RTCStatsCollectorTestHelper() |
| 156 : worker_thread_(rtc::Thread::Current()), | 296 : worker_thread_(rtc::Thread::Current()), |
| 157 network_thread_(rtc::Thread::Current()), | 297 network_thread_(rtc::Thread::Current()), |
| 158 media_engine_(new cricket::FakeMediaEngine()), | 298 media_engine_(new cricket::FakeMediaEngine()), |
| 159 channel_manager_( | 299 channel_manager_( |
| 160 new cricket::ChannelManager(media_engine_, | 300 new cricket::ChannelManager(media_engine_, |
| 161 worker_thread_, | 301 worker_thread_, |
| 162 network_thread_)), | 302 network_thread_)), |
| 163 media_controller_( | 303 media_controller_( |
| 164 MediaControllerInterface::Create(cricket::MediaConfig(), | 304 MediaControllerInterface::Create(cricket::MediaConfig(), |
| 165 worker_thread_, | 305 worker_thread_, |
| 166 channel_manager_.get(), | 306 channel_manager_.get(), |
| 167 &event_log_)), | 307 &event_log_)), |
| 168 session_(media_controller_.get()), | 308 session_(media_controller_.get()), |
| 169 pc_() { | 309 pc_() { |
| 170 // Default return values for mocks. | 310 // Default return values for mocks. |
| 311 EXPECT_CALL(pc_, local_streams()).WillRepeatedly(Return(nullptr)); | |
| 312 EXPECT_CALL(pc_, remote_streams()).WillRepeatedly(Return(nullptr)); | |
| 171 EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_)); | 313 EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_)); |
| 172 EXPECT_CALL(pc_, sctp_data_channels()).WillRepeatedly( | 314 EXPECT_CALL(pc_, sctp_data_channels()).WillRepeatedly( |
| 173 ReturnRef(data_channels_)); | 315 ReturnRef(data_channels_)); |
| 174 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); | 316 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull()); |
| 175 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); | 317 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull()); |
| 176 EXPECT_CALL(session_, GetTransportStats(_)).WillRepeatedly(Return(false)); | 318 EXPECT_CALL(session_, GetTransportStats(_)).WillRepeatedly(Return(false)); |
| 177 EXPECT_CALL(session_, GetLocalCertificate(_, _)).WillRepeatedly( | 319 EXPECT_CALL(session_, GetLocalCertificate(_, _)).WillRepeatedly( |
| 178 Return(false)); | 320 Return(false)); |
| 179 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) | 321 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) |
| 180 .WillRepeatedly(Return(nullptr)); | 322 .WillRepeatedly(Return(nullptr)); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 191 } | 333 } |
| 192 | 334 |
| 193 // SetSessionDescriptionObserver overrides. | 335 // SetSessionDescriptionObserver overrides. |
| 194 void OnSuccess() override {} | 336 void OnSuccess() override {} |
| 195 void OnFailure(const std::string& error) override { | 337 void OnFailure(const std::string& error) override { |
| 196 RTC_NOTREACHED() << error; | 338 RTC_NOTREACHED() << error; |
| 197 } | 339 } |
| 198 | 340 |
| 199 private: | 341 private: |
| 200 rtc::ScopedFakeClock fake_clock_; | 342 rtc::ScopedFakeClock fake_clock_; |
| 201 webrtc::RtcEventLogNullImpl event_log_; | 343 RtcEventLogNullImpl event_log_; |
| 202 rtc::Thread* const worker_thread_; | 344 rtc::Thread* const worker_thread_; |
| 203 rtc::Thread* const network_thread_; | 345 rtc::Thread* const network_thread_; |
| 204 cricket::FakeMediaEngine* media_engine_; | 346 cricket::FakeMediaEngine* media_engine_; |
| 205 std::unique_ptr<cricket::ChannelManager> channel_manager_; | 347 std::unique_ptr<cricket::ChannelManager> channel_manager_; |
| 206 std::unique_ptr<webrtc::MediaControllerInterface> media_controller_; | 348 std::unique_ptr<MediaControllerInterface> media_controller_; |
| 207 MockWebRtcSession session_; | 349 MockWebRtcSession session_; |
| 208 MockPeerConnection pc_; | 350 MockPeerConnection pc_; |
| 209 | 351 |
| 210 std::vector<rtc::scoped_refptr<DataChannel>> data_channels_; | 352 std::vector<rtc::scoped_refptr<DataChannel>> data_channels_; |
| 211 }; | 353 }; |
| 212 | 354 |
| 213 class RTCTestStats : public RTCStats { | 355 class RTCTestStats : public RTCStats { |
| 214 public: | 356 public: |
| 215 WEBRTC_RTCSTATS_DECL(); | 357 WEBRTC_RTCSTATS_DECL(); |
| 216 | 358 |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 972 // channels that have been opened and closed, not the numbers currently | 1114 // channels that have been opened and closed, not the numbers currently |
| 973 // open/closed, we would expect opened >= closed and (opened - closed) to be | 1115 // open/closed, we would expect opened >= closed and (opened - closed) to be |
| 974 // the number currently open. crbug.com/636818. | 1116 // the number currently open. crbug.com/636818. |
| 975 const RTCPeerConnectionStats& pcstats = | 1117 const RTCPeerConnectionStats& pcstats = |
| 976 stats->cast_to<RTCPeerConnectionStats>(); | 1118 stats->cast_to<RTCPeerConnectionStats>(); |
| 977 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(1)); | 1119 EXPECT_EQ(*pcstats.data_channels_opened, static_cast<uint32_t>(1)); |
| 978 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(3)); | 1120 EXPECT_EQ(*pcstats.data_channels_closed, static_cast<uint32_t>(3)); |
| 979 } | 1121 } |
| 980 } | 1122 } |
| 981 | 1123 |
| 1124 TEST_F(RTCStatsCollectorTest, | |
| 1125 CollectRTCMediaStreamStatsAndRTCMediaStreamTrackStats_Audio) { | |
| 1126 rtc::scoped_refptr<StreamCollection> local_streams = | |
| 1127 StreamCollection::Create(); | |
| 1128 rtc::scoped_refptr<StreamCollection> remote_streams = | |
| 1129 StreamCollection::Create(); | |
| 1130 EXPECT_CALL(test_->pc(), local_streams()) | |
| 1131 .WillRepeatedly(Return(local_streams)); | |
| 1132 EXPECT_CALL(test_->pc(), remote_streams()) | |
| 1133 .WillRepeatedly(Return(remote_streams)); | |
| 1134 | |
| 1135 rtc::scoped_refptr<MediaStream> local_stream = | |
| 1136 MediaStream::Create("LocalStreamLabel"); | |
| 1137 local_streams->AddStream(local_stream); | |
| 1138 rtc::scoped_refptr<MediaStream> remote_stream = | |
| 1139 MediaStream::Create("RemoteStreamLabel"); | |
| 1140 remote_streams->AddStream(remote_stream); | |
| 1141 | |
| 1142 // Local audio track | |
| 1143 AudioProcessorInterface::AudioProcessorStats local_audio_processor_stats; | |
| 1144 local_audio_processor_stats.echo_return_loss = 42; | |
| 1145 local_audio_processor_stats.echo_return_loss_enhancement = 52; | |
| 1146 rtc::scoped_refptr<FakeAudioTrackForStats> local_audio_track = | |
| 1147 FakeAudioTrackForStats::Create( | |
| 1148 "LocalAudioTrackID", | |
| 1149 MediaStreamTrackInterface::TrackState::kEnded, | |
| 1150 32767, | |
| 1151 FakeAudioProcessorForStats::Create(local_audio_processor_stats)); | |
| 1152 local_stream->AddTrack(local_audio_track); | |
| 1153 | |
| 1154 // Remote audio track | |
| 1155 AudioProcessorInterface::AudioProcessorStats remote_audio_processor_stats; | |
| 1156 remote_audio_processor_stats.echo_return_loss = 13; | |
| 1157 remote_audio_processor_stats.echo_return_loss_enhancement = 37; | |
| 1158 rtc::scoped_refptr<FakeAudioTrackForStats> remote_audio_track = | |
| 1159 FakeAudioTrackForStats::Create( | |
| 1160 "RemoteAudioTrackID", | |
| 1161 MediaStreamTrackInterface::TrackState::kLive, | |
| 1162 0, | |
| 1163 FakeAudioProcessorForStats::Create(remote_audio_processor_stats)); | |
| 1164 remote_stream->AddTrack(remote_audio_track); | |
| 1165 | |
| 1166 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | |
| 1167 | |
| 1168 RTCMediaStreamStats expected_local_stream( | |
| 1169 "RTCMediaStream_LocalStreamLabel", report->timestamp_us()); | |
| 1170 expected_local_stream.stream_identifier = "LocalStreamLabel"; | |
| 1171 expected_local_stream.track_ids = std::vector<std::string>(); | |
| 1172 expected_local_stream.track_ids->push_back( | |
| 1173 "RTCMediaStreamTrack_LocalAudioTrackID"); | |
| 1174 EXPECT_TRUE(report->Get(expected_local_stream.id())); | |
| 1175 EXPECT_EQ(expected_local_stream, | |
| 1176 report->Get(expected_local_stream.id())->cast_to< | |
| 1177 RTCMediaStreamStats>()); | |
| 1178 | |
| 1179 RTCMediaStreamStats expected_remote_stream( | |
| 1180 "RTCMediaStream_RemoteStreamLabel", report->timestamp_us()); | |
| 1181 expected_remote_stream.stream_identifier = "RemoteStreamLabel"; | |
| 1182 expected_remote_stream.track_ids = std::vector<std::string>(); | |
| 1183 expected_remote_stream.track_ids->push_back( | |
| 1184 "RTCMediaStreamTrack_RemoteAudioTrackID"); | |
| 1185 EXPECT_TRUE(report->Get(expected_remote_stream.id())); | |
| 1186 EXPECT_EQ(expected_remote_stream, | |
| 1187 report->Get(expected_remote_stream.id())->cast_to< | |
| 1188 RTCMediaStreamStats>()); | |
| 1189 | |
| 1190 RTCMediaStreamTrackStats expected_local_audio_track( | |
| 1191 "RTCMediaStreamTrack_LocalAudioTrackID", report->timestamp_us()); | |
| 1192 expected_local_audio_track.track_identifier = "LocalAudioTrackID"; | |
| 1193 expected_local_audio_track.remote_source = false; | |
| 1194 expected_local_audio_track.ended = true; | |
| 1195 expected_local_audio_track.detached = false; | |
| 1196 expected_local_audio_track.audio_level = 1.0; | |
| 1197 expected_local_audio_track.echo_return_loss = 42.0; | |
| 1198 expected_local_audio_track.echo_return_loss_enhancement = 52.0; | |
| 1199 EXPECT_TRUE(report->Get(expected_local_audio_track.id())); | |
| 1200 EXPECT_EQ(expected_local_audio_track, | |
| 1201 report->Get(expected_local_audio_track.id())->cast_to< | |
| 1202 RTCMediaStreamTrackStats>()); | |
| 1203 | |
| 1204 RTCMediaStreamTrackStats expected_remote_audio_track( | |
| 1205 "RTCMediaStreamTrack_RemoteAudioTrackID", report->timestamp_us()); | |
| 1206 expected_remote_audio_track.track_identifier = "RemoteAudioTrackID"; | |
| 1207 expected_remote_audio_track.remote_source = true; | |
| 1208 expected_remote_audio_track.ended = false; | |
| 1209 expected_remote_audio_track.detached = false; | |
| 1210 expected_remote_audio_track.audio_level = 0.0; | |
| 1211 expected_remote_audio_track.echo_return_loss = 13.0; | |
| 1212 expected_remote_audio_track.echo_return_loss_enhancement = 37.0; | |
| 1213 EXPECT_TRUE(report->Get(expected_remote_audio_track.id())); | |
| 1214 EXPECT_EQ(expected_remote_audio_track, | |
| 1215 report->Get(expected_remote_audio_track.id())->cast_to< | |
| 1216 RTCMediaStreamTrackStats>()); | |
| 1217 } | |
| 1218 | |
| 1219 TEST_F(RTCStatsCollectorTest, | |
| 1220 CollectRTCMediaStreamStatsAndRTCMediaStreamTrackStats_Video) { | |
| 1221 rtc::scoped_refptr<StreamCollection> local_streams = | |
| 1222 StreamCollection::Create(); | |
| 1223 rtc::scoped_refptr<StreamCollection> remote_streams = | |
| 1224 StreamCollection::Create(); | |
| 1225 EXPECT_CALL(test_->pc(), local_streams()) | |
| 1226 .WillRepeatedly(Return(local_streams)); | |
| 1227 EXPECT_CALL(test_->pc(), remote_streams()) | |
| 1228 .WillRepeatedly(Return(remote_streams)); | |
| 1229 | |
| 1230 rtc::scoped_refptr<MediaStream> local_stream = | |
| 1231 MediaStream::Create("LocalStreamLabel"); | |
| 1232 local_streams->AddStream(local_stream); | |
| 1233 rtc::scoped_refptr<MediaStream> remote_stream = | |
| 1234 MediaStream::Create("RemoteStreamLabel"); | |
| 1235 remote_streams->AddStream(remote_stream); | |
| 1236 | |
| 1237 // Local video track | |
| 1238 VideoTrackSourceInterface::Stats local_video_track_source_stats; | |
| 1239 local_video_track_source_stats.input_width = 1234; | |
| 1240 local_video_track_source_stats.input_height = 4321; | |
| 1241 rtc::scoped_refptr<FakeVideoTrackSourceForStats> local_video_track_source = | |
| 1242 FakeVideoTrackSourceForStats::Create(local_video_track_source_stats); | |
| 1243 rtc::scoped_refptr<FakeVideoTrackForStats> local_video_track = | |
| 1244 FakeVideoTrackForStats::Create( | |
| 1245 "LocalVideoTrackID", | |
| 1246 MediaStreamTrackInterface::TrackState::kLive, | |
| 1247 local_video_track_source); | |
| 1248 local_stream->AddTrack(local_video_track); | |
| 1249 | |
| 1250 // Remote video track | |
| 1251 VideoTrackSourceInterface::Stats remote_video_track_source_stats; | |
| 1252 remote_video_track_source_stats.input_width = 1234; | |
| 1253 remote_video_track_source_stats.input_height = 4321; | |
| 1254 rtc::scoped_refptr<FakeVideoTrackSourceForStats> remote_video_track_source = | |
| 1255 FakeVideoTrackSourceForStats::Create(remote_video_track_source_stats); | |
| 1256 rtc::scoped_refptr<FakeVideoTrackForStats> remote_video_track = | |
| 1257 FakeVideoTrackForStats::Create( | |
| 1258 "RemoteVideoTrackID", | |
| 1259 MediaStreamTrackInterface::TrackState::kEnded, | |
| 1260 remote_video_track_source); | |
| 1261 remote_stream->AddTrack(remote_video_track); | |
| 1262 | |
| 1263 rtc::scoped_refptr<const RTCStatsReport> report = GetStatsReport(); | |
| 1264 | |
| 1265 RTCMediaStreamStats expected_local_stream( | |
| 1266 "RTCMediaStream_LocalStreamLabel", report->timestamp_us()); | |
| 1267 expected_local_stream.stream_identifier = "LocalStreamLabel"; | |
| 1268 expected_local_stream.track_ids = std::vector<std::string>(); | |
| 1269 expected_local_stream.track_ids->push_back( | |
| 1270 "RTCMediaStreamTrack_LocalVideoTrackID"); | |
| 1271 EXPECT_TRUE(report->Get(expected_local_stream.id())); | |
| 1272 EXPECT_EQ(expected_local_stream, | |
| 1273 report->Get(expected_local_stream.id())->cast_to< | |
| 1274 RTCMediaStreamStats>()); | |
| 1275 | |
| 1276 RTCMediaStreamStats expected_remote_stream( | |
| 1277 "RTCMediaStream_RemoteStreamLabel", report->timestamp_us()); | |
| 1278 expected_remote_stream.stream_identifier = "RemoteStreamLabel"; | |
| 1279 expected_remote_stream.track_ids = std::vector<std::string>(); | |
| 1280 expected_remote_stream.track_ids->push_back( | |
| 1281 "RTCMediaStreamTrack_RemoteVideoTrackID"); | |
| 1282 EXPECT_TRUE(report->Get(expected_remote_stream.id())); | |
| 1283 EXPECT_EQ(expected_remote_stream, | |
| 1284 report->Get(expected_remote_stream.id())->cast_to< | |
| 1285 RTCMediaStreamStats>()); | |
| 1286 | |
| 1287 RTCMediaStreamTrackStats expected_local_video_track( | |
| 1288 "RTCMediaStreamTrack_LocalVideoTrackID", report->timestamp_us()); | |
| 1289 expected_local_video_track.track_identifier = "LocalVideoTrackID"; | |
| 1290 expected_local_video_track.remote_source = false; | |
| 1291 expected_local_video_track.ended = false; | |
| 1292 expected_local_video_track.detached = false; | |
| 1293 expected_local_video_track.frame_width = 1234; | |
| 1294 expected_local_video_track.frame_height = 4321; | |
| 1295 EXPECT_TRUE(report->Get(expected_local_video_track.id())); | |
| 1296 EXPECT_EQ(expected_local_video_track, | |
| 1297 report->Get(expected_local_video_track.id())->cast_to< | |
| 1298 RTCMediaStreamTrackStats>()); | |
| 1299 | |
| 1300 RTCMediaStreamTrackStats expected_remote_video_track( | |
| 1301 "RTCMediaStreamTrack_RemoteVideoTrackID", report->timestamp_us()); | |
| 1302 expected_remote_video_track.track_identifier = "RemoteVideoTrackID"; | |
|
hta-webrtc
2016/11/08 09:50:22
Would it be clearer to use remote_video_track->id
hbos
2016/11/08 13:43:37
Done, updated all "blah_identifiers" (but not RTCS
| |
| 1303 expected_remote_video_track.remote_source = true; | |
| 1304 expected_remote_video_track.ended = true; | |
| 1305 expected_remote_video_track.detached = false; | |
| 1306 expected_remote_video_track.frame_width = 1234; | |
| 1307 expected_remote_video_track.frame_height = 4321; | |
| 1308 EXPECT_TRUE(report->Get(expected_remote_video_track.id())); | |
| 1309 EXPECT_EQ(expected_remote_video_track, | |
| 1310 report->Get(expected_remote_video_track.id())->cast_to< | |
| 1311 RTCMediaStreamTrackStats>()); | |
| 1312 } | |
| 1313 | |
| 982 TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) { | 1314 TEST_F(RTCStatsCollectorTest, CollectRTCInboundRTPStreamStats_Audio) { |
| 983 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); | 1315 MockVoiceMediaChannel* voice_media_channel = new MockVoiceMediaChannel(); |
| 984 cricket::VoiceChannel voice_channel( | 1316 cricket::VoiceChannel voice_channel( |
| 985 test_->worker_thread(), test_->network_thread(), test_->media_engine(), | 1317 test_->worker_thread(), test_->network_thread(), test_->media_engine(), |
| 986 voice_media_channel, nullptr, "VoiceContentName", false); | 1318 voice_media_channel, nullptr, "VoiceContentName", false); |
| 987 | 1319 |
| 988 cricket::VoiceMediaInfo voice_media_info; | 1320 cricket::VoiceMediaInfo voice_media_info; |
| 989 voice_media_info.receivers.push_back(cricket::VoiceReceiverInfo()); | 1321 voice_media_info.receivers.push_back(cricket::VoiceReceiverInfo()); |
| 990 voice_media_info.receivers[0].local_stats.push_back( | 1322 voice_media_info.receivers[0].local_stats.push_back( |
| 991 cricket::SsrcReceiverInfo()); | 1323 cricket::SsrcReceiverInfo()); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1313 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; | 1645 rtc::scoped_refptr<FakeRTCStatsCollector> collector_; |
| 1314 }; | 1646 }; |
| 1315 | 1647 |
| 1316 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { | 1648 TEST_F(RTCStatsCollectorTestWithFakeCollector, ThreadUsageAndResultsMerging) { |
| 1317 collector_->VerifyThreadUsageAndResultsMerging(); | 1649 collector_->VerifyThreadUsageAndResultsMerging(); |
| 1318 } | 1650 } |
| 1319 | 1651 |
| 1320 } // namespace | 1652 } // namespace |
| 1321 | 1653 |
| 1322 } // namespace webrtc | 1654 } // namespace webrtc |
| OLD | NEW |