OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base/video_frame.h" | 5 #include "media/base/video_frame.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <climits> | 8 #include <climits> |
9 | 9 |
10 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 for (size_t i = 0; i < NumPlanes(format); ++i) { | 434 for (size_t i = 0; i < NumPlanes(format); ++i) { |
435 wrapping_frame->strides_[i] = frame->stride(i); | 435 wrapping_frame->strides_[i] = frame->stride(i); |
436 wrapping_frame->data_[i] = frame->data(i); | 436 wrapping_frame->data_[i] = frame->data(i); |
437 } | 437 } |
438 | 438 |
439 #if defined(OS_LINUX) | 439 #if defined(OS_LINUX) |
440 // If there are any |dmabuf_fds_| plugged in, we should duplicate them. | 440 // If there are any |dmabuf_fds_| plugged in, we should duplicate them. |
441 if (frame->storage_type() == STORAGE_DMABUFS) { | 441 if (frame->storage_type() == STORAGE_DMABUFS) { |
442 std::vector<int> original_fds; | 442 std::vector<int> original_fds; |
443 for (size_t i = 0; i < kMaxPlanes; ++i) | 443 for (size_t i = 0; i < kMaxPlanes; ++i) |
444 original_fds.push_back(frame->dmabuf_fd(i)); | 444 original_fds.push_back(frame->DmabufFd(i)); |
445 if (!wrapping_frame->DuplicateFileDescriptors(original_fds)) { | 445 if (!wrapping_frame->DuplicateFileDescriptors(original_fds)) { |
446 LOG(DFATAL) << __func__ << " Couldn't duplicate fds."; | 446 LOG(DFATAL) << __func__ << " Couldn't duplicate fds."; |
447 return nullptr; | 447 return nullptr; |
448 } | 448 } |
449 } | 449 } |
450 #endif | 450 #endif |
451 | 451 |
452 if (frame->storage_type() == STORAGE_SHMEM) | 452 if (frame->storage_type() == STORAGE_SHMEM) |
453 wrapping_frame->AddSharedMemoryHandle(frame->shared_memory_handle_); | 453 wrapping_frame->AddSharedMemoryHandle(frame->shared_memory_handle_); |
454 | 454 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 return shared_memory_handle_; | 716 return shared_memory_handle_; |
717 } | 717 } |
718 | 718 |
719 size_t VideoFrame::shared_memory_offset() const { | 719 size_t VideoFrame::shared_memory_offset() const { |
720 DCHECK_EQ(storage_type_, STORAGE_SHMEM); | 720 DCHECK_EQ(storage_type_, STORAGE_SHMEM); |
721 DCHECK(shared_memory_handle_ != base::SharedMemory::NULLHandle()); | 721 DCHECK(shared_memory_handle_ != base::SharedMemory::NULLHandle()); |
722 return shared_memory_offset_; | 722 return shared_memory_offset_; |
723 } | 723 } |
724 | 724 |
725 #if defined(OS_LINUX) | 725 #if defined(OS_LINUX) |
726 int VideoFrame::dmabuf_fd(size_t plane) const { | 726 int VideoFrame::DmabufFd(size_t plane) const { |
727 DCHECK_EQ(storage_type_, STORAGE_DMABUFS); | 727 DCHECK_EQ(storage_type_, STORAGE_DMABUFS); |
728 DCHECK(IsValidPlane(plane, format_)); | 728 DCHECK(IsValidPlane(plane, format_)); |
729 return dmabuf_fds_[plane].get(); | 729 return dmabuf_fds_[plane].get(); |
730 } | 730 } |
731 | 731 |
732 bool VideoFrame::DuplicateFileDescriptors(const std::vector<int>& in_fds) { | 732 bool VideoFrame::DuplicateFileDescriptors(const std::vector<int>& in_fds) { |
733 // TODO(mcasas): Support offsets for e.g. multiplanar inside a single |in_fd|. | 733 // TODO(mcasas): Support offsets for e.g. multiplanar inside a single |in_fd|. |
734 | 734 |
735 storage_type_ = STORAGE_DMABUFS; | 735 storage_type_ = STORAGE_DMABUFS; |
736 // TODO(posciak): This is not exactly correct, it's possible for one | 736 // TODO(posciak): This is not exactly correct, it's possible for one |
(...skipping 19 matching lines...) Expand all Loading... |
756 return true; | 756 return true; |
757 } | 757 } |
758 #endif | 758 #endif |
759 | 759 |
760 void VideoFrame::AddSharedMemoryHandle(base::SharedMemoryHandle handle) { | 760 void VideoFrame::AddSharedMemoryHandle(base::SharedMemoryHandle handle) { |
761 storage_type_ = STORAGE_SHMEM; | 761 storage_type_ = STORAGE_SHMEM; |
762 shared_memory_handle_ = handle; | 762 shared_memory_handle_ = handle; |
763 } | 763 } |
764 | 764 |
765 #if defined(OS_MACOSX) | 765 #if defined(OS_MACOSX) |
766 CVPixelBufferRef VideoFrame::cv_pixel_buffer() const { | 766 CVPixelBufferRef VideoFrame::CvPixelBuffer() const { |
767 return cv_pixel_buffer_.get(); | 767 return cv_pixel_buffer_.get(); |
768 } | 768 } |
769 #endif | 769 #endif |
770 | 770 |
771 void VideoFrame::SetReleaseMailboxCB( | 771 void VideoFrame::SetReleaseMailboxCB( |
772 const ReleaseMailboxCB& release_mailbox_cb) { | 772 const ReleaseMailboxCB& release_mailbox_cb) { |
773 DCHECK(!release_mailbox_cb.is_null()); | 773 DCHECK(!release_mailbox_cb.is_null()); |
774 DCHECK(mailbox_holders_release_cb_.is_null()); | 774 DCHECK(mailbox_holders_release_cb_.is_null()); |
775 mailbox_holders_release_cb_ = release_mailbox_cb; | 775 mailbox_holders_release_cb_ = release_mailbox_cb; |
776 } | 776 } |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 if (zero_initialize_memory) | 1206 if (zero_initialize_memory) |
1207 memset(data, 0, data_size); | 1207 memset(data, 0, data_size); |
1208 | 1208 |
1209 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) | 1209 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) |
1210 data_[plane] = data + offset[plane]; | 1210 data_[plane] = data + offset[plane]; |
1211 | 1211 |
1212 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); | 1212 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); |
1213 } | 1213 } |
1214 | 1214 |
1215 } // namespace media | 1215 } // namespace media |
OLD | NEW |