• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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 
interface_name()14 template <> const char* interface_name<PPB_VideoFrame_0_1>() {
15   return PPB_VIDEOFRAME_INTERFACE_0_1;
16 }
17 
18 }
19 
VideoFrame()20 VideoFrame::VideoFrame() {
21 }
22 
VideoFrame(const VideoFrame & other)23 VideoFrame::VideoFrame(const VideoFrame& other) : Resource(other) {
24 }
25 
VideoFrame(const Resource & resource)26 VideoFrame::VideoFrame(const Resource& resource) : Resource(resource) {
27 }
28 
VideoFrame(PassRef,PP_Resource resource)29 VideoFrame::VideoFrame(PassRef, PP_Resource resource)
30     : Resource(PASS_REF, resource) {
31 }
32 
~VideoFrame()33 VideoFrame::~VideoFrame() {
34 }
35 
GetTimestamp() const36 PP_TimeDelta VideoFrame::GetTimestamp() const {
37   if (has_interface<PPB_VideoFrame_0_1>())
38     return get_interface<PPB_VideoFrame_0_1>()->GetTimestamp(pp_resource());
39   return 0.0;
40 }
41 
SetTimestamp(PP_TimeDelta timestamp)42 void VideoFrame::SetTimestamp(PP_TimeDelta timestamp) {
43   if (has_interface<PPB_VideoFrame_0_1>())
44     get_interface<PPB_VideoFrame_0_1>()->SetTimestamp(pp_resource(), timestamp);
45 }
46 
GetFormat() const47 PP_VideoFrame_Format VideoFrame::GetFormat() const {
48   if (has_interface<PPB_VideoFrame_0_1>())
49     return get_interface<PPB_VideoFrame_0_1>()->GetFormat(pp_resource());
50   return PP_VIDEOFRAME_FORMAT_UNKNOWN;
51 }
52 
GetSize(Size * size) const53 bool VideoFrame::GetSize(Size* size) const {
54   if (has_interface<PPB_VideoFrame_0_1>())
55     return PP_ToBool(get_interface<PPB_VideoFrame_0_1>()->GetSize(
56         pp_resource(), &size->pp_size()));
57   return false;
58 }
59 
GetDataBuffer()60 void* VideoFrame::GetDataBuffer() {
61   if (has_interface<PPB_VideoFrame_0_1>())
62     return get_interface<PPB_VideoFrame_0_1>()->GetDataBuffer(pp_resource());
63   return NULL;
64 }
65 
GetDataBufferSize() const66 uint32_t VideoFrame::GetDataBufferSize() const {
67   if (has_interface<PPB_VideoFrame_0_1>()) {
68     return get_interface<PPB_VideoFrame_0_1>()->GetDataBufferSize(
69         pp_resource());
70   }
71   return 0;
72 }
73 
74 }  // namespace pp
75