diff options
author | penghuang@chromium.org <penghuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-26 00:44:05 +0000 |
---|---|---|
committer | penghuang@chromium.org <penghuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-26 00:44:05 +0000 |
commit | 61ebd74e979d3be1daea3569e9e7411401afdf40 (patch) | |
tree | a781bafd3cc5980b2f3a4bea95f9e71c70abf047 /ppapi/proxy/media_stream_video_track_resource.cc | |
parent | 679f6679273c9cafd8f49fe18359c1774f50b744 (diff) | |
download | chromium_src-61ebd74e979d3be1daea3569e9e7411401afdf40.zip chromium_src-61ebd74e979d3be1daea3569e9e7411401afdf40.tar.gz chromium_src-61ebd74e979d3be1daea3569e9e7411401afdf40.tar.bz2 |
[PPAPI][MediaStream] Support configure for video input.
Support configuring frame format and size for video input.
BUG=330851
Review URL: https://codereview.chromium.org/150403006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253307 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/media_stream_video_track_resource.cc')
-rw-r--r-- | ppapi/proxy/media_stream_video_track_resource.cc | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/ppapi/proxy/media_stream_video_track_resource.cc b/ppapi/proxy/media_stream_video_track_resource.cc index 451f259..aaa5b52 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 |