| 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 #include "content/browser/device_monitor_mac.h" | 5 #include "content/browser/device_monitor_mac.h" |
| 6 | 6 |
| 7 #import <QTKit/QTKit.h> | 7 #import <QTKit/QTKit.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 DeviceMonitorMac::QTMonitorImpl::QTMonitorImpl(DeviceMonitorMac* monitor) | 33 DeviceMonitorMac::QTMonitorImpl::QTMonitorImpl(DeviceMonitorMac* monitor) |
| 34 : monitor_(monitor), | 34 : monitor_(monitor), |
| 35 number_audio_devices_(0), | 35 number_audio_devices_(0), |
| 36 number_video_devices_(0), | 36 number_video_devices_(0), |
| 37 device_arrival_(nil), | 37 device_arrival_(nil), |
| 38 device_removal_(nil) { | 38 device_removal_(nil) { |
| 39 DCHECK(monitor); | 39 DCHECK(monitor); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void DeviceMonitorMac::QTMonitorImpl::Start() { | 42 void DeviceMonitorMac::QTMonitorImpl::Start() { |
| 43 NSArray* devices = [QTCaptureDevice inputDevices]; | |
| 44 for (QTCaptureDevice* device in devices) { | |
| 45 if ([device hasMediaType:QTMediaTypeVideo] || | |
| 46 [device hasMediaType:QTMediaTypeMuxed]) | |
| 47 ++number_video_devices_; | |
| 48 | |
| 49 if ([device hasMediaType:QTMediaTypeSound] || | |
| 50 [device hasMediaType:QTMediaTypeMuxed]) | |
| 51 ++number_audio_devices_; | |
| 52 } | |
| 53 | |
| 54 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; | 43 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; |
| 55 device_arrival_ = | 44 device_arrival_ = |
| 56 [nc addObserverForName:QTCaptureDeviceWasConnectedNotification | 45 [nc addObserverForName:QTCaptureDeviceWasConnectedNotification |
| 57 object:nil | 46 object:nil |
| 58 queue:nil | 47 queue:nil |
| 59 usingBlock:^(NSNotification* notification) { | 48 usingBlock:^(NSNotification* notification) { |
| 60 OnDeviceChanged();}]; | 49 OnDeviceChanged();}]; |
| 61 | 50 |
| 62 device_removal_ = | 51 device_removal_ = |
| 63 [nc addObserverForName:QTCaptureDeviceWasDisconnectedNotification | 52 [nc addObserverForName:QTCaptureDeviceWasDisconnectedNotification |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 qt_monitor_->Stop(); | 99 qt_monitor_->Stop(); |
| 111 } | 100 } |
| 112 | 101 |
| 113 void DeviceMonitorMac::NotifyDeviceChanged( | 102 void DeviceMonitorMac::NotifyDeviceChanged( |
| 114 base::SystemMonitor::DeviceType type) { | 103 base::SystemMonitor::DeviceType type) { |
| 115 // TODO(xians): Remove the global variable for SystemMonitor. | 104 // TODO(xians): Remove the global variable for SystemMonitor. |
| 116 base::SystemMonitor::Get()->ProcessDevicesChanged(type); | 105 base::SystemMonitor::Get()->ProcessDevicesChanged(type); |
| 117 } | 106 } |
| 118 | 107 |
| 119 } // namespace content | 108 } // namespace content |
| OLD | NEW |