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
10namespace pp {
11
12namespace {
13
14template <> const char* interface_name<PPB_VideoFrame_0_1>() {
15  return PPB_VIDEOFRAME_INTERFACE_0_1;
16}
17
18}
19
20VideoFrame::VideoFrame() {
21}
22
23VideoFrame::VideoFrame(const VideoFrame& other) : Resource(other) {
24}
25
26VideoFrame::VideoFrame(const Resource& resource) : Resource(resource) {
27}
28
29VideoFrame::VideoFrame(PassRef, PP_Resource resource)
30    : Resource(PASS_REF, resource) {
31}
32
33VideoFrame::~VideoFrame() {
34}
35
36PP_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
42void 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
47PP_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
53bool 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
60void* 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
66uint32_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