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/video/fake_video_encode_accelerator.h" | 5 #include "media/video/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" |
(...skipping 26 matching lines...) Expand all Loading... |
37 profile.profile = media::H264PROFILE_MAIN; | 37 profile.profile = media::H264PROFILE_MAIN; |
38 profiles.push_back(profile); | 38 profiles.push_back(profile); |
39 profile.profile = media::VP8PROFILE_ANY; | 39 profile.profile = media::VP8PROFILE_ANY; |
40 profiles.push_back(profile); | 40 profiles.push_back(profile); |
41 return profiles; | 41 return profiles; |
42 } | 42 } |
43 | 43 |
44 bool FakeVideoEncodeAccelerator::Initialize(VideoPixelFormat input_format, | 44 bool FakeVideoEncodeAccelerator::Initialize(VideoPixelFormat input_format, |
45 const gfx::Size& input_visible_size, | 45 const gfx::Size& input_visible_size, |
46 VideoCodecProfile output_profile, | 46 VideoCodecProfile output_profile, |
47 uint32 initial_bitrate, | 47 uint32_t initial_bitrate, |
48 Client* client) { | 48 Client* client) { |
49 if (!will_initialization_succeed_) { | 49 if (!will_initialization_succeed_) { |
50 return false; | 50 return false; |
51 } | 51 } |
52 if (output_profile == VIDEO_CODEC_PROFILE_UNKNOWN || | 52 if (output_profile == VIDEO_CODEC_PROFILE_UNKNOWN || |
53 output_profile > VIDEO_CODEC_PROFILE_MAX) { | 53 output_profile > VIDEO_CODEC_PROFILE_MAX) { |
54 return false; | 54 return false; |
55 } | 55 } |
56 client_ = client; | 56 client_ = client; |
57 task_runner_->PostTask( | 57 task_runner_->PostTask( |
(...skipping 14 matching lines...) Expand all Loading... |
72 EncodeTask(); | 72 EncodeTask(); |
73 } | 73 } |
74 | 74 |
75 void FakeVideoEncodeAccelerator::UseOutputBitstreamBuffer( | 75 void FakeVideoEncodeAccelerator::UseOutputBitstreamBuffer( |
76 const BitstreamBuffer& buffer) { | 76 const BitstreamBuffer& buffer) { |
77 available_buffers_.push_back(buffer); | 77 available_buffers_.push_back(buffer); |
78 EncodeTask(); | 78 EncodeTask(); |
79 } | 79 } |
80 | 80 |
81 void FakeVideoEncodeAccelerator::RequestEncodingParametersChange( | 81 void FakeVideoEncodeAccelerator::RequestEncodingParametersChange( |
82 uint32 bitrate, | 82 uint32_t bitrate, |
83 uint32 framerate) { | 83 uint32_t framerate) { |
84 stored_bitrates_.push_back(bitrate); | 84 stored_bitrates_.push_back(bitrate); |
85 } | 85 } |
86 | 86 |
87 void FakeVideoEncodeAccelerator::Destroy() { delete this; } | 87 void FakeVideoEncodeAccelerator::Destroy() { delete this; } |
88 | 88 |
89 void FakeVideoEncodeAccelerator::SendDummyFrameForTesting(bool key_frame) { | 89 void FakeVideoEncodeAccelerator::SendDummyFrameForTesting(bool key_frame) { |
90 task_runner_->PostTask( | 90 task_runner_->PostTask( |
91 FROM_HERE, | 91 FROM_HERE, |
92 base::Bind(&FakeVideoEncodeAccelerator::DoBitstreamBufferReady, | 92 base::Bind(&FakeVideoEncodeAccelerator::DoBitstreamBufferReady, |
93 weak_this_factory_.GetWeakPtr(), | 93 weak_this_factory_.GetWeakPtr(), |
(...skipping 12 matching lines...) Expand all Loading... |
106 const gfx::Size& input_coded_size, | 106 const gfx::Size& input_coded_size, |
107 size_t output_buffer_size) const { | 107 size_t output_buffer_size) const { |
108 client_->RequireBitstreamBuffers( | 108 client_->RequireBitstreamBuffers( |
109 input_count, input_coded_size, output_buffer_size); | 109 input_count, input_coded_size, output_buffer_size); |
110 } | 110 } |
111 | 111 |
112 void FakeVideoEncodeAccelerator::EncodeTask() { | 112 void FakeVideoEncodeAccelerator::EncodeTask() { |
113 while (!queued_frames_.empty() && !available_buffers_.empty()) { | 113 while (!queued_frames_.empty() && !available_buffers_.empty()) { |
114 bool force_key_frame = queued_frames_.front(); | 114 bool force_key_frame = queued_frames_.front(); |
115 queued_frames_.pop(); | 115 queued_frames_.pop(); |
116 int32 bitstream_buffer_id = available_buffers_.front().id(); | 116 int32_t bitstream_buffer_id = available_buffers_.front().id(); |
117 available_buffers_.pop_front(); | 117 available_buffers_.pop_front(); |
118 bool key_frame = next_frame_is_first_frame_ || force_key_frame; | 118 bool key_frame = next_frame_is_first_frame_ || force_key_frame; |
119 next_frame_is_first_frame_ = false; | 119 next_frame_is_first_frame_ = false; |
120 task_runner_->PostTask( | 120 task_runner_->PostTask( |
121 FROM_HERE, | 121 FROM_HERE, |
122 base::Bind(&FakeVideoEncodeAccelerator::DoBitstreamBufferReady, | 122 base::Bind(&FakeVideoEncodeAccelerator::DoBitstreamBufferReady, |
123 weak_this_factory_.GetWeakPtr(), | 123 weak_this_factory_.GetWeakPtr(), |
124 bitstream_buffer_id, | 124 bitstream_buffer_id, |
125 kMinimumOutputBufferSize, | 125 kMinimumOutputBufferSize, |
126 key_frame)); | 126 key_frame)); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 void FakeVideoEncodeAccelerator::DoBitstreamBufferReady( | 130 void FakeVideoEncodeAccelerator::DoBitstreamBufferReady( |
131 int32 bitstream_buffer_id, | 131 int32_t bitstream_buffer_id, |
132 size_t payload_size, | 132 size_t payload_size, |
133 bool key_frame) const { | 133 bool key_frame) const { |
134 client_->BitstreamBufferReady(bitstream_buffer_id, | 134 client_->BitstreamBufferReady(bitstream_buffer_id, |
135 payload_size, | 135 payload_size, |
136 key_frame); | 136 key_frame); |
137 } | 137 } |
138 | 138 |
139 } // namespace media | 139 } // namespace media |
OLD | NEW |