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

Unified Diff: ppapi/proxy/media_stream_audio_track_resource.cc

Issue 290993005: Support configuring number of audio buffers in MediaStream Pepper API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix uninitialized variable Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/media_stream_audio_track_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/media_stream_audio_track_resource.cc
diff --git a/ppapi/proxy/media_stream_audio_track_resource.cc b/ppapi/proxy/media_stream_audio_track_resource.cc
index 15a6a16eb153c21128df6a385a8f20928d69fe29..621b7b02c869d00860a76fc0d91a9d8d0fcf6f57 100644
--- a/ppapi/proxy/media_stream_audio_track_resource.cc
+++ b/ppapi/proxy/media_stream_audio_track_resource.cc
@@ -5,6 +5,8 @@
#include "ppapi/proxy/media_stream_audio_track_resource.h"
#include "ppapi/proxy/audio_buffer_resource.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/media_stream_audio_track_shared.h"
#include "ppapi/shared_impl/media_stream_buffer.h"
#include "ppapi/shared_impl/var.h"
@@ -41,8 +43,46 @@ PP_Bool MediaStreamAudioTrackResource::HasEnded() {
int32_t MediaStreamAudioTrackResource::Configure(
const int32_t attrib_list[],
scoped_refptr<TrackedCallback> callback) {
- // TODO(penghuang): Implement this function.
- return PP_ERROR_NOTSUPPORTED;
+ if (has_ended())
+ return PP_ERROR_FAILED;
+
+ if (TrackedCallback::IsPending(configure_callback_) ||
+ TrackedCallback::IsPending(get_buffer_callback_)) {
+ return PP_ERROR_INPROGRESS;
+ }
+
+ // Do not support configure if audio buffers are held by plugin.
+ if (!buffers_.empty())
+ return PP_ERROR_INPROGRESS;
+
+ MediaStreamAudioTrackShared::Attributes attributes;
+ int i = 0;
+ for (; attrib_list[i] != PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE; i += 2) {
+ switch (attrib_list[i]) {
+ case PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS:
+ attributes.buffers = attrib_list[i + 1];
+ break;
+ case PP_MEDIASTREAMAUDIOTRACK_ATTRIB_SAMPLE_RATE:
+ case PP_MEDIASTREAMAUDIOTRACK_ATTRIB_SAMPLE_SIZE:
+ case PP_MEDIASTREAMAUDIOTRACK_ATTRIB_CHANNELS:
+ case PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION:
+ return PP_ERROR_NOTSUPPORTED;
+ default:
+ return PP_ERROR_BADARGUMENT;
+ }
+ }
+
+ if (!MediaStreamAudioTrackShared::VerifyAttributes(attributes))
+ return PP_ERROR_BADARGUMENT;
+
+ configure_callback_ = callback;
+ Call<PpapiPluginMsg_MediaStreamAudioTrack_ConfigureReply>(
+ RENDERER,
+ PpapiHostMsg_MediaStreamAudioTrack_Configure(attributes),
+ base::Bind(&MediaStreamAudioTrackResource::OnPluginMsgConfigureReply,
+ base::Unretained(this)),
+ callback);
+ return PP_OK_COMPLETIONPENDING;
}
int32_t MediaStreamAudioTrackResource::GetAttrib(
@@ -58,7 +98,8 @@ int32_t MediaStreamAudioTrackResource::GetBuffer(
if (has_ended())
return PP_ERROR_FAILED;
- if (TrackedCallback::IsPending(get_buffer_callback_))
+ if (TrackedCallback::IsPending(configure_callback_) ||
+ TrackedCallback::IsPending(get_buffer_callback_))
return PP_ERROR_INPROGRESS;
*buffer = GetAudioBuffer();
@@ -144,5 +185,14 @@ void MediaStreamAudioTrackResource::ReleaseBuffers() {
}
}
+void MediaStreamAudioTrackResource::OnPluginMsgConfigureReply(
+ const ResourceMessageReplyParams& params) {
+ if (TrackedCallback::IsPending(configure_callback_)) {
+ scoped_refptr<TrackedCallback> callback;
+ callback.swap(configure_callback_);
+ callback->Run(params.result());
+ }
+}
+
} // namespace proxy
} // namespace ppapi
« no previous file with comments | « ppapi/proxy/media_stream_audio_track_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698