| 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/callback.h" |
| 10 #include "base/memory/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
| 11 #include "base/sync_socket.h" | 12 #include "base/sync_socket.h" |
| 12 #include "media/audio/audio_parameters.h" | 13 #include "media/audio/audio_parameters.h" |
| 13 #include "media/base/media_export.h" | 14 #include "media/base/media_export.h" |
| 14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 15 | 16 |
| 16 namespace media { | 17 namespace media { |
| 17 | 18 |
| 18 // Result of an audio output device switch operation | 19 // Result of an audio output device switch operation |
| 19 enum SwitchOutputDeviceResult { | 20 enum SwitchOutputDeviceResult { |
| 20 SWITCH_OUTPUT_DEVICE_RESULT_SUCCESS = 0, | 21 SWITCH_OUTPUT_DEVICE_RESULT_SUCCESS = 0, |
| 21 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_FOUND, | 22 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_FOUND, |
| 22 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_AUTHORIZED, | 23 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_AUTHORIZED, |
| 23 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_OBSOLETE, | 24 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_OBSOLETE, |
| 24 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_SUPPORTED, | 25 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_SUPPORTED, |
| 25 SWITCH_OUTPUT_DEVICE_RESULT_LAST = | 26 SWITCH_OUTPUT_DEVICE_RESULT_LAST = |
| 26 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_SUPPORTED, | 27 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_SUPPORTED, |
| 27 }; | 28 }; |
| 28 | 29 |
| 30 typedef base::Callback<void(SwitchOutputDeviceResult)> SwitchOutputDeviceCB; |
| 31 |
| 29 // Current status of the audio output stream in the browser process. Browser | 32 // Current status of the audio output stream in the browser process. Browser |
| 30 // sends information about the current playback state and error to the | 33 // sends information about the current playback state and error to the |
| 31 // renderer process using this type. | 34 // renderer process using this type. |
| 32 enum AudioOutputIPCDelegateState { | 35 enum AudioOutputIPCDelegateState { |
| 33 AUDIO_OUTPUT_IPC_DELEGATE_STATE_PLAYING, | 36 AUDIO_OUTPUT_IPC_DELEGATE_STATE_PLAYING, |
| 34 AUDIO_OUTPUT_IPC_DELEGATE_STATE_PAUSED, | 37 AUDIO_OUTPUT_IPC_DELEGATE_STATE_PAUSED, |
| 35 AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR, | 38 AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR, |
| 36 AUDIO_OUTPUT_IPC_DELEGATE_STATE_LAST = AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR | 39 AUDIO_OUTPUT_IPC_DELEGATE_STATE_LAST = AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR |
| 37 }; | 40 }; |
| 38 | 41 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 50 // transfer audio buffers from the AudioOutputIPCDelegate back to the | 53 // transfer audio buffers from the AudioOutputIPCDelegate back to the |
| 51 // AudioRendererHost. The implementation of OnStreamCreated takes ownership. | 54 // AudioRendererHost. The implementation of OnStreamCreated takes ownership. |
| 52 // The |socket_handle| is used by AudioRendererHost to signal requests for | 55 // The |socket_handle| is used by AudioRendererHost to signal requests for |
| 53 // audio data to be written into the shared memory. The AudioOutputIPCDelegate | 56 // audio data to be written into the shared memory. The AudioOutputIPCDelegate |
| 54 // must read from this socket and provide audio whenever data (search for | 57 // must read from this socket and provide audio whenever data (search for |
| 55 // "pending_bytes") is received. | 58 // "pending_bytes") is received. |
| 56 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 59 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
| 57 base::SyncSocket::Handle socket_handle, | 60 base::SyncSocket::Handle socket_handle, |
| 58 int length) = 0; | 61 int length) = 0; |
| 59 | 62 |
| 63 // Called when an attempt to switch the output device has been completed |
| 64 virtual void OnOutputDeviceSwitched(int request_id, |
| 65 SwitchOutputDeviceResult result) = 0; |
| 66 |
| 60 // Called when the AudioOutputIPC object is going away and/or when the IPC | 67 // Called when the AudioOutputIPC object is going away and/or when the IPC |
| 61 // channel has been closed and no more ipc requests can be made. | 68 // channel has been closed and no more ipc requests can be made. |
| 62 // Implementations should delete their owned AudioOutputIPC instance | 69 // Implementations should delete their owned AudioOutputIPC instance |
| 63 // immediately. | 70 // immediately. |
| 64 virtual void OnIPCClosed() = 0; | 71 virtual void OnIPCClosed() = 0; |
| 65 | 72 |
| 66 protected: | 73 protected: |
| 67 virtual ~AudioOutputIPCDelegate(); | 74 virtual ~AudioOutputIPCDelegate(); |
| 68 }; | 75 }; |
| 69 | 76 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 92 // Pauses an audio stream. This should generate a call to | 99 // Pauses an audio stream. This should generate a call to |
| 93 // AudioOutputController::Pause(). | 100 // AudioOutputController::Pause(). |
| 94 virtual void PauseStream() = 0; | 101 virtual void PauseStream() = 0; |
| 95 | 102 |
| 96 // Closes the audio stream which should shut down the corresponding | 103 // Closes the audio stream which should shut down the corresponding |
| 97 // AudioOutputController in the peer process. | 104 // AudioOutputController in the peer process. |
| 98 virtual void CloseStream() = 0; | 105 virtual void CloseStream() = 0; |
| 99 | 106 |
| 100 // Sets the volume of the audio stream. | 107 // Sets the volume of the audio stream. |
| 101 virtual void SetVolume(double volume) = 0; | 108 virtual void SetVolume(double volume) = 0; |
| 109 |
| 110 // Switches the output device of the audio stream. |
| 111 virtual void SwitchOutputDevice(const std::string& device_id, |
| 112 const GURL& security_origin, |
| 113 int request_id) = 0; |
| 102 }; | 114 }; |
| 103 | 115 |
| 104 } // namespace media | 116 } // namespace media |
| 105 | 117 |
| 106 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ | 118 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ |
| OLD | NEW |