| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <deque> | 5 #include <deque> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 } | 277 } |
| 278 | 278 |
| 279 // Pass some empty frames through the encoder. | 279 // Pass some empty frames through the encoder. |
| 280 for (int i = 0; i < 10; ++i) { | 280 for (int i = 0; i < 10; ++i) { |
| 281 TestEncodingRects(encoder, &tester, frame.get(), nullptr, 0); | 281 TestEncodingRects(encoder, &tester, frame.get(), nullptr, 0); |
| 282 } | 282 } |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 | 286 |
| 287 void TestVideoEncoderEmptyFrames(VideoEncoder* encoder, int topoff_frames) { | 287 void TestVideoEncoderEmptyFrames(VideoEncoder* encoder, |
| 288 int expected_topoff_frames) { |
| 288 const DesktopSize kSize(640, 480); | 289 const DesktopSize kSize(640, 480); |
| 289 scoped_ptr<DesktopFrame> frame(PrepareFrame(kSize)); | 290 scoped_ptr<DesktopFrame> frame(PrepareFrame(kSize)); |
| 290 | 291 |
| 291 frame->mutable_updated_region()->SetRect( | 292 frame->mutable_updated_region()->SetRect( |
| 292 webrtc::DesktopRect::MakeSize(kSize)); | 293 webrtc::DesktopRect::MakeSize(kSize)); |
| 293 EXPECT_TRUE(encoder->Encode(*frame)); | 294 EXPECT_TRUE(encoder->Encode(*frame)); |
| 294 | 295 |
| 296 int topoff_frames = 0; |
| 295 frame->mutable_updated_region()->Clear(); | 297 frame->mutable_updated_region()->Clear(); |
| 296 for (int i=0; i < topoff_frames; ++i) { | 298 for (int i = 0; i < expected_topoff_frames + 1; ++i) { |
| 297 EXPECT_TRUE(encoder->Encode(*frame)); | 299 if (!encoder->Encode(*frame)) |
| 300 break; |
| 301 topoff_frames++; |
| 298 } | 302 } |
| 299 | 303 |
| 300 EXPECT_FALSE(encoder->Encode(*frame)); | 304 EXPECT_EQ(topoff_frames, expected_topoff_frames); |
| 301 } | 305 } |
| 302 | 306 |
| 303 static void TestEncodeDecodeRects(VideoEncoder* encoder, | 307 static void TestEncodeDecodeRects(VideoEncoder* encoder, |
| 304 VideoEncoderTester* encoder_tester, | 308 VideoEncoderTester* encoder_tester, |
| 305 VideoDecoderTester* decoder_tester, | 309 VideoDecoderTester* decoder_tester, |
| 306 DesktopFrame* frame, | 310 DesktopFrame* frame, |
| 307 const DesktopRect* rects, int count) { | 311 const DesktopRect* rects, int count) { |
| 308 frame->mutable_updated_region()->Clear(); | 312 frame->mutable_updated_region()->Clear(); |
| 309 for (int i = 0; i < count; ++i) { | 313 for (int i = 0; i < count; ++i) { |
| 310 frame->mutable_updated_region()->AddRect(rects[i]); | 314 frame->mutable_updated_region()->AddRect(rects[i]); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 | 446 |
| 443 if (frame_count >= kWarmUpFrameCount) { | 447 if (frame_count >= kWarmUpFrameCount) { |
| 444 elapsed = base::TimeTicks::Now() - start_time; | 448 elapsed = base::TimeTicks::Now() - start_time; |
| 445 } | 449 } |
| 446 } | 450 } |
| 447 | 451 |
| 448 return (frame_count * base::TimeDelta::FromSeconds(1)) / elapsed; | 452 return (frame_count * base::TimeDelta::FromSeconds(1)) / elapsed; |
| 449 } | 453 } |
| 450 | 454 |
| 451 } // namespace remoting | 455 } // namespace remoting |
| OLD | NEW |