| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // AudioInputDeviceManager manages the audio input devices. In particular it | 5 // AudioInputDeviceManager manages the audio input devices. In particular it |
| 6 // communicates with MediaStreamManager and AudioInputRendererHost on the | 6 // communicates with MediaStreamManager and AudioInputRendererHost on the |
| 7 // browser IO thread, handles queries like enumerate/open/close from | 7 // browser IO thread, handles queries like enumerate/open/close from |
| 8 // MediaStreamManager and start/stop from AudioInputRendererHost. | 8 // MediaStreamManager and start/stop from AudioInputRendererHost. |
| 9 | 9 |
| 10 // All the queries come from the IO thread, while the work to enumerate devices | 10 // All the queries come from the IO thread, while the work to enumerate devices |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 namespace media_stream { | 24 namespace media_stream { |
| 25 | 25 |
| 26 class AudioInputDeviceManagerEventHandler; | 26 class AudioInputDeviceManagerEventHandler; |
| 27 | 27 |
| 28 class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider { | 28 class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider { |
| 29 public: | 29 public: |
| 30 // Calling Start() with this kFakeOpenSessionId will open the default device, | 30 // Calling Start() with this kFakeOpenSessionId will open the default device, |
| 31 // even though Open() has not been called. This is used to be able to use the | 31 // even though Open() has not been called. This is used to be able to use the |
| 32 // AudioInputDeviceManager before MediaStream is implemented. | 32 // AudioInputDeviceManager before MediaStream is implemented. |
| 33 static const int kFakeOpenSessionId; | 33 static const int kFakeOpenSessionId; |
| 34 |
| 34 static const int kInvalidSessionId; | 35 static const int kInvalidSessionId; |
| 35 static const int kInvalidDevice; | 36 static const char kInvalidDeviceId[]; |
| 36 static const int kDefaultDeviceIndex; | |
| 37 | 37 |
| 38 AudioInputDeviceManager(); | 38 AudioInputDeviceManager(); |
| 39 virtual ~AudioInputDeviceManager(); | 39 virtual ~AudioInputDeviceManager(); |
| 40 | 40 |
| 41 // MediaStreamProvider implementation, called on IO thread. | 41 // MediaStreamProvider implementation, called on IO thread. |
| 42 virtual void Register(MediaStreamProviderListener* listener); | 42 virtual void Register(MediaStreamProviderListener* listener); |
| 43 virtual void Unregister(); | 43 virtual void Unregister(); |
| 44 virtual void EnumerateDevices(); | 44 virtual void EnumerateDevices(); |
| 45 virtual int Open(const StreamDeviceInfo& device); | 45 virtual int Open(const StreamDeviceInfo& device); |
| 46 virtual void Close(int session_id); | 46 virtual void Close(int session_id); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 63 void StartOnDeviceThread(int session_id); | 63 void StartOnDeviceThread(int session_id); |
| 64 void StopOnDeviceThread(int session_id); | 64 void StopOnDeviceThread(int session_id); |
| 65 | 65 |
| 66 // Executed on IO thread to call Listener. | 66 // Executed on IO thread to call Listener. |
| 67 void DevicesEnumeratedOnIOThread(const StreamDeviceInfoArray& devices); | 67 void DevicesEnumeratedOnIOThread(const StreamDeviceInfoArray& devices); |
| 68 void OpenedOnIOThread(int session_id); | 68 void OpenedOnIOThread(int session_id); |
| 69 void ClosedOnIOThread(int session_id); | 69 void ClosedOnIOThread(int session_id); |
| 70 void ErrorOnIOThread(int session_id, MediaStreamProviderError error); | 70 void ErrorOnIOThread(int session_id, MediaStreamProviderError error); |
| 71 | 71 |
| 72 // Executed on IO thread to call the event handler. | 72 // Executed on IO thread to call the event handler. |
| 73 void StartedOnIOThread(int session_id, int index); | 73 void StartedOnIOThread(int session_id, const std::string& device_id); |
| 74 void StoppedOnIOThread(int session_id); | 74 void StoppedOnIOThread(int session_id); |
| 75 | 75 |
| 76 // Executed on audio_input_device_thread_ to make sure | 76 // Executed on audio_input_device_thread_ to make sure |
| 77 // MediaStreamProviderListener is called from IO thread. | 77 // MediaStreamProviderListener is called from IO thread. |
| 78 void SignalError(int session_id, MediaStreamProviderError error); | 78 void SignalError(int session_id, MediaStreamProviderError error); |
| 79 | 79 |
| 80 // Helpers. | 80 // Helpers. |
| 81 bool IsOnCaptureDeviceThread() const; | 81 bool IsOnCaptureDeviceThread() const; |
| 82 void UnregisterEventHandler(int session_id); | 82 void UnregisterEventHandler(int session_id); |
| 83 bool HasEventHandler(int session_id); | 83 bool HasEventHandler(int session_id); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 96 AudioInputDeviceMap devices_; | 96 AudioInputDeviceMap devices_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); | 98 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManager); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 } // namespace media_stream | 101 } // namespace media_stream |
| 102 | 102 |
| 103 DISABLE_RUNNABLE_METHOD_REFCOUNT(media_stream::AudioInputDeviceManager); | 103 DISABLE_RUNNABLE_METHOD_REFCOUNT(media_stream::AudioInputDeviceManager); |
| 104 | 104 |
| 105 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ | 105 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_ |
| OLD | NEW |