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