Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: webrtc/api/rtcstatscollector.cc

Issue 2489693002: Don't copy loop variables when we don't have to (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 return; 243 return;
244 for (size_t i = 0; i < streams->count(); ++i) { 244 for (size_t i = 0; i < streams->count(); ++i) {
245 MediaStreamInterface* stream = streams->at(i); 245 MediaStreamInterface* stream = streams->at(i);
246 246
247 std::unique_ptr<RTCMediaStreamStats> stream_stats( 247 std::unique_ptr<RTCMediaStreamStats> stream_stats(
248 new RTCMediaStreamStats("RTCMediaStream_" + stream->label(), 248 new RTCMediaStreamStats("RTCMediaStream_" + stream->label(),
249 timestamp_us)); 249 timestamp_us));
250 stream_stats->stream_identifier = stream->label(); 250 stream_stats->stream_identifier = stream->label();
251 stream_stats->track_ids = std::vector<std::string>(); 251 stream_stats->track_ids = std::vector<std::string>();
252 // Audio Tracks 252 // Audio Tracks
253 for (rtc::scoped_refptr<AudioTrackInterface> audio_track : 253 for (const rtc::scoped_refptr<AudioTrackInterface>& audio_track :
254 stream->GetAudioTracks()) { 254 stream->GetAudioTracks()) {
255 std::string id = RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( 255 std::string id = RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface(
256 *audio_track.get()); 256 *audio_track.get());
257 if (report->Get(id)) { 257 if (report->Get(id)) {
258 // Skip track, stats already exist for it. 258 // Skip track, stats already exist for it.
259 continue; 259 continue;
260 } 260 }
261 std::unique_ptr<RTCMediaStreamTrackStats> audio_track_stats( 261 std::unique_ptr<RTCMediaStreamTrackStats> audio_track_stats(
262 new RTCMediaStreamTrackStats(id, timestamp_us)); 262 new RTCMediaStreamTrackStats(id, timestamp_us));
263 stream_stats->track_ids->push_back(audio_track_stats->id()); 263 stream_stats->track_ids->push_back(audio_track_stats->id());
(...skipping 13 matching lines...) Expand all
277 AudioProcessorInterface::AudioProcessorStats audio_processor_stats; 277 AudioProcessorInterface::AudioProcessorStats audio_processor_stats;
278 audio_track->GetAudioProcessor()->GetStats(&audio_processor_stats); 278 audio_track->GetAudioProcessor()->GetStats(&audio_processor_stats);
279 audio_track_stats->echo_return_loss = static_cast<double>( 279 audio_track_stats->echo_return_loss = static_cast<double>(
280 audio_processor_stats.echo_return_loss); 280 audio_processor_stats.echo_return_loss);
281 audio_track_stats->echo_return_loss_enhancement = static_cast<double>( 281 audio_track_stats->echo_return_loss_enhancement = static_cast<double>(
282 audio_processor_stats.echo_return_loss_enhancement); 282 audio_processor_stats.echo_return_loss_enhancement);
283 } 283 }
284 report->AddStats(std::move(audio_track_stats)); 284 report->AddStats(std::move(audio_track_stats));
285 } 285 }
286 // Video Tracks 286 // Video Tracks
287 for (rtc::scoped_refptr<VideoTrackInterface> video_track : 287 for (const rtc::scoped_refptr<VideoTrackInterface>& video_track :
288 stream->GetVideoTracks()) { 288 stream->GetVideoTracks()) {
289 std::string id = RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface( 289 std::string id = RTCMediaStreamTrackStatsIDFromMediaStreamTrackInterface(
290 *video_track.get()); 290 *video_track.get());
291 if (report->Get(id)) { 291 if (report->Get(id)) {
292 // Skip track, stats already exist for it. 292 // Skip track, stats already exist for it.
293 continue; 293 continue;
294 } 294 }
295 std::unique_ptr<RTCMediaStreamTrackStats> video_track_stats( 295 std::unique_ptr<RTCMediaStreamTrackStats> video_track_stats(
296 new RTCMediaStreamTrackStats(id, timestamp_us)); 296 new RTCMediaStreamTrackStats(id, timestamp_us));
297 stream_stats->track_ids->push_back(video_track_stats->id()); 297 stream_stats->track_ids->push_back(video_track_stats->id());
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 const std::string& type) { 790 const std::string& type) {
791 return CandidateTypeToRTCIceCandidateType(type); 791 return CandidateTypeToRTCIceCandidateType(type);
792 } 792 }
793 793
794 const char* DataStateToRTCDataChannelStateForTesting( 794 const char* DataStateToRTCDataChannelStateForTesting(
795 DataChannelInterface::DataState state) { 795 DataChannelInterface::DataState state) {
796 return DataStateToRTCDataChannelState(state); 796 return DataStateToRTCDataChannelState(state);
797 } 797 }
798 798
799 } // namespace webrtc 799 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698