Chromium Code Reviews| 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..ff8ccba3787fe6c2564d5cd129ac612c24f15c4c 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,64 @@ 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()) { |
|
yzshen1
2014/02/13 19:23:26
nit: no need to have {} and line 57.
Peng
2014/02/13 21:28:34
Done.
|
| + 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_FAILED; |
| + } |
| + |
| + MediaStreamVideoTrackShared::Attributes attributes; |
| + int i = 0; |
| + for (;attrib_list[i] != PP_MEDIASTREAMVIDEOTRACK_ATTRIB_NONE; i += 2) { |
|
jschuh
2014/02/13 20:38:46
Which process does this come from, and how do you
Peng
2014/02/13 21:28:34
It is from plugin. And this function is executed i
Peng
2014/02/13 21:28:34
The argument is from plugin. And this function is
|
| + 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 +114,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 +199,13 @@ void MediaStreamVideoTrackResource::ReleaseFrames() { |
| } |
| } |
| +void MediaStreamVideoTrackResource::OnPluginMsgConfigureReply( |
| + const ResourceMessageReplyParams& params) { |
| + DCHECK(TrackedCallback::IsPending(configure_callback_)); |
|
yzshen1
2014/02/13 19:23:26
Please explicitly check if (!IsPending()) return.
Peng
2014/02/13 21:28:34
Done.
|
| + scoped_refptr<TrackedCallback> callback; |
| + callback.swap(configure_callback_); |
| + callback->Run(params.result()); |
| +} |
| + |
| } // namespace proxy |
| } // namespace ppapi |