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 "content/common/gpu/media/exynos_video_encode_accelerator.h" | 5 #include "content/common/gpu/media/exynos_video_encode_accelerator.h" |
6 | 6 |
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 <sys/eventfd.h> | 10 #include <sys/eventfd.h> |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 device_poll_thread_("ExynosEncoderDevicePollThread"), | 108 device_poll_thread_("ExynosEncoderDevicePollThread"), |
109 device_poll_interrupt_fd_(-1) { | 109 device_poll_interrupt_fd_(-1) { |
110 DCHECK(client_); | 110 DCHECK(client_); |
111 } | 111 } |
112 | 112 |
113 ExynosVideoEncodeAccelerator::~ExynosVideoEncodeAccelerator() { | 113 ExynosVideoEncodeAccelerator::~ExynosVideoEncodeAccelerator() { |
114 DCHECK(!encoder_thread_.IsRunning()); | 114 DCHECK(!encoder_thread_.IsRunning()); |
115 DCHECK(!device_poll_thread_.IsRunning()); | 115 DCHECK(!device_poll_thread_.IsRunning()); |
116 | 116 |
117 if (device_poll_interrupt_fd_ != -1) { | 117 if (device_poll_interrupt_fd_ != -1) { |
118 HANDLE_EINTR(close(device_poll_interrupt_fd_)); | 118 close(device_poll_interrupt_fd_); |
119 device_poll_interrupt_fd_ = -1; | 119 device_poll_interrupt_fd_ = -1; |
120 } | 120 } |
121 if (gsc_fd_ != -1) { | 121 if (gsc_fd_ != -1) { |
122 DestroyGscInputBuffers(); | 122 DestroyGscInputBuffers(); |
123 DestroyGscOutputBuffers(); | 123 DestroyGscOutputBuffers(); |
124 HANDLE_EINTR(close(gsc_fd_)); | 124 close(gsc_fd_); |
125 gsc_fd_ = -1; | 125 gsc_fd_ = -1; |
126 } | 126 } |
127 if (mfc_fd_ != -1) { | 127 if (mfc_fd_ != -1) { |
128 DestroyMfcInputBuffers(); | 128 DestroyMfcInputBuffers(); |
129 DestroyMfcOutputBuffers(); | 129 DestroyMfcOutputBuffers(); |
130 HANDLE_EINTR(close(mfc_fd_)); | 130 close(mfc_fd_); |
131 mfc_fd_ = -1; | 131 mfc_fd_ = -1; |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 void ExynosVideoEncodeAccelerator::Initialize( | 135 void ExynosVideoEncodeAccelerator::Initialize( |
136 media::VideoFrame::Format input_format, | 136 media::VideoFrame::Format input_format, |
137 const gfx::Size& input_visible_size, | 137 const gfx::Size& input_visible_size, |
138 media::VideoCodecProfile output_profile, | 138 media::VideoCodecProfile output_profile, |
139 uint32 initial_bitrate) { | 139 uint32 initial_bitrate) { |
140 DVLOG(3) << "Initialize(): input_format=" << input_format | 140 DVLOG(3) << "Initialize(): input_format=" << input_format |
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 | 1505 |
1506 void ExynosVideoEncodeAccelerator::DestroyMfcInputBuffers() { | 1506 void ExynosVideoEncodeAccelerator::DestroyMfcInputBuffers() { |
1507 DVLOG(3) << "DestroyMfcInputBuffers()"; | 1507 DVLOG(3) << "DestroyMfcInputBuffers()"; |
1508 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); | 1508 DCHECK(child_message_loop_proxy_->BelongsToCurrentThread()); |
1509 DCHECK(!mfc_input_streamon_); | 1509 DCHECK(!mfc_input_streamon_); |
1510 | 1510 |
1511 for (size_t buf = 0; buf < mfc_input_buffer_map_.size(); ++buf) { | 1511 for (size_t buf = 0; buf < mfc_input_buffer_map_.size(); ++buf) { |
1512 MfcInputRecord& input_record = mfc_input_buffer_map_[buf]; | 1512 MfcInputRecord& input_record = mfc_input_buffer_map_[buf]; |
1513 | 1513 |
1514 for (size_t plane = 0; plane < arraysize(input_record.fd); ++plane) | 1514 for (size_t plane = 0; plane < arraysize(input_record.fd); ++plane) |
1515 HANDLE_EINTR(close(mfc_input_buffer_map_[buf].fd[plane])); | 1515 close(mfc_input_buffer_map_[buf].fd[plane]); |
1516 } | 1516 } |
1517 | 1517 |
1518 struct v4l2_requestbuffers reqbufs; | 1518 struct v4l2_requestbuffers reqbufs; |
1519 memset(&reqbufs, 0, sizeof(reqbufs)); | 1519 memset(&reqbufs, 0, sizeof(reqbufs)); |
1520 reqbufs.count = 0; | 1520 reqbufs.count = 0; |
1521 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; | 1521 reqbufs.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; |
1522 reqbufs.memory = V4L2_MEMORY_MMAP; | 1522 reqbufs.memory = V4L2_MEMORY_MMAP; |
1523 if (HANDLE_EINTR(ioctl(mfc_fd_, VIDIOC_REQBUFS, &reqbufs)) != 0) | 1523 if (HANDLE_EINTR(ioctl(mfc_fd_, VIDIOC_REQBUFS, &reqbufs)) != 0) |
1524 DPLOG(ERROR) << "DestroyMfcInputBuffers(): ioctl() failed: VIDIOC_REQBUFS"; | 1524 DPLOG(ERROR) << "DestroyMfcInputBuffers(): ioctl() failed: VIDIOC_REQBUFS"; |
1525 | 1525 |
(...skipping 19 matching lines...) Expand all Loading... |
1545 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; | 1545 reqbufs.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; |
1546 reqbufs.memory = V4L2_MEMORY_MMAP; | 1546 reqbufs.memory = V4L2_MEMORY_MMAP; |
1547 if (HANDLE_EINTR(ioctl(mfc_fd_, VIDIOC_REQBUFS, &reqbufs)) != 0) | 1547 if (HANDLE_EINTR(ioctl(mfc_fd_, VIDIOC_REQBUFS, &reqbufs)) != 0) |
1548 DPLOG(ERROR) << "DestroyMfcOutputBuffers(): ioctl() failed: VIDIOC_REQBUFS"; | 1548 DPLOG(ERROR) << "DestroyMfcOutputBuffers(): ioctl() failed: VIDIOC_REQBUFS"; |
1549 | 1549 |
1550 mfc_output_buffer_map_.clear(); | 1550 mfc_output_buffer_map_.clear(); |
1551 mfc_free_output_buffers_.clear(); | 1551 mfc_free_output_buffers_.clear(); |
1552 } | 1552 } |
1553 | 1553 |
1554 } // namespace content | 1554 } // namespace content |
OLD | NEW |