| 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 15 matching lines...) Expand all Loading... |
| 26 : video_frame_(video_frame) { | 26 : video_frame_(video_frame) { |
| 27 } | 27 } |
| 28 | 28 |
| 29 WebVideoFrameImpl::~WebVideoFrameImpl() {} | 29 WebVideoFrameImpl::~WebVideoFrameImpl() {} |
| 30 | 30 |
| 31 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, chromium_name) \ | 31 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, chromium_name) \ |
| 32 COMPILE_ASSERT(int(WebKit::WebVideoFrame::webkit_name) == \ | 32 COMPILE_ASSERT(int(WebKit::WebVideoFrame::webkit_name) == \ |
| 33 int(media::VideoFrame::chromium_name), \ | 33 int(media::VideoFrame::chromium_name), \ |
| 34 mismatching_enums) | 34 mismatching_enums) |
| 35 COMPILE_ASSERT_MATCHING_ENUM(FormatInvalid, INVALID); | 35 COMPILE_ASSERT_MATCHING_ENUM(FormatInvalid, INVALID); |
| 36 COMPILE_ASSERT_MATCHING_ENUM(FormatRGB555, RGB555); | |
| 37 COMPILE_ASSERT_MATCHING_ENUM(FormatRGB565, RGB565); | |
| 38 COMPILE_ASSERT_MATCHING_ENUM(FormatRGB24, RGB24); | |
| 39 COMPILE_ASSERT_MATCHING_ENUM(FormatRGB32, RGB32); | 36 COMPILE_ASSERT_MATCHING_ENUM(FormatRGB32, RGB32); |
| 40 COMPILE_ASSERT_MATCHING_ENUM(FormatRGBA, RGBA); | |
| 41 COMPILE_ASSERT_MATCHING_ENUM(FormatYV12, YV12); | 37 COMPILE_ASSERT_MATCHING_ENUM(FormatYV12, YV12); |
| 42 COMPILE_ASSERT_MATCHING_ENUM(FormatYV16, YV16); | 38 COMPILE_ASSERT_MATCHING_ENUM(FormatYV16, YV16); |
| 43 COMPILE_ASSERT_MATCHING_ENUM(FormatNV12, NV12); | |
| 44 COMPILE_ASSERT_MATCHING_ENUM(FormatEmpty, EMPTY); | 39 COMPILE_ASSERT_MATCHING_ENUM(FormatEmpty, EMPTY); |
| 45 COMPILE_ASSERT_MATCHING_ENUM(FormatASCII, ASCII); | |
| 46 COMPILE_ASSERT_MATCHING_ENUM(FormatI420, I420); | 40 COMPILE_ASSERT_MATCHING_ENUM(FormatI420, I420); |
| 47 COMPILE_ASSERT_MATCHING_ENUM(FormatNativeTexture, NATIVE_TEXTURE); | 41 COMPILE_ASSERT_MATCHING_ENUM(FormatNativeTexture, NATIVE_TEXTURE); |
| 48 | 42 |
| 49 WebVideoFrame::Format WebVideoFrameImpl::format() const { | 43 WebVideoFrame::Format WebVideoFrameImpl::format() const { |
| 50 if (video_frame_.get()) | 44 if (video_frame_.get()) |
| 51 return static_cast<WebVideoFrame::Format>(video_frame_->format()); | 45 return static_cast<WebVideoFrame::Format>(video_frame_->format()); |
| 52 return WebVideoFrame::FormatInvalid; | 46 return WebVideoFrame::FormatInvalid; |
| 53 } | 47 } |
| 54 | 48 |
| 55 unsigned WebVideoFrameImpl::width() const { | 49 unsigned WebVideoFrameImpl::width() const { |
| 56 if (video_frame_.get()) | 50 if (video_frame_.get()) |
| 57 return video_frame_->width(); | 51 return video_frame_->width(); |
| 58 return 0; | 52 return 0; |
| 59 } | 53 } |
| 60 | 54 |
| 61 unsigned WebVideoFrameImpl::height() const { | 55 unsigned WebVideoFrameImpl::height() const { |
| 62 if (video_frame_.get()) | 56 if (video_frame_.get()) |
| 63 return video_frame_->height(); | 57 return video_frame_->height(); |
| 64 return 0; | 58 return 0; |
| 65 } | 59 } |
| 66 | 60 |
| 67 unsigned WebVideoFrameImpl::planes() const { | 61 unsigned WebVideoFrameImpl::planes() const { |
| 68 if (!video_frame_.get()) | 62 if (!video_frame_.get()) |
| 69 return 0; | 63 return 0; |
| 70 switch (video_frame_->format()) { | 64 switch (video_frame_->format()) { |
| 71 case media::VideoFrame::RGB555: | |
| 72 case media::VideoFrame::RGB565: | |
| 73 case media::VideoFrame::RGB24: | |
| 74 case media::VideoFrame::RGB32: | 65 case media::VideoFrame::RGB32: |
| 75 case media::VideoFrame::RGBA: | |
| 76 return 1; | 66 return 1; |
| 77 case media::VideoFrame::YV12: | 67 case media::VideoFrame::YV12: |
| 78 case media::VideoFrame::YV16: | 68 case media::VideoFrame::YV16: |
| 79 return 3; | 69 return 3; |
| 80 case media::VideoFrame::INVALID: | 70 case media::VideoFrame::INVALID: |
| 81 case media::VideoFrame::NV12: | |
| 82 case media::VideoFrame::EMPTY: | 71 case media::VideoFrame::EMPTY: |
| 83 case media::VideoFrame::ASCII: | |
| 84 case media::VideoFrame::I420: | 72 case media::VideoFrame::I420: |
| 85 break; | 73 break; |
| 86 case media::VideoFrame::NATIVE_TEXTURE: | 74 case media::VideoFrame::NATIVE_TEXTURE: |
| 87 return 0; | 75 return 0; |
| 88 } | 76 } |
| 89 NOTREACHED(); | 77 NOTREACHED(); |
| 90 return 0; | 78 return 0; |
| 91 } | 79 } |
| 92 | 80 |
| 93 int WebVideoFrameImpl::stride(unsigned plane) const { | 81 int WebVideoFrameImpl::stride(unsigned plane) const { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 108 return video_frame_->texture_id(); | 96 return video_frame_->texture_id(); |
| 109 } | 97 } |
| 110 | 98 |
| 111 unsigned WebVideoFrameImpl::textureTarget() const { | 99 unsigned WebVideoFrameImpl::textureTarget() const { |
| 112 if (!video_frame_.get() || format() != FormatNativeTexture) | 100 if (!video_frame_.get() || format() != FormatNativeTexture) |
| 113 return 0; | 101 return 0; |
| 114 return video_frame_->texture_target(); | 102 return video_frame_->texture_target(); |
| 115 } | 103 } |
| 116 | 104 |
| 117 } // namespace webkit_media | 105 } // namespace webkit_media |
| OLD | NEW |