All Projects → lvsti → CMIOKit

lvsti / CMIOKit

Licence: MIT license
Developer-friendly Swift wrapper around the CoreMediaIO C APIs

Programming Languages

swift
15916 projects
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to CMIOKit

base
小而美的业务基础框架,也是本项目的核心
Stars: ✭ 47 (+4.44%)
Mutual labels:  dal
Db
Data access layer for PostgreSQL, CockroachDB, MySQL, SQLite and MongoDB with ORM-like features.
Stars: ✭ 2,832 (+6193.33%)
Mutual labels:  dal
neural-greenscreen
Real time background replacement on a mac os driven webcam using the DeepLabV3 neural network for image segmentation and the native CoreMediaIO DAL framework of Mac OS.
Stars: ✭ 18 (-60%)
Mutual labels:  dal
akvirtualcamera
akvirtualcamera, virtual camera for Mac and Windows
Stars: ✭ 95 (+111.11%)
Mutual labels:  coremediaio
SimpleDALPlugin
Simple CoreMediaIO DAL virtual camera plugin example written in Swift
Stars: ✭ 138 (+206.67%)
Mutual labels:  coremediaio

CMIOKit

Swift wrapper around the CoreMediaIO C APIs

Description

CoreMediaIO (CMIO for short) is a neglected foster child in the macOS platform SDK for that its API is still a decades-old C interface that auto-translates miserably to Swift with all that unsafe pointer business going on. CMIOKit aims at offering a somewhat higher-level, developer-friendly API for these calls while making no simplifications or compromises on the data that can be accessed.

Elevator pitch

Why would you write this:

var address = CMIOObjectPropertyAddress(mSelector: CMIOObjectPropertySelector(kCMIOHardwarePropertyAllowScreenCaptureDevices),
                                        mScope: CMIOObjectPropertyScope(kCMIOObjectPropertyScopeGlobal),
                                        mElement: CMIOObjectPropertyElement(kCMIOObjectPropertyElementMaster))
let dataSize = UInt32(MemoryLayout<UInt32>.size)
var dataUsed: UInt32 = 0
var data = UnsafeMutableRawPointer.allocate(byteCount: Int(dataSize), alignment: MemoryLayout<UInt32>.alignment)
defer { data.deallocate() }

let status = CMIOObjectGetPropertyData(objectID, &address, 0, nil, dataSize, &dataUsed, data)
if status == kCMIOHardwareNoError {
    let typedData = data.bindMemory(to: UInt32.self, capacity: 1)
    print("property value = \(typedData.pointee)")
}

when you can also do this?

if case .boolean(let value) = SystemProperty.allowScreenCaptureDevices.value(in: .systemObject) {
    print("property value = \(value)")
}

Usage

See the docs for more detailed instructions.

Requirements

To build: Xcode 10.1+, Swift 4.2+
To use: macOS 10.13+

Note: To use CMIOKit in your application, you'll need to link to the CoreMediaIO.framework as well.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].