OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_IMPL_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_IMPL_H_ |
6 #define WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_IMPL_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_IMPL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
11 #include "base/sync_socket.h" | 11 #include "base/sync_socket.h" |
12 #include "ppapi/c/pp_completion_callback.h" | 12 #include "ppapi/c/pp_completion_callback.h" |
13 #include "ppapi/c/ppb_audio.h" | 13 #include "ppapi/c/ppb_audio.h" |
14 #include "ppapi/c/ppb_audio_config.h" | 14 #include "ppapi/c/ppb_audio_config.h" |
15 #include "ppapi/c/trusted/ppb_audio_trusted.h" | 15 #include "ppapi/c/trusted/ppb_audio_trusted.h" |
16 #include "ppapi/shared_impl/audio_config_impl.h" | 16 #include "ppapi/shared_impl/audio_config_impl.h" |
17 #include "ppapi/shared_impl/audio_impl.h" | 17 #include "ppapi/shared_impl/audio_impl.h" |
18 #include "ppapi/shared_impl/scoped_pp_resource.h" | 18 #include "ppapi/shared_impl/scoped_pp_resource.h" |
19 #include "ppapi/shared_impl/resource.h" | 19 #include "ppapi/shared_impl/resource.h" |
| 20 #include "webkit/plugins/ppapi/audio_helper.h" |
20 #include "webkit/plugins/ppapi/plugin_delegate.h" | 21 #include "webkit/plugins/ppapi/plugin_delegate.h" |
21 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
22 | 23 |
23 namespace webkit { | 24 namespace webkit { |
24 namespace ppapi { | 25 namespace ppapi { |
25 | 26 |
26 // Some of the backend functionality of this class is implemented by the | 27 // Some of the backend functionality of this class is implemented by the |
27 // AudioImpl so it can be shared with the proxy. | 28 // AudioImpl so it can be shared with the proxy. |
28 class PPB_Audio_Impl : public ::ppapi::Resource, | 29 class PPB_Audio_Impl : public ::ppapi::Resource, |
29 public ::ppapi::AudioImpl, | 30 public ::ppapi::AudioImpl, |
30 public PluginDelegate::PlatformAudio::Client { | 31 public PluginDelegate::PlatformAudio::Client, |
| 32 public AudioHelper { |
31 public: | 33 public: |
32 // Trusted initialization. You must call Init after this. | 34 // Trusted initialization. You must call Init after this. |
33 // | 35 // |
34 // Untrusted initialization should just call the static Create() function | 36 // Untrusted initialization should just call the static Create() function |
35 // to properly create & initialize this class. | 37 // to properly create & initialize this class. |
36 explicit PPB_Audio_Impl(PP_Instance instance); | 38 explicit PPB_Audio_Impl(PP_Instance instance); |
37 | 39 |
38 virtual ~PPB_Audio_Impl(); | 40 virtual ~PPB_Audio_Impl(); |
39 | 41 |
40 // Creation function for untrusted plugins. This handles all initialization | 42 // Creation function for untrusted plugins. This handles all initialization |
(...skipping 13 matching lines...) Expand all Loading... |
54 // PPB_Audio_API implementation. | 56 // PPB_Audio_API implementation. |
55 virtual PP_Resource GetCurrentConfig() OVERRIDE; | 57 virtual PP_Resource GetCurrentConfig() OVERRIDE; |
56 virtual PP_Bool StartPlayback() OVERRIDE; | 58 virtual PP_Bool StartPlayback() OVERRIDE; |
57 virtual PP_Bool StopPlayback() OVERRIDE; | 59 virtual PP_Bool StopPlayback() OVERRIDE; |
58 virtual int32_t OpenTrusted(PP_Resource config_id, | 60 virtual int32_t OpenTrusted(PP_Resource config_id, |
59 PP_CompletionCallback create_callback) OVERRIDE; | 61 PP_CompletionCallback create_callback) OVERRIDE; |
60 virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE; | 62 virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE; |
61 virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE; | 63 virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE; |
62 | 64 |
63 private: | 65 private: |
| 66 virtual void OnSetStreamInfo(base::SharedMemoryHandle shared_memory_handle, |
| 67 size_t shared_memory_size_, |
| 68 base::SyncSocket::Handle socket); |
| 69 |
64 // PluginDelegate::PlatformAudio::Client implementation. | 70 // PluginDelegate::PlatformAudio::Client implementation. |
65 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, | 71 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, |
66 size_t shared_memory_size_, | 72 size_t shared_memory_size_, |
67 base::SyncSocket::Handle socket); | 73 base::SyncSocket::Handle socket); |
68 | 74 |
69 // AudioConfig used for creating this Audio object. We own a ref. | 75 // AudioConfig used for creating this Audio object. We own a ref. |
70 ::ppapi::ScopedPPResource config_; | 76 ::ppapi::ScopedPPResource config_; |
71 | 77 |
72 // PluginDelegate audio object that we delegate audio IPC through. We don't | 78 // PluginDelegate audio object that we delegate audio IPC through. We don't |
73 // own this pointer but are responsible for calling Shutdown on it. | 79 // own this pointer but are responsible for calling Shutdown on it. |
74 PluginDelegate::PlatformAudio* audio_; | 80 PluginDelegate::PlatformAudio* audio_; |
75 | 81 |
76 // Is a create callback pending to fire? | |
77 bool create_callback_pending_; | |
78 | |
79 // Trusted callback invoked from StreamCreated. | |
80 PP_CompletionCallback create_callback_; | |
81 | |
82 // When a create callback is being issued, these will save the info for | |
83 // querying from the callback. The proxy uses this to get the handles to the | |
84 // other process instead of mapping them in the renderer. These will be | |
85 // invalid all other times. | |
86 scoped_ptr<base::SharedMemory> shared_memory_for_create_callback_; | |
87 size_t shared_memory_size_for_create_callback_; | |
88 scoped_ptr<base::SyncSocket> socket_for_create_callback_; | |
89 | |
90 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Impl); | 82 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Impl); |
91 }; | 83 }; |
92 | 84 |
93 } // namespace ppapi | 85 } // namespace ppapi |
94 } // namespace webkit | 86 } // namespace webkit |
95 | 87 |
96 #endif // WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_IMPL_H_ | 88 #endif // WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_IMPL_H_ |
OLD | NEW |