OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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 "ppapi/cpp/video_frame.h" | |
6 | |
7 #include "ppapi/cpp/module.h" | |
8 #include "ppapi/cpp/module_impl.h" | |
9 | |
10 namespace pp { | |
11 | |
12 namespace { | |
13 | |
14 template <> const char* interface_name<PPB_VideoFrame_0_1>() { | |
15 return PPB_VIDEOFRAME_INTERFACE_0_1; | |
16 } | |
17 | |
18 } | |
19 | |
20 VideoFrame::VideoFrame(PassRef, PP_Resource resource) | |
21 : Resource(PASS_REF, resource) { | |
yzshen1
2013/12/20 23:37:43
wrong indent.
Peng
2013/12/23 02:41:49
Done.
| |
22 } | |
23 | |
24 VideoFrame::~VideoFrame() {} | |
25 | |
26 PP_TimeDelta VideoFrame::GetTimestamp() const { | |
27 PP_TimeDelta timestamp = .0; | |
28 if (!has_interface<PPB_VideoFrame_0_1>()) { | |
yzshen1
2013/12/20 23:37:43
The condition of if() is incorrect.
Peng
2013/12/23 02:41:49
Done.
| |
29 timestamp = get_interface<PPB_VideoFrame_0_1>()->GetTimestamp( | |
30 pp_resource()); | |
31 } | |
32 return timestamp; | |
33 } | |
34 | |
35 void VideoFrame::SetTimestamp(PP_TimeDelta timestamp) { | |
36 if (has_interface<PPB_VideoFrame_0_1>()) { | |
yzshen1
2013/12/20 23:37:43
nit: no need to have {}
Peng
2013/12/23 02:41:49
Done.
| |
37 get_interface<PPB_VideoFrame_0_1>()->SetTimestamp(pp_resource(), timestamp); | |
38 } | |
39 } | |
40 | |
41 PP_VideoFrame_Format VideoFrame::GetFormat() const { | |
42 if (!has_interface<PPB_VideoFrame_0_1>()) | |
yzshen1
2013/12/20 23:37:43
nit, optional: I would prefer to always test has_i
Peng
2013/12/23 02:41:49
Done.
| |
43 return PP_VIDEOFRAME_FORMAT_UNKNOWN; | |
44 return get_interface<PPB_VideoFrame_0_1>()->GetFormat(pp_resource()); | |
45 } | |
46 | |
47 const Size VideoFrame::GetSize() const { | |
48 Size size; | |
49 if (has_interface<PPB_VideoFrame_0_1>()) { | |
50 get_interface<PPB_VideoFrame_0_1>()->GetSize(pp_resource(), | |
51 &size.pp_size()); | |
52 } | |
53 return size; | |
54 } | |
55 | |
56 void* VideoFrame::GetDataBuffer() { | |
57 if (!has_interface<PPB_VideoFrame_0_1>()) | |
58 return NULL; | |
59 return get_interface<PPB_VideoFrame_0_1>()->GetDataBuffer(pp_resource()); | |
60 } | |
61 | |
62 uint32_t VideoFrame::GetDataBufferSize() const { | |
63 int32_t size = 0; | |
yzshen1
2013/12/20 23:37:43
uint32_t
Peng
2013/12/23 02:41:49
Done.
| |
64 if (has_interface<PPB_VideoFrame_0_1>()) { | |
65 size = get_interface<PPB_VideoFrame_0_1>()->GetDataBufferSize( | |
66 pp_resource()); | |
67 } | |
68 return (size >= 0) ? size : 0; | |
yzshen1
2013/12/20 23:37:43
You don't need this check if |size| is uint32_t
Peng
2013/12/23 02:41:49
Done.
| |
69 } | |
70 | |
71 } // namespace pp | |
OLD | NEW |