Chromium Code Reviews| 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 #ifndef MEDIA_CAST_TEST_FAKE_MOCK_VIDEO_ENCODE_ACCELERATOR_H_ | 5 #ifndef MEDIA_VIDEO_FAKE_VIDEO_ENCODE_ACCELERATOR_H_ |
| 6 #define MEDIA_CAST_TEST_FAKE_MOCK_VIDEO_ENCODE_ACCELERATOR_H_ | 6 #define MEDIA_VIDEO_FAKE_VIDEO_ENCODE_ACCELERATOR_H_ |
| 7 | |
| 8 #include "media/video/video_encode_accelerator.h" | |
| 9 | 7 |
| 10 #include <list> | 8 #include <list> |
| 11 #include <vector> | 9 #include <vector> |
| 12 | 10 |
| 13 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 14 #include "media/base/bitstream_buffer.h" | 12 #include "media/base/bitstream_buffer.h" |
| 13 #include "media/video/video_encode_accelerator.h" | |
| 15 | 14 |
| 16 namespace base { | 15 namespace base { |
| 16 | |
| 17 class SingleThreadTaskRunner; | 17 class SingleThreadTaskRunner; |
| 18 | |
| 18 } // namespace base | 19 } // namespace base |
| 19 | 20 |
| 20 namespace media { | 21 namespace media { |
| 21 namespace cast { | |
| 22 namespace test { | |
| 23 | 22 |
| 24 class FakeVideoEncodeAccelerator : public VideoEncodeAccelerator { | 23 class FakeVideoEncodeAccelerator : public VideoEncodeAccelerator { |
| 25 public: | 24 public: |
| 26 explicit FakeVideoEncodeAccelerator( | 25 FakeVideoEncodeAccelerator( |
| 27 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 26 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
| 28 std::vector<uint32>* stored_bitrates); | |
| 29 ~FakeVideoEncodeAccelerator() override; | 27 ~FakeVideoEncodeAccelerator() override; |
| 30 | 28 |
| 31 std::vector<VideoEncodeAccelerator::SupportedProfile> GetSupportedProfiles() | 29 std::vector<VideoEncodeAccelerator::SupportedProfile> GetSupportedProfiles() |
| 32 override; | 30 override; |
| 33 bool Initialize(media::VideoFrame::Format input_format, | 31 bool Initialize(VideoFrame::Format input_format, |
| 34 const gfx::Size& input_visible_size, | 32 const gfx::Size& input_visible_size, |
| 35 VideoCodecProfile output_profile, | 33 VideoCodecProfile output_profile, |
| 36 uint32 initial_bitrate, | 34 uint32 initial_bitrate, |
| 37 Client* client) override; | 35 Client* client) override; |
| 38 | |
| 39 void Encode(const scoped_refptr<VideoFrame>& frame, | 36 void Encode(const scoped_refptr<VideoFrame>& frame, |
| 40 bool force_keyframe) override; | 37 bool force_keyframe) override; |
| 41 | |
| 42 void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) override; | 38 void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) override; |
| 43 | |
| 44 void RequestEncodingParametersChange(uint32 bitrate, | 39 void RequestEncodingParametersChange(uint32 bitrate, |
| 45 uint32 framerate) override; | 40 uint32 framerate) override; |
| 46 | |
| 47 void Destroy() override; | 41 void Destroy() override; |
| 48 | 42 |
| 43 const std::vector<uint32>& stored_bitrates() { | |
| 44 return stored_bitrates_; | |
| 45 } | |
| 49 void SendDummyFrameForTesting(bool key_frame); | 46 void SendDummyFrameForTesting(bool key_frame); |
| 50 void SetWillInitializationSucceed(bool will_initialization_succeed) { | 47 void SetWillInitializationSucceed(bool will_initialization_succeed); |
| 51 will_initialization_succeed_ = will_initialization_succeed; | 48 private: |
| 52 } | 49 struct BitstreamBufferRef; |
| 53 | 50 |
| 54 private: | |
| 55 void DoRequireBitstreamBuffers(unsigned int input_count, | 51 void DoRequireBitstreamBuffers(unsigned int input_count, |
| 56 const gfx::Size& input_coded_size, | 52 const gfx::Size& input_coded_size, |
| 57 size_t output_buffer_size) const; | 53 size_t output_buffer_size) const; |
| 58 void DoBitstreamBufferReady(int32 bitstream_buffer_id, | 54 void DoBitstreamBufferReady(int32 bitstream_buffer_id, |
| 59 size_t payload_size, | 55 size_t payload_size, |
| 60 bool key_frame) const; | 56 bool key_frame) const; |
| 61 | 57 |
| 58 // Our original calling message loop for the child thread. | |
|
wuchengli
2014/12/11 02:14:31
nit: remove "the child thread" because it doesn't
hellner1
2014/12/11 19:34:19
Done.
| |
| 62 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 59 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 63 std::vector<uint32>* const stored_bitrates_; | 60 std::vector<uint32> stored_bitrates_; |
| 64 VideoEncodeAccelerator::Client* client_; | |
| 65 bool first_; | |
| 66 bool will_initialization_succeed_; | 61 bool will_initialization_succeed_; |
| 67 | 62 |
| 68 std::list<int32> available_buffer_ids_; | 63 VideoEncodeAccelerator::Client* client_; |
|
wuchengli
2014/12/11 02:14:31
nit: add blank line
hellner1
2014/12/11 19:34:19
Done.
| |
| 64 // Keeps track of if the current frame is the first encoded frame. This | |
| 65 // is used to force a fake key frame for the first encoded frame. | |
| 66 bool first_; | |
| 67 | |
| 68 // A list of buffers available for putting fake encoded frames in. | |
| 69 std::list<scoped_ptr<BitstreamBufferRef> > available_buffers_; | |
| 69 | 70 |
| 70 base::WeakPtrFactory<FakeVideoEncodeAccelerator> weak_this_factory_; | 71 base::WeakPtrFactory<FakeVideoEncodeAccelerator> weak_this_factory_; |
| 71 | 72 |
| 72 DISALLOW_COPY_AND_ASSIGN(FakeVideoEncodeAccelerator); | 73 DISALLOW_COPY_AND_ASSIGN(FakeVideoEncodeAccelerator); |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 } // namespace test | |
| 76 } // namespace cast | |
| 77 } // namespace media | 76 } // namespace media |
| 78 | 77 |
| 79 #endif // MEDIA_CAST_TEST_FAKE_MOCK_VIDEO_ENCODE_ACCELERATOR_H_ | 78 #endif // MEDIA_VIDEO_FAKE_VIDEO_ENCODE_ACCELERATOR_H_ |
| OLD | NEW |