OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/gpu/ipc/service/gpu_video_encode_accelerator.h" | 5 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 return true; | 54 return true; |
55 } | 55 } |
56 | 56 |
57 GpuVideoEncodeAccelerator::GpuVideoEncodeAccelerator( | 57 GpuVideoEncodeAccelerator::GpuVideoEncodeAccelerator( |
58 int32_t host_route_id, | 58 int32_t host_route_id, |
59 gpu::GpuCommandBufferStub* stub) | 59 gpu::GpuCommandBufferStub* stub) |
60 : host_route_id_(host_route_id), | 60 : host_route_id_(host_route_id), |
61 stub_(stub), | 61 stub_(stub), |
62 input_format_(media::PIXEL_FORMAT_UNKNOWN), | 62 input_format_(PIXEL_FORMAT_UNKNOWN), |
63 output_buffer_size_(0), | 63 output_buffer_size_(0), |
64 weak_this_factory_(this) { | 64 weak_this_factory_(this) { |
65 stub_->AddDestructionObserver(this); | 65 stub_->AddDestructionObserver(this); |
66 make_context_current_ = | 66 make_context_current_ = |
67 base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); | 67 base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); |
68 } | 68 } |
69 | 69 |
70 GpuVideoEncodeAccelerator::~GpuVideoEncodeAccelerator() { | 70 GpuVideoEncodeAccelerator::~GpuVideoEncodeAccelerator() { |
71 // This class can only be self-deleted from OnWillDestroyStub(), which means | 71 // This class can only be self-deleted from OnWillDestroyStub(), which means |
72 // the VEA has already been destroyed in there. | 72 // the VEA has already been destroyed in there. |
73 DCHECK(!encoder_); | 73 DCHECK(!encoder_); |
74 } | 74 } |
75 | 75 |
76 bool GpuVideoEncodeAccelerator::Initialize( | 76 bool GpuVideoEncodeAccelerator::Initialize(VideoPixelFormat input_format, |
77 media::VideoPixelFormat input_format, | 77 const gfx::Size& input_visible_size, |
78 const gfx::Size& input_visible_size, | 78 VideoCodecProfile output_profile, |
79 media::VideoCodecProfile output_profile, | 79 uint32_t initial_bitrate) { |
80 uint32_t initial_bitrate) { | |
81 DVLOG(2) << "GpuVideoEncodeAccelerator::Initialize(): " | 80 DVLOG(2) << "GpuVideoEncodeAccelerator::Initialize(): " |
82 << "input_format=" << input_format | 81 << "input_format=" << input_format |
83 << ", input_visible_size=" << input_visible_size.ToString() | 82 << ", input_visible_size=" << input_visible_size.ToString() |
84 << ", output_profile=" << output_profile | 83 << ", output_profile=" << output_profile |
85 << ", initial_bitrate=" << initial_bitrate; | 84 << ", initial_bitrate=" << initial_bitrate; |
86 DCHECK(!encoder_); | 85 DCHECK(!encoder_); |
87 | 86 |
88 if (!stub_->channel()->AddRoute(host_route_id_, stub_->stream_id(), this)) { | 87 if (!stub_->channel()->AddRoute(host_route_id_, stub_->stream_id(), this)) { |
89 DLOG(ERROR) << "GpuVideoEncodeAccelerator::Initialize(): " | 88 DLOG(ERROR) << "GpuVideoEncodeAccelerator::Initialize(): " |
90 "failed to add route"; | 89 "failed to add route"; |
91 return false; | 90 return false; |
92 } | 91 } |
93 | 92 |
94 if (input_visible_size.width() > media::limits::kMaxDimension || | 93 if (input_visible_size.width() > limits::kMaxDimension || |
95 input_visible_size.height() > media::limits::kMaxDimension || | 94 input_visible_size.height() > limits::kMaxDimension || |
96 input_visible_size.GetArea() > media::limits::kMaxCanvas) { | 95 input_visible_size.GetArea() > limits::kMaxCanvas) { |
97 DLOG(ERROR) << "GpuVideoEncodeAccelerator::Initialize(): " | 96 DLOG(ERROR) << "GpuVideoEncodeAccelerator::Initialize(): " |
98 << "input_visible_size " << input_visible_size.ToString() | 97 << "input_visible_size " << input_visible_size.ToString() |
99 << " too large"; | 98 << " too large"; |
100 return false; | 99 return false; |
101 } | 100 } |
102 | 101 |
103 const gpu::GpuPreferences& gpu_preferences = | 102 const gpu::GpuPreferences& gpu_preferences = |
104 stub_->channel()->gpu_channel_manager()->gpu_preferences(); | 103 stub_->channel()->gpu_channel_manager()->gpu_preferences(); |
105 | 104 |
106 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps = | 105 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps = |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 void GpuVideoEncodeAccelerator::BitstreamBufferReady( | 150 void GpuVideoEncodeAccelerator::BitstreamBufferReady( |
152 int32_t bitstream_buffer_id, | 151 int32_t bitstream_buffer_id, |
153 size_t payload_size, | 152 size_t payload_size, |
154 bool key_frame, | 153 bool key_frame, |
155 base::TimeDelta timestamp) { | 154 base::TimeDelta timestamp) { |
156 Send(new AcceleratedVideoEncoderHostMsg_BitstreamBufferReady( | 155 Send(new AcceleratedVideoEncoderHostMsg_BitstreamBufferReady( |
157 host_route_id_, bitstream_buffer_id, payload_size, key_frame, timestamp)); | 156 host_route_id_, bitstream_buffer_id, payload_size, key_frame, timestamp)); |
158 } | 157 } |
159 | 158 |
160 void GpuVideoEncodeAccelerator::NotifyError( | 159 void GpuVideoEncodeAccelerator::NotifyError( |
161 media::VideoEncodeAccelerator::Error error) { | 160 VideoEncodeAccelerator::Error error) { |
162 Send(new AcceleratedVideoEncoderHostMsg_NotifyError(host_route_id_, error)); | 161 Send(new AcceleratedVideoEncoderHostMsg_NotifyError(host_route_id_, error)); |
163 } | 162 } |
164 | 163 |
165 void GpuVideoEncodeAccelerator::OnWillDestroyStub() { | 164 void GpuVideoEncodeAccelerator::OnWillDestroyStub() { |
166 DCHECK(stub_); | 165 DCHECK(stub_); |
167 stub_->channel()->RemoveRoute(host_route_id_); | 166 stub_->channel()->RemoveRoute(host_route_id_); |
168 stub_->RemoveDestructionObserver(this); | 167 stub_->RemoveDestructionObserver(this); |
169 encoder_.reset(); | 168 encoder_.reset(); |
170 delete this; | 169 delete this; |
171 } | 170 } |
172 | 171 |
173 // static | 172 // static |
174 gpu::VideoEncodeAcceleratorSupportedProfiles | 173 gpu::VideoEncodeAcceleratorSupportedProfiles |
175 GpuVideoEncodeAccelerator::GetSupportedProfiles( | 174 GpuVideoEncodeAccelerator::GetSupportedProfiles( |
176 const gpu::GpuPreferences& gpu_preferences) { | 175 const gpu::GpuPreferences& gpu_preferences) { |
177 media::VideoEncodeAccelerator::SupportedProfiles profiles; | 176 VideoEncodeAccelerator::SupportedProfiles profiles; |
178 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps = | 177 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps = |
179 CreateVEAFps(gpu_preferences); | 178 CreateVEAFps(gpu_preferences); |
180 | 179 |
181 for (size_t i = 0; i < create_vea_fps.size(); ++i) { | 180 for (size_t i = 0; i < create_vea_fps.size(); ++i) { |
182 std::unique_ptr<media::VideoEncodeAccelerator> encoder = | 181 std::unique_ptr<VideoEncodeAccelerator> encoder = (*create_vea_fps[i])(); |
183 (*create_vea_fps[i])(); | |
184 if (!encoder) | 182 if (!encoder) |
185 continue; | 183 continue; |
186 media::VideoEncodeAccelerator::SupportedProfiles vea_profiles = | 184 VideoEncodeAccelerator::SupportedProfiles vea_profiles = |
187 encoder->GetSupportedProfiles(); | 185 encoder->GetSupportedProfiles(); |
188 media::GpuVideoAcceleratorUtil::InsertUniqueEncodeProfiles(vea_profiles, | 186 GpuVideoAcceleratorUtil::InsertUniqueEncodeProfiles(vea_profiles, |
189 &profiles); | 187 &profiles); |
190 } | 188 } |
191 return media::GpuVideoAcceleratorUtil::ConvertMediaToGpuEncodeProfiles( | 189 return GpuVideoAcceleratorUtil::ConvertMediaToGpuEncodeProfiles(profiles); |
192 profiles); | |
193 } | 190 } |
194 | 191 |
195 // static | 192 // static |
196 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> | 193 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> |
197 GpuVideoEncodeAccelerator::CreateVEAFps( | 194 GpuVideoEncodeAccelerator::CreateVEAFps( |
198 const gpu::GpuPreferences& gpu_preferences) { | 195 const gpu::GpuPreferences& gpu_preferences) { |
199 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps; | 196 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps; |
200 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | 197 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) |
201 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateV4L2VEA); | 198 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateV4L2VEA); |
202 #endif | 199 #endif |
203 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 200 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
204 if (!gpu_preferences.disable_vaapi_accelerated_video_encode) | 201 if (!gpu_preferences.disable_vaapi_accelerated_video_encode) |
205 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVaapiVEA); | 202 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVaapiVEA); |
206 #endif | 203 #endif |
207 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 204 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
208 if (!gpu_preferences.disable_web_rtc_hw_encoding) | 205 if (!gpu_preferences.disable_web_rtc_hw_encoding) |
209 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateAndroidVEA); | 206 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateAndroidVEA); |
210 #endif | 207 #endif |
211 #if defined(OS_MACOSX) | 208 #if defined(OS_MACOSX) |
212 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVTVEA); | 209 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVTVEA); |
213 #endif | 210 #endif |
214 return create_vea_fps; | 211 return create_vea_fps; |
215 } | 212 } |
216 | 213 |
217 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | 214 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) |
218 // static | 215 // static |
219 std::unique_ptr<media::VideoEncodeAccelerator> | 216 std::unique_ptr<VideoEncodeAccelerator> |
220 GpuVideoEncodeAccelerator::CreateV4L2VEA() { | 217 GpuVideoEncodeAccelerator::CreateV4L2VEA() { |
221 std::unique_ptr<media::VideoEncodeAccelerator> encoder; | 218 std::unique_ptr<VideoEncodeAccelerator> encoder; |
222 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); | 219 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); |
223 if (device) | 220 if (device) |
224 encoder.reset(new V4L2VideoEncodeAccelerator(device)); | 221 encoder.reset(new V4L2VideoEncodeAccelerator(device)); |
225 return encoder; | 222 return encoder; |
226 } | 223 } |
227 #endif | 224 #endif |
228 | 225 |
229 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 226 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
230 // static | 227 // static |
231 std::unique_ptr<media::VideoEncodeAccelerator> | 228 std::unique_ptr<VideoEncodeAccelerator> |
232 GpuVideoEncodeAccelerator::CreateVaapiVEA() { | 229 GpuVideoEncodeAccelerator::CreateVaapiVEA() { |
233 return base::WrapUnique<media::VideoEncodeAccelerator>( | 230 return base::WrapUnique<VideoEncodeAccelerator>( |
234 new VaapiVideoEncodeAccelerator()); | 231 new VaapiVideoEncodeAccelerator()); |
235 } | 232 } |
236 #endif | 233 #endif |
237 | 234 |
238 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 235 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
239 // static | 236 // static |
240 std::unique_ptr<media::VideoEncodeAccelerator> | 237 std::unique_ptr<VideoEncodeAccelerator> |
241 GpuVideoEncodeAccelerator::CreateAndroidVEA() { | 238 GpuVideoEncodeAccelerator::CreateAndroidVEA() { |
242 return base::WrapUnique<media::VideoEncodeAccelerator>( | 239 return base::WrapUnique<VideoEncodeAccelerator>( |
243 new AndroidVideoEncodeAccelerator()); | 240 new AndroidVideoEncodeAccelerator()); |
244 } | 241 } |
245 #endif | 242 #endif |
246 | 243 |
247 #if defined(OS_MACOSX) | 244 #if defined(OS_MACOSX) |
248 // static | 245 // static |
249 std::unique_ptr<media::VideoEncodeAccelerator> | 246 std::unique_ptr<VideoEncodeAccelerator> |
250 GpuVideoEncodeAccelerator::CreateVTVEA() { | 247 GpuVideoEncodeAccelerator::CreateVTVEA() { |
251 return base::WrapUnique<media::VideoEncodeAccelerator>( | 248 return base::WrapUnique<VideoEncodeAccelerator>( |
252 new VTVideoEncodeAccelerator()); | 249 new VTVideoEncodeAccelerator()); |
253 } | 250 } |
254 #endif | 251 #endif |
255 | 252 |
256 void GpuVideoEncodeAccelerator::OnEncode( | 253 void GpuVideoEncodeAccelerator::OnEncode( |
257 const AcceleratedVideoEncoderMsg_Encode_Params& params) { | 254 const AcceleratedVideoEncoderMsg_Encode_Params& params) { |
258 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode: frame_id = " | 255 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode: frame_id = " |
259 << params.frame_id << ", buffer_size=" << params.buffer_size | 256 << params.frame_id << ", buffer_size=" << params.buffer_size |
260 << ", force_keyframe=" << params.force_keyframe; | 257 << ", force_keyframe=" << params.force_keyframe; |
261 DCHECK_EQ(media::PIXEL_FORMAT_I420, input_format_); | 258 DCHECK_EQ(PIXEL_FORMAT_I420, input_format_); |
262 | 259 |
263 // Wrap into a SharedMemory in the beginning, so that |params.buffer_handle| | 260 // Wrap into a SharedMemory in the beginning, so that |params.buffer_handle| |
264 // is cleaned properly in case of an early return. | 261 // is cleaned properly in case of an early return. |
265 std::unique_ptr<base::SharedMemory> shm( | 262 std::unique_ptr<base::SharedMemory> shm( |
266 new base::SharedMemory(params.buffer_handle, true)); | 263 new base::SharedMemory(params.buffer_handle, true)); |
267 | 264 |
268 if (!encoder_) | 265 if (!encoder_) |
269 return; | 266 return; |
270 | 267 |
271 if (params.frame_id < 0) { | 268 if (params.frame_id < 0) { |
272 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): invalid " | 269 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): invalid " |
273 << "frame_id=" << params.frame_id; | 270 << "frame_id=" << params.frame_id; |
274 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); | 271 NotifyError(VideoEncodeAccelerator::kPlatformFailureError); |
275 return; | 272 return; |
276 } | 273 } |
277 | 274 |
278 const uint32_t aligned_offset = | 275 const uint32_t aligned_offset = |
279 params.buffer_offset % base::SysInfo::VMAllocationGranularity(); | 276 params.buffer_offset % base::SysInfo::VMAllocationGranularity(); |
280 base::CheckedNumeric<off_t> map_offset = params.buffer_offset; | 277 base::CheckedNumeric<off_t> map_offset = params.buffer_offset; |
281 map_offset -= aligned_offset; | 278 map_offset -= aligned_offset; |
282 base::CheckedNumeric<size_t> map_size = params.buffer_size; | 279 base::CheckedNumeric<size_t> map_size = params.buffer_size; |
283 map_size += aligned_offset; | 280 map_size += aligned_offset; |
284 | 281 |
285 if (!map_offset.IsValid() || !map_size.IsValid()) { | 282 if (!map_offset.IsValid() || !map_size.IsValid()) { |
286 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode():" | 283 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode():" |
287 << " invalid (buffer_offset,buffer_size)"; | 284 << " invalid (buffer_offset,buffer_size)"; |
288 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); | 285 NotifyError(VideoEncodeAccelerator::kPlatformFailureError); |
289 return; | 286 return; |
290 } | 287 } |
291 | 288 |
292 if (!shm->MapAt(map_offset.ValueOrDie(), map_size.ValueOrDie())) { | 289 if (!shm->MapAt(map_offset.ValueOrDie(), map_size.ValueOrDie())) { |
293 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): " | 290 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): " |
294 << "could not map frame_id=" << params.frame_id; | 291 << "could not map frame_id=" << params.frame_id; |
295 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); | 292 NotifyError(VideoEncodeAccelerator::kPlatformFailureError); |
296 return; | 293 return; |
297 } | 294 } |
298 | 295 |
299 uint8_t* shm_memory = | 296 uint8_t* shm_memory = |
300 reinterpret_cast<uint8_t*>(shm->memory()) + aligned_offset; | 297 reinterpret_cast<uint8_t*>(shm->memory()) + aligned_offset; |
301 scoped_refptr<media::VideoFrame> frame = | 298 scoped_refptr<VideoFrame> frame = VideoFrame::WrapExternalSharedMemory( |
302 media::VideoFrame::WrapExternalSharedMemory( | 299 input_format_, input_coded_size_, gfx::Rect(input_visible_size_), |
303 input_format_, input_coded_size_, gfx::Rect(input_visible_size_), | 300 input_visible_size_, shm_memory, params.buffer_size, params.buffer_handle, |
304 input_visible_size_, shm_memory, params.buffer_size, | 301 params.buffer_offset, params.timestamp); |
305 params.buffer_handle, params.buffer_offset, params.timestamp); | |
306 if (!frame) { | 302 if (!frame) { |
307 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): " | 303 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): " |
308 << "could not create a frame"; | 304 << "could not create a frame"; |
309 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); | 305 NotifyError(VideoEncodeAccelerator::kPlatformFailureError); |
310 return; | 306 return; |
311 } | 307 } |
312 frame->AddDestructionObserver(media::BindToCurrentLoop(base::Bind( | 308 frame->AddDestructionObserver(BindToCurrentLoop(base::Bind( |
313 &GpuVideoEncodeAccelerator::EncodeFrameFinished, | 309 &GpuVideoEncodeAccelerator::EncodeFrameFinished, |
314 weak_this_factory_.GetWeakPtr(), params.frame_id, base::Passed(&shm)))); | 310 weak_this_factory_.GetWeakPtr(), params.frame_id, base::Passed(&shm)))); |
315 encoder_->Encode(frame, params.force_keyframe); | 311 encoder_->Encode(frame, params.force_keyframe); |
316 } | 312 } |
317 | 313 |
318 void GpuVideoEncodeAccelerator::OnEncode2( | 314 void GpuVideoEncodeAccelerator::OnEncode2( |
319 const AcceleratedVideoEncoderMsg_Encode_Params2& params) { | 315 const AcceleratedVideoEncoderMsg_Encode_Params2& params) { |
320 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode2: " | 316 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode2: " |
321 << "frame_id = " << params.frame_id | 317 << "frame_id = " << params.frame_id |
322 << ", size=" << params.size.ToString() | 318 << ", size=" << params.size.ToString() |
323 << ", force_keyframe=" << params.force_keyframe | 319 << ", force_keyframe=" << params.force_keyframe |
324 << ", handle type=" << params.gpu_memory_buffer_handles[0].type; | 320 << ", handle type=" << params.gpu_memory_buffer_handles[0].type; |
325 // Encoding GpuMemoryBuffer backed frames is not supported. | 321 // Encoding GpuMemoryBuffer backed frames is not supported. |
326 NOTREACHED(); | 322 NOTREACHED(); |
327 } | 323 } |
328 | 324 |
329 void GpuVideoEncodeAccelerator::OnUseOutputBitstreamBuffer( | 325 void GpuVideoEncodeAccelerator::OnUseOutputBitstreamBuffer( |
330 int32_t buffer_id, | 326 int32_t buffer_id, |
331 base::SharedMemoryHandle buffer_handle, | 327 base::SharedMemoryHandle buffer_handle, |
332 uint32_t buffer_size) { | 328 uint32_t buffer_size) { |
333 DVLOG(3) << "GpuVideoEncodeAccelerator::OnUseOutputBitstreamBuffer(): " | 329 DVLOG(3) << "GpuVideoEncodeAccelerator::OnUseOutputBitstreamBuffer(): " |
334 << "buffer_id=" << buffer_id << ", buffer_size=" << buffer_size; | 330 << "buffer_id=" << buffer_id << ", buffer_size=" << buffer_size; |
335 if (!encoder_) | 331 if (!encoder_) |
336 return; | 332 return; |
337 if (buffer_id < 0) { | 333 if (buffer_id < 0) { |
338 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnUseOutputBitstreamBuffer(): " | 334 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnUseOutputBitstreamBuffer(): " |
339 << "invalid buffer_id=" << buffer_id; | 335 << "invalid buffer_id=" << buffer_id; |
340 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); | 336 NotifyError(VideoEncodeAccelerator::kPlatformFailureError); |
341 return; | 337 return; |
342 } | 338 } |
343 if (buffer_size < output_buffer_size_) { | 339 if (buffer_size < output_buffer_size_) { |
344 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnUseOutputBitstreamBuffer(): " | 340 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnUseOutputBitstreamBuffer(): " |
345 << "buffer too small for buffer_id=" << buffer_id; | 341 << "buffer too small for buffer_id=" << buffer_id; |
346 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); | 342 NotifyError(VideoEncodeAccelerator::kPlatformFailureError); |
347 return; | 343 return; |
348 } | 344 } |
349 encoder_->UseOutputBitstreamBuffer( | 345 encoder_->UseOutputBitstreamBuffer( |
350 media::BitstreamBuffer(buffer_id, buffer_handle, buffer_size)); | 346 BitstreamBuffer(buffer_id, buffer_handle, buffer_size)); |
351 } | 347 } |
352 | 348 |
353 void GpuVideoEncodeAccelerator::OnDestroy() { | 349 void GpuVideoEncodeAccelerator::OnDestroy() { |
354 DVLOG(2) << "GpuVideoEncodeAccelerator::OnDestroy()"; | 350 DVLOG(2) << "GpuVideoEncodeAccelerator::OnDestroy()"; |
355 OnWillDestroyStub(); | 351 OnWillDestroyStub(); |
356 } | 352 } |
357 | 353 |
358 void GpuVideoEncodeAccelerator::OnRequestEncodingParametersChange( | 354 void GpuVideoEncodeAccelerator::OnRequestEncodingParametersChange( |
359 uint32_t bitrate, | 355 uint32_t bitrate, |
360 uint32_t framerate) { | 356 uint32_t framerate) { |
(...skipping 10 matching lines...) Expand all Loading... |
371 Send(new AcceleratedVideoEncoderHostMsg_NotifyInputDone(host_route_id_, | 367 Send(new AcceleratedVideoEncoderHostMsg_NotifyInputDone(host_route_id_, |
372 frame_id)); | 368 frame_id)); |
373 // Just let |shm| fall out of scope. | 369 // Just let |shm| fall out of scope. |
374 } | 370 } |
375 | 371 |
376 void GpuVideoEncodeAccelerator::Send(IPC::Message* message) { | 372 void GpuVideoEncodeAccelerator::Send(IPC::Message* message) { |
377 stub_->channel()->Send(message); | 373 stub_->channel()->Send(message); |
378 } | 374 } |
379 | 375 |
380 } // namespace media | 376 } // namespace media |
OLD | NEW |