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

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

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

Powered by Google App Engine
This is Rietveld 408576698