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/thunk/ppb_audio_trusted_api.h" | |
19 #include "webkit/plugins/ppapi/plugin_delegate.h" | 18 #include "webkit/plugins/ppapi/plugin_delegate.h" |
20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
21 #include "webkit/plugins/ppapi/resource.h" | 20 #include "webkit/plugins/ppapi/resource.h" |
22 | 21 |
23 namespace webkit { | 22 namespace webkit { |
24 namespace ppapi { | 23 namespace ppapi { |
25 | 24 |
26 class PluginInstance; | 25 class PluginInstance; |
27 | 26 |
28 // The implementation is actually in AudioConfigImpl. | 27 // The implementation is actually in AudioConfigImpl. |
(...skipping 13 matching lines...) Expand all Loading... |
42 private: | 41 private: |
43 explicit PPB_AudioConfig_Impl(PluginInstance* instance); | 42 explicit PPB_AudioConfig_Impl(PluginInstance* instance); |
44 | 43 |
45 DISALLOW_COPY_AND_ASSIGN(PPB_AudioConfig_Impl); | 44 DISALLOW_COPY_AND_ASSIGN(PPB_AudioConfig_Impl); |
46 }; | 45 }; |
47 | 46 |
48 // Some of the backend functionality of this class is implemented by the | 47 // Some of the backend functionality of this class is implemented by the |
49 // AudioImpl so it can be shared with the proxy. | 48 // AudioImpl so it can be shared with the proxy. |
50 class PPB_Audio_Impl : public Resource, | 49 class PPB_Audio_Impl : public Resource, |
51 public ::ppapi::AudioImpl, | 50 public ::ppapi::AudioImpl, |
52 public ::ppapi::thunk::PPB_AudioTrusted_API, | |
53 public PluginDelegate::PlatformAudio::Client { | 51 public PluginDelegate::PlatformAudio::Client { |
54 public: | 52 public: |
55 // Trusted initialization. You must call Init after this. | 53 // Trusted initialization. You must call Init after this. |
56 // | 54 // |
57 // Untrusted initialization should just call the static Create() function | 55 // Untrusted initialization should just call the static Create() function |
58 // to properly create & initialize this class. | 56 // to properly create & initialize this class. |
59 explicit PPB_Audio_Impl(PluginInstance* instance); | 57 explicit PPB_Audio_Impl(PluginInstance* instance); |
60 | 58 |
61 virtual ~PPB_Audio_Impl(); | 59 virtual ~PPB_Audio_Impl(); |
62 | 60 |
63 // Creation function for untrusted plugins. This handles all initialization | 61 // Creation function for untrusted plugins. This handles all initialization |
64 // and will return 0 on failure. | 62 // and will return 0 on failure. |
65 static PP_Resource Create(PluginInstance* instance, | 63 static PP_Resource Create(PluginInstance* instance, |
66 PP_Resource config_id, | 64 PP_Resource config_id, |
67 PPB_Audio_Callback audio_callback, | 65 PPB_Audio_Callback audio_callback, |
68 void* user_data); | 66 void* user_data); |
69 | 67 |
70 // Initialization function for non-trusted init. | 68 // Initialization function for non-trusted init. |
71 bool Init(PP_Resource config_id, | 69 bool Init(PP_Resource config_id, |
72 PPB_Audio_Callback user_callback, void* user_data); | 70 PPB_Audio_Callback user_callback, void* user_data); |
73 | 71 |
74 // ResourceObjectBase overrides. | 72 // ResourceObjectBase overrides. |
75 virtual ::ppapi::thunk::PPB_Audio_API* AsPPB_Audio_API(); | 73 virtual ::ppapi::thunk::PPB_Audio_API* AsPPB_Audio_API(); |
76 virtual ::ppapi::thunk::PPB_AudioTrusted_API* AsPPB_AudioTrusted_API(); | |
77 | 74 |
78 // PPB_Audio_API implementation. | 75 // PPB_Audio_API implementation. |
79 virtual PP_Resource GetCurrentConfig() OVERRIDE; | 76 virtual PP_Resource GetCurrentConfig() OVERRIDE; |
80 virtual PP_Bool StartPlayback() OVERRIDE; | 77 virtual PP_Bool StartPlayback() OVERRIDE; |
81 virtual PP_Bool StopPlayback() OVERRIDE; | 78 virtual PP_Bool StopPlayback() OVERRIDE; |
82 | |
83 // PPB_AudioTrusted_API implementation. | |
84 virtual int32_t OpenTrusted(PP_Resource config_id, | 79 virtual int32_t OpenTrusted(PP_Resource config_id, |
85 PP_CompletionCallback create_callback) OVERRIDE; | 80 PP_CompletionCallback create_callback) OVERRIDE; |
86 virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE; | 81 virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE; |
87 virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE; | 82 virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE; |
88 | 83 |
89 private: | 84 private: |
90 // PluginDelegate::PlatformAudio::Client implementation. | 85 // PluginDelegate::PlatformAudio::Client implementation. |
91 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, | 86 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, |
92 size_t shared_memory_size_, | 87 size_t shared_memory_size_, |
93 base::SyncSocket::Handle socket); | 88 base::SyncSocket::Handle socket); |
(...skipping 19 matching lines...) Expand all Loading... |
113 size_t shared_memory_size_for_create_callback_; | 108 size_t shared_memory_size_for_create_callback_; |
114 scoped_ptr<base::SyncSocket> socket_for_create_callback_; | 109 scoped_ptr<base::SyncSocket> socket_for_create_callback_; |
115 | 110 |
116 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Impl); | 111 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Impl); |
117 }; | 112 }; |
118 | 113 |
119 } // namespace ppapi | 114 } // namespace ppapi |
120 } // namespace webkit | 115 } // namespace webkit |
121 | 116 |
122 #endif // WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_IMPL_H_ | 117 #endif // WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_IMPL_H_ |
OLD | NEW |