OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "gfx/rect.h" | 8 #include "gfx/rect.h" |
9 #include "media/base/video_frame.h" | 9 #include "media/base/video_frame.h" |
10 #include "remoting/base/codec_test.h" | 10 #include "remoting/base/codec_test.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 scoped_refptr<CaptureData> data = | 332 scoped_refptr<CaptureData> data = |
333 new CaptureData(planes, kWidth, kHeight, format); | 333 new CaptureData(planes, kWidth, kHeight, format); |
334 return data; | 334 return data; |
335 } | 335 } |
336 | 336 |
337 static void TestEncodingRects(Encoder* encoder, | 337 static void TestEncodingRects(Encoder* encoder, |
338 EncoderTester* tester, | 338 EncoderTester* tester, |
339 scoped_refptr<CaptureData> data, | 339 scoped_refptr<CaptureData> data, |
340 const gfx::Rect* rects, int count) { | 340 const gfx::Rect* rects, int count) { |
341 data->mutable_dirty_rects().clear(); | 341 data->mutable_dirty_rects().clear(); |
342 data->mutable_dirty_rects().insert( | 342 for (int i = 0; i < count; ++i) { |
343 data->mutable_dirty_rects().begin(), rects, rects + count); | 343 data->mutable_dirty_rects().insert(rects[i]); |
| 344 } |
344 tester->AddRects(rects, count); | 345 tester->AddRects(rects, count); |
345 | 346 |
346 encoder->Encode(data, true, | 347 encoder->Encode(data, true, |
347 NewCallback(tester, &EncoderTester::DataAvailable)); | 348 NewCallback(tester, &EncoderTester::DataAvailable)); |
348 } | 349 } |
349 | 350 |
350 void TestEncoder(Encoder* encoder, bool strict) { | 351 void TestEncoder(Encoder* encoder, bool strict) { |
351 EncoderMessageTester message_tester; | 352 EncoderMessageTester message_tester; |
352 message_tester.set_strict(strict); | 353 message_tester.set_strict(strict); |
353 | 354 |
(...skipping 10 matching lines...) Expand all Loading... |
364 TestEncodingRects(encoder, &tester, data, kTestRects + 3, 2); | 365 TestEncodingRects(encoder, &tester, data, kTestRects + 3, 2); |
365 delete [] memory; | 366 delete [] memory; |
366 } | 367 } |
367 | 368 |
368 static void TestEncodingRects(Encoder* encoder, | 369 static void TestEncodingRects(Encoder* encoder, |
369 EncoderTester* encoder_tester, | 370 EncoderTester* encoder_tester, |
370 DecoderTester* decoder_tester, | 371 DecoderTester* decoder_tester, |
371 scoped_refptr<CaptureData> data, | 372 scoped_refptr<CaptureData> data, |
372 const gfx::Rect* rects, int count) { | 373 const gfx::Rect* rects, int count) { |
373 data->mutable_dirty_rects().clear(); | 374 data->mutable_dirty_rects().clear(); |
374 data->mutable_dirty_rects().insert( | 375 for (int i = 0; i < count; ++i) { |
375 data->mutable_dirty_rects().begin(), rects, rects + count); | 376 data->mutable_dirty_rects().insert(rects[i]); |
| 377 } |
376 encoder_tester->AddRects(rects, count); | 378 encoder_tester->AddRects(rects, count); |
377 decoder_tester->AddRects(rects, count); | 379 decoder_tester->AddRects(rects, count); |
378 decoder_tester->reset_decode_done(); | 380 decoder_tester->reset_decode_done(); |
379 | 381 |
380 // Generate random data for the updated rects. | 382 // Generate random data for the updated rects. |
381 srand(0); | 383 srand(0); |
382 for (int i = 0; i < count; ++i) { | 384 for (int i = 0; i < count; ++i) { |
383 const gfx::Rect rect = rects[i]; | 385 const gfx::Rect rect = rects[i]; |
384 const int bytes_per_pixel = GetBytesPerPixel(data->pixel_format()); | 386 const int bytes_per_pixel = GetBytesPerPixel(data->pixel_format()); |
385 const int row_size = bytes_per_pixel * rect.width(); | 387 const int row_size = bytes_per_pixel * rect.width(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, | 422 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, |
421 kTestRects + 2, 1); | 423 kTestRects + 2, 1); |
422 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, | 424 TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, |
423 kTestRects + 3, 2); | 425 kTestRects + 3, 2); |
424 delete [] memory; | 426 delete [] memory; |
425 } | 427 } |
426 | 428 |
427 } // namespace remoting | 429 } // namespace remoting |
428 | 430 |
429 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::DecoderTester); | 431 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::DecoderTester); |
OLD | NEW |