diff options
author | penghuang@chromium.org <penghuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-14 16:01:01 +0000 |
---|---|---|
committer | penghuang@chromium.org <penghuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-14 16:01:01 +0000 |
commit | 2ae036503e150d97e08d18e3bd70a40ea812659f (patch) | |
tree | 59272788c896b71d544167c6852447299dbfea68 /ppapi/thunk | |
parent | 1e1cfab7e09b67b9972663362e294d26f12c7e73 (diff) | |
download | chromium_src-2ae036503e150d97e08d18e3bd70a40ea812659f.zip chromium_src-2ae036503e150d97e08d18e3bd70a40ea812659f.tar.gz chromium_src-2ae036503e150d97e08d18e3bd70a40ea812659f.tar.bz2 |
[PPAPI] Pepper MediaStream API audio thunk implementation
BUG=330851
Review URL: https://codereview.chromium.org/133703004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244731 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk')
-rw-r--r-- | ppapi/thunk/interfaces_ppb_public_dev_channel.h | 3 | ||||
-rw-r--r-- | ppapi/thunk/ppb_audio_frame_api.h | 29 | ||||
-rw-r--r-- | ppapi/thunk/ppb_audio_frame_thunk.cc | 101 | ||||
-rw-r--r-- | ppapi/thunk/ppb_media_stream_audio_track_api.h | 28 | ||||
-rw-r--r-- | ppapi/thunk/ppb_media_stream_audio_track_thunk.cc | 99 |
5 files changed, 260 insertions, 0 deletions
diff --git a/ppapi/thunk/interfaces_ppb_public_dev_channel.h b/ppapi/thunk/interfaces_ppb_public_dev_channel.h index 2d2519e..34e5de4 100644 --- a/ppapi/thunk/interfaces_ppb_public_dev_channel.h +++ b/ppapi/thunk/interfaces_ppb_public_dev_channel.h @@ -8,7 +8,10 @@ #include "ppapi/thunk/interfaces_preamble.h" // Interfaces go here. +PROXIED_IFACE(PPB_AUDIOFRAME_INTERFACE_0_1, PPB_AudioFrame_0_1) PROXIED_IFACE(PPB_FILEREF_INTERFACE_1_2, PPB_FileRef_1_2) +PROXIED_IFACE(PPB_MEDIASTREAMAUDIOTRACK_INTERFACE_0_1, + PPB_MediaStreamAudioTrack_0_1) PROXIED_IFACE(PPB_MEDIASTREAMVIDEOTRACK_INTERFACE_0_1, PPB_MediaStreamVideoTrack_0_1) PROXIED_IFACE(PPB_VIDEOFRAME_INTERFACE_0_1, PPB_VideoFrame_0_1) diff --git a/ppapi/thunk/ppb_audio_frame_api.h b/ppapi/thunk/ppb_audio_frame_api.h new file mode 100644 index 0000000..d900538 --- /dev/null +++ b/ppapi/thunk/ppb_audio_frame_api.h @@ -0,0 +1,29 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_THUNK_PPB_AUDIO_FRAME_API_H_ +#define PPAPI_THUNK_PPB_AUDIO_FRAME_API_H_ + +#include "ppapi/c/ppb_audio_frame.h" +#include "ppapi/thunk/ppapi_thunk_export.h" + +namespace ppapi { +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_AudioFrame_API { + public: + virtual ~PPB_AudioFrame_API() {} + virtual PP_TimeDelta GetTimestamp() = 0; + virtual void SetTimestamp(PP_TimeDelta timestamp) = 0; + virtual uint32_t GetSampleSize() = 0; + virtual uint32_t GetNumberOfChannels() = 0; + virtual uint32_t GetNumberOfSamples() = 0; + virtual void* GetDataBuffer() = 0; + virtual uint32_t GetDataBufferSize() = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_AUDIO_FRAME_API_H_ diff --git a/ppapi/thunk/ppb_audio_frame_thunk.cc b/ppapi/thunk/ppb_audio_frame_thunk.cc new file mode 100644 index 0000000..fa4d865 --- /dev/null +++ b/ppapi/thunk/ppb_audio_frame_thunk.cc @@ -0,0 +1,101 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// From ppb_audio_frame.idl modified Mon Jan 13 11:39:02 2014. + +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_audio_frame.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_audio_frame_api.h" +#include "ppapi/thunk/ppb_instance_api.h" +#include "ppapi/thunk/resource_creation_api.h" +#include "ppapi/thunk/thunk.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Bool IsAudioFrame(PP_Resource resource) { + VLOG(4) << "PPB_AudioFrame::IsAudioFrame()"; + EnterResource<PPB_AudioFrame_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +PP_TimeDelta GetTimestamp(PP_Resource frame) { + VLOG(4) << "PPB_AudioFrame::GetTimestamp()"; + EnterResource<PPB_AudioFrame_API> enter(frame, true); + if (enter.failed()) + return 0.0; + return enter.object()->GetTimestamp(); +} + +void SetTimestamp(PP_Resource frame, PP_TimeDelta timestamp) { + VLOG(4) << "PPB_AudioFrame::SetTimestamp()"; + EnterResource<PPB_AudioFrame_API> enter(frame, true); + if (enter.failed()) + return; + enter.object()->SetTimestamp(timestamp); +} + +uint32_t GetSampleSize(PP_Resource frame) { + VLOG(4) << "PPB_AudioFrame::GetSampleSize()"; + EnterResource<PPB_AudioFrame_API> enter(frame, true); + if (enter.failed()) + return 0; + return enter.object()->GetSampleSize(); +} + +uint32_t GetNumberOfChannels(PP_Resource frame) { + VLOG(4) << "PPB_AudioFrame::GetNumberOfChannels()"; + EnterResource<PPB_AudioFrame_API> enter(frame, true); + if (enter.failed()) + return 0; + return enter.object()->GetNumberOfChannels(); +} + +uint32_t GetNumberOfSamples(PP_Resource frame) { + VLOG(4) << "PPB_AudioFrame::GetNumberOfSamples()"; + EnterResource<PPB_AudioFrame_API> enter(frame, true); + if (enter.failed()) + return 0; + return enter.object()->GetNumberOfSamples(); +} + +void* GetDataBuffer(PP_Resource frame) { + VLOG(4) << "PPB_AudioFrame::GetDataBuffer()"; + EnterResource<PPB_AudioFrame_API> enter(frame, true); + if (enter.failed()) + return NULL; + return enter.object()->GetDataBuffer(); +} + +uint32_t GetDataBufferSize(PP_Resource frame) { + VLOG(4) << "PPB_AudioFrame::GetDataBufferSize()"; + EnterResource<PPB_AudioFrame_API> enter(frame, true); + if (enter.failed()) + return 0; + return enter.object()->GetDataBufferSize(); +} + +const PPB_AudioFrame_0_1 g_ppb_audioframe_thunk_0_1 = { + &IsAudioFrame, + &GetTimestamp, + &SetTimestamp, + &GetSampleSize, + &GetNumberOfChannels, + &GetNumberOfSamples, + &GetDataBuffer, + &GetDataBufferSize +}; + +} // namespace + +const PPB_AudioFrame_0_1* GetPPB_AudioFrame_0_1_Thunk() { + return &g_ppb_audioframe_thunk_0_1; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_media_stream_audio_track_api.h b/ppapi/thunk/ppb_media_stream_audio_track_api.h new file mode 100644 index 0000000..7b2068a --- /dev/null +++ b/ppapi/thunk/ppb_media_stream_audio_track_api.h @@ -0,0 +1,28 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_THUNK_PPB_MEDIA_STREAM_AUDIO_TRACK_API_H_ +#define PPAPI_THUNK_PPB_MEDIA_STREAM_AUDIO_TRACK_API_H_ + +namespace ppapi { +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_MediaStreamAudioTrack_API { + public: + virtual ~PPB_MediaStreamAudioTrack_API() {} + virtual PP_Var GetId() = 0; + virtual PP_Bool HasEnded() = 0; + virtual int32_t Configure(uint32_t samples_per_frame, + uint32_t max_buffered_frames) = 0; + virtual int32_t GetFrame( + PP_Resource* frame, + scoped_refptr<ppapi::TrackedCallback> callback) = 0; + virtual int32_t RecycleFrame(PP_Resource frame) = 0; + virtual void Close() = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_MEDIA_STREAM_AUDIO_TRACK_API_H_ diff --git a/ppapi/thunk/ppb_media_stream_audio_track_thunk.cc b/ppapi/thunk/ppb_media_stream_audio_track_thunk.cc new file mode 100644 index 0000000..ca066c1 --- /dev/null +++ b/ppapi/thunk/ppb_media_stream_audio_track_thunk.cc @@ -0,0 +1,99 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// From ppb_media_stream_audio_track.idl modified Mon Jan 13 11:50:41 2014. + +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_media_stream_audio_track.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_instance_api.h" +#include "ppapi/thunk/ppb_media_stream_audio_track_api.h" +#include "ppapi/thunk/resource_creation_api.h" +#include "ppapi/thunk/thunk.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Bool IsMediaStreamAudioTrack(PP_Resource resource) { + VLOG(4) << "PPB_MediaStreamAudioTrack::IsMediaStreamAudioTrack()"; + EnterResource<PPB_MediaStreamAudioTrack_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +int32_t Configure(PP_Resource audio_track, + uint32_t samples_per_frame, + uint32_t max_buffered_frames) { + VLOG(4) << "PPB_MediaStreamAudioTrack::Configure()"; + EnterResource<PPB_MediaStreamAudioTrack_API> enter(audio_track, true); + if (enter.failed()) + return enter.retval(); + return enter.object()->Configure(samples_per_frame, max_buffered_frames); +} + +struct PP_Var GetId(PP_Resource audio_track) { + VLOG(4) << "PPB_MediaStreamAudioTrack::GetId()"; + EnterResource<PPB_MediaStreamAudioTrack_API> enter(audio_track, true); + if (enter.failed()) + return PP_MakeUndefined(); + return enter.object()->GetId(); +} + +PP_Bool HasEnded(PP_Resource audio_track) { + VLOG(4) << "PPB_MediaStreamAudioTrack::HasEnded()"; + EnterResource<PPB_MediaStreamAudioTrack_API> enter(audio_track, true); + if (enter.failed()) + return PP_TRUE; + return enter.object()->HasEnded(); +} + +int32_t GetFrame(PP_Resource audio_track, + PP_Resource* frame, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_MediaStreamAudioTrack::GetFrame()"; + EnterResource<PPB_MediaStreamAudioTrack_API> enter(audio_track, + callback, + true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->GetFrame(frame, enter.callback())); +} + +int32_t RecycleFrame(PP_Resource audio_track, PP_Resource frame) { + VLOG(4) << "PPB_MediaStreamAudioTrack::RecycleFrame()"; + EnterResource<PPB_MediaStreamAudioTrack_API> enter(audio_track, true); + if (enter.failed()) + return enter.retval(); + return enter.object()->RecycleFrame(frame); +} + +void Close(PP_Resource audio_track) { + VLOG(4) << "PPB_MediaStreamAudioTrack::Close()"; + EnterResource<PPB_MediaStreamAudioTrack_API> enter(audio_track, true); + if (enter.failed()) + return; + enter.object()->Close(); +} + +const PPB_MediaStreamAudioTrack_0_1 g_ppb_mediastreamaudiotrack_thunk_0_1 = { + &IsMediaStreamAudioTrack, + &Configure, + &GetId, + &HasEnded, + &GetFrame, + &RecycleFrame, + &Close +}; + +} // namespace + +const PPB_MediaStreamAudioTrack_0_1* GetPPB_MediaStreamAudioTrack_0_1_Thunk() { + return &g_ppb_mediastreamaudiotrack_thunk_0_1; +} + +} // namespace thunk +} // namespace ppapi |