| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 241 } |
| 242 | 242 |
| 243 // static | 243 // static |
| 244 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( | 244 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( |
| 245 scoped_ptr<gpu::MailboxHolder> mailbox_holder, | 245 scoped_ptr<gpu::MailboxHolder> mailbox_holder, |
| 246 const ReleaseMailboxCB& mailbox_holder_release_cb, | 246 const ReleaseMailboxCB& mailbox_holder_release_cb, |
| 247 const gfx::Size& coded_size, | 247 const gfx::Size& coded_size, |
| 248 const gfx::Rect& visible_rect, | 248 const gfx::Rect& visible_rect, |
| 249 const gfx::Size& natural_size, | 249 const gfx::Size& natural_size, |
| 250 base::TimeDelta timestamp, | 250 base::TimeDelta timestamp, |
| 251 const ReadPixelsCB& read_pixels_cb) { | 251 const ReadPixelsCB& read_pixels_cb, |
| 252 bool allow_overlay) { |
| 252 scoped_refptr<VideoFrame> frame(new VideoFrame(NATIVE_TEXTURE, | 253 scoped_refptr<VideoFrame> frame(new VideoFrame(NATIVE_TEXTURE, |
| 253 coded_size, | 254 coded_size, |
| 254 visible_rect, | 255 visible_rect, |
| 255 natural_size, | 256 natural_size, |
| 256 mailbox_holder.Pass(), | 257 mailbox_holder.Pass(), |
| 257 timestamp, | 258 timestamp, |
| 258 false)); | 259 false)); |
| 259 frame->mailbox_holder_release_cb_ = mailbox_holder_release_cb; | 260 frame->mailbox_holder_release_cb_ = mailbox_holder_release_cb; |
| 260 frame->read_pixels_cb_ = read_pixels_cb; | 261 frame->read_pixels_cb_ = read_pixels_cb; |
| 262 frame->allow_overlay_ = allow_overlay; |
| 261 | 263 |
| 262 return frame; | 264 return frame; |
| 263 } | 265 } |
| 264 | 266 |
| 265 #if !defined(MEDIA_FOR_CAST_IOS) | 267 #if !defined(MEDIA_FOR_CAST_IOS) |
| 266 void VideoFrame::ReadPixelsFromNativeTexture(const SkBitmap& pixels) { | 268 void VideoFrame::ReadPixelsFromNativeTexture(const SkBitmap& pixels) { |
| 267 DCHECK_EQ(format_, NATIVE_TEXTURE); | 269 DCHECK_EQ(format_, NATIVE_TEXTURE); |
| 268 if (!read_pixels_cb_.is_null()) | 270 if (!read_pixels_cb_.is_null()) |
| 269 read_pixels_cb_.Run(pixels); | 271 read_pixels_cb_.Run(pixels); |
| 270 } | 272 } |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 base::TimeDelta timestamp, | 673 base::TimeDelta timestamp, |
| 672 bool end_of_stream) | 674 bool end_of_stream) |
| 673 : format_(format), | 675 : format_(format), |
| 674 coded_size_(coded_size), | 676 coded_size_(coded_size), |
| 675 visible_rect_(visible_rect), | 677 visible_rect_(visible_rect), |
| 676 natural_size_(natural_size), | 678 natural_size_(natural_size), |
| 677 mailbox_holder_(mailbox_holder.Pass()), | 679 mailbox_holder_(mailbox_holder.Pass()), |
| 678 shared_memory_handle_(base::SharedMemory::NULLHandle()), | 680 shared_memory_handle_(base::SharedMemory::NULLHandle()), |
| 679 timestamp_(timestamp), | 681 timestamp_(timestamp), |
| 680 release_sync_point_(0), | 682 release_sync_point_(0), |
| 681 end_of_stream_(end_of_stream) { | 683 end_of_stream_(end_of_stream), |
| 684 allow_overlay_(false) { |
| 682 DCHECK(IsValidConfig(format_, coded_size_, visible_rect_, natural_size_)); | 685 DCHECK(IsValidConfig(format_, coded_size_, visible_rect_, natural_size_)); |
| 683 | 686 |
| 684 memset(&strides_, 0, sizeof(strides_)); | 687 memset(&strides_, 0, sizeof(strides_)); |
| 685 memset(&data_, 0, sizeof(data_)); | 688 memset(&data_, 0, sizeof(data_)); |
| 686 } | 689 } |
| 687 | 690 |
| 688 VideoFrame::~VideoFrame() { | 691 VideoFrame::~VideoFrame() { |
| 689 if (!mailbox_holder_release_cb_.is_null()) { | 692 if (!mailbox_holder_release_cb_.is_null()) { |
| 690 uint32 release_sync_point; | 693 uint32 release_sync_point; |
| 691 { | 694 { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) { | 811 for (size_t plane = 0; plane < NumPlanes(format_); ++plane) { |
| 809 for (int row = 0; row < rows(plane); ++row) { | 812 for (int row = 0; row < rows(plane); ++row) { |
| 810 base::MD5Update(context, base::StringPiece( | 813 base::MD5Update(context, base::StringPiece( |
| 811 reinterpret_cast<char*>(data(plane) + stride(plane) * row), | 814 reinterpret_cast<char*>(data(plane) + stride(plane) * row), |
| 812 row_bytes(plane))); | 815 row_bytes(plane))); |
| 813 } | 816 } |
| 814 } | 817 } |
| 815 } | 818 } |
| 816 | 819 |
| 817 } // namespace media | 820 } // namespace media |
| OLD | NEW |