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_VIDEO_FAKE_VIDEO_ENCODE_ACCELERATOR_H_ | 5 #ifndef MEDIA_VIDEO_FAKE_VIDEO_ENCODE_ACCELERATOR_H_ |
6 #define MEDIA_VIDEO_FAKE_VIDEO_ENCODE_ACCELERATOR_H_ | 6 #define MEDIA_VIDEO_FAKE_VIDEO_ENCODE_ACCELERATOR_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <queue> | 9 #include <queue> |
10 #include <vector> | 10 #include <vector> |
(...skipping 14 matching lines...) Expand all Loading... |
25 class MEDIA_EXPORT FakeVideoEncodeAccelerator : public VideoEncodeAccelerator { | 25 class MEDIA_EXPORT FakeVideoEncodeAccelerator : public VideoEncodeAccelerator { |
26 public: | 26 public: |
27 explicit FakeVideoEncodeAccelerator( | 27 explicit FakeVideoEncodeAccelerator( |
28 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 28 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
29 ~FakeVideoEncodeAccelerator() override; | 29 ~FakeVideoEncodeAccelerator() override; |
30 | 30 |
31 VideoEncodeAccelerator::SupportedProfiles GetSupportedProfiles() override; | 31 VideoEncodeAccelerator::SupportedProfiles GetSupportedProfiles() override; |
32 bool Initialize(VideoPixelFormat input_format, | 32 bool Initialize(VideoPixelFormat input_format, |
33 const gfx::Size& input_visible_size, | 33 const gfx::Size& input_visible_size, |
34 VideoCodecProfile output_profile, | 34 VideoCodecProfile output_profile, |
35 uint32 initial_bitrate, | 35 uint32_t initial_bitrate, |
36 Client* client) override; | 36 Client* client) override; |
37 void Encode(const scoped_refptr<VideoFrame>& frame, | 37 void Encode(const scoped_refptr<VideoFrame>& frame, |
38 bool force_keyframe) override; | 38 bool force_keyframe) override; |
39 void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) override; | 39 void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) override; |
40 void RequestEncodingParametersChange(uint32 bitrate, | 40 void RequestEncodingParametersChange(uint32_t bitrate, |
41 uint32 framerate) override; | 41 uint32_t framerate) override; |
42 void Destroy() override; | 42 void Destroy() override; |
43 | 43 |
44 const std::vector<uint32>& stored_bitrates() const { | 44 const std::vector<uint32_t>& stored_bitrates() const { |
45 return stored_bitrates_; | 45 return stored_bitrates_; |
46 } | 46 } |
47 void SendDummyFrameForTesting(bool key_frame); | 47 void SendDummyFrameForTesting(bool key_frame); |
48 void SetWillInitializationSucceed(bool will_initialization_succeed); | 48 void SetWillInitializationSucceed(bool will_initialization_succeed); |
49 | 49 |
50 private: | 50 private: |
51 void DoRequireBitstreamBuffers(unsigned int input_count, | 51 void DoRequireBitstreamBuffers(unsigned int input_count, |
52 const gfx::Size& input_coded_size, | 52 const gfx::Size& input_coded_size, |
53 size_t output_buffer_size) const; | 53 size_t output_buffer_size) const; |
54 void EncodeTask(); | 54 void EncodeTask(); |
55 void DoBitstreamBufferReady(int32 bitstream_buffer_id, | 55 void DoBitstreamBufferReady(int32_t bitstream_buffer_id, |
56 size_t payload_size, | 56 size_t payload_size, |
57 bool key_frame) const; | 57 bool key_frame) const; |
58 | 58 |
59 // Our original (constructor) calling message loop used for all tasks. | 59 // Our original (constructor) calling message loop used for all tasks. |
60 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 60 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
61 std::vector<uint32> stored_bitrates_; | 61 std::vector<uint32_t> stored_bitrates_; |
62 bool will_initialization_succeed_; | 62 bool will_initialization_succeed_; |
63 | 63 |
64 VideoEncodeAccelerator::Client* client_; | 64 VideoEncodeAccelerator::Client* client_; |
65 | 65 |
66 // Keeps track of if the current frame is the first encoded frame. This | 66 // Keeps track of if the current frame is the first encoded frame. This |
67 // is used to force a fake key frame for the first encoded frame. | 67 // is used to force a fake key frame for the first encoded frame. |
68 bool next_frame_is_first_frame_; | 68 bool next_frame_is_first_frame_; |
69 | 69 |
70 // A queue containing the necessary data for incoming frames. The boolean | 70 // A queue containing the necessary data for incoming frames. The boolean |
71 // represent whether the queued frame should force a key frame. | 71 // represent whether the queued frame should force a key frame. |
72 std::queue<bool> queued_frames_; | 72 std::queue<bool> queued_frames_; |
73 | 73 |
74 // A list of buffers available for putting fake encoded frames in. | 74 // A list of buffers available for putting fake encoded frames in. |
75 std::list<BitstreamBuffer> available_buffers_; | 75 std::list<BitstreamBuffer> available_buffers_; |
76 | 76 |
77 base::WeakPtrFactory<FakeVideoEncodeAccelerator> weak_this_factory_; | 77 base::WeakPtrFactory<FakeVideoEncodeAccelerator> weak_this_factory_; |
78 | 78 |
79 DISALLOW_COPY_AND_ASSIGN(FakeVideoEncodeAccelerator); | 79 DISALLOW_COPY_AND_ASSIGN(FakeVideoEncodeAccelerator); |
80 }; | 80 }; |
81 | 81 |
82 } // namespace media | 82 } // namespace media |
83 | 83 |
84 #endif // MEDIA_VIDEO_FAKE_VIDEO_ENCODE_ACCELERATOR_H_ | 84 #endif // MEDIA_VIDEO_FAKE_VIDEO_ENCODE_ACCELERATOR_H_ |
OLD | NEW |