| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/cast/test/fake_video_encode_accelerator.h" | 5 #include "media/cast/test/fake_video_encode_accelerator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 | 11 |
| 12 namespace media { | 12 namespace media { |
| 13 namespace cast { | 13 namespace cast { |
| 14 namespace test { | 14 namespace test { |
| 15 | 15 |
| 16 static const unsigned int kMinimumInputCount = 1; | 16 static const unsigned int kMinimumInputCount = 1; |
| 17 static const size_t kMinimumOutputBufferSize = 123456; | 17 static const size_t kMinimumOutputBufferSize = 123456; |
| 18 | 18 |
| 19 FakeVideoEncodeAccelerator::FakeVideoEncodeAccelerator( | 19 FakeVideoEncodeAccelerator::FakeVideoEncodeAccelerator( |
| 20 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 20 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 21 std::vector<uint32>* stored_bitrates) | 21 std::vector<uint32>* stored_bitrates) |
| 22 : task_runner_(task_runner), | 22 : task_runner_(task_runner), |
| 23 stored_bitrates_(stored_bitrates), | 23 stored_bitrates_(stored_bitrates), |
| 24 client_(NULL), | 24 client_(NULL), |
| 25 first_(true), | 25 first_(true), |
| 26 will_initialization_succeed_(true), |
| 26 weak_this_factory_(this) { | 27 weak_this_factory_(this) { |
| 27 DCHECK(stored_bitrates_); | 28 DCHECK(stored_bitrates_); |
| 28 } | 29 } |
| 29 | 30 |
| 30 FakeVideoEncodeAccelerator::~FakeVideoEncodeAccelerator() { | 31 FakeVideoEncodeAccelerator::~FakeVideoEncodeAccelerator() { |
| 31 weak_this_factory_.InvalidateWeakPtrs(); | 32 weak_this_factory_.InvalidateWeakPtrs(); |
| 32 } | 33 } |
| 33 | 34 |
| 34 bool FakeVideoEncodeAccelerator::Initialize( | 35 bool FakeVideoEncodeAccelerator::Initialize( |
| 35 media::VideoFrame::Format input_format, | 36 media::VideoFrame::Format input_format, |
| 36 const gfx::Size& input_visible_size, | 37 const gfx::Size& input_visible_size, |
| 37 VideoCodecProfile output_profile, | 38 VideoCodecProfile output_profile, |
| 38 uint32 initial_bitrate, | 39 uint32 initial_bitrate, |
| 39 Client* client) { | 40 Client* client) { |
| 41 if (!will_initialization_succeed_) |
| 42 return false; |
| 40 client_ = client; | 43 client_ = client; |
| 41 if (output_profile != media::VP8PROFILE_ANY && | 44 if (output_profile != media::VP8PROFILE_ANY && |
| 42 output_profile != media::H264PROFILE_MAIN) { | 45 output_profile != media::H264PROFILE_MAIN) { |
| 43 return false; | 46 return false; |
| 44 } | 47 } |
| 45 task_runner_->PostTask( | 48 task_runner_->PostTask( |
| 46 FROM_HERE, | 49 FROM_HERE, |
| 47 base::Bind(&FakeVideoEncodeAccelerator::DoRequireBitstreamBuffers, | 50 base::Bind(&FakeVideoEncodeAccelerator::DoRequireBitstreamBuffers, |
| 48 weak_this_factory_.GetWeakPtr(), | 51 weak_this_factory_.GetWeakPtr(), |
| 49 kMinimumInputCount, | 52 kMinimumInputCount, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 void FakeVideoEncodeAccelerator::DoBitstreamBufferReady( | 107 void FakeVideoEncodeAccelerator::DoBitstreamBufferReady( |
| 105 int32 bitstream_buffer_id, | 108 int32 bitstream_buffer_id, |
| 106 size_t payload_size, | 109 size_t payload_size, |
| 107 bool key_frame) const { | 110 bool key_frame) const { |
| 108 client_->BitstreamBufferReady(bitstream_buffer_id, payload_size, key_frame); | 111 client_->BitstreamBufferReady(bitstream_buffer_id, payload_size, key_frame); |
| 109 } | 112 } |
| 110 | 113 |
| 111 } // namespace test | 114 } // namespace test |
| 112 } // namespace cast | 115 } // namespace cast |
| 113 } // namespace media | 116 } // namespace media |
| OLD | NEW |