Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ppapi/shared_impl/video_decoder_impl.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "gpu/command_buffer/client/gles2_implementation.h" | |
| 9 #include "ppapi/c/pp_errors.h" | |
| 10 #include "ppapi/proxy/plugin_resource_tracker.h" | |
| 11 #include "ppapi/thunk/ppb_context_3d_api.h" | |
| 12 #include "ppapi/thunk/enter.h" | |
| 13 #include "webkit/plugins/ppapi/resource_tracker.h" | |
|
brettw
2011/08/03 19:19:57
The point of the shared_impl directory is that it'
vrk (LEFT CHROMIUM)
2011/08/03 22:05:22
Using the pure virtual methods instead and DEPS re
| |
| 14 | |
| 15 using ppapi::thunk::PPB_Context3D_API; | |
| 16 | |
| 17 namespace ppapi { | |
| 18 | |
| 19 VideoDecoderImpl::VideoDecoderImpl(bool in_renderer_process) | |
| 20 : context3d_id_(0), | |
| 21 in_renderer_process_(in_renderer_process), | |
| 22 gles2_impl_(NULL) { | |
| 23 } | |
| 24 | |
| 25 thunk::PPB_VideoDecoder_API* VideoDecoderImpl::AsPPB_VideoDecoder_API() { | |
| 26 return this; | |
| 27 } | |
| 28 | |
| 29 VideoDecoderImpl::~VideoDecoderImpl() { | |
| 30 } | |
| 31 | |
| 32 bool VideoDecoderImpl::Init(PP_Resource context3d_id, | |
| 33 PPB_Context3D_API* context3d, | |
| 34 const PP_VideoConfigElement* decoder_config) { | |
| 35 if (!context3d || !decoder_config || !context3d_id) | |
| 36 return false; | |
| 37 | |
| 38 DCHECK(!gles2_impl_ && !context3d_id_); | |
| 39 gles2_impl_ = context3d->GetGLES2Impl(); | |
| 40 AddRefResource(context3d_id); | |
| 41 context3d_id_ = context3d_id; | |
| 42 return true; | |
| 43 } | |
| 44 | |
| 45 void VideoDecoderImpl::Destroy() { | |
| 46 context3d_id_ = 0; | |
| 47 gles2_impl_ = NULL; | |
| 48 UnrefResource(context3d_id_); | |
| 49 } | |
| 50 | |
| 51 void VideoDecoderImpl::SetFlushCallback(PP_CompletionCallback callback) { | |
| 52 // TODO(fischman,vrk): consider implications of already-outstanding callback. | |
|
Ami GONE FROM CHROMIUM
2011/08/03 20:25:53
Instead of future-considering it would you accept
vrk (LEFT CHROMIUM)
2011/08/03 22:05:22
SGTM. Done!
| |
| 53 CHECK(callback.func); | |
| 54 flush_callback_ = callback; | |
| 55 } | |
| 56 | |
| 57 void VideoDecoderImpl::SetResetCallback(PP_CompletionCallback callback) { | |
| 58 // TODO(fischman,vrk): consider implications of already-outstanding callback. | |
| 59 CHECK(callback.func); | |
| 60 reset_callback_ = callback; | |
| 61 } | |
| 62 | |
| 63 void VideoDecoderImpl::SetBitstreamBufferCallback( | |
| 64 int32 bitstream_buffer_id, PP_CompletionCallback callback) { | |
| 65 CHECK(bitstream_buffer_callbacks_.insert( | |
| 66 std::make_pair(bitstream_buffer_id, callback)).second); | |
| 67 } | |
| 68 | |
| 69 void VideoDecoderImpl::RunFlushCallback(int32 result) { | |
| 70 DCHECK(flush_callback_.func); | |
| 71 PP_RunAndClearCompletionCallback(&flush_callback_, result); | |
| 72 } | |
| 73 | |
| 74 void VideoDecoderImpl::RunResetCallback(int32 result) { | |
| 75 DCHECK(reset_callback_.func); | |
| 76 PP_RunAndClearCompletionCallback(&reset_callback_, result); | |
| 77 } | |
| 78 | |
| 79 void VideoDecoderImpl::RunBitstreamBufferCallback( | |
| 80 int32 bitstream_buffer_id, int32 result) { | |
| 81 CallbackById::iterator it = | |
| 82 bitstream_buffer_callbacks_.find(bitstream_buffer_id); | |
| 83 DCHECK(it != bitstream_buffer_callbacks_.end()); | |
| 84 PP_CompletionCallback cc = it->second; | |
| 85 bitstream_buffer_callbacks_.erase(it); | |
| 86 PP_RunCompletionCallback(&cc, PP_OK); | |
| 87 } | |
| 88 | |
| 89 void VideoDecoderImpl::FlushCommandBuffer() { | |
| 90 if (gles2_impl_) | |
| 91 gles2_impl_->Flush(); | |
| 92 } | |
| 93 | |
| 94 bool VideoDecoderImpl::CopyConfigsToVector( | |
| 95 const PP_VideoConfigElement* configs_to_copy, | |
| 96 std::vector<PP_VideoConfigElement>* out_configs) { | |
| 97 // TODO(fischman/vrk): This is still broken. We need to get rid of the silly | |
| 98 // PP_VideoConfigElement vector in favor of a struct (see TODO in | |
| 99 // ppb_video_decoder_dev.h). | |
| 100 const PP_VideoConfigElement* current = configs_to_copy; | |
| 101 while (*current && *current != PP_VIDEOATTR_DICTIONARY_TERMINATOR) { | |
|
Ami GONE FROM CHROMIUM
2011/08/03 20:25:53
The first *current isn't useful. You want either
vrk (LEFT CHROMIUM)
2011/08/03 22:05:22
Dang it now I'm adding stars to everything!! Must
| |
| 102 if (*(current + 1) == PP_VIDEOATTR_DICTIONARY_TERMINATOR) | |
|
Ami GONE FROM CHROMIUM
2011/08/03 20:25:53
No, I think you want to drop this test entirely.
vrk (LEFT CHROMIUM)
2011/08/03 22:05:22
Hahaha yeah. Removed.
| |
| 103 return false; | |
| 104 out_configs->push_back(*current); | |
| 105 out_configs->push_back(*(current + 1)); | |
| 106 current += 2; | |
| 107 } | |
| 108 return true; | |
| 109 } | |
| 110 | |
| 111 void VideoDecoderImpl::AddRefResource(PP_Resource resource) { | |
| 112 if (in_renderer_process_) | |
| 113 ::webkit::ppapi::ResourceTracker::Get()->AddRefResource(resource); | |
| 114 else | |
| 115 ::pp::proxy::PluginResourceTracker::GetInstance()->AddRefResource(resource); | |
| 116 } | |
| 117 | |
| 118 void VideoDecoderImpl::UnrefResource(PP_Resource resource) { | |
| 119 if (in_renderer_process_) { | |
| 120 ::webkit::ppapi::ResourceTracker::Get()->UnrefResource(resource); | |
| 121 } else { | |
| 122 ::pp::proxy::PluginResourceTracker:: | |
| 123 GetInstance()->ReleaseResource(resource); | |
| 124 } | |
| 125 } | |
| 126 | |
| 127 } // namespace ppapi | |
| OLD | NEW |