Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Side by Side Diff: ppapi/proxy/video_frame_resource.cc

Issue 128683003: [PPAPI] Implement media stream video track API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@video_track_impl_cl
Patch Set: Fix review issues Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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* frame)
16 : Resource(OBJECT_IS_PROXY, instance),
17 index_(index),
18 frame_(frame) {
19 DCHECK_EQ(frame_->header.type, MediaStreamFrame::TYPE_VIDEO);
20 }
21
22 VideoFrameResource::~VideoFrameResource() {
23 CHECK(!frame_) << "An unused (or unrecycled) frame is destroyed.";
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_->video.timestamp;
36 }
37
38 void VideoFrameResource::SetTimestamp(PP_TimeDelta timestamp) {
39 if (!frame_) {
40 VLOG(1) << "Frame is invalid";
41 return;
42 }
43 frame_->video.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_->video.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_->video.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_->video.data;
69 }
70
71 uint32_t VideoFrameResource::GetDataBufferSize() {
72 if (!frame_) {
73 VLOG(1) << "Frame is invalid";
74 return 0;
75 }
76 return frame_->video.data_size;
77 }
78
79 MediaStreamFrame* VideoFrameResource::GetFrameBuffer() {
80 return frame_;
81 }
82
83 int32_t VideoFrameResource::GetFrameBufferIndex() {
84 return index_;
85 }
86
87 void VideoFrameResource::Invalidate() {
88 DCHECK(frame_);
89 DCHECK_GE(index_, 0);
90 frame_ = NULL;
91 index_ = -1;
92 }
93
94 } // namespace proxy
95 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698