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 PPAPI_PROXY_PPB_AUDIO_PROXY_H_ | 5 #ifndef PPAPI_PROXY_PPB_AUDIO_PROXY_H_ |
6 #define PPAPI_PROXY_PPB_AUDIO_PROXY_H_ | 6 #define PPAPI_PROXY_PPB_AUDIO_PROXY_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
12 #include "base/sync_socket.h" | 12 #include "base/sync_socket.h" |
13 #include "ipc/ipc_platform_file.h" | 13 #include "ipc/ipc_platform_file.h" |
14 #include "ppapi/c/pp_instance.h" | 14 #include "ppapi/c/pp_instance.h" |
15 #include "ppapi/c/pp_module.h" | 15 #include "ppapi/c/pp_module.h" |
16 #include "ppapi/c/pp_resource.h" | 16 #include "ppapi/c/pp_resource.h" |
17 #include "ppapi/c/ppb_audio.h" | 17 #include "ppapi/c/ppb_audio.h" |
18 #include "ppapi/c/ppb_audio_config.h" | 18 #include "ppapi/c/ppb_audio_config.h" |
19 #include "ppapi/cpp/completion_callback.h" | 19 #include "ppapi/cpp/completion_callback.h" |
20 #include "ppapi/proxy/interface_proxy.h" | 20 #include "ppapi/proxy/interface_proxy.h" |
21 #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" | 21 #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" |
22 | 22 |
23 struct PPB_Audio; | 23 struct PPB_Audio; |
24 | 24 |
| 25 namespace ppapi { |
| 26 class HostResource; |
| 27 } |
| 28 |
25 namespace pp { | 29 namespace pp { |
26 namespace proxy { | 30 namespace proxy { |
27 | 31 |
28 class HostResource; | |
29 | |
30 class PPB_Audio_Proxy : public InterfaceProxy { | 32 class PPB_Audio_Proxy : public InterfaceProxy { |
31 public: | 33 public: |
32 PPB_Audio_Proxy(Dispatcher* dispatcher, const void* target_interface); | 34 PPB_Audio_Proxy(Dispatcher* dispatcher, const void* target_interface); |
33 virtual ~PPB_Audio_Proxy(); | 35 virtual ~PPB_Audio_Proxy(); |
34 | 36 |
35 static const Info* GetInfo(); | 37 static const Info* GetInfo(); |
36 | 38 |
37 // Creates an Audio object in the plugin process. | 39 // Creates an Audio object in the plugin process. |
38 static PP_Resource CreateProxyResource(PP_Instance instance_id, | 40 static PP_Resource CreateProxyResource(PP_Instance instance_id, |
39 PP_Resource config_id, | 41 PP_Resource config_id, |
40 PPB_Audio_Callback audio_callback, | 42 PPB_Audio_Callback audio_callback, |
41 void* user_data); | 43 void* user_data); |
42 | 44 |
43 | 45 |
44 const PPB_Audio* ppb_audio_target() const { | 46 const PPB_Audio* ppb_audio_target() const { |
45 return static_cast<const PPB_Audio*>(target_interface()); | 47 return static_cast<const PPB_Audio*>(target_interface()); |
46 } | 48 } |
47 | 49 |
48 // InterfaceProxy implementation. | 50 // InterfaceProxy implementation. |
49 virtual bool OnMessageReceived(const IPC::Message& msg); | 51 virtual bool OnMessageReceived(const IPC::Message& msg); |
50 | 52 |
51 private: | 53 private: |
52 // Plugin->renderer message handlers. | 54 // Plugin->renderer message handlers. |
53 void OnMsgCreate(PP_Instance instance_id, | 55 void OnMsgCreate(PP_Instance instance_id, |
54 int32_t sample_rate, | 56 int32_t sample_rate, |
55 uint32_t sample_frame_count, | 57 uint32_t sample_frame_count, |
56 HostResource* result); | 58 ppapi::HostResource* result); |
57 void OnMsgStartOrStop(const HostResource& audio_id, bool play); | 59 void OnMsgStartOrStop(const ppapi::HostResource& audio_id, bool play); |
58 | 60 |
59 // Renderer->plugin message handlers. | 61 // Renderer->plugin message handlers. |
60 void OnMsgNotifyAudioStreamCreated(const HostResource& audio_id, | 62 void OnMsgNotifyAudioStreamCreated(const ppapi::HostResource& audio_id, |
61 int32_t result_code, | 63 int32_t result_code, |
62 IPC::PlatformFileForTransit socket_handle, | 64 IPC::PlatformFileForTransit socket_handle, |
63 base::SharedMemoryHandle handle, | 65 base::SharedMemoryHandle handle, |
64 uint32_t length); | 66 uint32_t length); |
65 | 67 |
66 void AudioChannelConnected(int32_t result, | 68 void AudioChannelConnected(int32_t result, |
67 const HostResource& resource); | 69 const ppapi::HostResource& resource); |
68 | 70 |
69 // In the renderer, this is called in response to a stream created message. | 71 // In the renderer, this is called in response to a stream created message. |
70 // It will retrieve the shared memory and socket handles and place them into | 72 // It will retrieve the shared memory and socket handles and place them into |
71 // the given out params. The return value is a PPAPI error code. | 73 // the given out params. The return value is a PPAPI error code. |
72 // | 74 // |
73 // The input arguments should be initialized to 0 or -1, depending on the | 75 // The input arguments should be initialized to 0 or -1, depending on the |
74 // platform's default invalid handle values. On error, some of these | 76 // platform's default invalid handle values. On error, some of these |
75 // arguments may be written to, and others may be untouched, depending on | 77 // arguments may be written to, and others may be untouched, depending on |
76 // where the error occurred. | 78 // where the error occurred. |
77 int32_t GetAudioConnectedHandles( | 79 int32_t GetAudioConnectedHandles( |
78 const HostResource& resource, | 80 const ppapi::HostResource& resource, |
79 IPC::PlatformFileForTransit* foreign_socket_handle, | 81 IPC::PlatformFileForTransit* foreign_socket_handle, |
80 base::SharedMemoryHandle* foreign_shared_memory_handle, | 82 base::SharedMemoryHandle* foreign_shared_memory_handle, |
81 uint32_t* shared_memory_length); | 83 uint32_t* shared_memory_length); |
82 | 84 |
83 CompletionCallbackFactory<PPB_Audio_Proxy, | 85 CompletionCallbackFactory<PPB_Audio_Proxy, |
84 ProxyNonThreadSafeRefCount> callback_factory_; | 86 ProxyNonThreadSafeRefCount> callback_factory_; |
85 | 87 |
86 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Proxy); | 88 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Proxy); |
87 }; | 89 }; |
88 | 90 |
89 } // namespace proxy | 91 } // namespace proxy |
90 } // namespace pp | 92 } // namespace pp |
91 | 93 |
92 #endif // PPAPI_PROXY_PPB_AUDIO_PROXY_H_ | 94 #endif // PPAPI_PROXY_PPB_AUDIO_PROXY_H_ |
OLD | NEW |