| 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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 DCHECK(shared_memory_handle_ != base::SharedMemory::NULLHandle()); | 779 DCHECK(shared_memory_handle_ != base::SharedMemory::NULLHandle()); |
| 780 return shared_memory_handle_; | 780 return shared_memory_handle_; |
| 781 } | 781 } |
| 782 | 782 |
| 783 size_t VideoFrame::shared_memory_offset() const { | 783 size_t VideoFrame::shared_memory_offset() const { |
| 784 DCHECK_EQ(storage_type_, STORAGE_SHMEM); | 784 DCHECK_EQ(storage_type_, STORAGE_SHMEM); |
| 785 DCHECK(shared_memory_handle_ != base::SharedMemory::NULLHandle()); | 785 DCHECK(shared_memory_handle_ != base::SharedMemory::NULLHandle()); |
| 786 return shared_memory_offset_; | 786 return shared_memory_offset_; |
| 787 } | 787 } |
| 788 | 788 |
| 789 const base::SharedMemory& VideoFrame::shared_memory() const { |
| 790 DCHECK_EQ(storage_type_, STORAGE_SHMEM); |
| 791 return *shared_memory_.get(); |
| 792 } |
| 793 |
| 794 |
| 789 const std::vector<gfx::GpuMemoryBufferHandle>& | 795 const std::vector<gfx::GpuMemoryBufferHandle>& |
| 790 VideoFrame::gpu_memory_buffer_handles() const { | 796 VideoFrame::gpu_memory_buffer_handles() const { |
| 791 DCHECK_EQ(storage_type_, STORAGE_GPU_MEMORY_BUFFERS); | 797 DCHECK_EQ(storage_type_, STORAGE_GPU_MEMORY_BUFFERS); |
| 792 DCHECK(!gpu_memory_buffer_handles_.empty()); | 798 DCHECK(!gpu_memory_buffer_handles_.empty()); |
| 793 return gpu_memory_buffer_handles_; | 799 return gpu_memory_buffer_handles_; |
| 794 } | 800 } |
| 795 | 801 |
| 796 #if defined(OS_LINUX) | 802 #if defined(OS_LINUX) |
| 797 int VideoFrame::dmabuf_fd(size_t plane) const { | 803 int VideoFrame::dmabuf_fd(size_t plane) const { |
| 798 DCHECK_EQ(storage_type_, STORAGE_DMABUFS); | 804 DCHECK_EQ(storage_type_, STORAGE_DMABUFS); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 826 | 832 |
| 827 return true; | 833 return true; |
| 828 } | 834 } |
| 829 #endif | 835 #endif |
| 830 | 836 |
| 831 void VideoFrame::AddSharedMemoryHandle(base::SharedMemoryHandle handle) { | 837 void VideoFrame::AddSharedMemoryHandle(base::SharedMemoryHandle handle) { |
| 832 storage_type_ = STORAGE_SHMEM; | 838 storage_type_ = STORAGE_SHMEM; |
| 833 shared_memory_handle_ = handle; | 839 shared_memory_handle_ = handle; |
| 834 } | 840 } |
| 835 | 841 |
| 842 void VideoFrame::AddSharedMemory(scoped_ptr<base::SharedMemory> shared_memory) { |
| 843 storage_type_ = STORAGE_SHMEM; |
| 844 shared_memory_ = std::move(shared_memory); |
| 845 } |
| 846 |
| 836 #if defined(OS_MACOSX) | 847 #if defined(OS_MACOSX) |
| 837 CVPixelBufferRef VideoFrame::cv_pixel_buffer() const { | 848 CVPixelBufferRef VideoFrame::cv_pixel_buffer() const { |
| 838 return cv_pixel_buffer_.get(); | 849 return cv_pixel_buffer_.get(); |
| 839 } | 850 } |
| 840 #endif | 851 #endif |
| 841 | 852 |
| 842 void VideoFrame::AddDestructionObserver(const base::Closure& callback) { | 853 void VideoFrame::AddDestructionObserver(const base::Closure& callback) { |
| 843 DCHECK(!callback.is_null()); | 854 DCHECK(!callback.is_null()); |
| 844 done_callbacks_.push_back(callback); | 855 done_callbacks_.push_back(callback); |
| 845 } | 856 } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 if (zero_initialize_memory) | 1073 if (zero_initialize_memory) |
| 1063 memset(data, 0, data_size); | 1074 memset(data, 0, data_size); |
| 1064 | 1075 |
| 1065 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) | 1076 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) |
| 1066 data_[plane] = data + offset[plane]; | 1077 data_[plane] = data + offset[plane]; |
| 1067 | 1078 |
| 1068 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); | 1079 AddDestructionObserver(base::Bind(&base::AlignedFree, data)); |
| 1069 } | 1080 } |
| 1070 | 1081 |
| 1071 } // namespace media | 1082 } // namespace media |
| OLD | NEW |