Upgrade to Pro — share decks privately, control downloads, hide ads and more …

UVC(USB video class)と マルチプラットフォーム - UVC support...

notoroid
December 08, 2023

UVC(USB video class)と マルチプラットフォーム - UVC support by Apple multiplatform

iPadOS17 でサポートされたUVC(USB Video Class) を使ったゲームモニターのデモンストレーション用セッション資料

notoroid

December 08, 2023
Tweet

More Decks by notoroid

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ w J1IPOFΞϓϦ։ൃऀ 9!OPUPSPJE  w ΞϓϦ։ൃऀྺ ʙ  w

    ΞϓϦ࡞࢛ͬͯ൒ੈل ೥౸ୡ  w झຯ͸ήʔϜ ൓ࣹਆܦ͕ਰ͑ͱ໨ͷർΕ͕ൈ͚ͳ͍
  2. ਺ʑͷ৽ػೳ w ελϯόΠϞʔυ w ετϨʔδ΁ͷಈը࿥ը J1IPOF QSP  w ͜Ε͸ͱ͍ͬͨػೳ͸๡͔͔ͬͨ͠

    ΋ʜ w ϓϩάϥϛϯάपΓ ಺෦త ͷڧԽ w 6*पΓͷॆ࣮ "OJNBUJPO 8JEHFU  w 0CTFSWBUJPOGSBNFXPSL J04ϦϦʔε͞Ε·ͨ͠ IUUQTEFWFMPQFSBQQMFDPNXXED UJNF
  3. 4JNQMF(BNF.POJUPS IUUQTHJUIVCDPNOPUPSPJE4JNQMF(BNF.POJUPS w J04ͱNBD04ͷࠩҟΛٵऩ͢Δ w J04NBD04ͷίʔυΛJGPT ʙFOEJGͰͦΕͧΕهड़ w 6*7JFX3FQSFTFOUBCMF w

    /47JFX3FQSFTFOUBCMF w ඳըΛ୲౰͢Δ$"-BZFS ͱ೿ੜΫϥε͸ڞ௨  w $"-BZFSͷѻ͍ํ͸J04ͱNBD04ͰҟͳΔ #if os(iOS) import UIKit #elseif os(macOS) import AppKit #endif
  4. 4JNQMF(BNF.POJUPSᶃ ֎෦σόΠεΛݟ͚ͭΔ // external guard let captureDevice = AVCaptureDevice.default(AVCaptureDevice.DeviceType.external, for:

    .video, position: .unspecified) else { teardownAVCapture() return } let session = AVCaptureSession() guard session.canSetSessionPreset(.hd1920x1080) else { teardownAVCapture() return } session.sessionPreset = .hd1920x1080 $BQUVSF.BOBHFSTXJGU ֎෦ FYUFSOBM σόΠεΛ)%ը࣭Ͱѻ͏
  5. 4JNQMF(BNF.POJUPSᶄ ֎෦σόΠεΛηογϣϯ΁௥Ճ $BQUVSF.BOBHFSTXJGU let deviceInput = try AVCaptureDeviceInput(device: captureDevice) if

    session.canAddInput(deviceInput) { session.addInput(deviceInput) print("added session") } else { print("not add session") } ηογϣϯ΁ͷ௥Ճ͸಺ଂΧϝϥͱมΘΓͳ͠
  6. 4JNQMF(BNF.POJUPSᶅ ϓϨϏϡʔΛ༻ҙ $BQUVSF.BOBHFSTXJGU ηογϣϯܦ༝ͰϓϨϏϡʔͱͯ͠දࣔ͢Δө૾Λ౉͢ previewLayer = AVCaptureVideoPreviewLayer(session:session) if let previewLayer

    { previewLayer.backgroundColor = CGColor(gray: 0.5, alpha: 1.0) previewLayer.videoGravity = .resizeAspect } self.session = session DispatchQueue.global(qos: .background).async { session.startRunning() }
  7. ࢀߟ w 4VQQPSUFYUFSOBMDBNFSBTJOZPVSJ1BE04 BQQ88%$7JEFPT"QQMF%FWFMPQFS w IUUQTEFWFMPQFSBQQMFDPN XXED w "7$BN#VJMEJOHB$BNFSB"QQc"QQMF %FWFMPQFS%PDVNFOUBUJPO

    w IUUQTEFWFMPQFSBQQMFDPN EPDVNFOUBUJPOBWGPVOEBUJPO DBQUVSF@TFUVQ BWDBN@CVJMEJOH@B@DBNFSB@BQQ w .BD04ͷγϯάϧ΢Οϯυ΢ΞϓϦέʔγϣ ϯΛ࡞Δͱ͖ʹ΍͓ͬͯ͘͜ͱ w IUUQT[FOOEFWPIOBNJBSUJDMFT CEBEBCB w OPUPSPJE4JNQMF(BNF.POJUPSFYUFSOBM WJEFPEFWJDFQSFWJFXTBNQMFDPEFGPS BQQMFNVMUJQMBUGPSN J1BE04 NBD04  w IUUQTHJUIVCDPNOPUPSPJE 4JNQMF(BNF.POJUPS w 4XJGU6*Ή͚ʹ੔ཧ͞Εͨঢ়ଶ؂ࢹ 0CTFSWBUJPO4QFBLFS%FDL w IUUQTTQFBLFSEFDLDPNOPUPSPJE TXJGUVJNVLFOJ[IFOHMJTBSFUB[IVBOHUBJ KJBOTIJPCTFSWBUJPO