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..e665d5bcc3b444eac2b54cd0c44ebc662069bef7 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,62 @@ 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.mask |= MediaStreamVideoTrackShared::Attributes::MASK_BUFFERS; |
+ attributes.buffers = attrib_list[i + 1]; |
+ break; |
+ case PP_MEDIASTREAMVIDEOTRACK_ATTRIB_WIDTH: |
+ attributes.mask |= MediaStreamVideoTrackShared::Attributes::MASK_WIDTH; |
+ attributes.width = attrib_list[i + 1]; |
+ break; |
+ case PP_MEDIASTREAMVIDEOTRACK_ATTRIB_HEIGHT: |
+ attributes.mask |= MediaStreamVideoTrackShared::Attributes::MASK_HEIGHT; |
+ attributes.height = attrib_list[i + 1]; |
+ break; |
+ case PP_MEDIASTREAMVIDEOTRACK_ATTRIB_FORMAT: |
+ attributes.mask |= MediaStreamVideoTrackShared::Attributes::MASK_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; |
+ } |
+ |
+ if (!attributes.mask) { |
+ return PP_OK; |
+ } |
+ |
+ 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 +112,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 +197,14 @@ void MediaStreamVideoTrackResource::ReleaseFrames() { |
} |
} |
+void MediaStreamVideoTrackResource::OnPluginMsgConfigureReply( |
yzshen1
2014/02/14 18:25:44
In the case of failure, do we guarantee that the u
Peng
2014/02/14 20:04:50
We verify attrib_list in both plugin and renderer
yzshen1
2014/02/18 18:11:39
It seems bad if we mess up the state this way. (Na
Peng
2014/02/18 22:30:09
discussed it offline. Updated the doc. Done
|
+ const ResourceMessageReplyParams& params) { |
+ if (TrackedCallback::IsPending(configure_callback_)) { |
+ scoped_refptr<TrackedCallback> callback; |
+ callback.swap(configure_callback_); |
+ callback->Run(params.result()); |
+ } |
+} |
+ |
} // namespace proxy |
} // namespace ppapi |