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

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

Issue 142023008: [PPAPI][MediaStream] Rename AudioFrame to AudioBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/video_frame_resource.h" 5 #include "ppapi/proxy/video_frame_resource.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ppapi/c/pp_bool.h" 8 #include "ppapi/c/pp_bool.h"
9 #include "ppapi/shared_impl/var.h" 9 #include "ppapi/shared_impl/var.h"
10 10
11 namespace ppapi { 11 namespace ppapi {
12 namespace proxy { 12 namespace proxy {
13 13
14 VideoFrameResource::VideoFrameResource(PP_Instance instance, 14 VideoFrameResource::VideoFrameResource(PP_Instance instance,
15 int32_t index, 15 int32_t index,
16 MediaStreamFrame* frame) 16 MediaStreamBuffer* buffer)
17 : Resource(OBJECT_IS_PROXY, instance), 17 : Resource(OBJECT_IS_PROXY, instance),
18 index_(index), 18 index_(index),
19 frame_(frame) { 19 buffer_(buffer) {
20 DCHECK_EQ(frame_->header.type, MediaStreamFrame::TYPE_VIDEO); 20 DCHECK_EQ(buffer_->header.type, MediaStreamBuffer::TYPE_VIDEO);
21 } 21 }
22 22
23 VideoFrameResource::~VideoFrameResource() { 23 VideoFrameResource::~VideoFrameResource() {
24 CHECK(!frame_) << "An unused (or unrecycled) frame is destroyed."; 24 CHECK(!buffer_) << "An unused (or unrecycled) frame is destroyed.";
25 } 25 }
26 26
27 thunk::PPB_VideoFrame_API* VideoFrameResource::AsPPB_VideoFrame_API() { 27 thunk::PPB_VideoFrame_API* VideoFrameResource::AsPPB_VideoFrame_API() {
28 return this; 28 return this;
29 } 29 }
30 30
31 PP_TimeDelta VideoFrameResource::GetTimestamp() { 31 PP_TimeDelta VideoFrameResource::GetTimestamp() {
32 if (!frame_) { 32 if (!buffer_) {
33 VLOG(1) << "Frame is invalid"; 33 VLOG(1) << "Frame is invalid";
34 return 0.0; 34 return 0.0;
35 } 35 }
36 return frame_->video.timestamp; 36 return buffer_->video.timestamp;
37 } 37 }
38 38
39 void VideoFrameResource::SetTimestamp(PP_TimeDelta timestamp) { 39 void VideoFrameResource::SetTimestamp(PP_TimeDelta timestamp) {
40 if (!frame_) { 40 if (!buffer_) {
41 VLOG(1) << "Frame is invalid"; 41 VLOG(1) << "Frame is invalid";
42 return; 42 return;
43 } 43 }
44 frame_->video.timestamp = timestamp; 44 buffer_->video.timestamp = timestamp;
45 } 45 }
46 46
47 PP_VideoFrame_Format VideoFrameResource::GetFormat() { 47 PP_VideoFrame_Format VideoFrameResource::GetFormat() {
48 if (!frame_) { 48 if (!buffer_) {
49 VLOG(1) << "Frame is invalid"; 49 VLOG(1) << "Frame is invalid";
50 return PP_VIDEOFRAME_FORMAT_UNKNOWN; 50 return PP_VIDEOFRAME_FORMAT_UNKNOWN;
51 } 51 }
52 return frame_->video.format; 52 return buffer_->video.format;
53 } 53 }
54 54
55 PP_Bool VideoFrameResource::GetSize(PP_Size* size) { 55 PP_Bool VideoFrameResource::GetSize(PP_Size* size) {
56 if (!frame_) { 56 if (!buffer_) {
57 VLOG(1) << "Frame is invalid"; 57 VLOG(1) << "Frame is invalid";
58 return PP_FALSE; 58 return PP_FALSE;
59 } 59 }
60 *size = frame_->video.size; 60 *size = buffer_->video.size;
61 return PP_TRUE; 61 return PP_TRUE;
62 } 62 }
63 63
64 void* VideoFrameResource::GetDataBuffer() { 64 void* VideoFrameResource::GetDataBuffer() {
65 if (!frame_) { 65 if (!buffer_) {
66 VLOG(1) << "Frame is invalid"; 66 VLOG(1) << "Frame is invalid";
67 return NULL; 67 return NULL;
68 } 68 }
69 return frame_->video.data; 69 return buffer_->video.data;
70 } 70 }
71 71
72 uint32_t VideoFrameResource::GetDataBufferSize() { 72 uint32_t VideoFrameResource::GetDataBufferSize() {
73 if (!frame_) { 73 if (!buffer_) {
74 VLOG(1) << "Frame is invalid"; 74 VLOG(1) << "Frame is invalid";
75 return 0; 75 return 0;
76 } 76 }
77 return frame_->video.data_size; 77 return buffer_->video.data_size;
78 } 78 }
79 79
80 MediaStreamFrame* VideoFrameResource::GetFrameBuffer() { 80 MediaStreamBuffer* VideoFrameResource::GetBuffer() {
81 return frame_; 81 return buffer_;
82 } 82 }
83 83
84 int32_t VideoFrameResource::GetFrameBufferIndex() { 84 int32_t VideoFrameResource::GetBufferIndex() {
85 return index_; 85 return index_;
86 } 86 }
87 87
88 void VideoFrameResource::Invalidate() { 88 void VideoFrameResource::Invalidate() {
89 DCHECK(frame_); 89 DCHECK(buffer_);
90 DCHECK_GE(index_, 0); 90 DCHECK_GE(index_, 0);
91 frame_ = NULL; 91 buffer_ = NULL;
92 index_ = -1; 92 index_ = -1;
93 } 93 }
94 94
95 } // namespace proxy 95 } // namespace proxy
96 } // namespace ppapi 96 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698