 Chromium Code Reviews
 Chromium Code Reviews Issue 12440027:
  Do not pass the string device_id via IPC message to create an audio input stream  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 12440027:
  Do not pass the string device_id via IPC message to create an audio input stream  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| 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..81e4d305b0384eeb2b5106f8c6048b07b37ce604 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,8 +29,6 @@ class AudioManager; | 
| namespace content { | 
| -class AudioInputDeviceManagerEventHandler; | 
| - | 
| class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider { | 
| public: | 
| // Calling Start() with this kFakeOpenSessionId will open the default device, | 
| @@ -39,6 +38,10 @@ class CONTENT_EXPORT AudioInputDeviceManager : public MediaStreamProvider { | 
| explicit AudioInputDeviceManager(media::AudioManager* audio_manager); | 
| + // Gets the opened device info by |session_id|. If the device is not | 
| + // opened, it will return an empty object, called on IO thread. | 
| + StreamDeviceInfo GetOpenedDeviceInfoById(int session_id); | 
| 
miu
2013/03/18 23:19:05
nit: Consider returning a bool and having the call
 
no longer working on chromium
2013/03/19 14:06:49
Then I think it might be clearer to return a const
 | 
| + | 
| // MediaStreamProvider implementation, called on IO thread. | 
| virtual void Register(MediaStreamProviderListener* listener, | 
| base::MessageLoopProxy* device_thread_loop) OVERRIDE; | 
| @@ -47,26 +50,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 +68,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 +76,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); | 
| 
miu
2013/03/18 23:19:05
Suggest you return a StreamDeviceInfo* instead of
 
no longer working on chromium
2013/03/19 14:06:49
This iterator returned by GetDevice() is used by C
 | 
| + | 
| // 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_; |