Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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/proxy/video_frame_resource.h" | |
| 6 | |
| 7 #include "ppapi/c/pp_bool.h" | |
| 8 #include "ppapi/shared_impl/var.h" | |
| 9 | |
| 10 namespace ppapi { | |
| 11 namespace proxy { | |
| 12 | |
| 13 VideoFrameResource::VideoFrameResource(PP_Instance instance, | |
| 14 int32_t index, | |
| 15 MediaStreamFrame::Video* frame) | |
| 16 : Resource(OBJECT_IS_PROXY, instance), | |
| 17 index_(index), | |
| 18 frame_(frame) { | |
| 19 } | |
| 20 | |
| 21 VideoFrameResource::~VideoFrameResource() { | |
| 22 CHECK(!frame_) << "An unused (or unrecycled) frame is destroyed."; | |
|
yzshen1
2014/01/10 21:05:17
If I read the code correctly, currently the track
Peng
2014/01/10 22:46:58
It is good idea.
| |
| 23 } | |
| 24 | |
| 25 thunk::PPB_VideoFrame_API* VideoFrameResource::AsPPB_VideoFrame_API() { | |
| 26 return this; | |
| 27 } | |
| 28 | |
| 29 PP_TimeDelta VideoFrameResource::GetTimestamp() { | |
| 30 if (!frame_) { | |
| 31 VLOG(1) << "Frame is invalid"; | |
| 32 return 0.0; | |
| 33 } | |
| 34 return frame_->timestamp; | |
| 35 } | |
| 36 | |
| 37 void VideoFrameResource::SetTimestamp(PP_TimeDelta timestamp) { | |
| 38 if (!frame_) { | |
| 39 VLOG(1) << "Frame is invalid"; | |
| 40 return; | |
| 41 } | |
| 42 frame_->timestamp = timestamp; | |
| 43 } | |
| 44 | |
| 45 PP_VideoFrame_Format VideoFrameResource::GetFormat() { | |
| 46 if (!frame_) { | |
| 47 VLOG(1) << "Frame is invalid"; | |
| 48 return PP_VIDEOFRAME_FORMAT_UNKNOWN; | |
| 49 } | |
| 50 return frame_->format; | |
| 51 } | |
| 52 | |
| 53 PP_Bool VideoFrameResource::GetSize(PP_Size* size) { | |
| 54 if (!frame_) { | |
| 55 VLOG(1) << "Frame is invalid"; | |
| 56 return PP_FALSE; | |
| 57 } | |
| 58 *size = frame_->size; | |
| 59 return PP_TRUE; | |
| 60 } | |
| 61 | |
| 62 void* VideoFrameResource::GetDataBuffer() { | |
| 63 if (!frame_) { | |
| 64 VLOG(1) << "Frame is invalid"; | |
| 65 return NULL; | |
| 66 } | |
| 67 return frame_->data; | |
| 68 } | |
| 69 | |
| 70 uint32_t VideoFrameResource::GetDataBufferSize() { | |
| 71 if (!frame_) { | |
| 72 VLOG(1) << "Frame is invalid"; | |
| 73 return 0; | |
| 74 } | |
| 75 return frame_->data_size; | |
| 76 } | |
| 77 | |
| 78 } // namespace proxy | |
| 79 } // namespace ppapi | |
| OLD | NEW |