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

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

Issue 142023008: [PPAPI][MediaStream] Rename AudioFrame to AudioBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review issues 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
« no previous file with comments | « ppapi/proxy/audio_frame_resource.h ('k') | ppapi/proxy/media_stream_audio_track_resource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/audio_frame_resource.h" 5 #include "ppapi/proxy/audio_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/media_stream_buffer.h"
9 #include "ppapi/shared_impl/var.h" 10 #include "ppapi/shared_impl/var.h"
10 11
11 namespace ppapi { 12 namespace ppapi {
12 namespace proxy { 13 namespace proxy {
13 14
14 AudioFrameResource::AudioFrameResource(PP_Instance instance, 15 AudioFrameResource::AudioFrameResource(PP_Instance instance,
15 int32_t index, 16 int32_t index,
16 MediaStreamFrame* frame) 17 MediaStreamBuffer* buffer)
17 : Resource(OBJECT_IS_PROXY, instance), 18 : Resource(OBJECT_IS_PROXY, instance),
18 index_(index), 19 index_(index),
19 frame_(frame) { 20 buffer_(buffer) {
20 DCHECK_EQ(frame_->header.type, MediaStreamFrame::TYPE_AUDIO); 21 DCHECK_EQ(buffer_->header.type, MediaStreamBuffer::TYPE_AUDIO);
21 } 22 }
22 23
23 AudioFrameResource::~AudioFrameResource() { 24 AudioFrameResource::~AudioFrameResource() {
24 CHECK(!frame_) << "An unused (or unrecycled) frame is destroyed."; 25 CHECK(!buffer_) << "An unused (or unrecycled) frame is destroyed.";
25 } 26 }
26 27
27 thunk::PPB_AudioFrame_API* AudioFrameResource::AsPPB_AudioFrame_API() { 28 thunk::PPB_AudioFrame_API* AudioFrameResource::AsPPB_AudioFrame_API() {
28 return this; 29 return this;
29 } 30 }
30 31
31 PP_TimeDelta AudioFrameResource::GetTimestamp() { 32 PP_TimeDelta AudioFrameResource::GetTimestamp() {
32 if (!frame_) { 33 if (!buffer_) {
33 VLOG(1) << "Frame is invalid"; 34 VLOG(1) << "Buffer is invalid";
34 return 0.0; 35 return 0.0;
35 } 36 }
36 return frame_->audio.timestamp; 37 return buffer_->audio.timestamp;
37 } 38 }
38 39
39 void AudioFrameResource::SetTimestamp(PP_TimeDelta timestamp) { 40 void AudioFrameResource::SetTimestamp(PP_TimeDelta timestamp) {
40 if (!frame_) { 41 if (!buffer_) {
41 VLOG(1) << "Frame is invalid"; 42 VLOG(1) << "Buffer is invalid";
42 return; 43 return;
43 } 44 }
44 frame_->audio.timestamp = timestamp; 45 buffer_->audio.timestamp = timestamp;
45 } 46 }
46 47
47 PP_AudioFrame_SampleRate AudioFrameResource::GetSampleRate() { 48 PP_AudioFrame_SampleRate AudioFrameResource::GetSampleRate() {
48 if (!frame_) { 49 if (!buffer_) {
49 VLOG(1) << "Frame is invalid"; 50 VLOG(1) << "Buffer is invalid";
50 return PP_AUDIOFRAME_SAMPLERATE_UNKNOWN; 51 return PP_AUDIOFRAME_SAMPLERATE_UNKNOWN;
51 } 52 }
52 return frame_->audio.sample_rate; 53 return buffer_->audio.sample_rate;
53 } 54 }
54 55
55 PP_AudioFrame_SampleSize AudioFrameResource::GetSampleSize() { 56 PP_AudioFrame_SampleSize AudioFrameResource::GetSampleSize() {
56 if (!frame_) { 57 if (!buffer_) {
57 VLOG(1) << "Frame is invalid"; 58 VLOG(1) << "Buffer is invalid";
58 return PP_AUDIOFRAME_SAMPLESIZE_UNKNOWN; 59 return PP_AUDIOFRAME_SAMPLESIZE_UNKNOWN;
59 } 60 }
60 return PP_AUDIOFRAME_SAMPLESIZE_16_BITS; 61 return PP_AUDIOFRAME_SAMPLESIZE_16_BITS;
61 } 62 }
62 63
63 uint32_t AudioFrameResource::GetNumberOfChannels() { 64 uint32_t AudioFrameResource::GetNumberOfChannels() {
64 if (!frame_) { 65 if (!buffer_) {
65 VLOG(1) << "Frame is invalid"; 66 VLOG(1) << "Buffer is invalid";
66 return 0; 67 return 0;
67 } 68 }
68 return frame_->audio.number_of_channels; 69 return buffer_->audio.number_of_channels;
69 } 70 }
70 71
71 uint32_t AudioFrameResource::GetNumberOfSamples() { 72 uint32_t AudioFrameResource::GetNumberOfSamples() {
72 if (!frame_) { 73 if (!buffer_) {
73 VLOG(1) << "Frame is invalid"; 74 VLOG(1) << "Buffer is invalid";
74 return 0; 75 return 0;
75 } 76 }
76 return frame_->audio.number_of_samples; 77 return buffer_->audio.number_of_samples;
77 } 78 }
78 79
79 void* AudioFrameResource::GetDataBuffer() { 80 void* AudioFrameResource::GetDataBuffer() {
80 if (!frame_) { 81 if (!buffer_) {
81 VLOG(1) << "Frame is invalid"; 82 VLOG(1) << "Buffer is invalid";
82 return NULL; 83 return NULL;
83 } 84 }
84 return frame_->audio.data; 85 return buffer_->audio.data;
85 } 86 }
86 87
87 uint32_t AudioFrameResource::GetDataBufferSize() { 88 uint32_t AudioFrameResource::GetDataBufferSize() {
88 if (!frame_) { 89 if (!buffer_) {
89 VLOG(1) << "Frame is invalid"; 90 VLOG(1) << "Buffer is invalid";
90 return 0; 91 return 0;
91 } 92 }
92 return frame_->audio.data_size; 93 return buffer_->audio.data_size;
93 } 94 }
94 95
95 MediaStreamFrame* AudioFrameResource::GetFrameBuffer() { 96 MediaStreamBuffer* AudioFrameResource::GetBuffer() {
96 return frame_; 97 return buffer_;
97 } 98 }
98 99
99 int32_t AudioFrameResource::GetFrameBufferIndex() { 100 int32_t AudioFrameResource::GetBufferIndex() {
100 return index_; 101 return index_;
101 } 102 }
102 103
103 void AudioFrameResource::Invalidate() { 104 void AudioFrameResource::Invalidate() {
104 DCHECK(frame_); 105 DCHECK(buffer_);
105 DCHECK_GE(index_, 0); 106 DCHECK_GE(index_, 0);
106 frame_ = NULL; 107 buffer_ = NULL;
107 index_ = -1; 108 index_ = -1;
108 } 109 }
109 110
110 } // namespace proxy 111 } // namespace proxy
111 } // namespace ppapi 112 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/audio_frame_resource.h ('k') | ppapi/proxy/media_stream_audio_track_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698