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.
5 #include "ppapi/proxy/video_frame_resource.h"
7 #include "base/logging.h"
8 #include "ppapi/c/pp_bool.h"
9 #include "ppapi/shared_impl/var.h"
14 VideoFrameResource::VideoFrameResource(PP_Instance instance
,
16 MediaStreamBuffer
* buffer
)
17 : Resource(OBJECT_IS_PROXY
, instance
),
20 DCHECK_EQ(buffer_
->header
.type
, MediaStreamBuffer::TYPE_VIDEO
);
23 VideoFrameResource::~VideoFrameResource() {
24 CHECK(!buffer_
) << "An unused (or unrecycled) frame is destroyed.";
27 thunk::PPB_VideoFrame_API
* VideoFrameResource::AsPPB_VideoFrame_API() {
31 PP_TimeDelta
VideoFrameResource::GetTimestamp() {
33 VLOG(1) << "Frame is invalid";
36 return buffer_
->video
.timestamp
;
39 void VideoFrameResource::SetTimestamp(PP_TimeDelta timestamp
) {
41 VLOG(1) << "Frame is invalid";
44 buffer_
->video
.timestamp
= timestamp
;
47 PP_VideoFrame_Format
VideoFrameResource::GetFormat() {
49 VLOG(1) << "Frame is invalid";
50 return PP_VIDEOFRAME_FORMAT_UNKNOWN
;
52 return buffer_
->video
.format
;
55 PP_Bool
VideoFrameResource::GetSize(PP_Size
* size
) {
57 VLOG(1) << "Frame is invalid";
60 *size
= buffer_
->video
.size
;
64 void* VideoFrameResource::GetDataBuffer() {
66 VLOG(1) << "Frame is invalid";
69 return buffer_
->video
.data
;
72 uint32_t VideoFrameResource::GetDataBufferSize() {
74 VLOG(1) << "Frame is invalid";
77 return buffer_
->video
.data_size
;
80 MediaStreamBuffer
* VideoFrameResource::GetBuffer() {
84 int32_t VideoFrameResource::GetBufferIndex() {
88 void VideoFrameResource::Invalidate() {