Simple Objective-C++ wrapper for Blackmagic DeckLink API (C++ APIs).
- Requirement: macOS 12.x, 11.x, 10.15, 10.14.
- Capture Device: Blackmagic DeckLink devices.
- Restriction: Compressed capture is not supported.
- Dependency: DeckLinkAPI.framework from Blackmagic_Desktop_Video_Macintosh (11.4-11.7, 12.0-12.2)
- Architecture: Universal binary (x86_64 + arm64)
NOTE: This framework is under development.
: Following interfaces are not supported. (Section # are from SDK 11.6 pdf)
: 2.5.8 IDeckLinkVideoFrame3DExtensions
: 2.5.18 IDeckLinkMemoryAllocator
: 2.5.26 IDeckLinkGLScreenPreviewHelper
: 2.5.27 IDeckLinkCocoaScreenPreviewCallback
: 2.5.28 IDeckLinkDX9ScreenPreviewHelper
: 2.5.35 IDeckLinkEncoderInput
: 2.5.36 IDeckLinkEncoderInputCallback
: 2.5.37 IDeckLinkEncoderPacket
: 2.5.38 IDeckLinkEncoderVideoPacket
: 2.5.39 IDeckLinkEncoderAudioPacket
: 2.5.40 IDeckLinkH265NALPacket
: 2.5.41 IDeckLinkEncoderConfiguration
: 2.5.44 IDeckLinkVideoConversion
: 2.6.x Any Streaming Interface APIs
import Cocoa
import DLABridging
var device :DLABDevice? = nil
var running :Bool = false
do {
let browser = DLABBrowser()
_ = browser.registerDevicesForInput()
let deviceList = browser.allDevices
device = deviceList.first!
}
do {
try device.setInputScreenPreviewTo(parentView)
var vSetting:DLABVideoSetting? = nil
try vSetting = device.createInputVideoSetting(of: .modeNTSC,
pixelFormat: .format8BitYUV,
inputFlag: [])
var aSetting:DLABAudioSetting? = nil
try aSetting = device.createInputAudioSetting(of: .type16bitInteger,
channelCount: 2,
sampleRate: .rate48kHz)
if let vSetting = vSetting {
try vSetting.addClapExt(ofWidthN: 704, widthD: 1,
heightN: 480, heightD: 1,
hOffsetN: 4, hOffsetD: 1,
vOffsetN: 0, vOffsetD: 1)
try vSetting.addPaspExt(ofHSpacing: 40,
vSpacing: 33)
}
// rebuild formatDescription with new CVPixelFormat
// vSetting.cvPixelFormatType = cvPixelFormat
// try vSetting.buildVideoFormatDescription()
if let vSetting = vSetting, let aSetting = aSetting {
device.inputDelegate = self
try device.enableVideoInput(with: vSetting, on: .HDMI)
try device.enableAudioInput(with: aSetting, on: audioConnection)
try device.startStreams()
running = true
}
} catch {
print("ERROR!!")
:
}
public func processCapturedVideoSample(_ sampleBuffer: CMSampleBuffer,
of sender:DLABDevice) {
print("video")
}
public func processCapturedAudioSample(_ sampleBuffer: CMSampleBuffer,
of sender:DLABDevice) {
print("audio")
}
public func processCapturedVideoSample(_ sampleBuffer: CMSampleBuffer,
timecodeSetting setting: DLABTimecodeSetting,
of sender:DLABDevice) {
print("video/timecode")
}
running = false
do {
try device.stopStreams()
try device.disableVideoInput()
try device.disableAudioInput()
device.inputDelegate = nil
try device.setInputScreenPreviewTo(nil)
} catch {
print("ERROR!!")
}
device = nil
- macOS 11.6.2 BigSur
- Xcode 13.2.1
- Swift 5.5.2
- The MIT License
Copyright © 2017-2022年 MyCometG3. All rights reserved.