| OLD | NEW |
| (Empty) | |
| 1 // Copyright 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/proxy/video_frame_resource.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "ppapi/c/pp_bool.h" |
| 10 #include "ppapi/shared_impl/private/net_address_private_impl.h" |
| 11 #include "ppapi/shared_impl/var.h" |
| 12 |
| 13 namespace ppapi { |
| 14 namespace proxy { |
| 15 |
| 16 VideoFrameResource::VideoFrameResource(PP_Instance instance, |
| 17 VideoFrame* frame) |
| 18 : Resource(OBJECT_IS_PROXY, instance), |
| 19 frame_(frame) { |
| 20 } |
| 21 |
| 22 VideoFrameResource::~VideoFrameResource() { |
| 23 CHECK(!frame_) << "Frame underlaying buffer is not used or recycled."; |
| 24 } |
| 25 |
| 26 thunk::PPB_VideoFrame_API* VideoFrameResource::AsPPB_VideoFrame_API() { |
| 27 return this; |
| 28 } |
| 29 |
| 30 PP_TimeDelta VideoFrameResource::GetTimestamp() { |
| 31 if (!frame_) { |
| 32 VLOG(1) << "Frame is invalid"; |
| 33 return 0.0; |
| 34 } |
| 35 return frame_->timestamp; |
| 36 } |
| 37 |
| 38 void VideoFrameResource::SetTimestamp(PP_TimeDelta timestamp) { |
| 39 if (!frame_) { |
| 40 VLOG(1) << "Frame is invalid"; |
| 41 return; |
| 42 } |
| 43 frame_->timestamp = timestamp; |
| 44 } |
| 45 |
| 46 PP_VideoFrame_Format VideoFrameResource::GetFormat() { |
| 47 if (!frame_) { |
| 48 VLOG(1) << "Frame is invalid"; |
| 49 return PP_VIDEOFRAME_FORMAT_UNKNOWN; |
| 50 } |
| 51 return frame_->format; |
| 52 } |
| 53 |
| 54 PP_Bool VideoFrameResource::GetSize(PP_Size* size) { |
| 55 if (!frame_) { |
| 56 VLOG(1) << "Frame is invalid"; |
| 57 return PP_FALSE; |
| 58 } |
| 59 *size = frame_->size; |
| 60 return PP_TRUE; |
| 61 } |
| 62 |
| 63 void* VideoFrameResource::GetDataBuffer() { |
| 64 if (!frame_) { |
| 65 VLOG(1) << "Frame is invalid"; |
| 66 return NULL; |
| 67 } |
| 68 return frame_->data; |
| 69 } |
| 70 |
| 71 uint32_t VideoFrameResource::GetDataBufferSize() { |
| 72 if (!frame_) { |
| 73 VLOG(1) << "Frame is invalid"; |
| 74 return 0; |
| 75 } |
| 76 return frame_->data_size; |
| 77 } |
| 78 |
| 79 } // namespace proxy |
| 80 } // namespace ppapi |
| OLD | NEW |