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), | |
miu
2014/08/05 21:52:07
For safety, DCHECK(stored_bitrates_), since it is
Alpha Left Google
2014/08/06 01:24:54
Done.
| |
22 client_(NULL), | 24 client_(NULL), |
23 first_(true), | 25 first_(true), |
24 weak_this_factory_(this) {} | 26 weak_this_factory_(this) {} |
25 | 27 |
26 FakeVideoEncodeAccelerator::~FakeVideoEncodeAccelerator() { | 28 FakeVideoEncodeAccelerator::~FakeVideoEncodeAccelerator() { |
27 weak_this_factory_.InvalidateWeakPtrs(); | 29 weak_this_factory_.InvalidateWeakPtrs(); |
28 } | 30 } |
29 | 31 |
30 bool FakeVideoEncodeAccelerator::Initialize( | 32 bool FakeVideoEncodeAccelerator::Initialize( |
31 media::VideoFrame::Format input_format, | 33 media::VideoFrame::Format input_format, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 } | 75 } |
74 | 76 |
75 void FakeVideoEncodeAccelerator::UseOutputBitstreamBuffer( | 77 void FakeVideoEncodeAccelerator::UseOutputBitstreamBuffer( |
76 const BitstreamBuffer& buffer) { | 78 const BitstreamBuffer& buffer) { |
77 available_buffer_ids_.push_back(buffer.id()); | 79 available_buffer_ids_.push_back(buffer.id()); |
78 } | 80 } |
79 | 81 |
80 void FakeVideoEncodeAccelerator::RequestEncodingParametersChange( | 82 void FakeVideoEncodeAccelerator::RequestEncodingParametersChange( |
81 uint32 bitrate, | 83 uint32 bitrate, |
82 uint32 framerate) { | 84 uint32 framerate) { |
83 // No-op. | 85 stored_bitrates_->push_back(bitrate); |
84 } | 86 } |
85 | 87 |
86 void FakeVideoEncodeAccelerator::Destroy() { delete this; } | 88 void FakeVideoEncodeAccelerator::Destroy() { delete this; } |
87 | 89 |
88 void FakeVideoEncodeAccelerator::SendDummyFrameForTesting(bool key_frame) { | 90 void FakeVideoEncodeAccelerator::SendDummyFrameForTesting(bool key_frame) { |
89 DoBitstreamBufferReady(0, 23, key_frame); | 91 DoBitstreamBufferReady(0, 23, key_frame); |
90 } | 92 } |
91 | 93 |
92 void FakeVideoEncodeAccelerator::DoRequireBitstreamBuffers( | 94 void FakeVideoEncodeAccelerator::DoRequireBitstreamBuffers( |
93 unsigned int input_count, | 95 unsigned int input_count, |
94 const gfx::Size& input_coded_size, | 96 const gfx::Size& input_coded_size, |
95 size_t output_buffer_size) const { | 97 size_t output_buffer_size) const { |
96 client_->RequireBitstreamBuffers( | 98 client_->RequireBitstreamBuffers( |
97 input_count, input_coded_size, output_buffer_size); | 99 input_count, input_coded_size, output_buffer_size); |
98 } | 100 } |
99 | 101 |
100 void FakeVideoEncodeAccelerator::DoBitstreamBufferReady( | 102 void FakeVideoEncodeAccelerator::DoBitstreamBufferReady( |
101 int32 bitstream_buffer_id, | 103 int32 bitstream_buffer_id, |
102 size_t payload_size, | 104 size_t payload_size, |
103 bool key_frame) const { | 105 bool key_frame) const { |
104 client_->BitstreamBufferReady(bitstream_buffer_id, payload_size, key_frame); | 106 client_->BitstreamBufferReady(bitstream_buffer_id, payload_size, key_frame); |
105 } | 107 } |
106 | 108 |
107 } // namespace test | 109 } // namespace test |
108 } // namespace cast | 110 } // namespace cast |
109 } // namespace media | 111 } // namespace media |
OLD | NEW |