Index: ppapi/proxy/audio_frame_resource.cc |
diff --git a/ppapi/proxy/video_frame_resource.cc b/ppapi/proxy/audio_frame_resource.cc |
similarity index 46% |
copy from ppapi/proxy/video_frame_resource.cc |
copy to ppapi/proxy/audio_frame_resource.cc |
index b314838076aea7e517f9ba4fca90280631208c4a..fd18eeaacffbdc35c0a784ec2f37f40b614f69eb 100644 |
--- a/ppapi/proxy/video_frame_resource.cc |
+++ b/ppapi/proxy/audio_frame_resource.cc |
@@ -2,90 +2,104 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "ppapi/proxy/video_frame_resource.h" |
+#include "ppapi/proxy/audio_frame_resource.h" |
-#include "base/logging.h" |
#include "ppapi/c/pp_bool.h" |
#include "ppapi/shared_impl/var.h" |
namespace ppapi { |
namespace proxy { |
-VideoFrameResource::VideoFrameResource(PP_Instance instance, |
+AudioFrameResource::AudioFrameResource(PP_Instance instance, |
int32_t index, |
MediaStreamFrame* frame) |
: Resource(OBJECT_IS_PROXY, instance), |
index_(index), |
frame_(frame) { |
- DCHECK_EQ(frame_->header.type, MediaStreamFrame::TYPE_VIDEO); |
+ DCHECK_EQ(frame_->header.type, MediaStreamFrame::TYPE_AUDIO); |
} |
-VideoFrameResource::~VideoFrameResource() { |
+AudioFrameResource::~AudioFrameResource() { |
CHECK(!frame_) << "An unused (or unrecycled) frame is destroyed."; |
} |
-thunk::PPB_VideoFrame_API* VideoFrameResource::AsPPB_VideoFrame_API() { |
+thunk::PPB_AudioFrame_API* AudioFrameResource::AsPPB_AudioFrame_API() { |
return this; |
} |
-PP_TimeDelta VideoFrameResource::GetTimestamp() { |
+PP_TimeDelta AudioFrameResource::GetTimestamp() { |
if (!frame_) { |
VLOG(1) << "Frame is invalid"; |
return 0.0; |
} |
- return frame_->video.timestamp; |
+ return frame_->audio.timestamp; |
} |
-void VideoFrameResource::SetTimestamp(PP_TimeDelta timestamp) { |
+void AudioFrameResource::SetTimestamp(PP_TimeDelta timestamp) { |
if (!frame_) { |
VLOG(1) << "Frame is invalid"; |
return; |
} |
- frame_->video.timestamp = timestamp; |
+ frame_->audio.timestamp = timestamp; |
} |
-PP_VideoFrame_Format VideoFrameResource::GetFormat() { |
+PP_AudioSampleRate AudioFrameResource::GetSampleRate() { |
if (!frame_) { |
VLOG(1) << "Frame is invalid"; |
- return PP_VIDEOFRAME_FORMAT_UNKNOWN; |
+ return PP_AUDIOSAMPLERATE_NONE; |
} |
- return frame_->video.format; |
+ return frame_->audio.sample_rate; |
} |
-PP_Bool VideoFrameResource::GetSize(PP_Size* size) { |
+uint32_t AudioFrameResource::GetSampleSize() { |
if (!frame_) { |
VLOG(1) << "Frame is invalid"; |
- return PP_FALSE; |
+ return 0; |
+ } |
+ return 2; |
+} |
+ |
+uint32_t AudioFrameResource::GetNumberOfChannels() { |
+ if (!frame_) { |
+ VLOG(1) << "Frame is invalid"; |
+ return 0; |
+ } |
+ return frame_->audio.number_of_channels; |
+} |
+ |
+uint32_t AudioFrameResource::GetNumberOfSamples() { |
+ if (!frame_) { |
+ VLOG(1) << "Frame is invalid"; |
+ return 0; |
} |
- *size = frame_->video.size; |
- return PP_TRUE; |
+ return frame_->audio.number_of_samples; |
} |
-void* VideoFrameResource::GetDataBuffer() { |
+void* AudioFrameResource::GetDataBuffer() { |
if (!frame_) { |
VLOG(1) << "Frame is invalid"; |
return NULL; |
} |
- return frame_->video.data; |
+ return frame_->audio.data; |
} |
-uint32_t VideoFrameResource::GetDataBufferSize() { |
+uint32_t AudioFrameResource::GetDataBufferSize() { |
if (!frame_) { |
VLOG(1) << "Frame is invalid"; |
return 0; |
} |
- return frame_->video.data_size; |
+ return frame_->audio.data_size; |
} |
-MediaStreamFrame* VideoFrameResource::GetFrameBuffer() { |
+MediaStreamFrame* AudioFrameResource::GetFrameBuffer() { |
return frame_; |
} |
-int32_t VideoFrameResource::GetFrameBufferIndex() { |
+int32_t AudioFrameResource::GetFrameBufferIndex() { |
return index_; |
} |
-void VideoFrameResource::Invalidate() { |
+void AudioFrameResource::Invalidate() { |
DCHECK(frame_); |
DCHECK_GE(index_, 0); |
frame_ = NULL; |