OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ | 5 #ifndef WEBKIT_PLUGINS_PPAPI_DEVICE_CONTEXT_AUDIO_H_ |
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ | 6 #define WEBKIT_PLUGINS_PPAPI_DEVICE_CONTEXT_AUDIO_H_ |
7 | 7 |
| 8 #include "base/basictypes.h" |
8 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
9 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
10 #include "base/sync_socket.h" | 11 #include "base/sync_socket.h" |
11 #include "ppapi/c/dev/ppb_audio_dev.h" | 12 #include "ppapi/c/dev/ppb_audio_dev.h" |
12 #include "ppapi/c/dev/ppb_audio_config_dev.h" | 13 #include "ppapi/c/dev/ppb_audio_config_dev.h" |
13 #include "ppapi/c/dev/ppb_audio_trusted_dev.h" | 14 #include "ppapi/c/dev/ppb_audio_trusted_dev.h" |
14 #include "ppapi/c/pp_completion_callback.h" | 15 #include "ppapi/c/pp_completion_callback.h" |
15 #include "ppapi/shared_impl/audio_impl.h" | 16 #include "ppapi/shared_impl/audio_impl.h" |
16 #include "webkit/glue/plugins/pepper_plugin_delegate.h" | 17 #include "webkit/plugins/ppapi/plugin_delegate.h" |
17 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 18 #include "webkit/plugins/ppapi/plugin_instance.h" |
18 #include "webkit/glue/plugins/pepper_plugin_module.h" | 19 #include "webkit/plugins/ppapi/plugin_module.h" |
19 #include "webkit/glue/plugins/pepper_resource.h" | 20 #include "webkit/plugins/ppapi/resource.h" |
20 | 21 |
21 namespace pepper { | 22 namespace webkit { |
| 23 namespace plugins { |
| 24 namespace ppapi { |
22 | 25 |
23 class PluginInstance; | 26 class PluginInstance; |
24 class PluginModule; | 27 class PluginModule; |
25 | 28 |
26 class AudioConfig : public Resource { | 29 class PPB_AudioConfig_Impl : public Resource { |
27 public: | 30 public: |
28 AudioConfig(PluginModule* module, | 31 PPB_AudioConfig_Impl(PluginModule* module, |
29 PP_AudioSampleRate_Dev sample_rate, | 32 PP_AudioSampleRate_Dev sample_rate, |
30 uint32_t sample_frame_count); | 33 uint32_t sample_frame_count); |
31 size_t BufferSize(); | 34 size_t BufferSize(); |
32 static const PPB_AudioConfig_Dev* GetInterface(); | 35 static const PPB_AudioConfig_Dev* GetInterface(); |
33 | 36 |
34 PP_AudioSampleRate_Dev sample_rate() { return sample_rate_; } | 37 PP_AudioSampleRate_Dev sample_rate() { return sample_rate_; } |
35 uint32_t sample_frame_count() { return sample_frame_count_; } | 38 uint32_t sample_frame_count() { return sample_frame_count_; } |
36 | 39 |
37 private: | 40 private: |
38 // Resource override. | 41 // Resource override. |
39 virtual AudioConfig* AsAudioConfig(); | 42 virtual PPB_AudioConfig_Impl* AsAudioConfig(); |
40 | 43 |
41 PP_AudioSampleRate_Dev sample_rate_; | 44 PP_AudioSampleRate_Dev sample_rate_; |
42 uint32_t sample_frame_count_; | 45 uint32_t sample_frame_count_; |
43 }; | 46 }; |
44 | 47 |
45 // Some of the backend functionality of this class is implemented by the | 48 // Some of the backend functionality of this class is implemented by the |
46 // AudioImpl so it can be shared with the proxy. | 49 // AudioImpl so it can be shared with the proxy. |
47 class Audio : public Resource, | 50 class PPB_Audio_Impl : public Resource, |
48 public pp::shared_impl::AudioImpl, | 51 public pp::shared_impl::AudioImpl, |
49 public PluginDelegate::PlatformAudio::Client { | 52 public PluginDelegate::PlatformAudio::Client { |
50 public: | 53 public: |
51 explicit Audio(PluginModule* module, PP_Instance instance_id); | 54 explicit PPB_Audio_Impl(PluginModule* module, PP_Instance instance_id); |
52 virtual ~Audio(); | 55 virtual ~PPB_Audio_Impl(); |
53 | 56 |
54 static const PPB_Audio_Dev* GetInterface(); | 57 static const PPB_Audio_Dev* GetInterface(); |
55 static const PPB_AudioTrusted_Dev* GetTrustedInterface(); | 58 static const PPB_AudioTrusted_Dev* GetTrustedInterface(); |
56 | 59 |
57 PP_Instance pp_instance() { | 60 PP_Instance pp_instance() { |
58 return pp_instance_; | 61 return pp_instance_; |
59 } | 62 } |
60 | 63 |
61 // PPB_Audio implementation. | 64 // PPB_Audio implementation. |
62 bool Init(PluginDelegate* plugin_delegate, | 65 bool Init(PluginDelegate* plugin_delegate, |
63 PP_Resource config_id, | 66 PP_Resource config_id, |
64 PPB_Audio_Callback user_callback, void* user_data); | 67 PPB_Audio_Callback user_callback, void* user_data); |
65 PP_Resource GetCurrentConfig(); | 68 PP_Resource GetCurrentConfig(); |
66 bool StartPlayback(); | 69 bool StartPlayback(); |
67 bool StopPlayback(); | 70 bool StopPlayback(); |
68 | 71 |
69 // PPB_Audio_Trusted implementation. | 72 // PPB_Audio_Trusted implementation. |
70 int32_t Open(PluginDelegate* plugin_delegate, | 73 int32_t Open(PluginDelegate* plugin_delegate, |
71 PP_Resource config_id, | 74 PP_Resource config_id, |
72 PP_CompletionCallback create_callback); | 75 PP_CompletionCallback create_callback); |
73 int32_t GetSyncSocket(int* sync_socket); | 76 int32_t GetSyncSocket(int* sync_socket); |
74 int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size); | 77 int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size); |
75 | 78 |
76 // Resource override. | 79 // Resource override. |
77 virtual Audio* AsAudio(); | 80 virtual PPB_Audio_Impl* AsAudio(); |
78 | 81 |
79 private: | 82 private: |
80 // pepper::PluginDelegate::PlatformAudio::Client implementation. | 83 // PluginDelegate::PlatformAudio::Client implementation. |
81 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, | 84 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, |
82 size_t shared_memory_size_, | 85 size_t shared_memory_size_, |
83 base::SyncSocket::Handle socket); | 86 base::SyncSocket::Handle socket); |
84 | 87 |
85 // AudioConfig used for creating this Audio object. | 88 // AudioConfig used for creating this Audio object. |
86 scoped_refptr<AudioConfig> config_; | 89 scoped_refptr<PPB_AudioConfig_Impl> config_; |
87 | 90 |
88 // Plugin instance that owns this audio object. | 91 // Plugin instance that owns this audio object. |
89 PP_Instance pp_instance_; | 92 PP_Instance pp_instance_; |
90 | 93 |
91 // PluginDelegate audio object that we delegate audio IPC through. | 94 // PluginDelegate audio object that we delegate audio IPC through. |
92 PluginDelegate::PlatformAudio* audio_; | 95 PluginDelegate::PlatformAudio* audio_; |
93 | 96 |
94 // Is a create callback pending to fire? | 97 // Is a create callback pending to fire? |
95 bool create_callback_pending_; | 98 bool create_callback_pending_; |
96 | 99 |
97 // Trusted callback invoked from StreamCreated. | 100 // Trusted callback invoked from StreamCreated. |
98 PP_CompletionCallback create_callback_; | 101 PP_CompletionCallback create_callback_; |
99 | 102 |
100 // When a create callback is being issued, these will save the info for | 103 // When a create callback is being issued, these will save the info for |
101 // querying from the callback. The proxy uses this to get the handles to the | 104 // querying from the callback. The proxy uses this to get the handles to the |
102 // other process instead of mapping them in the renderer. These will be | 105 // other process instead of mapping them in the renderer. These will be |
103 // invalid all other times. | 106 // invalid all other times. |
104 scoped_ptr<base::SharedMemory> shared_memory_for_create_callback_; | 107 scoped_ptr<base::SharedMemory> shared_memory_for_create_callback_; |
105 size_t shared_memory_size_for_create_callback_; | 108 size_t shared_memory_size_for_create_callback_; |
106 scoped_ptr<base::SyncSocket> socket_for_create_callback_; | 109 scoped_ptr<base::SyncSocket> socket_for_create_callback_; |
| 110 |
| 111 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Impl); |
107 }; | 112 }; |
108 | 113 |
109 } // namespace pepper | 114 } // namespace ppapi |
| 115 } // namespace plugins |
| 116 } // namespace webkit |
110 | 117 |
111 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ | 118 #endif // WEBKIT_PLUGINS_PPAPI_DEVICE_CONTEXT_AUDIO_H_ |
OLD | NEW |