| Index: content/browser/renderer_host/media/audio_input_device_manager.h
|
| diff --git a/content/browser/renderer_host/media/audio_input_device_manager.h b/content/browser/renderer_host/media/audio_input_device_manager.h
|
| index 5f1e2df76fc87e9cb3bc6bc90396008c5b8a7a70..133673f2a5fc97c301902856ef044f06375a49f5 100644
|
| --- a/content/browser/renderer_host/media/audio_input_device_manager.h
|
| +++ b/content/browser/renderer_host/media/audio_input_device_manager.h
|
| @@ -4,10 +4,11 @@
|
| //
|
| // AudioInputDeviceManager manages the audio input devices. In particular it
|
| // communicates with MediaStreamManager and AudioInputRendererHost on the
|
| -// browser IO thread, handles queries like enumerate/open/close from
|
| -// MediaStreamManager and start/stop from AudioInputRendererHost.
|
| +// browser IO thread, handles queries like
|
| +// enumerate/open/close/GetOpenedDeviceInfoById from MediaStreamManager and
|
| +// GetOpenedDeviceInfoById from AudioInputRendererHost.
|
| // The work for enumerate/open/close is handled asynchronously on Media Stream
|
| -// device thread, while start/stop are synchronous on the IO thread.
|
| +// device thread, while GetOpenedDeviceInfoById is synchronous on the IO thread.
|
|
|
| #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_
|
| #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEVICE_MANAGER_H_
|
| @@ -28,17 +29,20 @@ class AudioManager;
|
|
|
| namespace content {
|
|
|
| -class AudioInputDeviceManagerEventHandler;
|
| -
|
| class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider {
|
| public:
|
| // Calling Start() with this kFakeOpenSessionId will open the default device,
|
| // even though Open() has not been called. This is used to be able to use the
|
| // AudioInputDeviceManager before MediaStream is implemented.
|
| + // TODO(xians): Remove it when the webrtc unittest does not need it any more.
|
| static const int kFakeOpenSessionId;
|
|
|
| explicit AudioInputDeviceManager(media::AudioManager* audio_manager);
|
|
|
| + // Gets the opened device info by |session_id|. Returns NULL if the device
|
| + // is not opened, otherwise the opened device. Called on IO thread.
|
| + const StreamDeviceInfo* GetOpenedDeviceInfoById(int session_id);
|
| +
|
| // MediaStreamProvider implementation, called on IO thread.
|
| virtual void Register(MediaStreamProviderListener* listener,
|
| base::MessageLoopProxy* device_thread_loop) OVERRIDE;
|
| @@ -47,26 +51,17 @@ class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider {
|
| virtual int Open(const StreamDeviceInfo& device) OVERRIDE;
|
| virtual void Close(int session_id) OVERRIDE;
|
|
|
| - // Functions used by AudioInputRenderHost, called on IO thread.
|
| - // Starts the device referenced by the session id.
|
| - void Start(int session_id, AudioInputDeviceManagerEventHandler* handler);
|
| - // Stops the device referenced by the session id.
|
| - void Stop(int session_id);
|
| -
|
| void UseFakeDevice();
|
| bool ShouldUseFakeDevice() const;
|
|
|
| private:
|
| - typedef std::map<int, AudioInputDeviceManagerEventHandler*> EventHandlerMap;
|
| - typedef std::map<int, StreamDeviceInfo> StreamDeviceMap;
|
| + typedef std::vector<StreamDeviceInfo> StreamDeviceList;
|
| virtual ~AudioInputDeviceManager();
|
|
|
| // Enumerates audio input devices on media stream device thread.
|
| void EnumerateOnDeviceThread(MediaStreamType stream_type);
|
| // Opens the device on media stream device thread.
|
| - void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& device);
|
| - // Closes the deivce on the media stream device thread.
|
| - void CloseOnDeviceThread(int session_id);
|
| + void OpenOnDeviceThread(int session_id, const StreamDeviceInfo& info);
|
|
|
| // Callback used by EnumerateOnDeviceThread(), called with a list of
|
| // enumerated devices on IO thread.
|
| @@ -74,7 +69,7 @@ class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider {
|
| scoped_ptr<StreamDeviceInfoArray> devices);
|
| // Callback used by OpenOnDeviceThread(), called with the session_id
|
| // referencing the opened device on IO thread.
|
| - void OpenedOnIOThread(MediaStreamType type, int session_id);
|
| + void OpenedOnIOThread(int session_id, const StreamDeviceInfo& info);
|
| // Callback used by CloseOnDeviceThread(), called with the session_id
|
| // referencing the closed device on IO thread.
|
| void ClosedOnIOThread(MediaStreamType type, int session_id);
|
| @@ -82,15 +77,17 @@ class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider {
|
| // Verifies that the calling thread is media stream device thread.
|
| bool IsOnDeviceThread() const;
|
|
|
| + // Helper to return iterator to the device referenced by |session_id|. If no
|
| + // device is found, it will return devices_.end().
|
| + StreamDeviceList::iterator GetDevice(int session_id);
|
| +
|
| // Only accessed on Browser::IO thread.
|
| MediaStreamProviderListener* listener_;
|
| int next_capture_session_id_;
|
| - EventHandlerMap event_handlers_;
|
| bool use_fake_device_;
|
| + StreamDeviceList devices_;
|
|
|
| - // Only accessed from media stream device thread.
|
| - StreamDeviceMap devices_;
|
| - media::AudioManager* const audio_manager_;
|
| + media::AudioManager* const audio_manager_; // Weak.
|
|
|
| // The message loop of media stream device thread that this object runs on.
|
| scoped_refptr<base::MessageLoopProxy> device_loop_;
|
|
|