| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ |
| 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ | 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 AUDIO_OUTPUT_IPC_DELEGATE_STATE_PAUSED, | 24 AUDIO_OUTPUT_IPC_DELEGATE_STATE_PAUSED, |
| 25 AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR, | 25 AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR, |
| 26 AUDIO_OUTPUT_IPC_DELEGATE_STATE_LAST = AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR | 26 AUDIO_OUTPUT_IPC_DELEGATE_STATE_LAST = AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 // Contains IPC notifications for the state of the server side | 29 // Contains IPC notifications for the state of the server side |
| 30 // (AudioOutputController) audio state changes and when an AudioOutputController | 30 // (AudioOutputController) audio state changes and when an AudioOutputController |
| 31 // has been created. Implemented by AudioOutputDevice. | 31 // has been created. Implemented by AudioOutputDevice. |
| 32 class MEDIA_EXPORT AudioOutputIPCDelegate { | 32 class MEDIA_EXPORT AudioOutputIPCDelegate { |
| 33 public: | 33 public: |
| 34 | |
| 35 // Called when state of an audio stream has changed. | 34 // Called when state of an audio stream has changed. |
| 36 virtual void OnStateChanged(AudioOutputIPCDelegateState state) = 0; | 35 virtual void OnStateChanged(AudioOutputIPCDelegateState state) = 0; |
| 37 | 36 |
| 37 // Called when an authorization request for an output device has been |
| 38 // completed |
| 39 virtual void OnDeviceAuthorized( |
| 40 bool success, |
| 41 const media::AudioParameters& output_params) = 0; |
| 42 |
| 38 // Called when an audio stream has been created. | 43 // Called when an audio stream has been created. |
| 39 // The shared memory |handle| points to a memory section that's used to | 44 // The shared memory |handle| points to a memory section that's used to |
| 40 // transfer audio buffers from the AudioOutputIPCDelegate back to the | 45 // transfer audio buffers from the AudioOutputIPCDelegate back to the |
| 41 // AudioRendererHost. The implementation of OnStreamCreated takes ownership. | 46 // AudioRendererHost. The implementation of OnStreamCreated takes ownership. |
| 42 // The |socket_handle| is used by AudioRendererHost to signal requests for | 47 // The |socket_handle| is used by AudioRendererHost to signal requests for |
| 43 // audio data to be written into the shared memory. The AudioOutputIPCDelegate | 48 // audio data to be written into the shared memory. The AudioOutputIPCDelegate |
| 44 // must read from this socket and provide audio whenever data (search for | 49 // must read from this socket and provide audio whenever data (search for |
| 45 // "pending_bytes") is received. | 50 // "pending_bytes") is received. |
| 46 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 51 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
| 47 base::SyncSocket::Handle socket_handle, | 52 base::SyncSocket::Handle socket_handle, |
| 48 int length) = 0; | 53 int length) = 0; |
| 49 | 54 |
| 50 // Called when an attempt to switch the output device has been completed | 55 // Called when an attempt to switch the output device has been completed |
| 51 virtual void OnOutputDeviceSwitched(int request_id, | 56 virtual void OnOutputDeviceSwitched( |
| 52 SwitchOutputDeviceResult result) = 0; | 57 SwitchOutputDeviceResult result, |
| 58 const media::AudioParameters& output_params) = 0; |
| 53 | 59 |
| 54 // Called when the AudioOutputIPC object is going away and/or when the IPC | 60 // Called when the AudioOutputIPC object is going away and/or when the IPC |
| 55 // channel has been closed and no more ipc requests can be made. | 61 // channel has been closed and no more ipc requests can be made. |
| 56 // Implementations should delete their owned AudioOutputIPC instance | 62 // Implementations should delete their owned AudioOutputIPC instance |
| 57 // immediately. | 63 // immediately. |
| 58 virtual void OnIPCClosed() = 0; | 64 virtual void OnIPCClosed() = 0; |
| 59 | 65 |
| 60 protected: | 66 protected: |
| 61 virtual ~AudioOutputIPCDelegate(); | 67 virtual ~AudioOutputIPCDelegate(); |
| 62 }; | 68 }; |
| 63 | 69 |
| 64 // Provides the IPC functionality for an AudioOutputIPCDelegate (e.g., an | 70 // Provides the IPC functionality for an AudioOutputIPCDelegate (e.g., an |
| 65 // AudioOutputDevice). The implementation should asynchronously deliver the | 71 // AudioOutputDevice). The implementation should asynchronously deliver the |
| 66 // messages to an AudioOutputController object (or create one in the case of | 72 // messages to an AudioOutputController object (or create one in the case of |
| 67 // CreateStream()), that may live in a separate process. | 73 // CreateStream()), that may live in a separate process. |
| 68 class MEDIA_EXPORT AudioOutputIPC { | 74 class MEDIA_EXPORT AudioOutputIPC { |
| 69 public: | 75 public: |
| 70 virtual ~AudioOutputIPC(); | 76 virtual ~AudioOutputIPC(); |
| 71 | 77 |
| 78 // Sends a request to authorize the use of a specific audio output device |
| 79 // in the peer process. |
| 80 // If |session_id| is nonzero, the browser selects the output device |
| 81 // associated with an opened input device indicated by |session_id|. If no |
| 82 // such device is found, the browser attempts to select the device indicated |
| 83 // by |device_id|. If |device_id| is the empty string, the default |
| 84 // audio output device will be selected. |
| 85 // Once the authorization process is complete, the implementation will |
| 86 // notify |delegate| by calling OnDeviceAuthorized(). |
| 87 virtual void RequestDeviceAuthorization(AudioOutputIPCDelegate* delegate, |
| 88 int session_id, |
| 89 const std::string& device_id, |
| 90 const GURL& security_origin) = 0; |
| 91 |
| 72 // Sends a request to create an AudioOutputController object in the peer | 92 // Sends a request to create an AudioOutputController object in the peer |
| 73 // process and configures it to use the specified audio |params| including | 93 // process and configures it to use the specified audio |params| including |
| 74 // number of synchronized input channels.|session_id| is used by the browser | 94 // number of synchronized input channels. |
| 75 // to select the correct input device if the input channel in |params| is | 95 // Once the stream has been created, the implementation will notify |
| 76 // valid, otherwise it will be ignored. Once the stream has been created, | 96 // |delegate| by calling OnStreamCreated(). |
| 77 // the implementation will notify |delegate| by calling OnStreamCreated(). | |
| 78 virtual void CreateStream(AudioOutputIPCDelegate* delegate, | 97 virtual void CreateStream(AudioOutputIPCDelegate* delegate, |
| 79 const AudioParameters& params, | 98 const AudioParameters& params) = 0; |
| 80 int session_id) = 0; | |
| 81 | 99 |
| 82 // Starts playing the stream. This should generate a call to | 100 // Starts playing the stream. This should generate a call to |
| 83 // AudioOutputController::Play(). | 101 // AudioOutputController::Play(). |
| 84 virtual void PlayStream() = 0; | 102 virtual void PlayStream() = 0; |
| 85 | 103 |
| 86 // Pauses an audio stream. This should generate a call to | 104 // Pauses an audio stream. This should generate a call to |
| 87 // AudioOutputController::Pause(). | 105 // AudioOutputController::Pause(). |
| 88 virtual void PauseStream() = 0; | 106 virtual void PauseStream() = 0; |
| 89 | 107 |
| 90 // Closes the audio stream which should shut down the corresponding | 108 // Closes the audio stream which should shut down the corresponding |
| 91 // AudioOutputController in the peer process. | 109 // AudioOutputController in the peer process. |
| 92 virtual void CloseStream() = 0; | 110 virtual void CloseStream() = 0; |
| 93 | 111 |
| 94 // Sets the volume of the audio stream. | 112 // Sets the volume of the audio stream. |
| 95 virtual void SetVolume(double volume) = 0; | 113 virtual void SetVolume(double volume) = 0; |
| 96 | 114 |
| 97 // Switches the output device of the audio stream. | 115 // Switches the output device of the audio stream. |
| 98 virtual void SwitchOutputDevice(const std::string& device_id, | 116 virtual void SwitchOutputDevice(const std::string& device_id, |
| 99 const GURL& security_origin, | 117 const GURL& security_origin) = 0; |
| 100 int request_id) = 0; | |
| 101 }; | 118 }; |
| 102 | 119 |
| 103 } // namespace media | 120 } // namespace media |
| 104 | 121 |
| 105 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ | 122 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ |
| OLD | NEW |