| 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" | |
| 8 #include "media/base/video_frame.h" | |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVideoFrame.h" | |
| 10 | |
| 11 using WebKit::WebVideoFrame; | |
| 12 | |
| 13 namespace webkit_media { | 7 namespace webkit_media { |
| 14 | 8 |
| 15 WebVideoFrameImpl::WebVideoFrameImpl( | 9 WebVideoFrameImpl::WebVideoFrameImpl( |
| 16 scoped_refptr<media::VideoFrame> video_frame) | 10 scoped_refptr<media::VideoFrame> video_frame) |
| 17 : video_frame_(video_frame) { | 11 : video_frame(video_frame) { |
| 18 } | 12 } |
| 19 | 13 |
| 20 WebVideoFrameImpl::~WebVideoFrameImpl() {} | 14 WebVideoFrameImpl::~WebVideoFrameImpl() {} |
| 21 | 15 |
| 22 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, chromium_name) \ | |
| 23 COMPILE_ASSERT(int(WebKit::WebVideoFrame::webkit_name) == \ | |
| 24 int(media::VideoFrame::chromium_name), \ | |
| 25 mismatching_enums) | |
| 26 COMPILE_ASSERT_MATCHING_ENUM(FormatInvalid, INVALID); | |
| 27 COMPILE_ASSERT_MATCHING_ENUM(FormatRGB32, RGB32); | |
| 28 COMPILE_ASSERT_MATCHING_ENUM(FormatYV12, YV12); | |
| 29 COMPILE_ASSERT_MATCHING_ENUM(FormatYV16, YV16); | |
| 30 COMPILE_ASSERT_MATCHING_ENUM(FormatEmpty, EMPTY); | |
| 31 COMPILE_ASSERT_MATCHING_ENUM(FormatI420, I420); | |
| 32 COMPILE_ASSERT_MATCHING_ENUM(FormatNativeTexture, NATIVE_TEXTURE); | |
| 33 | |
| 34 WebVideoFrame::Format WebVideoFrameImpl::format() const { | |
| 35 if (video_frame_.get()) | |
| 36 return static_cast<WebVideoFrame::Format>(video_frame_->format()); | |
| 37 return WebVideoFrame::FormatInvalid; | |
| 38 } | |
| 39 | |
| 40 unsigned WebVideoFrameImpl::planes() const { | |
| 41 if (!video_frame_.get()) | |
| 42 return 0; | |
| 43 switch (video_frame_->format()) { | |
| 44 case media::VideoFrame::RGB32: | |
| 45 return 1; | |
| 46 case media::VideoFrame::YV12: | |
| 47 case media::VideoFrame::YV16: | |
| 48 return 3; | |
| 49 case media::VideoFrame::INVALID: | |
| 50 case media::VideoFrame::EMPTY: | |
| 51 case media::VideoFrame::I420: | |
| 52 break; | |
| 53 case media::VideoFrame::NATIVE_TEXTURE: | |
| 54 return 0; | |
| 55 } | |
| 56 NOTREACHED(); | |
| 57 return 0; | |
| 58 } | |
| 59 | |
| 60 const void* WebVideoFrameImpl::data(unsigned plane) const { | |
| 61 if (!video_frame_.get() || format() == FormatNativeTexture) | |
| 62 return NULL; | |
| 63 return static_cast<const void*>(video_frame_->data(plane)); | |
| 64 } | |
| 65 | |
| 66 unsigned WebVideoFrameImpl::textureId() const { | |
| 67 if (!video_frame_.get() || format() != FormatNativeTexture) | |
| 68 return 0; | |
| 69 return video_frame_->texture_id(); | |
| 70 } | |
| 71 | |
| 72 unsigned WebVideoFrameImpl::textureTarget() const { | |
| 73 if (!video_frame_.get() || format() != FormatNativeTexture) | |
| 74 return 0; | |
| 75 return video_frame_->texture_target(); | |
| 76 } | |
| 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 | |
| 90 } // namespace webkit_media | 16 } // namespace webkit_media |
| OLD | NEW |