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/shared_memory.h" | 8 #include "base/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 // Contains IPC notifications for the state of the server side | 15 // Contains IPC notifications for the state of the server side |
16 // (AudioInputController) audio state changes and when an AudioInputController | 16 // (AudioInputController) audio state changes and when an AudioInputController |
17 // has been created. Implemented by AudioInputDevice. | 17 // has been created. Implemented by AudioInputDevice. |
18 class MEDIA_EXPORT AudioInputIPCDelegate { | 18 class MEDIA_EXPORT AudioInputIPCDelegate { |
19 public: | 19 public: |
20 // Valid states for the input stream. | 20 // Valid states for the input stream. |
21 enum State { | 21 enum State { |
22 kRecording, | 22 kRecording, |
23 kStopped, | 23 kStopped, |
24 kError | 24 kError |
25 }; | 25 }; |
26 | 26 |
27 // Called when an AudioInputController has been created. | 27 // Called when an AudioInputController has been created. |
28 // The |socket_handle| is used by the AudioInputController to signal | |
29 // notifications that more data is available and can optionally provide | |
30 // parameter changes back. The AudioInputDevice must read from this socket | |
31 // and process the shared memory whenever data is read from the socket. | |
32 virtual void OnStreamCreated(base::SyncSocket::Handle socket_handle, | |
henrika (OOO until Aug 14)
2013/03/04 13:12:51
Nothing is mentioned about |total_handles| here.
wjia(left Chromium)
2013/03/05 02:40:13
Done.
| |
33 int total_handles) = 0; | |
34 | |
35 // Called when an AudioInputController has been created. | |
28 // The shared memory |handle| points to a memory section that's used to | 36 // The shared memory |handle| points to a memory section that's used to |
29 // transfer data between the AudioInputDevice and AudioInputController | 37 // transfer data between the AudioInputDevice and AudioInputController |
30 // objects. The implementation of OnStreamCreated takes ownership. | 38 // objects. The implementation of OnStreamCreated takes ownership. |
henrika (OOO until Aug 14)
2013/03/04 13:12:51
Add comments about |length| and |index|.
wjia(left Chromium)
2013/03/05 02:40:13
Done.
| |
31 // The |socket_handle| is used by the AudioInputController to signal | 39 virtual void OnSharedMemoryCreated(base::SharedMemoryHandle handle, |
32 // notifications that more data is available and can optionally provide | 40 int length, |
33 // parameter changes back. The AudioInputDevice must read from this socket | 41 int index) = 0; |
34 // and process the shared memory whenever data is read from the socket. | |
35 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | |
36 base::SyncSocket::Handle socket_handle, | |
37 int length) = 0; | |
38 | 42 |
39 // Called when state of an audio stream has changed. | 43 // Called when state of an audio stream has changed. |
40 virtual void OnStateChanged(State state) = 0; | 44 virtual void OnStateChanged(State state) = 0; |
41 | 45 |
42 // Called when the input stream volume has changed. | 46 // Called when the input stream volume has changed. |
43 virtual void OnVolume(double volume) = 0; | 47 virtual void OnVolume(double volume) = 0; |
44 | 48 |
45 // Called when a device has been started on the server side. | 49 // Called when a device has been started on the server side. |
46 // If the device could not be started, |device_id| will be empty. | 50 // If the device could not be started, |device_id| will be empty. |
47 virtual void OnDeviceReady(const std::string& device_id) = 0; | 51 virtual void OnDeviceReady(const std::string& device_id) = 0; |
(...skipping 21 matching lines...) Expand all Loading... | |
69 // Unregisters a delegate that was previously registered via a call to | 73 // Unregisters a delegate that was previously registered via a call to |
70 // AddDelegate(). The audio stream should be in a closed state prior to | 74 // AddDelegate(). The audio stream should be in a closed state prior to |
71 // calling this function. | 75 // calling this function. |
72 virtual void RemoveDelegate(int stream_id) = 0; | 76 virtual void RemoveDelegate(int stream_id) = 0; |
73 | 77 |
74 // Sends a request to create an AudioInputController object in the peer | 78 // Sends a request to create an AudioInputController object in the peer |
75 // process, identify it by |stream_id| and configure it to use the specified | 79 // process, identify it by |stream_id| and configure it to use the specified |
76 // audio |params|. Once the stream has been created, the implementation must | 80 // audio |params|. Once the stream has been created, the implementation must |
77 // generate a notification to the AudioInputIPCDelegate and call | 81 // generate a notification to the AudioInputIPCDelegate and call |
78 // OnStreamCreated(). | 82 // OnStreamCreated(). |
79 virtual void CreateStream(int stream_id, const AudioParameters& params, | 83 virtual void CreateStream( |
80 const std::string& device_id, bool automatic_gain_control) = 0; | 84 int stream_id, |
85 const AudioParameters& params, | |
86 const std::string& device_id, | |
87 bool automatic_gain_control, | |
88 int shared_memory_count) = 0; | |
81 | 89 |
82 // Starts the device on the server side. Once the device has started, | 90 // Starts the device on the server side. Once the device has started, |
83 // or failed to start, a callback to | 91 // or failed to start, a callback to |
84 // AudioInputIPCDelegate::OnDeviceReady() must be made. | 92 // AudioInputIPCDelegate::OnDeviceReady() must be made. |
85 virtual void StartDevice(int stream_id, int session_id) = 0; | 93 virtual void StartDevice(int stream_id, int session_id) = 0; |
86 | 94 |
87 // Corresponds to a call to AudioInputController::Record() on the server side. | 95 // Corresponds to a call to AudioInputController::Record() on the server side. |
88 virtual void RecordStream(int stream_id) = 0; | 96 virtual void RecordStream(int stream_id) = 0; |
89 | 97 |
90 // Sets the volume of the audio stream. | 98 // Sets the volume of the audio stream. |
91 virtual void SetVolume(int stream_id, double volume) = 0; | 99 virtual void SetVolume(int stream_id, double volume) = 0; |
92 | 100 |
93 // Closes the audio stream and deletes the matching AudioInputController | 101 // Closes the audio stream and deletes the matching AudioInputController |
94 // instance. Prior to deleting the AudioInputController object, a call to | 102 // instance. Prior to deleting the AudioInputController object, a call to |
95 // AudioInputController::Close must be made. | 103 // AudioInputController::Close must be made. |
96 virtual void CloseStream(int stream_id) = 0; | 104 virtual void CloseStream(int stream_id) = 0; |
97 | 105 |
98 protected: | 106 protected: |
99 virtual ~AudioInputIPC(); | 107 virtual ~AudioInputIPC(); |
100 }; | 108 }; |
101 | 109 |
102 } // namespace media | 110 } // namespace media |
103 | 111 |
104 #endif // MEDIA_AUDIO_AUDIO_INPUT_IPC_H_ | 112 #endif // MEDIA_AUDIO_AUDIO_INPUT_IPC_H_ |
OLD | NEW |