summaryrefslogtreecommitdiffstats
path: root/webkit/plugins
diff options
context:
space:
mode:
authorfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-21 01:41:15 +0000
committerfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-21 01:41:15 +0000
commit3f1e5b1080e54d8c9baf6410a27631163d473148 (patch)
tree312c45edef08ddc022e4e26cc5c4180703d5399c /webkit/plugins
parent5d1363b22e8b04f390f5a0abdd785331a75ea79f (diff)
downloadchromium_src-3f1e5b1080e54d8c9baf6410a27631163d473148.zip
chromium_src-3f1e5b1080e54d8c9baf6410a27631163d473148.tar.gz
chromium_src-3f1e5b1080e54d8c9baf6410a27631163d473148.tar.bz2
Fix PPB_VideoDecoder_Impl::NotifyEndOfBitstreamBuffer to use correct ID.
Enhanced gles2.cc sample plugin to have multipe decodes outstanding at a time, and assert that we get back from the decode API exactly the bitstream buffers we sent to it. This CL is relative to http://codereview.chromium.org/7200033/ which must land first. BUG=86235 TEST=gles2 sample plugin completes correctly even with concurrent Decode()s. Review URL: http://codereview.chromium.org/7204038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89779 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r--webkit/plugins/ppapi/ppb_video_decoder_impl.cc21
-rw-r--r--webkit/plugins/ppapi/ppb_video_decoder_impl.h6
2 files changed, 14 insertions, 13 deletions
diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
index 6e36e2e..6469fbe 100644
--- a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
+++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
@@ -63,8 +63,7 @@ PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PluginInstance* instance)
: Resource(instance),
callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
abort_callback_(PP_BlockUntilComplete()),
- flush_callback_(PP_BlockUntilComplete()),
- bitstream_buffer_callback_(PP_BlockUntilComplete()) {
+ flush_callback_(PP_BlockUntilComplete()) {
ppp_videodecoder_ =
static_cast<const PPP_VideoDecoder_Dev*>(instance->module()->
GetPluginInterface(PPP_VIDEODECODER_DEV_INTERFACE));
@@ -166,10 +165,8 @@ int32_t PPB_VideoDecoder_Impl::Decode(
media::BitstreamBuffer decode_buffer(bitstream_buffer->id,
buffer->shared_memory()->handle(),
static_cast<size_t>(buffer->size()));
-
- // Store the callback to inform when bitstream buffer has been processed.
- // TODO(vmr): handle simultaneous decodes + callbacks.
- bitstream_buffer_callback_ = callback;
+ CHECK(bitstream_buffer_callbacks_.insert(std::make_pair(
+ bitstream_buffer->id, callback)).second);
if (platform_video_decoder_->Decode(decode_buffer))
return PP_OK_COMPLETIONPENDING;
@@ -311,12 +308,12 @@ void PPB_VideoDecoder_Impl::NotifyAbortDone() {
void PPB_VideoDecoder_Impl::NotifyEndOfBitstreamBuffer(
int32 bitstream_buffer_id) {
- if (bitstream_buffer_callback_.func == NULL)
- return;
-
- // Call the callback that was stored to be called when bitstream was sent for
- // decoding.
- PP_RunAndClearCompletionCallback(&bitstream_buffer_callback_, PP_OK);
+ CallbackById::iterator it =
+ bitstream_buffer_callbacks_.find(bitstream_buffer_id);
+ DCHECK(it != bitstream_buffer_callbacks_.end());
+ PP_CompletionCallback cc = it->second;
+ bitstream_buffer_callbacks_.erase(it);
+ PP_RunCompletionCallback(&cc, PP_OK);
}
void PPB_VideoDecoder_Impl::NotifyFlushDone() {
diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.h b/webkit/plugins/ppapi/ppb_video_decoder_impl.h
index 0b39418..bc6b7ff 100644
--- a/webkit/plugins/ppapi/ppb_video_decoder_impl.h
+++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.h
@@ -75,6 +75,10 @@ class PPB_VideoDecoder_Impl : public Resource,
virtual void NotifyAbortDone() OVERRIDE;
private:
+ // Key: bitstream_buffer_id, value: callback to run when bitstream decode is
+ // done.
+ typedef std::map<int32, PP_CompletionCallback> CallbackById;
+
// This is NULL before initialization, and if this PPB_VideoDecoder_Impl is
// swapped with another.
scoped_ptr<PluginDelegate::PlatformVideoDecoder> platform_video_decoder_;
@@ -85,7 +89,7 @@ class PPB_VideoDecoder_Impl : public Resource,
PP_CompletionCallback initialization_callback_;
PP_CompletionCallback abort_callback_;
PP_CompletionCallback flush_callback_;
- PP_CompletionCallback bitstream_buffer_callback_;
+ CallbackById bitstream_buffer_callbacks_;
// Reference to the plugin requesting this interface.
const PPP_VideoDecoder_Dev* ppp_videodecoder_;