| 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 28 matching lines...) Expand all Loading... |
| 39 COMPILE_ASSERT_MATCHING_ENUM(FormatEmpty, EMPTY); | 39 COMPILE_ASSERT_MATCHING_ENUM(FormatEmpty, EMPTY); |
| 40 COMPILE_ASSERT_MATCHING_ENUM(FormatI420, I420); | 40 COMPILE_ASSERT_MATCHING_ENUM(FormatI420, I420); |
| 41 COMPILE_ASSERT_MATCHING_ENUM(FormatNativeTexture, NATIVE_TEXTURE); | 41 COMPILE_ASSERT_MATCHING_ENUM(FormatNativeTexture, NATIVE_TEXTURE); |
| 42 | 42 |
| 43 WebVideoFrame::Format WebVideoFrameImpl::format() const { | 43 WebVideoFrame::Format WebVideoFrameImpl::format() const { |
| 44 if (video_frame_.get()) | 44 if (video_frame_.get()) |
| 45 return static_cast<WebVideoFrame::Format>(video_frame_->format()); | 45 return static_cast<WebVideoFrame::Format>(video_frame_->format()); |
| 46 return WebVideoFrame::FormatInvalid; | 46 return WebVideoFrame::FormatInvalid; |
| 47 } | 47 } |
| 48 | 48 |
| 49 unsigned WebVideoFrameImpl::width() const { | |
| 50 if (video_frame_.get()) | |
| 51 return video_frame_->data_size().width(); | |
| 52 return 0; | |
| 53 } | |
| 54 | |
| 55 unsigned WebVideoFrameImpl::height() const { | |
| 56 if (video_frame_.get()) | |
| 57 return video_frame_->data_size().height(); | |
| 58 return 0; | |
| 59 } | |
| 60 | |
| 61 unsigned WebVideoFrameImpl::planes() const { | 49 unsigned WebVideoFrameImpl::planes() const { |
| 62 if (!video_frame_.get()) | 50 if (!video_frame_.get()) |
| 63 return 0; | 51 return 0; |
| 64 switch (video_frame_->format()) { | 52 switch (video_frame_->format()) { |
| 65 case media::VideoFrame::RGB32: | 53 case media::VideoFrame::RGB32: |
| 66 return 1; | 54 return 1; |
| 67 case media::VideoFrame::YV12: | 55 case media::VideoFrame::YV12: |
| 68 case media::VideoFrame::YV16: | 56 case media::VideoFrame::YV16: |
| 69 return 3; | 57 return 3; |
| 70 case media::VideoFrame::INVALID: | 58 case media::VideoFrame::INVALID: |
| 71 case media::VideoFrame::EMPTY: | 59 case media::VideoFrame::EMPTY: |
| 72 case media::VideoFrame::I420: | 60 case media::VideoFrame::I420: |
| 73 break; | 61 break; |
| 74 case media::VideoFrame::NATIVE_TEXTURE: | 62 case media::VideoFrame::NATIVE_TEXTURE: |
| 75 return 0; | 63 return 0; |
| 76 } | 64 } |
| 77 NOTREACHED(); | 65 NOTREACHED(); |
| 78 return 0; | 66 return 0; |
| 79 } | 67 } |
| 80 | 68 |
| 81 int WebVideoFrameImpl::stride(unsigned plane) const { | |
| 82 if (video_frame_.get()) | |
| 83 return static_cast<int>(video_frame_->stride(plane)); | |
| 84 return 0; | |
| 85 } | |
| 86 | |
| 87 const void* WebVideoFrameImpl::data(unsigned plane) const { | 69 const void* WebVideoFrameImpl::data(unsigned plane) const { |
| 88 if (!video_frame_.get() || format() == FormatNativeTexture) | 70 if (!video_frame_.get() || format() == FormatNativeTexture) |
| 89 return NULL; | 71 return NULL; |
| 90 return static_cast<const void*>(video_frame_->data(plane)); | 72 return static_cast<const void*>(video_frame_->data(plane)); |
| 91 } | 73 } |
| 92 | 74 |
| 93 unsigned WebVideoFrameImpl::textureId() const { | 75 unsigned WebVideoFrameImpl::textureId() const { |
| 94 if (!video_frame_.get() || format() != FormatNativeTexture) | 76 if (!video_frame_.get() || format() != FormatNativeTexture) |
| 95 return 0; | 77 return 0; |
| 96 return video_frame_->texture_id(); | 78 return video_frame_->texture_id(); |
| 97 } | 79 } |
| 98 | 80 |
| 99 unsigned WebVideoFrameImpl::textureTarget() const { | 81 unsigned WebVideoFrameImpl::textureTarget() const { |
| 100 if (!video_frame_.get() || format() != FormatNativeTexture) | 82 if (!video_frame_.get() || format() != FormatNativeTexture) |
| 101 return 0; | 83 return 0; |
| 102 return video_frame_->texture_target(); | 84 return video_frame_->texture_target(); |
| 103 } | 85 } |
| 104 | 86 |
| 87 WebKit::WebRect WebVideoFrameImpl::visibleRect() const { |
| 88 if (!video_frame_.get()) |
| 89 return WebKit::WebRect(0, 0, 0, 0); |
| 90 return WebKit::WebRect(video_frame_->visible_rect()); |
| 91 } |
| 92 |
| 93 WebKit::WebSize WebVideoFrameImpl::textureSize() const { |
| 94 if (!video_frame_.get() || format() != FormatNativeTexture) |
| 95 return WebKit::WebSize(0, 0); |
| 96 return WebKit::WebSize(video_frame_->coded_size()); |
| 97 } |
| 98 |
| 105 } // namespace webkit_media | 99 } // namespace webkit_media |
| OLD | NEW |