| 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 // MediaStreamManager is used to open/enumerate media capture devices (video | 5 // MediaStreamManager is used to open/enumerate media capture devices (video |
| 6 // supported now). Call flow: | 6 // supported now). Call flow: |
| 7 // 1. GenerateStream is called when a render process wants to use a capture | 7 // 1. GenerateStream is called when a render process wants to use a capture |
| 8 // device. | 8 // device. |
| 9 // 2. MediaStreamManager will ask MediaStreamUIController for permission to | 9 // 2. MediaStreamManager will ask MediaStreamUIController for permission to |
| 10 // use devices and for which device to use. | 10 // use devices and for which device to use. |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // This object gets deleted on the UI thread after the IO thread has been | 175 // This object gets deleted on the UI thread after the IO thread has been |
| 176 // destroyed. So we need to know when IO thread is being destroyed so that | 176 // destroyed. So we need to know when IO thread is being destroyed so that |
| 177 // we can delete VideoCaptureManager and AudioInputDeviceManager. Normally | 177 // we can delete VideoCaptureManager and AudioInputDeviceManager. Normally |
| 178 // this is handled by | 178 // this is handled by |
| 179 // base::MessageLoop::DestructionObserver::WillDestroyCurrentMessageLoop. | 179 // base::MessageLoop::DestructionObserver::WillDestroyCurrentMessageLoop. |
| 180 // But for some tests which use TestBrowserThreadBundle, we need to call | 180 // But for some tests which use TestBrowserThreadBundle, we need to call |
| 181 // WillDestroyCurrentMessageLoop explicitly because the notification happens | 181 // WillDestroyCurrentMessageLoop explicitly because the notification happens |
| 182 // too late. (see http://crbug.com/247525#c14). | 182 // too late. (see http://crbug.com/247525#c14). |
| 183 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | 183 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; |
| 184 | 184 |
| 185 // Sends log messages to the render processes making device requests, to be | 185 // Sends log messages to the render process hosts whose corresponding render |
| 186 // used by the webrtcLoggingPrivate API if requested. | 186 // processes are making device requests, to be used by the |
| 187 // webrtcLoggingPrivate API if requested. |
| 187 void AddLogMessageOnIOThread(const std::string& message); | 188 void AddLogMessageOnIOThread(const std::string& message); |
| 188 | 189 |
| 189 // Adds |message| to native logs for outstanding device requests, for use by | 190 // Adds |message| to native logs for outstanding device requests, for use by |
| 190 // render processes requesting logging from webrtcLoggingPrivate API. Safe to | 191 // render processes hosts whose corresponding render processes are requesting |
| 191 // call from any thread. | 192 // logging from webrtcLoggingPrivate API. Safe to call from any thread. |
| 192 static void SendMessageToNativeLog(const std::string& message); | 193 static void SendMessageToNativeLog(const std::string& message); |
| 193 | 194 |
| 194 protected: | 195 protected: |
| 195 // Used for testing. | 196 // Used for testing. |
| 196 MediaStreamManager(); | 197 MediaStreamManager(); |
| 197 | 198 |
| 198 private: | 199 private: |
| 199 // Contains all data needed to keep track of requests. | 200 // Contains all data needed to keep track of requests. |
| 200 class DeviceRequest; | 201 class DeviceRequest; |
| 201 | 202 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 310 |
| 310 // Finds the requested device id from constraints. The requested device type | 311 // Finds the requested device id from constraints. The requested device type |
| 311 // must be MEDIA_DEVICE_AUDIO_CAPTURE or MEDIA_DEVICE_VIDEO_CAPTURE. | 312 // must be MEDIA_DEVICE_AUDIO_CAPTURE or MEDIA_DEVICE_VIDEO_CAPTURE. |
| 312 bool GetRequestedDeviceCaptureId(const DeviceRequest* request, | 313 bool GetRequestedDeviceCaptureId(const DeviceRequest* request, |
| 313 MediaStreamType type, | 314 MediaStreamType type, |
| 314 std::string* device_id) const; | 315 std::string* device_id) const; |
| 315 | 316 |
| 316 void TranslateDeviceIdToSourceId(DeviceRequest* request, | 317 void TranslateDeviceIdToSourceId(DeviceRequest* request, |
| 317 MediaStreamDevice* device); | 318 MediaStreamDevice* device); |
| 318 | 319 |
| 319 // Helper method that sends log messages to the render processes in | 320 // Helper method that sends log messages to the render process hosts whose |
| 320 // |render_process_ids|, to be used by the webrtcLoggingPrivate API if | 321 // corresponding render processes are in |render_process_ids|, to be used by |
| 321 // requested. | 322 // the webrtcLoggingPrivate API if requested. |
| 322 void AddLogMessageOnUIThread(const std::set<int>& render_process_ids, | 323 void AddLogMessageOnUIThread(const std::set<int>& render_process_ids, |
| 323 const std::string& message); | 324 const std::string& message); |
| 324 | 325 |
| 325 // Finds and returns the device id corresponding to the given | 326 // Finds and returns the device id corresponding to the given |
| 326 // |source_id|. Returns true if there was a raw device id that matched the | 327 // |source_id|. Returns true if there was a raw device id that matched the |
| 327 // given |source_id|, false if nothing matched it. | 328 // given |source_id|, false if nothing matched it. |
| 328 bool TranslateSourceIdToDeviceId( | 329 bool TranslateSourceIdToDeviceId( |
| 329 MediaStreamType stream_type, | 330 MediaStreamType stream_type, |
| 330 ResourceContext* rc, | 331 ResourceContext* rc, |
| 331 const GURL& security_origin, | 332 const GURL& security_origin, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 362 | 363 |
| 363 bool use_fake_ui_; | 364 bool use_fake_ui_; |
| 364 scoped_ptr<FakeMediaStreamUIProxy> fake_ui_; | 365 scoped_ptr<FakeMediaStreamUIProxy> fake_ui_; |
| 365 | 366 |
| 366 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); | 367 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); |
| 367 }; | 368 }; |
| 368 | 369 |
| 369 } // namespace content | 370 } // namespace content |
| 370 | 371 |
| 371 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 372 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
| OLD | NEW |