summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorpenghuang@chromium.org <penghuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-14 16:01:01 +0000
committerpenghuang@chromium.org <penghuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-14 16:01:01 +0000
commit2ae036503e150d97e08d18e3bd70a40ea812659f (patch)
tree59272788c896b71d544167c6852447299dbfea68 /ppapi
parent1e1cfab7e09b67b9972663362e294d26f12c7e73 (diff)
downloadchromium_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')
-rw-r--r--ppapi/api/ppb_audio_frame.idl4
-rw-r--r--ppapi/api/ppb_media_stream_audio_track.idl4
-rw-r--r--ppapi/ppapi_shared.gypi4
-rw-r--r--ppapi/proxy/interface_list.cc4
-rw-r--r--ppapi/shared_impl/resource.h2
-rw-r--r--ppapi/thunk/interfaces_ppb_public_dev_channel.h3
-rw-r--r--ppapi/thunk/ppb_audio_frame_api.h29
-rw-r--r--ppapi/thunk/ppb_audio_frame_thunk.cc101
-rw-r--r--ppapi/thunk/ppb_media_stream_audio_track_api.h28
-rw-r--r--ppapi/thunk/ppb_media_stream_audio_track_thunk.cc99
10 files changed, 277 insertions, 1 deletions
diff --git a/ppapi/api/ppb_audio_frame.idl b/ppapi/api/ppb_audio_frame.idl
index b0a2a47..b0c14d4 100644
--- a/ppapi/api/ppb_audio_frame.idl
+++ b/ppapi/api/ppb_audio_frame.idl
@@ -6,6 +6,9 @@
/**
* Defines the <code>PPB_AudioFrame</code> interface.
*/
+
+[generate_thunk]
+
label Chrome {
[channel=dev] M34 = 0.1
};
@@ -30,6 +33,7 @@ interface PPB_AudioFrame {
* @return A <code>PP_TimeDelta</code> containing the timestamp of the audio
* frame. Given in seconds since the start of the containing audio stream.
*/
+ [on_failure=0.0]
PP_TimeDelta GetTimestamp([in] PP_Resource frame);
/**
diff --git a/ppapi/api/ppb_media_stream_audio_track.idl b/ppapi/api/ppb_media_stream_audio_track.idl
index d57ca21..0f435ea 100644
--- a/ppapi/api/ppb_media_stream_audio_track.idl
+++ b/ppapi/api/ppb_media_stream_audio_track.idl
@@ -8,6 +8,9 @@
* receiving audio frames from a MediaStream audio track in the browser.
* This interface is still in development (Dev API status) and may change.
*/
+
+[generate_thunk]
+
label Chrome {
[channel=dev] M34 = 0.1
};
@@ -67,6 +70,7 @@ interface PPB_MediaStreamAudioTrack {
* @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
* MediaStream track has ended or <code>PP_FALSE</code> otherwise.
*/
+ [on_failure=PP_TRUE]
PP_Bool HasEnded([in] PP_Resource audio_track);
/**
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index e87bf7c..694a9ea 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -133,6 +133,8 @@
'thunk/ppb_audio_api.h',
'thunk/ppb_audio_config_api.h',
'thunk/ppb_audio_config_thunk.cc',
+ 'thunk/ppb_audio_frame_api.h',
+ 'thunk/ppb_audio_frame_thunk.cc',
'thunk/ppb_audio_input_api.h',
'thunk/ppb_audio_input_dev_thunk.cc',
'thunk/ppb_audio_thunk.cc',
@@ -201,6 +203,8 @@
'thunk/ppb_instance_thunk.cc',
'thunk/ppb_isolated_file_system_private_api.h',
'thunk/ppb_isolated_file_system_private_thunk.cc',
+ 'thunk/ppb_media_stream_audio_track_api.h',
+ 'thunk/ppb_media_stream_audio_track_thunk.cc',
'thunk/ppb_media_stream_video_track_api.h',
'thunk/ppb_media_stream_video_track_thunk.cc',
'thunk/ppb_message_loop_api.h',
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index 327d9be1..f88d33c 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -30,8 +30,9 @@
#include "ppapi/c/dev/ppb_video_capture_dev.h"
#include "ppapi/c/dev/ppb_view_dev.h"
#include "ppapi/c/extensions/dev/ppb_ext_socket_dev.h"
-#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/c/ppb_audio.h"
+#include "ppapi/c/ppb_audio_config.h"
+#include "ppapi/c/ppb_audio_frame.h"
#include "ppapi/c/ppb_console.h"
#include "ppapi/c/ppb_core.h"
#include "ppapi/c/ppb_file_io.h"
@@ -43,6 +44,7 @@
#include "ppapi/c/ppb_image_data.h"
#include "ppapi/c/ppb_input_event.h"
#include "ppapi/c/ppb_instance.h"
+#include "ppapi/c/ppb_media_stream_audio_track.h"
#include "ppapi/c/ppb_media_stream_video_track.h"
#include "ppapi/c/ppb_message_loop.h"
#include "ppapi/c/ppb_messaging.h"
diff --git a/ppapi/shared_impl/resource.h b/ppapi/shared_impl/resource.h
index 6a11076..8c6e7d6 100644
--- a/ppapi/shared_impl/resource.h
+++ b/ppapi/shared_impl/resource.h
@@ -22,6 +22,7 @@
F(ExtensionsCommon_API) \
F(PPB_Audio_API) \
F(PPB_AudioConfig_API) \
+ F(PPB_AudioFrame_API) \
F(PPB_AudioInput_API) \
F(PPB_AudioTrusted_API) \
F(PPB_Broker_API) \
@@ -53,6 +54,7 @@
F(PPB_InputEvent_API) \
F(PPB_IsolatedFileSystem_Private_API) \
F(PPB_LayerCompositor_API) \
+ F(PPB_MediaStreamAudioTrack_API) \
F(PPB_MediaStreamVideoTrack_API) \
F(PPB_MessageLoop_API) \
F(PPB_NetAddress_API) \
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