OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "webkit/glue/webvideoframe_impl.h" | |
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_glue { | |
14 | |
15 media::VideoFrame* WebVideoFrameImpl::toVideoFrame( | |
16 WebVideoFrame* web_video_frame) { | |
17 WebVideoFrameImpl* wrapped_frame = | |
18 static_cast<WebVideoFrameImpl*>(web_video_frame); | |
19 if (wrapped_frame) | |
20 return wrapped_frame->video_frame_.get(); | |
21 return NULL; | |
22 } | |
23 | |
24 WebVideoFrameImpl::WebVideoFrameImpl( | |
25 scoped_refptr<media::VideoFrame> video_frame) | |
26 : video_frame_(video_frame) { | |
27 } | |
28 | |
29 WebVideoFrameImpl::~WebVideoFrameImpl() {} | |
30 | |
31 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, chromium_name) \ | |
32 COMPILE_ASSERT(int(WebKit::WebVideoFrame::webkit_name) == \ | |
33 int(media::VideoFrame::chromium_name), \ | |
34 mismatching_enums) | |
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); | |
40 COMPILE_ASSERT_MATCHING_ENUM(FormatRGBA, RGBA); | |
41 COMPILE_ASSERT_MATCHING_ENUM(FormatYV12, YV12); | |
42 COMPILE_ASSERT_MATCHING_ENUM(FormatYV16, YV16); | |
43 COMPILE_ASSERT_MATCHING_ENUM(FormatNV12, NV12); | |
44 COMPILE_ASSERT_MATCHING_ENUM(FormatEmpty, EMPTY); | |
45 COMPILE_ASSERT_MATCHING_ENUM(FormatASCII, ASCII); | |
46 | |
47 WebVideoFrame::Format WebVideoFrameImpl::format() const { | |
48 if (video_frame_.get()) | |
49 return static_cast<WebVideoFrame::Format>(video_frame_->format()); | |
50 return WebVideoFrame::FormatInvalid; | |
51 } | |
52 | |
53 unsigned WebVideoFrameImpl::width() const { | |
54 if (video_frame_.get()) | |
55 return video_frame_->width(); | |
56 return 0; | |
57 } | |
58 | |
59 unsigned WebVideoFrameImpl::height() const { | |
60 if (video_frame_.get()) | |
61 return video_frame_->height(); | |
62 return 0; | |
63 } | |
64 | |
65 unsigned WebVideoFrameImpl::planes() const { | |
66 if (video_frame_.get()) | |
67 return video_frame_->planes(); | |
68 return 0; | |
69 } | |
70 | |
71 int WebVideoFrameImpl::stride(unsigned plane) const { | |
72 if (video_frame_.get()) | |
73 return static_cast<int>(video_frame_->stride(plane)); | |
74 return 0; | |
75 } | |
76 | |
77 const void* WebVideoFrameImpl::data(unsigned plane) const { | |
78 if (video_frame_.get()) | |
79 return static_cast<const void*>(video_frame_->data(plane)); | |
80 return NULL; | |
81 } | |
82 | |
83 } // namespace webkit_glue | |
OLD | NEW |