| Index: media/capture/video/mac/video_capture_device_mac.mm
|
| diff --git a/media/capture/video/mac/video_capture_device_mac.mm b/media/capture/video/mac/video_capture_device_mac.mm
|
| index e11e646de7f847979beb018dbe337ca03937dfbd..521fef27080899ef9d081caa81ed51128bd77224 100644
|
| --- a/media/capture/video/mac/video_capture_device_mac.mm
|
| +++ b/media/capture/video/mac/video_capture_device_mac.mm
|
| @@ -292,32 +292,13 @@ static void SetAntiFlickerInUsbDevice(const int vendor_id,
|
| }
|
| }
|
|
|
| -const std::string VideoCaptureDevice::Name::GetModel() const {
|
| - // Skip the AVFoundation's not USB nor built-in devices.
|
| - if (capture_api_type() == AVFOUNDATION && transport_type() != USB_OR_BUILT_IN)
|
| - return "";
|
| - if (capture_api_type() == DECKLINK)
|
| - return "";
|
| - // Both PID and VID are 4 characters.
|
| - if (unique_id_.size() < 2 * kVidPidSize)
|
| - return "";
|
| -
|
| - // The last characters of device id is a concatenation of VID and then PID.
|
| - const size_t vid_location = unique_id_.size() - 2 * kVidPidSize;
|
| - std::string id_vendor = unique_id_.substr(vid_location, kVidPidSize);
|
| - const size_t pid_location = unique_id_.size() - kVidPidSize;
|
| - std::string id_product = unique_id_.substr(pid_location, kVidPidSize);
|
| -
|
| - return id_vendor + ":" + id_product;
|
| -}
|
| -
|
| -VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name)
|
| - : device_name_(device_name),
|
| +VideoCaptureDeviceMac::VideoCaptureDeviceMac(
|
| + const VideoCaptureDeviceDescriptor& device_descriptor)
|
| + : device_descriptor_(device_descriptor),
|
| task_runner_(base::ThreadTaskRunnerHandle::Get()),
|
| state_(kNotInitialized),
|
| capture_device_(nil),
|
| - weak_factory_(this) {
|
| -}
|
| + weak_factory_(this) {}
|
|
|
| VideoCaptureDeviceMac::~VideoCaptureDeviceMac() {
|
| DCHECK(task_runner_->BelongsToCurrentThread());
|
| @@ -332,11 +313,13 @@ void VideoCaptureDeviceMac::AllocateAndStart(
|
| }
|
|
|
| client_ = std::move(client);
|
| - if (device_name_.capture_api_type() == Name::AVFOUNDATION)
|
| - LogMessage("Using AVFoundation for device: " + device_name_.name());
|
| + if (device_descriptor_.capture_api ==
|
| + VideoCaptureApiType::MACOSX_AVFOUNDATION)
|
| + LogMessage("Using AVFoundation for device: " +
|
| + device_descriptor_.friendly_name);
|
|
|
| NSString* deviceId =
|
| - [NSString stringWithUTF8String:device_name_.id().c_str()];
|
| + [NSString stringWithUTF8String:device_descriptor_.device_id.c_str()];
|
|
|
| [capture_device_ setFrameReceiver:this];
|
|
|
| @@ -359,7 +342,7 @@ void VideoCaptureDeviceMac::AllocateAndStart(
|
| // Try setting the power line frequency removal (anti-flicker). The built-in
|
| // cameras are normally suspended so the configuration must happen right
|
| // before starting capture and during configuration.
|
| - const std::string& device_model = device_name_.GetModel();
|
| + std::string device_model = GetDeviceModelId(device_descriptor_);
|
| if (device_model.length() > 2 * kVidPidSize) {
|
| std::string vendor_id = device_model.substr(0, kVidPidSize);
|
| std::string model_id = device_model.substr(kVidPidSize + 1);
|
| @@ -400,12 +383,11 @@ void VideoCaptureDeviceMac::TakePhoto(TakePhotoCallback callback) {
|
| [capture_device_ takePhoto];
|
| }
|
|
|
| -bool VideoCaptureDeviceMac::Init(
|
| - VideoCaptureDevice::Name::CaptureApiType capture_api_type) {
|
| +bool VideoCaptureDeviceMac::Init(VideoCaptureApiType capture_api_type) {
|
| DCHECK(task_runner_->BelongsToCurrentThread());
|
| DCHECK_EQ(state_, kNotInitialized);
|
|
|
| - if (capture_api_type != Name::AVFOUNDATION)
|
| + if (capture_api_type != VideoCaptureApiType::MACOSX_AVFOUNDATION)
|
| return false;
|
|
|
| capture_device_.reset(
|
| @@ -488,4 +470,31 @@ bool VideoCaptureDeviceMac::UpdateCaptureResolution() {
|
| return true;
|
| }
|
|
|
| +// static
|
| +std::string VideoCaptureDeviceMac::GetDeviceModelId(
|
| + const VideoCaptureDeviceDescriptor& device_descriptor) {
|
| + // Skip the AVFoundation's not USB nor built-in devices.
|
| + if (device_descriptor.capture_api ==
|
| + VideoCaptureApiType::MACOSX_AVFOUNDATION &&
|
| + device_descriptor.transport_type !=
|
| + VideoCaptureTransportType::MACOSX_USB_OR_BUILT_IN)
|
| + return "";
|
| + if (device_descriptor.capture_api == VideoCaptureApiType::MACOSX_DECKLINK)
|
| + return "";
|
| + // Both PID and VID are 4 characters.
|
| + if (device_descriptor.device_id.size() < 2 * kVidPidSize)
|
| + return "";
|
| +
|
| + // The last characters of device id is a concatenation of VID and then PID.
|
| + const size_t vid_location =
|
| + device_descriptor.device_id.size() - 2 * kVidPidSize;
|
| + std::string id_vendor =
|
| + device_descriptor.device_id.substr(vid_location, kVidPidSize);
|
| + const size_t pid_location = device_descriptor.device_id.size() - kVidPidSize;
|
| + std::string id_product =
|
| + device_descriptor.device_id.substr(pid_location, kVidPidSize);
|
| +
|
| + return id_vendor + ":" + id_product;
|
| +}
|
| +
|
| } // namespace media
|
|
|