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 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/shared_memory.h" |
| 11 #include "base/sync_socket.h" |
| 12 #include "ppapi/c/pp_completion_callback.h" |
| 13 #include "ppapi/c/dev/ppb_audio_input_dev.h" |
| 14 #include "ppapi/c/trusted/ppb_audio_input_trusted_dev.h" |
| 15 #include "ppapi/shared_impl/audio_input_impl.h" |
| 16 #include "ppapi/shared_impl/scoped_pp_resource.h" |
| 17 #include "ppapi/shared_impl/resource.h" |
| 18 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 20 |
| 21 namespace webkit { |
| 22 namespace ppapi { |
| 23 |
| 24 // Some of the backend functionality of this class is implemented by the |
| 25 // AudioInputImpl so it can be shared with the proxy. |
| 26 class PPB_AudioInput_Impl : public ::ppapi::Resource, |
| 27 public ::ppapi::AudioInputImpl, |
| 28 public PluginDelegate::PlatformAudioInput::Client { |
| 29 public: |
| 30 // Trusted initialization. You must call Init after this. |
| 31 // |
| 32 // Untrusted initialization should just call the static Create() function |
| 33 // to properly create & initialize this class. |
| 34 explicit PPB_AudioInput_Impl(PP_Instance instance); |
| 35 |
| 36 virtual ~PPB_AudioInput_Impl(); |
| 37 |
| 38 // Creation function for untrusted plugins. This handles all initialization |
| 39 // and will return 0 on failure. |
| 40 static PP_Resource Create(PP_Instance instance, |
| 41 PPB_AudioInput_Callback audio_input_callback, |
| 42 void* user_data); |
| 43 |
| 44 // Initialization function for non-trusted init. |
| 45 bool Init(PPB_AudioInput_Callback callback, void* user_data); |
| 46 |
| 47 // Resource overrides. |
| 48 virtual ::ppapi::thunk::PPB_AudioInput_API* AsPPB_AudioInput_API(); |
| 49 |
| 50 // PPB_AudioInput_API implementation. |
| 51 virtual PP_Bool StartCapture() OVERRIDE; |
| 52 virtual PP_Bool StopCapture() OVERRIDE; |
| 53 |
| 54 virtual int32_t OpenTrusted(PP_CompletionCallback create_callback) OVERRIDE; |
| 55 virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE; |
| 56 virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE; |
| 57 |
| 58 private: |
| 59 // PluginDelegate::PlatformAudioInput::Client implementation. |
| 60 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, |
| 61 size_t shared_memory_size_, |
| 62 base::SyncSocket::Handle socket); |
| 63 |
| 64 // PluginDelegate audio input object that we delegate audio IPC through. |
| 65 // We don't own this pointer but are responsible for calling Shutdown on it. |
| 66 PluginDelegate::PlatformAudioInput* audio_input_; |
| 67 |
| 68 // Is a create callback pending to fire? |
| 69 bool create_callback_pending_; |
| 70 |
| 71 // Trusted callback invoked from StreamCreated. |
| 72 PP_CompletionCallback create_callback_; |
| 73 |
| 74 // When a create callback is being issued, these will save the info for |
| 75 // querying from the callback. The proxy uses this to get the handles to the |
| 76 // other process instead of mapping them in the renderer. These will be |
| 77 // invalid all other times. |
| 78 scoped_ptr<base::SharedMemory> shared_memory_for_create_callback_; |
| 79 size_t shared_memory_size_for_create_callback_; |
| 80 scoped_ptr<base::SyncSocket> socket_for_create_callback_; |
| 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(PPB_AudioInput_Impl); |
| 83 }; |
| 84 |
| 85 } // namespace ppapi |
| 86 } // namespace webkit |
| 87 |
| 88 #endif // WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_ |
OLD | NEW |