| 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_INPUT_IPC_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_INPUT_IPC_H_ |
| 6 #define MEDIA_AUDIO_AUDIO_INPUT_IPC_H_ | 6 #define MEDIA_AUDIO_AUDIO_INPUT_IPC_H_ |
| 7 | 7 |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "base/sync_socket.h" | 9 #include "base/sync_socket.h" |
| 10 #include "media/audio/audio_parameters.h" | 10 #include "media/audio/audio_parameters.h" |
| 11 #include "media/base/media_export.h" | 11 #include "media/base/media_export.h" |
| 12 | 12 |
| 13 namespace media { | 13 namespace media { |
| 14 | 14 |
| 15 enum AudioInputIPCDelegateState { |
| 16 AUDIO_INPUT_IPC_DELEGATE_STATE_RECORDING, |
| 17 AUDIO_INPUT_IPC_DELEGATE_STATE_STOPPED, |
| 18 AUDIO_INPUT_IPC_DELEGATE_STATE_ERROR, |
| 19 AUDIO_INPUT_IPC_DELEGATE_STATE_LAST = AUDIO_INPUT_IPC_DELEGATE_STATE_ERROR, |
| 20 }; |
| 21 |
| 15 // Contains IPC notifications for the state of the server side | 22 // Contains IPC notifications for the state of the server side |
| 16 // (AudioInputController) audio state changes and when an AudioInputController | 23 // (AudioInputController) audio state changes and when an AudioInputController |
| 17 // has been created. Implemented by AudioInputDevice. | 24 // has been created. Implemented by AudioInputDevice. |
| 18 class MEDIA_EXPORT AudioInputIPCDelegate { | 25 class MEDIA_EXPORT AudioInputIPCDelegate { |
| 19 public: | 26 public: |
| 20 // Valid states for the input stream. | |
| 21 enum State { | |
| 22 kRecording, | |
| 23 kStopped, | |
| 24 kError, | |
| 25 kStateLast = kError | |
| 26 }; | |
| 27 | |
| 28 // Called when an AudioInputController has been created. | 27 // Called when an AudioInputController has been created. |
| 29 // The shared memory |handle| points to a memory section that's used to | 28 // The shared memory |handle| points to a memory section that's used to |
| 30 // transfer data between the AudioInputDevice and AudioInputController | 29 // transfer data between the AudioInputDevice and AudioInputController |
| 31 // objects. The implementation of OnStreamCreated takes ownership. | 30 // objects. The implementation of OnStreamCreated takes ownership. |
| 32 // The |socket_handle| is used by the AudioInputController to signal | 31 // The |socket_handle| is used by the AudioInputController to signal |
| 33 // notifications that more data is available and can optionally provide | 32 // notifications that more data is available and can optionally provide |
| 34 // parameter changes back. The AudioInputDevice must read from this socket | 33 // parameter changes back. The AudioInputDevice must read from this socket |
| 35 // and process the shared memory whenever data is read from the socket. | 34 // and process the shared memory whenever data is read from the socket. |
| 36 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 35 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
| 37 base::SyncSocket::Handle socket_handle, | 36 base::SyncSocket::Handle socket_handle, |
| 38 int length, | 37 int length, |
| 39 int total_segments) = 0; | 38 int total_segments) = 0; |
| 40 | 39 |
| 41 // Called when state of an audio stream has changed. | 40 // Called when state of an audio stream has changed. |
| 42 virtual void OnStateChanged(State state) = 0; | 41 virtual void OnStateChanged(AudioInputIPCDelegateState state) = 0; |
| 43 | 42 |
| 44 // Called when the input stream volume has changed. | 43 // Called when the input stream volume has changed. |
| 45 virtual void OnVolume(double volume) = 0; | 44 virtual void OnVolume(double volume) = 0; |
| 46 | 45 |
| 47 // Called when the AudioInputIPC object is going away and/or when the | 46 // Called when the AudioInputIPC object is going away and/or when the |
| 48 // IPC channel has been closed and no more IPC requests can be made. | 47 // IPC channel has been closed and no more IPC requests can be made. |
| 49 // Implementations should delete their owned AudioInputIPC instance | 48 // Implementations should delete their owned AudioInputIPC instance |
| 50 // immediately. | 49 // immediately. |
| 51 virtual void OnIPCClosed() = 0; | 50 virtual void OnIPCClosed() = 0; |
| 52 | 51 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 80 virtual void SetVolume(double volume) = 0; | 79 virtual void SetVolume(double volume) = 0; |
| 81 | 80 |
| 82 // Closes the audio stream, which should shut down the corresponding | 81 // Closes the audio stream, which should shut down the corresponding |
| 83 // AudioInputController in the peer process. | 82 // AudioInputController in the peer process. |
| 84 virtual void CloseStream() = 0; | 83 virtual void CloseStream() = 0; |
| 85 }; | 84 }; |
| 86 | 85 |
| 87 } // namespace media | 86 } // namespace media |
| 88 | 87 |
| 89 #endif // MEDIA_AUDIO_AUDIO_INPUT_IPC_H_ | 88 #endif // MEDIA_AUDIO_AUDIO_INPUT_IPC_H_ |
| OLD | NEW |