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" |
(...skipping 27 matching lines...) Expand all Loading... |
38 int total_segments) = 0; | 38 int total_segments) = 0; |
39 | 39 |
40 // Called when state of an audio stream has changed. | 40 // Called when state of an audio stream has changed. |
41 virtual void OnStateChanged(State state) = 0; | 41 virtual void OnStateChanged(State state) = 0; |
42 | 42 |
43 // Called when the input stream volume has changed. | 43 // Called when the input stream volume has changed. |
44 virtual void OnVolume(double volume) = 0; | 44 virtual void OnVolume(double volume) = 0; |
45 | 45 |
46 // 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 |
47 // 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. |
48 // Implementations must clear any references to the AudioInputIPC object | 48 // Implementations should delete their owned AudioInputIPC instance |
49 // at this point. | 49 // immediately. |
50 virtual void OnIPCClosed() = 0; | 50 virtual void OnIPCClosed() = 0; |
51 | 51 |
52 protected: | 52 protected: |
53 virtual ~AudioInputIPCDelegate(); | 53 virtual ~AudioInputIPCDelegate(); |
54 }; | 54 }; |
55 | 55 |
56 // Provides IPC functionality for an AudioInputDevice. The implementation | 56 // Provides IPC functionality for an AudioInputIPCDelegate (e.g., an |
57 // should asynchronously deliver the messages to an AudioInputController object | 57 // AudioInputDevice). The implementation should asynchronously deliver the |
58 // (or create one in the case of CreateStream()), that may live in a separate | 58 // messages to an AudioInputController object (or create one in the case of |
59 // process. | 59 // CreateStream()), that may live in a separate process. |
60 class MEDIA_EXPORT AudioInputIPC { | 60 class MEDIA_EXPORT AudioInputIPC { |
61 public: | 61 public: |
62 // Registers an AudioInputIPCDelegate and returns a |stream_id| that | 62 virtual ~AudioInputIPC(); |
63 // must be used with all other IPC functions in this interface. | |
64 virtual int AddDelegate(AudioInputIPCDelegate* delegate) = 0; | |
65 | |
66 // Unregisters a delegate that was previously registered via a call to | |
67 // AddDelegate(). The audio stream should be in a closed state prior to | |
68 // calling this function. | |
69 virtual void RemoveDelegate(int stream_id) = 0; | |
70 | 63 |
71 // Sends a request to create an AudioInputController object in the peer | 64 // Sends a request to create an AudioInputController object in the peer |
72 // process, identify it by |stream_id| and configure it to use the specified | 65 // process, and configures it to use the specified audio |params|. The |
73 // audio |params|. The |total_segments| indidates number of equal-lengthed | 66 // |total_segments| indidates number of equal-lengthed segments in the shared |
74 // segments in the shared memory buffer. | 67 // memory buffer. Once the stream has been created, the implementation will |
75 // Once the stream has been created, the implementation must | 68 // notify |delegate| by calling OnStreamCreated(). |
76 // generate a notification to the AudioInputIPCDelegate and call | 69 virtual void CreateStream(AudioInputIPCDelegate* delegate, |
77 // OnStreamCreated(). | |
78 virtual void CreateStream(int stream_id, | |
79 int session_id, | 70 int session_id, |
80 const AudioParameters& params, | 71 const AudioParameters& params, |
81 bool automatic_gain_control, | 72 bool automatic_gain_control, |
82 uint32 total_segments) = 0; | 73 uint32 total_segments) = 0; |
83 | 74 |
84 // Corresponds to a call to AudioInputController::Record() on the server side. | 75 // Corresponds to a call to AudioInputController::Record() on the server side. |
85 virtual void RecordStream(int stream_id) = 0; | 76 virtual void RecordStream() = 0; |
86 | 77 |
87 // Sets the volume of the audio stream. | 78 // Sets the volume of the audio stream. |
88 virtual void SetVolume(int stream_id, double volume) = 0; | 79 virtual void SetVolume(double volume) = 0; |
89 | 80 |
90 // Closes the audio stream and deletes the matching AudioInputController | 81 // Closes the audio stream, which should shut down the corresponding |
91 // instance. Prior to deleting the AudioInputController object, a call to | 82 // AudioInputController in the peer process. |
92 // AudioInputController::Close must be made. | 83 virtual void CloseStream() = 0; |
93 virtual void CloseStream(int stream_id) = 0; | |
94 | |
95 protected: | |
96 virtual ~AudioInputIPC(); | |
97 }; | 84 }; |
98 | 85 |
99 } // namespace media | 86 } // namespace media |
100 | 87 |
101 #endif // MEDIA_AUDIO_AUDIO_INPUT_IPC_H_ | 88 #endif // MEDIA_AUDIO_AUDIO_INPUT_IPC_H_ |
OLD | NEW |