VideoCaptureDeviceFactory: change device enumeration to callback + QTKit enumerates in UI thread.
This CL changes the Enumeration to be based on a callback passed to the VideoCaptureDeviceFactory. It is used for QTKit enumeration on UI thread: this is speculatively better than trying to run -performSelectorOnMainThread:withObject:waitUntilDone: -- Description -- Currently VCM::EnumerateDevices() issues an internal PostTaskAndReplyWithResult where the first part is GetAvailableDevicesInfoOnDeviceThread() on DeviceThread and the second is OnDevicesInfoEnumerated() in IO thread. This CL changes this to a simple PostTask to the VCDFactory::EnumerateDeviceNames() with a callback to VCM::ConsolidateDevicesInfoOnDeviceThread(). This method has a jump at the end to VCM::OnDevicesInfoEnumerated() on IO thread. So what used to be a simple back-and-forth jump is now a 3 hop process. This is used for QTKit to be able to override the VCDF::EnumerateDeviceNames and run the device enumeration in UI thread. Note 1: The UI thread is currently passed in Create() method for all implementations. This is changed to earlier: on VCDF::CreateFactory(); injected from MediaStreamManager; and only used in VCDFLinux (for ChromeOS) and in VCDFMac for QTKit enumeration. This approach is cleaner since we don't send UI thread references to derived classes that don't need it. Note 2: VideoCaptureDeviceFactoryMac::Create() used to have a search-and-find for |device_id| that is removed; the search was a precaution for devices that disappeared between first enumeration and use. However, using a |device_name| that is gone would just cause a fail on AllocateAndStart() anyhow, and enumerating twice is very expensive. For compatibility reasons, this behaviour is kept for AVFoundation devices and blacklisted QTKit devices (that behave as a subset of AVF-type ones). BUG=255552, 115327 Review URL: https://codereview.chromium.org/294893006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274518 0039d316-1c4b-4281-b951-d872f2087c98
Showing
Please register or sign in to comment