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

Unified Diff: ppapi/proxy/media_stream_video_track_resource.cc

Issue 150403006: [PPAPI][MediaStream] Support configure for video input. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build errors 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/media_stream_video_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_video_track_resource.cc
diff --git a/ppapi/proxy/media_stream_video_track_resource.cc b/ppapi/proxy/media_stream_video_track_resource.cc
index 451f259caad37f16c5a99d036a5867c4e5c3c573..aaa5b5229c8d7e556a24e24106c245dfc657dd74 100644
--- a/ppapi/proxy/media_stream_video_track_resource.cc
+++ b/ppapi/proxy/media_stream_video_track_resource.cc
@@ -5,8 +5,10 @@
#include "ppapi/proxy/media_stream_video_track_resource.h"
#include "base/logging.h"
+#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/video_frame_resource.h"
#include "ppapi/shared_impl/media_stream_buffer.h"
+#include "ppapi/shared_impl/media_stream_video_track_shared.h"
#include "ppapi/shared_impl/var.h"
namespace ppapi {
@@ -39,13 +41,53 @@ PP_Bool MediaStreamVideoTrackResource::HasEnded() {
return PP_FromBool(has_ended());
}
-
int32_t MediaStreamVideoTrackResource::Configure(
const int32_t attrib_list[],
scoped_refptr<TrackedCallback> callback) {
- // TODO(penghuang): redesign and implement Configure() to support format,
- // size, etc.
- return PP_ERROR_NOTSUPPORTED;
+ if (has_ended())
+ return PP_ERROR_FAILED;
+
+ if (TrackedCallback::IsPending(configure_callback_) ||
+ TrackedCallback::IsPending(get_frame_callback_)) {
+ return PP_ERROR_INPROGRESS;
+ }
+
+ // Do not support configure, if frames are hold by plugin.
+ if (!frames_.empty())
+ return PP_ERROR_INPROGRESS;
+
+ MediaStreamVideoTrackShared::Attributes attributes;
+ int i = 0;
+ for (;attrib_list[i] != PP_MEDIASTREAMVIDEOTRACK_ATTRIB_NONE; i += 2) {
+ switch (attrib_list[i]) {
+ case PP_MEDIASTREAMVIDEOTRACK_ATTRIB_BUFFERED_FRAMES:
+ attributes.buffers = attrib_list[i + 1];
+ break;
+ case PP_MEDIASTREAMVIDEOTRACK_ATTRIB_WIDTH:
+ attributes.width = attrib_list[i + 1];
+ break;
+ case PP_MEDIASTREAMVIDEOTRACK_ATTRIB_HEIGHT:
+ attributes.height = attrib_list[i + 1];
+ break;
+ case PP_MEDIASTREAMVIDEOTRACK_ATTRIB_FORMAT:
+ attributes.format = static_cast<PP_VideoFrame_Format>(attrib_list[i + 1]);
+ break;
+ default:
+ return PP_ERROR_BADARGUMENT;
+ }
+ }
+
+ if (!MediaStreamVideoTrackShared::VerifyAttributes(attributes))
+ return PP_ERROR_BADARGUMENT;
+
+ configure_callback_ = callback;
+ Call<PpapiPluginMsg_MediaStreamVideoTrack_ConfigureReply>(
+ RENDERER,
+ PpapiHostMsg_MediaStreamVideoTrack_Configure(attributes),
+ base::Bind(&MediaStreamVideoTrackResource::OnPluginMsgConfigureReply,
+ base::Unretained(this)),
+ callback);
+ return PP_OK_COMPLETIONPENDING;
}
int32_t MediaStreamVideoTrackResource::GetAttrib(
@@ -61,8 +103,10 @@ int32_t MediaStreamVideoTrackResource::GetFrame(
if (has_ended())
return PP_ERROR_FAILED;
- if (TrackedCallback::IsPending(get_frame_callback_))
+ if (TrackedCallback::IsPending(configure_callback_) ||
+ TrackedCallback::IsPending(get_frame_callback_)) {
return PP_ERROR_INPROGRESS;
+ }
*frame = GetVideoFrame();
if (*frame)
@@ -144,5 +188,14 @@ void MediaStreamVideoTrackResource::ReleaseFrames() {
}
}
+void MediaStreamVideoTrackResource::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_video_track_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698