| 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 "webkit/media/webvideoframe_impl.h" | 5 #include "webkit/media/webvideoframe_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "media/base/video_frame.h" | 8 #include "media/base/video_frame.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVideoFrame.h" | 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVideoFrame.h" |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 COMPILE_ASSERT_MATCHING_ENUM(FormatEmpty, EMPTY); | 30 COMPILE_ASSERT_MATCHING_ENUM(FormatEmpty, EMPTY); |
| 31 COMPILE_ASSERT_MATCHING_ENUM(FormatI420, I420); | 31 COMPILE_ASSERT_MATCHING_ENUM(FormatI420, I420); |
| 32 COMPILE_ASSERT_MATCHING_ENUM(FormatNativeTexture, NATIVE_TEXTURE); | 32 COMPILE_ASSERT_MATCHING_ENUM(FormatNativeTexture, NATIVE_TEXTURE); |
| 33 | 33 |
| 34 WebVideoFrame::Format WebVideoFrameImpl::format() const { | 34 WebVideoFrame::Format WebVideoFrameImpl::format() const { |
| 35 if (video_frame_.get()) | 35 if (video_frame_.get()) |
| 36 return static_cast<WebVideoFrame::Format>(video_frame_->format()); | 36 return static_cast<WebVideoFrame::Format>(video_frame_->format()); |
| 37 return WebVideoFrame::FormatInvalid; | 37 return WebVideoFrame::FormatInvalid; |
| 38 } | 38 } |
| 39 | 39 |
| 40 unsigned WebVideoFrameImpl::width() const { | |
| 41 if (video_frame_.get()) | |
| 42 return video_frame_->data_size().width(); | |
| 43 return 0; | |
| 44 } | |
| 45 | |
| 46 unsigned WebVideoFrameImpl::height() const { | |
| 47 if (video_frame_.get()) | |
| 48 return video_frame_->data_size().height(); | |
| 49 return 0; | |
| 50 } | |
| 51 | |
| 52 unsigned WebVideoFrameImpl::planes() const { | 40 unsigned WebVideoFrameImpl::planes() const { |
| 53 if (!video_frame_.get()) | 41 if (!video_frame_.get()) |
| 54 return 0; | 42 return 0; |
| 55 switch (video_frame_->format()) { | 43 switch (video_frame_->format()) { |
| 56 case media::VideoFrame::RGB32: | 44 case media::VideoFrame::RGB32: |
| 57 return 1; | 45 return 1; |
| 58 case media::VideoFrame::YV12: | 46 case media::VideoFrame::YV12: |
| 59 case media::VideoFrame::YV16: | 47 case media::VideoFrame::YV16: |
| 60 return 3; | 48 return 3; |
| 61 case media::VideoFrame::INVALID: | 49 case media::VideoFrame::INVALID: |
| 62 case media::VideoFrame::EMPTY: | 50 case media::VideoFrame::EMPTY: |
| 63 case media::VideoFrame::I420: | 51 case media::VideoFrame::I420: |
| 64 break; | 52 break; |
| 65 case media::VideoFrame::NATIVE_TEXTURE: | 53 case media::VideoFrame::NATIVE_TEXTURE: |
| 66 return 0; | 54 return 0; |
| 67 } | 55 } |
| 68 NOTREACHED(); | 56 NOTREACHED(); |
| 69 return 0; | 57 return 0; |
| 70 } | 58 } |
| 71 | 59 |
| 72 int WebVideoFrameImpl::stride(unsigned plane) const { | |
| 73 if (video_frame_.get()) | |
| 74 return static_cast<int>(video_frame_->stride(plane)); | |
| 75 return 0; | |
| 76 } | |
| 77 | |
| 78 const void* WebVideoFrameImpl::data(unsigned plane) const { | 60 const void* WebVideoFrameImpl::data(unsigned plane) const { |
| 79 if (!video_frame_.get() || format() == FormatNativeTexture) | 61 if (!video_frame_.get() || format() == FormatNativeTexture) |
| 80 return NULL; | 62 return NULL; |
| 81 return static_cast<const void*>(video_frame_->data(plane)); | 63 return static_cast<const void*>(video_frame_->data(plane)); |
| 82 } | 64 } |
| 83 | 65 |
| 84 unsigned WebVideoFrameImpl::textureId() const { | 66 unsigned WebVideoFrameImpl::textureId() const { |
| 85 if (!video_frame_.get() || format() != FormatNativeTexture) | 67 if (!video_frame_.get() || format() != FormatNativeTexture) |
| 86 return 0; | 68 return 0; |
| 87 return video_frame_->texture_id(); | 69 return video_frame_->texture_id(); |
| 88 } | 70 } |
| 89 | 71 |
| 90 unsigned WebVideoFrameImpl::textureTarget() const { | 72 unsigned WebVideoFrameImpl::textureTarget() const { |
| 91 if (!video_frame_.get() || format() != FormatNativeTexture) | 73 if (!video_frame_.get() || format() != FormatNativeTexture) |
| 92 return 0; | 74 return 0; |
| 93 return video_frame_->texture_target(); | 75 return video_frame_->texture_target(); |
| 94 } | 76 } |
| 95 | 77 |
| 78 WebKit::WebRect WebVideoFrameImpl::visibleRect() const { |
| 79 if (!video_frame_.get()) |
| 80 return WebKit::WebRect(0, 0, 0, 0); |
| 81 return WebKit::WebRect(video_frame_->visible_rect()); |
| 82 } |
| 83 |
| 84 WebKit::WebSize WebVideoFrameImpl::textureSize() const { |
| 85 if (!video_frame_.get() || format() != FormatNativeTexture) |
| 86 return WebKit::WebSize(0, 0); |
| 87 return WebKit::WebSize(video_frame_->coded_size()); |
| 88 } |
| 89 |
| 96 } // namespace webkit_media | 90 } // namespace webkit_media |
| OLD | NEW |