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 <dlfcn.h> | 5 #include <dlfcn.h> |
6 #include <errno.h> | 6 #include <errno.h> |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <linux/videodev2.h> | 8 #include <linux/videodev2.h> |
9 #include <poll.h> | 9 #include <poll.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 if (get_gl_context_cb_.is_null() || make_context_current_cb_.is_null()) { | 208 if (get_gl_context_cb_.is_null() || make_context_current_cb_.is_null()) { |
209 NOTREACHED() << "GL callbacks are required for this VDA"; | 209 NOTREACHED() << "GL callbacks are required for this VDA"; |
210 return false; | 210 return false; |
211 } | 211 } |
212 | 212 |
213 if (config.is_encrypted) { | 213 if (config.is_encrypted) { |
214 NOTREACHED() << "Encrypted streams are not supported for this VDA"; | 214 NOTREACHED() << "Encrypted streams are not supported for this VDA"; |
215 return false; | 215 return false; |
216 } | 216 } |
217 | 217 |
| 218 if (config.output_mode != Config::OutputMode::ALLOCATE) { |
| 219 NOTREACHED() << "Only ALLOCATE OutputMode is supported by this VDA"; |
| 220 return false; |
| 221 } |
| 222 |
218 if (!device_->SupportsDecodeProfileForV4L2PixelFormats( | 223 if (!device_->SupportsDecodeProfileForV4L2PixelFormats( |
219 config.profile, arraysize(supported_input_fourccs_), | 224 config.profile, arraysize(supported_input_fourccs_), |
220 supported_input_fourccs_)) { | 225 supported_input_fourccs_)) { |
221 DVLOG(1) << "Initialize(): unsupported profile=" << config.profile; | 226 DVLOG(1) << "Initialize(): unsupported profile=" << config.profile; |
222 return false; | 227 return false; |
223 } | 228 } |
224 | 229 |
225 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); | 230 client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client)); |
226 client_ = client_ptr_factory_->GetWeakPtr(); | 231 client_ = client_ptr_factory_->GetWeakPtr(); |
227 // If we haven't been set up to decode on separate thread via | 232 // If we haven't been set up to decode on separate thread via |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 DCHECK(buffers[i].size() == coded_size_); | 372 DCHECK(buffers[i].size() == coded_size_); |
368 | 373 |
369 OutputRecord& output_record = output_buffer_map_[i]; | 374 OutputRecord& output_record = output_buffer_map_[i]; |
370 DCHECK(!output_record.at_device); | 375 DCHECK(!output_record.at_device); |
371 DCHECK(!output_record.at_client); | 376 DCHECK(!output_record.at_client); |
372 DCHECK_EQ(output_record.egl_image, EGL_NO_IMAGE_KHR); | 377 DCHECK_EQ(output_record.egl_image, EGL_NO_IMAGE_KHR); |
373 DCHECK_EQ(output_record.egl_sync, EGL_NO_SYNC_KHR); | 378 DCHECK_EQ(output_record.egl_sync, EGL_NO_SYNC_KHR); |
374 DCHECK_EQ(output_record.picture_id, -1); | 379 DCHECK_EQ(output_record.picture_id, -1); |
375 DCHECK_EQ(output_record.cleared, false); | 380 DCHECK_EQ(output_record.cleared, false); |
376 | 381 |
| 382 std::vector<base::ScopedFD> dmabuf_fds; |
| 383 dmabuf_fds = device_->GetDmabufsForV4L2Buffer( |
| 384 i, output_planes_count_, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); |
| 385 if (dmabuf_fds.empty()) { |
| 386 NOTIFY_ERROR(PLATFORM_FAILURE); |
| 387 return; |
| 388 } |
| 389 |
377 EGLImageKHR egl_image = device_->CreateEGLImage(egl_display_, | 390 EGLImageKHR egl_image = device_->CreateEGLImage(egl_display_, |
378 gl_context->GetHandle(), | 391 gl_context->GetHandle(), |
379 buffers[i].texture_id(), | 392 buffers[i].texture_id(), |
380 coded_size_, | 393 coded_size_, |
381 i, | 394 i, |
382 output_format_fourcc_, | 395 output_format_fourcc_, |
383 output_planes_count_); | 396 dmabuf_fds); |
384 if (egl_image == EGL_NO_IMAGE_KHR) { | 397 if (egl_image == EGL_NO_IMAGE_KHR) { |
385 LOG(ERROR) << "AssignPictureBuffers(): could not create EGLImageKHR"; | 398 LOG(ERROR) << "AssignPictureBuffers(): could not create EGLImageKHR"; |
386 // Ownership of EGLImages allocated in previous iterations of this loop | 399 // Ownership of EGLImages allocated in previous iterations of this loop |
387 // has been transferred to output_buffer_map_. After we error-out here | 400 // has been transferred to output_buffer_map_. After we error-out here |
388 // the destructor will handle their cleanup. | 401 // the destructor will handle their cleanup. |
389 NOTIFY_ERROR(PLATFORM_FAILURE); | 402 NOTIFY_ERROR(PLATFORM_FAILURE); |
390 return; | 403 return; |
391 } | 404 } |
392 | 405 |
393 output_record.egl_image = egl_image; | 406 output_record.egl_image = egl_image; |
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2046 | 2059 |
2047 void V4L2VideoDecodeAccelerator::PictureCleared() { | 2060 void V4L2VideoDecodeAccelerator::PictureCleared() { |
2048 DVLOG(3) << "PictureCleared(). clearing count=" << picture_clearing_count_; | 2061 DVLOG(3) << "PictureCleared(). clearing count=" << picture_clearing_count_; |
2049 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); | 2062 DCHECK_EQ(decoder_thread_.message_loop(), base::MessageLoop::current()); |
2050 DCHECK_GT(picture_clearing_count_, 0); | 2063 DCHECK_GT(picture_clearing_count_, 0); |
2051 picture_clearing_count_--; | 2064 picture_clearing_count_--; |
2052 SendPictureReady(); | 2065 SendPictureReady(); |
2053 } | 2066 } |
2054 | 2067 |
2055 } // namespace content | 2068 } // namespace content |
OLD | NEW |