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/dev/ppb_audio_input_dev.h" |
| 13 #include "ppapi/c/pp_completion_callback.h" |
| 14 #include "ppapi/c/trusted/ppb_audio_input_trusted_dev.h" |
| 15 #include "ppapi/shared_impl/audio_config_impl.h" |
| 16 #include "ppapi/shared_impl/audio_input_impl.h" |
| 17 #include "ppapi/shared_impl/resource.h" |
| 18 #include "ppapi/shared_impl/scoped_pp_resource.h" |
| 19 #include "webkit/plugins/ppapi/audio_helper.h" |
| 20 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 21 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 22 |
| 23 namespace webkit { |
| 24 namespace ppapi { |
| 25 |
| 26 // Some of the backend functionality of this class is implemented by the |
| 27 // AudioInputImpl so it can be shared with the proxy. |
| 28 class PPB_AudioInput_Impl : public ::ppapi::Resource, |
| 29 public ::ppapi::AudioInputImpl, |
| 30 public PluginDelegate::PlatformAudioInput::Client, |
| 31 public AudioHelper { |
| 32 public: |
| 33 // Trusted initialization. You must call Init after this. |
| 34 // |
| 35 // Untrusted initialization should just call the static Create() function |
| 36 // to properly create & initialize this class. |
| 37 explicit PPB_AudioInput_Impl(PP_Instance instance); |
| 38 |
| 39 virtual ~PPB_AudioInput_Impl(); |
| 40 |
| 41 // Creation function for untrusted plugins. This handles all initialization |
| 42 // and will return 0 on failure. |
| 43 static PP_Resource Create(PP_Instance instance, |
| 44 PP_Resource config_id, |
| 45 PPB_AudioInput_Callback audio_input_callback, |
| 46 void* user_data); |
| 47 |
| 48 // Initialization function for non-trusted init. |
| 49 bool Init(PP_Resource config_id, |
| 50 PPB_AudioInput_Callback callback, void* user_data); |
| 51 |
| 52 // Resource overrides. |
| 53 virtual ::ppapi::thunk::PPB_AudioInput_API* AsPPB_AudioInput_API() OVERRIDE; |
| 54 |
| 55 // PPB_AudioInput_API implementation. |
| 56 virtual PP_Resource GetCurrentConfig() OVERRIDE; |
| 57 virtual PP_Bool StartCapture() OVERRIDE; |
| 58 virtual PP_Bool StopCapture() OVERRIDE; |
| 59 |
| 60 virtual int32_t OpenTrusted(PP_Resource config_id, |
| 61 PP_CompletionCallback create_callback) OVERRIDE; |
| 62 virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE; |
| 63 virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE; |
| 64 |
| 65 private: |
| 66 virtual void OnSetStreamInfo(base::SharedMemoryHandle shared_memory_handle, |
| 67 size_t shared_memory_size_, |
| 68 base::SyncSocket::Handle socket) OVERRIDE; |
| 69 |
| 70 // PluginDelegate::PlatformAudioInput::Client implementation. |
| 71 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, |
| 72 size_t shared_memory_size_, |
| 73 base::SyncSocket::Handle socket) OVERRIDE; |
| 74 |
| 75 // AudioConfig used for creating this AudioInput object. We own a ref. |
| 76 ::ppapi::ScopedPPResource config_; |
| 77 |
| 78 // PluginDelegate audio input object that we delegate audio IPC through. |
| 79 // We don't own this pointer but are responsible for calling Shutdown on it. |
| 80 PluginDelegate::PlatformAudioInput* audio_input_; |
| 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_ |
| 89 |
OLD | NEW |