| 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 : task_runner_(task_runner), | 22 : task_runner_(task_runner), |
| 23 stored_bitrates_(stored_bitrates), |
| 22 client_(NULL), | 24 client_(NULL), |
| 23 first_(true), | 25 first_(true), |
| 24 weak_this_factory_(this) {} | 26 weak_this_factory_(this) { |
| 27 DCHECK(stored_bitrates_); |
| 28 } |
| 25 | 29 |
| 26 FakeVideoEncodeAccelerator::~FakeVideoEncodeAccelerator() { | 30 FakeVideoEncodeAccelerator::~FakeVideoEncodeAccelerator() { |
| 27 weak_this_factory_.InvalidateWeakPtrs(); | 31 weak_this_factory_.InvalidateWeakPtrs(); |
| 28 } | 32 } |
| 29 | 33 |
| 30 bool FakeVideoEncodeAccelerator::Initialize( | 34 bool FakeVideoEncodeAccelerator::Initialize( |
| 31 media::VideoFrame::Format input_format, | 35 media::VideoFrame::Format input_format, |
| 32 const gfx::Size& input_visible_size, | 36 const gfx::Size& input_visible_size, |
| 33 VideoCodecProfile output_profile, | 37 VideoCodecProfile output_profile, |
| 34 uint32 initial_bitrate, | 38 uint32 initial_bitrate, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 77 } |
| 74 | 78 |
| 75 void FakeVideoEncodeAccelerator::UseOutputBitstreamBuffer( | 79 void FakeVideoEncodeAccelerator::UseOutputBitstreamBuffer( |
| 76 const BitstreamBuffer& buffer) { | 80 const BitstreamBuffer& buffer) { |
| 77 available_buffer_ids_.push_back(buffer.id()); | 81 available_buffer_ids_.push_back(buffer.id()); |
| 78 } | 82 } |
| 79 | 83 |
| 80 void FakeVideoEncodeAccelerator::RequestEncodingParametersChange( | 84 void FakeVideoEncodeAccelerator::RequestEncodingParametersChange( |
| 81 uint32 bitrate, | 85 uint32 bitrate, |
| 82 uint32 framerate) { | 86 uint32 framerate) { |
| 83 // No-op. | 87 stored_bitrates_->push_back(bitrate); |
| 84 } | 88 } |
| 85 | 89 |
| 86 void FakeVideoEncodeAccelerator::Destroy() { delete this; } | 90 void FakeVideoEncodeAccelerator::Destroy() { delete this; } |
| 87 | 91 |
| 88 void FakeVideoEncodeAccelerator::SendDummyFrameForTesting(bool key_frame) { | 92 void FakeVideoEncodeAccelerator::SendDummyFrameForTesting(bool key_frame) { |
| 89 DoBitstreamBufferReady(0, 23, key_frame); | 93 DoBitstreamBufferReady(0, 23, key_frame); |
| 90 } | 94 } |
| 91 | 95 |
| 92 void FakeVideoEncodeAccelerator::DoRequireBitstreamBuffers( | 96 void FakeVideoEncodeAccelerator::DoRequireBitstreamBuffers( |
| 93 unsigned int input_count, | 97 unsigned int input_count, |
| 94 const gfx::Size& input_coded_size, | 98 const gfx::Size& input_coded_size, |
| 95 size_t output_buffer_size) const { | 99 size_t output_buffer_size) const { |
| 96 client_->RequireBitstreamBuffers( | 100 client_->RequireBitstreamBuffers( |
| 97 input_count, input_coded_size, output_buffer_size); | 101 input_count, input_coded_size, output_buffer_size); |
| 98 } | 102 } |
| 99 | 103 |
| 100 void FakeVideoEncodeAccelerator::DoBitstreamBufferReady( | 104 void FakeVideoEncodeAccelerator::DoBitstreamBufferReady( |
| 101 int32 bitstream_buffer_id, | 105 int32 bitstream_buffer_id, |
| 102 size_t payload_size, | 106 size_t payload_size, |
| 103 bool key_frame) const { | 107 bool key_frame) const { |
| 104 client_->BitstreamBufferReady(bitstream_buffer_id, payload_size, key_frame); | 108 client_->BitstreamBufferReady(bitstream_buffer_id, payload_size, key_frame); |
| 105 } | 109 } |
| 106 | 110 |
| 107 } // namespace test | 111 } // namespace test |
| 108 } // namespace cast | 112 } // namespace cast |
| 109 } // namespace media | 113 } // namespace media |
| OLD | NEW |