| 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 // Low-latency audio capturing class utilizing audio input stream provided | 5 // Low-latency audio capturing class utilizing audio input stream provided |
| 6 // by a server (browser) process by use of an IPC interface. | 6 // by a server (browser) process by use of an IPC interface. |
| 7 // | 7 // |
| 8 // Relationship of classes: | 8 // Relationship of classes: |
| 9 // | 9 // |
| 10 // AudioInputController AudioInputDevice | 10 // AudioInputController AudioInputDevice |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 NON_EXPORTED_BASE(public ScopedTaskRunnerObserver) { | 80 NON_EXPORTED_BASE(public ScopedTaskRunnerObserver) { |
| 81 public: | 81 public: |
| 82 // NOTE: Clients must call Initialize() before using. | 82 // NOTE: Clients must call Initialize() before using. |
| 83 AudioInputDevice( | 83 AudioInputDevice( |
| 84 scoped_ptr<AudioInputIPC> ipc, | 84 scoped_ptr<AudioInputIPC> ipc, |
| 85 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 85 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
| 86 | 86 |
| 87 // AudioCapturerSource implementation. | 87 // AudioCapturerSource implementation. |
| 88 virtual void Initialize(const AudioParameters& params, | 88 virtual void Initialize(const AudioParameters& params, |
| 89 CaptureCallback* callback, | 89 CaptureCallback* callback, |
| 90 int session_id) OVERRIDE; | 90 int session_id) override; |
| 91 virtual void Start() OVERRIDE; | 91 virtual void Start() override; |
| 92 virtual void Stop() OVERRIDE; | 92 virtual void Stop() override; |
| 93 virtual void SetVolume(double volume) OVERRIDE; | 93 virtual void SetVolume(double volume) override; |
| 94 virtual void SetAutomaticGainControl(bool enabled) OVERRIDE; | 94 virtual void SetAutomaticGainControl(bool enabled) override; |
| 95 | 95 |
| 96 protected: | 96 protected: |
| 97 friend class base::RefCountedThreadSafe<AudioInputDevice>; | 97 friend class base::RefCountedThreadSafe<AudioInputDevice>; |
| 98 virtual ~AudioInputDevice(); | 98 virtual ~AudioInputDevice(); |
| 99 | 99 |
| 100 // Methods called on IO thread ---------------------------------------------- | 100 // Methods called on IO thread ---------------------------------------------- |
| 101 // AudioInputIPCDelegate implementation. | 101 // AudioInputIPCDelegate implementation. |
| 102 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 102 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
| 103 base::SyncSocket::Handle socket_handle, | 103 base::SyncSocket::Handle socket_handle, |
| 104 int length, | 104 int length, |
| 105 int total_segments) OVERRIDE; | 105 int total_segments) override; |
| 106 virtual void OnVolume(double volume) OVERRIDE; | 106 virtual void OnVolume(double volume) override; |
| 107 virtual void OnStateChanged( | 107 virtual void OnStateChanged( |
| 108 AudioInputIPCDelegate::State state) OVERRIDE; | 108 AudioInputIPCDelegate::State state) override; |
| 109 virtual void OnIPCClosed() OVERRIDE; | 109 virtual void OnIPCClosed() override; |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 // Note: The ordering of members in this enum is critical to correct behavior! | 112 // Note: The ordering of members in this enum is critical to correct behavior! |
| 113 enum State { | 113 enum State { |
| 114 IPC_CLOSED, // No more IPCs can take place. | 114 IPC_CLOSED, // No more IPCs can take place. |
| 115 IDLE, // Not started. | 115 IDLE, // Not started. |
| 116 CREATING_STREAM, // Waiting for OnStreamCreated() to be called back. | 116 CREATING_STREAM, // Waiting for OnStreamCreated() to be called back. |
| 117 RECORDING, // Receiving audio data. | 117 RECORDING, // Receiving audio data. |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 // Methods called on IO thread ---------------------------------------------- | 120 // Methods called on IO thread ---------------------------------------------- |
| 121 // The following methods are tasks posted on the IO thread that needs to | 121 // The following methods are tasks posted on the IO thread that needs to |
| 122 // be executed on that thread. They interact with AudioInputMessageFilter and | 122 // be executed on that thread. They interact with AudioInputMessageFilter and |
| 123 // sends IPC messages on that thread. | 123 // sends IPC messages on that thread. |
| 124 void StartUpOnIOThread(); | 124 void StartUpOnIOThread(); |
| 125 void ShutDownOnIOThread(); | 125 void ShutDownOnIOThread(); |
| 126 void SetVolumeOnIOThread(double volume); | 126 void SetVolumeOnIOThread(double volume); |
| 127 void SetAutomaticGainControlOnIOThread(bool enabled); | 127 void SetAutomaticGainControlOnIOThread(bool enabled); |
| 128 | 128 |
| 129 // base::MessageLoop::DestructionObserver implementation for the IO loop. | 129 // base::MessageLoop::DestructionObserver implementation for the IO loop. |
| 130 // If the IO loop dies before we do, we shut down the audio thread from here. | 130 // If the IO loop dies before we do, we shut down the audio thread from here. |
| 131 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | 131 virtual void WillDestroyCurrentMessageLoop() override; |
| 132 | 132 |
| 133 AudioParameters audio_parameters_; | 133 AudioParameters audio_parameters_; |
| 134 | 134 |
| 135 CaptureCallback* callback_; | 135 CaptureCallback* callback_; |
| 136 | 136 |
| 137 // A pointer to the IPC layer that takes care of sending requests over to | 137 // A pointer to the IPC layer that takes care of sending requests over to |
| 138 // the AudioInputRendererHost. Only valid when state_ != IPC_CLOSED and must | 138 // the AudioInputRendererHost. Only valid when state_ != IPC_CLOSED and must |
| 139 // only be accessed on the IO thread. | 139 // only be accessed on the IO thread. |
| 140 scoped_ptr<AudioInputIPC> ipc_; | 140 scoped_ptr<AudioInputIPC> ipc_; |
| 141 | 141 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 167 // TODO(miu): Replace this by changing AudioCapturerSource to accept the | 167 // TODO(miu): Replace this by changing AudioCapturerSource to accept the |
| 168 // callback via Start(). See http://crbug.com/151051 for details. | 168 // callback via Start(). See http://crbug.com/151051 for details. |
| 169 bool stopping_hack_; | 169 bool stopping_hack_; |
| 170 | 170 |
| 171 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); | 171 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); |
| 172 }; | 172 }; |
| 173 | 173 |
| 174 } // namespace media | 174 } // namespace media |
| 175 | 175 |
| 176 #endif // MEDIA_AUDIO_AUDIO_INPUT_DEVICE_H_ | 176 #endif // MEDIA_AUDIO_AUDIO_INPUT_DEVICE_H_ |
| OLD | NEW |