OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 55 matching lines...) Loading... | |
66 frames_to_process_(duration_frames), | 66 frames_to_process_(duration_frames), |
67 frames_recorded_(0), | 67 frames_recorded_(0), |
68 frames_processed_(0), | 68 frames_processed_(0), |
69 dropped_frames_(0), | 69 dropped_frames_(0), |
70 last_render_time_(0), | 70 last_render_time_(0), |
71 rtp_timestamp_delta_(0), | 71 rtp_timestamp_delta_(0), |
72 avg_psnr_threshold_(avg_psnr_threshold), | 72 avg_psnr_threshold_(avg_psnr_threshold), |
73 avg_ssim_threshold_(avg_ssim_threshold), | 73 avg_ssim_threshold_(avg_ssim_threshold), |
74 stats_polling_thread_(&PollStatsThread, this, "StatsPoller"), | 74 stats_polling_thread_(&PollStatsThread, this, "StatsPoller"), |
75 comparison_available_event_(false, false), | 75 comparison_available_event_(false, false), |
76 done_(false, false) { | 76 done_(true, false) { |
77 // Create thread pool for CPU-expensive PSNR/SSIM calculations. | 77 // Create thread pool for CPU-expensive PSNR/SSIM calculations. |
78 | 78 |
79 // Try to use about as many threads as cores, but leave kMinCoresLeft alone, | 79 // Try to use about as many threads as cores, but leave kMinCoresLeft alone, |
80 // so that we don't accidentally starve "real" worker threads (codec etc). | 80 // so that we don't accidentally starve "real" worker threads (codec etc). |
81 // Also, don't allocate more than kMaxComparisonThreads, even if there are | 81 // Also, don't allocate more than kMaxComparisonThreads, even if there are |
82 // spare cores. | 82 // spare cores. |
83 | 83 |
84 uint32_t num_cores = CpuInfo::DetectNumberOfCores(); | 84 uint32_t num_cores = CpuInfo::DetectNumberOfCores(); |
85 RTC_DCHECK_GE(num_cores, 1u); | 85 RTC_DCHECK_GE(num_cores, 1u); |
86 static const uint32_t kMinCoresLeft = 4; | 86 static const uint32_t kMinCoresLeft = 4; |
(...skipping 149 matching lines...) Loading... | |
236 const char* kKeepAliveMessages[3] = { | 236 const char* kKeepAliveMessages[3] = { |
237 "Uh, I'm-I'm not quite dead, sir.", | 237 "Uh, I'm-I'm not quite dead, sir.", |
238 "Uh, I-I think uh, I could pull through, sir.", | 238 "Uh, I-I think uh, I could pull through, sir.", |
239 "Actually, I think I'm all right to come with you--"}; | 239 "Actually, I think I'm all right to come with you--"}; |
240 printf("- %s\n", kKeepAliveMessages[iteration++ % 3]); | 240 printf("- %s\n", kKeepAliveMessages[iteration++ % 3]); |
241 | 241 |
242 if (last_frames_processed == -1) { | 242 if (last_frames_processed == -1) { |
243 last_frames_processed = frames_processed; | 243 last_frames_processed = frames_processed; |
244 continue; | 244 continue; |
245 } | 245 } |
246 ASSERT_GT(frames_processed, last_frames_processed) | 246 if (frames_processed == last_frames_processed) { |
pbos-webrtc
2016/01/19 13:37:28
This ASSERT caused the function to abort before st
| |
247 << "Analyzer stalled while waiting for test to finish."; | 247 EXPECT_GT(frames_processed, last_frames_processed) |
248 << "Analyzer stalled while waiting for test to finish."; | |
249 done_.Set(); | |
250 break; | |
251 } | |
248 last_frames_processed = frames_processed; | 252 last_frames_processed = frames_processed; |
249 } | 253 } |
250 | 254 |
251 if (iteration > 0) | 255 if (iteration > 0) |
252 printf("- Farewell, sweet Concorde!\n"); | 256 printf("- Farewell, sweet Concorde!\n"); |
253 | 257 |
254 // Signal stats polling thread if that is still waiting and stop it now, | |
255 // since it uses the send_stream_ reference that might be reclaimed after | |
256 // returning from this method. | |
257 done_.Set(); | |
258 stats_polling_thread_.Stop(); | 258 stats_polling_thread_.Stop(); |
259 } | 259 } |
260 | 260 |
261 VideoCaptureInput* input_; | 261 VideoCaptureInput* input_; |
262 test::LayerFilteringTransport* const transport_; | 262 test::LayerFilteringTransport* const transport_; |
263 PacketReceiver* receiver_; | 263 PacketReceiver* receiver_; |
264 VideoSendStream* send_stream_; | 264 VideoSendStream* send_stream_; |
265 | 265 |
266 private: | 266 private: |
267 struct FrameComparison { | 267 struct FrameComparison { |
(...skipping 84 matching lines...) Loading... | |
352 send_time_ms, recv_time_ms, | 352 send_time_ms, recv_time_ms, |
353 render_time_ms, encoded_size)); | 353 render_time_ms, encoded_size)); |
354 comparison_available_event_.Set(); | 354 comparison_available_event_.Set(); |
355 } | 355 } |
356 | 356 |
357 static bool PollStatsThread(void* obj) { | 357 static bool PollStatsThread(void* obj) { |
358 return static_cast<VideoAnalyzer*>(obj)->PollStats(); | 358 return static_cast<VideoAnalyzer*>(obj)->PollStats(); |
359 } | 359 } |
360 | 360 |
361 bool PollStats() { | 361 bool PollStats() { |
362 if (done_.Wait(kSendStatsPollingIntervalMs)) { | 362 if (done_.Wait(kSendStatsPollingIntervalMs)) |
363 // Set event again to make sure main thread is also signaled, then we're | |
364 // done. | |
365 done_.Set(); | |
366 return false; | 363 return false; |
367 } | |
368 | 364 |
369 VideoSendStream::Stats stats = send_stream_->GetStats(); | 365 VideoSendStream::Stats stats = send_stream_->GetStats(); |
370 | 366 |
371 rtc::CritScope crit(&comparison_lock_); | 367 rtc::CritScope crit(&comparison_lock_); |
372 encode_frame_rate_.AddSample(stats.encode_frame_rate); | 368 encode_frame_rate_.AddSample(stats.encode_frame_rate); |
373 encode_time_ms.AddSample(stats.avg_encode_time_ms); | 369 encode_time_ms.AddSample(stats.avg_encode_time_ms); |
374 encode_usage_percent.AddSample(stats.encode_usage_percent); | 370 encode_usage_percent.AddSample(stats.encode_usage_percent); |
375 media_bitrate_bps.AddSample(stats.media_bitrate_bps); | 371 media_bitrate_bps.AddSample(stats.media_bitrate_bps); |
376 | 372 |
377 return true; | 373 return true; |
(...skipping 686 matching lines...) Loading... | |
1064 video_send_stream_->Stop(); | 1060 video_send_stream_->Stop(); |
1065 receive_stream->Stop(); | 1061 receive_stream->Stop(); |
1066 | 1062 |
1067 call->DestroyVideoReceiveStream(receive_stream); | 1063 call->DestroyVideoReceiveStream(receive_stream); |
1068 call->DestroyVideoSendStream(video_send_stream_); | 1064 call->DestroyVideoSendStream(video_send_stream_); |
1069 | 1065 |
1070 transport.StopSending(); | 1066 transport.StopSending(); |
1071 } | 1067 } |
1072 | 1068 |
1073 } // namespace webrtc | 1069 } // namespace webrtc |
OLD | NEW |