Skip to content

Instantly share code, notes, and snippets.

@banjun
Created November 3, 2017 03:43
Show Gist options
  • Save banjun/aacbc0ccd7a5f7da65d58806201d3eb8 to your computer and use it in GitHub Desktop.
Save banjun/aacbc0ccd7a5f7da65d58806201d3eb8 to your computer and use it in GitHub Desktop.
list AVCaptureDevice including iOSScreenCaptureAssistant
import Cocoa
import CoreMediaIO
import AVFoundation
class ViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
var prop = CMIOObjectPropertyAddress(
mSelector: CMIOObjectPropertySelector(kCMIOHardwarePropertyAllowScreenCaptureDevices),
mScope: CMIOObjectPropertyScope(kCMIOObjectPropertyScopeGlobal),
mElement: CMIOObjectPropertyElement(kCMIOObjectPropertyElementMaster))
var allow: UInt32 = 1;
CMIOObjectSetPropertyData(CMIOObjectID(kCMIOObjectSystemObject), &prop,
0, nil,
UInt32(MemoryLayout.size(ofValue: allow)), &allow)
let devices = AVCaptureDevice.devices()
NSLog("%@", "devices = \(devices)")
}
}
@banjun
Copy link
Author

banjun commented Nov 3, 2017

2017-11-03 12:41:51.256772+0900 CoreMediaIORecorder[25780:3363152] devices = [<AVCaptureHALDevice: 0x60c0000e1800 [Soundflower (2ch)][SoundflowerEngine:0]>, <AVCaptureHALDevice: 0x60c0000e1780 [Built-in Microphone][AppleHDAEngineInput:1B,0,1,0:1]>, <AVCaptureHALDevice: 0x60c0000e1980 [Soundflower (64ch)][SoundflowerEngine:1]>, <AVCaptureDALDevice: 0x101002ce0 [FaceTime HD Camera (Built-in)][0x1450000005ac8511]>, <AVCaptureDALDevice: 0x1010134c0 [iPhone banjun 7 Plus][21c0235fe3b2e1aa8928f7e6677c8d045e20d48b]>]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment