+ +
9cd67fc refactor(compat): move CMIO DAL compatibility stub to include/compat/cmio
saifmukhtar · 2026-11-25
main
| 1 | /* |
| 2 | * SPDX-License-Identifier: AGPL-3.0-or-later WITH Classpath-exception-2.0 |
| 3 | * Copyright (c) 2026 Saif Mukhtar |
| 4 | * |
| 5 | * OpenAVX - Open Audio-Video eXchange |
| 6 | * include/compat/cmio/CMIOHardwarePlugIn.h - CoreMediaIO DAL Compatibility Stub for Non-macOS Builds |
| 7 | * |
| 8 | * Provides minimal ABI-compatible types, FourCCs, UUIDs, and vtable struct |
| 9 | * definitions for compiling and testing CoreMediaIO DAL integration on |
| 10 | * non-macOS platforms. Native macOS builds use the system Xcode SDK headers. |
| 11 | */ |
| 12 | |
| 13 | #ifndef AVX_COMPAT_CMIO_HARDWARE_PLUGIN_H |
| 14 | #define AVX_COMPAT_CMIO_HARDWARE_PLUGIN_H |
| 15 | |
| 16 | #if defined(AVX_OS_MACOS) && !defined(AVX_FORCE_COMPAT_CMIO) |
| 17 | |
| 18 | #include <CoreFoundation/CoreFoundation.h> |
| 19 | #include <CoreMedia/CoreMedia.h> |
| 20 | #include <CoreMediaIO/CMIOHardwarePlugIn.h> |
| 21 | #include <CoreMediaIO/CMIOHardwareStream.h> |
| 22 | #include <CoreMediaIO/CMIOHardwareDevice.h> |
| 23 | |
| 24 | #else |
| 25 | |
| 26 | #include <stdint.h> |
| 27 | #include <stdbool.h> |
| 28 | #include <stddef.h> |
| 29 | |
| 30 | /* CoreFoundation Base Types */ |
| 31 | typedef const void *CFAllocatorRef; |
| 32 | typedef const void *CFUUIDRef; |
| 33 | typedef const void *CFStringRef; |
| 34 | typedef const void *CFTypeRef; |
| 35 | typedef const void *CFArrayRef; |
| 36 | |
| 37 | typedef struct CFUUIDBytes { |
| 38 | uint8_t byte0; uint8_t byte1; uint8_t byte2; uint8_t byte3; |
| 39 | uint8_t byte4; uint8_t byte5; uint8_t byte6; uint8_t byte7; |
| 40 | uint8_t byte8; uint8_t byte9; uint8_t byte10; uint8_t byte11; |
| 41 | uint8_t byte12; uint8_t byte13; uint8_t byte14; uint8_t byte15; |
| 42 | } CFUUIDBytes; |
| 43 | |
| 44 | /* Apple / COM Base Types */ |
| 45 | typedef int32_t OSStatus; |
| 46 | typedef uint32_t UInt32; |
| 47 | typedef int32_t SInt32; |
| 48 | typedef uint64_t UInt64; |
| 49 | typedef uint8_t Boolean; |
| 50 | typedef int32_t HRESULT; |
| 51 | typedef uint32_t ULONG; |
| 52 | typedef void *LPVOID; |
| 53 | |
| 54 | #ifndef S_OK |
| 55 | #define S_OK ((HRESULT)0L) |
| 56 | #endif |
| 57 | #ifndef E_POINTER |
| 58 | #define E_POINTER ((HRESULT)0x80004003L) |
| 59 | #endif |
| 60 | #ifndef E_NOINTERFACE |
| 61 | #define E_NOINTERFACE ((HRESULT)0x80004002L) |
| 62 | #endif |
| 63 | #ifndef noErr |
| 64 | #define noErr 0 |
| 65 | #endif |
| 66 | #ifndef kCMIOHardwareNoError |
| 67 | #define kCMIOHardwareNoError 0 |
| 68 | #endif |
| 69 | #ifndef kCMIOHardwareUnspecifiedError |
| 70 | #define kCMIOHardwareUnspecifiedError 0x77686174 /* 'what' */ |
| 71 | #endif |
| 72 | #ifndef kCMIOHardwareUnknownPropertyError |
| 73 | #define kCMIOHardwareUnknownPropertyError 0x77686f3f /* 'who?' */ |
| 74 | #endif |
| 75 | #ifndef kCMIOHardwareBadObjectError |
| 76 | #define kCMIOHardwareBadObjectError 0x216f626a /* '!obj' */ |
| 77 | #endif |
| 78 | |
| 79 | /* CoreMediaIO Object Types */ |
| 80 | typedef UInt32 CMIOObjectID; |
| 81 | typedef CMIOObjectID CMIODeviceID; |
| 82 | typedef CMIOObjectID CMIOStreamID; |
| 83 | typedef CMIOObjectID CMIOControlID; |
| 84 | typedef UInt32 CMIOClassID; |
| 85 | |
| 86 | /* Special Object IDs */ |
| 87 | #define kCMIOObjectSystemObject 1 |
| 88 | #define kCMIOObjectUnknown 0 |
| 89 | |
| 90 | /* Object Scopes & Elements */ |
| 91 | #define kCMIOObjectPropertyScopeGlobal 0x676c6f62 /* 'glob' */ |
| 92 | #define kCMIOObjectPropertyScopeInput 0x696e7074 /* 'inpt' */ |
| 93 | #define kCMIOObjectPropertyScopeOutput 0x6f757470 /* 'outp' */ |
| 94 | #define kCMIOObjectPropertyScopeWildcard 0x2a2a2a2a /* '****' */ |
| 95 | #define kCMIOObjectPropertyElementMaster 0 |
| 96 | #define kCMIOObjectPropertyElementWildcard 0xFFFFFFFF |
| 97 | |
| 98 | /* CoreMediaIO Property Address */ |
| 99 | typedef struct CMIOObjectPropertyAddress { |
| 100 | UInt32 mSelector; |
| 101 | UInt32 mScope; |
| 102 | UInt32 mElement; |
| 103 | } CMIOObjectPropertyAddress; |
| 104 | |
| 105 | /* Property Selectors */ |
| 106 | #define kCMIOObjectPropertyClass 0x636c6173 /* 'clas' */ |
| 107 | #define kCMIOObjectPropertyOwner 0x73746476 /* 'stdv' */ |
| 108 | #define kCMIOObjectPropertyCreator 0x6f706c67 /* 'oplg' */ |
| 109 | #define kCMIOObjectPropertyName 0x6c6e616d /* 'lnam' */ |
| 110 | #define kCMIOObjectPropertyManufacturer 0x6c6d616b /* 'lmak' */ |
| 111 | #define kCMIOObjectPropertyModelUID 0x6d756964 /* 'muid' */ |
| 112 | |
| 113 | /* Device Properties */ |
| 114 | #define kCMIODevicePropertyDeviceUID 0x75696465 /* 'uide' */ |
| 115 | #define kCMIODevicePropertyModelUID 0x6d756964 /* 'muid' */ |
| 116 | #define kCMIODevicePropertyTransportType 0x7472616e /* 'tran' */ |
| 117 | #define kCMIODevicePropertyDeviceIsAlive 0x6c69766e /* 'livn' */ |
| 118 | #define kCMIODevicePropertyDeviceIsRunning 0x676f696e /* 'goin' */ |
| 119 | #define kCMIODevicePropertyStreams 0x73746d23 /* 'stm#' */ |
| 120 | #define kCMIODevicePropertyExcludeNonDALAccess 0x7864616c /* 'xdal' */ |
| 121 | |
| 122 | /* Stream Properties */ |
| 123 | #define kCMIOStreamPropertyDirection 0x73646972 /* 'sdir' */ |
| 124 | #define kCMIOStreamPropertyTerminalType 0x7465726d /* 'term' */ |
| 125 | #define kCMIOStreamPropertyStartingChannel 0x7363686e /* 'schn' */ |
| 126 | #define kCMIOStreamPropertyLatency 0x6c746e63 /* 'ltnc' */ |
| 127 | #define kCMIOStreamPropertyFormatDescription 0x70667420 /* 'pft ' */ |
| 128 | #define kCMIOStreamPropertyFormatDescriptions 0x70667473 /* 'pfts' */ |
| 129 | #define kCMIOStreamPropertyFrameRate 0x6e667274 /* 'nfrt' */ |
| 130 | #define kCMIOStreamPropertyFrameRates 0x6e667223 /* 'nfr#' */ |
| 131 | |
| 132 | /* AudioTimeStamp representation */ |
| 133 | typedef struct AudioTimeStamp { |
| 134 | double mSampleTime; |
| 135 | UInt64 mHostTime; |
| 136 | double mRateScalar; |
| 137 | UInt64 mWordClockTime; |
| 138 | UInt32 mSMPTETime[8]; |
| 139 | UInt32 mFlags; |
| 140 | UInt32 mReserved; |
| 141 | } AudioTimeStamp; |
| 142 | |
| 143 | /* CoreMedia Video Dimensions */ |
| 144 | typedef struct CMVideoDimensions { |
| 145 | int32_t width; |
| 146 | int32_t height; |
| 147 | } CMVideoDimensions; |
| 148 | |
| 149 | /* CMIOHardwarePlugIn Forward References */ |
| 150 | typedef struct CMIOHardwarePlugInInterface CMIOHardwarePlugInInterface; |
| 151 | typedef CMIOHardwarePlugInInterface **CMIOHardwarePlugInRef; |
| 152 | |
| 153 | struct CMIOHardwarePlugInInterface { |
| 154 | /* IUnknown */ |
| 155 | void* _reserved; |
| 156 | HRESULT (*QueryInterface)(void *thisPointer, CFUUIDBytes iid, LPVOID *ppv); |
| 157 | ULONG (*AddRef)(void *thisPointer); |
| 158 | ULONG (*Release)(void *thisPointer); |
| 159 | |
| 160 | /* CMIOHardwarePlugIn Interface */ |
| 161 | OSStatus (*Initialize)(CMIOHardwarePlugInRef self); |
| 162 | OSStatus (*InitializeWithObjectID)(CMIOHardwarePlugInRef self, CMIOObjectID objectID); |
| 163 | OSStatus (*Teardown)(CMIOHardwarePlugInRef self); |
| 164 | void (*ObjectShow)(CMIOHardwarePlugInRef self, CMIOObjectID objectID); |
| 165 | Boolean (*ObjectHasProperty)(CMIOHardwarePlugInRef self, CMIOObjectID objectID, const CMIOObjectPropertyAddress *address); |
| 166 | OSStatus (*ObjectIsPropertySettable)(CMIOHardwarePlugInRef self, CMIOObjectID objectID, const CMIOObjectPropertyAddress *address, Boolean *isSettable); |
| 167 | OSStatus (*ObjectGetPropertyDataSize)(CMIOHardwarePlugInRef self, CMIOObjectID objectID, const CMIOObjectPropertyAddress *address, UInt32 qualifierDataSize, const void *qualifierData, UInt32 *dataSize); |
| 168 | OSStatus (*ObjectGetPropertyData)(CMIOHardwarePlugInRef self, CMIOObjectID objectID, const CMIOObjectPropertyAddress *address, UInt32 qualifierDataSize, const void *qualifierData, UInt32 dataSize, UInt32 *dataUsed, void *data); |
| 169 | OSStatus (*ObjectSetPropertyData)(CMIOHardwarePlugInRef self, CMIOObjectID objectID, const CMIOObjectPropertyAddress *address, UInt32 qualifierDataSize, const void *qualifierData, UInt32 dataSize, const void *data); |
| 170 | OSStatus (*DeviceSuspend)(CMIOHardwarePlugInRef self, CMIODeviceID deviceID); |
| 171 | OSStatus (*DeviceResume)(CMIOHardwarePlugInRef self, CMIODeviceID deviceID); |
| 172 | OSStatus (*DeviceStartStream)(CMIOHardwarePlugInRef self, CMIODeviceID deviceID, CMIOStreamID streamID); |
| 173 | OSStatus (*DeviceStopStream)(CMIOHardwarePlugInRef self, CMIODeviceID deviceID, CMIOStreamID streamID); |
| 174 | OSStatus (*DeviceProcessAVCCommand)(CMIOHardwarePlugInRef self, CMIODeviceID deviceID, void *ioAVCCommand); |
| 175 | OSStatus (*DeviceProcessRS422Command)(CMIOHardwarePlugInRef self, CMIODeviceID deviceID, void *ioRS422Command); |
| 176 | }; |
| 177 | |
| 178 | /* CMIO Hardware Plugin Type UUID: 30010C1C-93BF-11D8-8B5B-000A95881667 */ |
| 179 | static const CFUUIDBytes kCMIOHardwarePlugInTypeUUID = { |
| 180 | 0x30, 0x01, 0x0c, 0x1c, 0x93, 0xbf, 0x11, 0xd8, |
| 181 | 0x8b, 0x5b, 0x00, 0x0a, 0x95, 0x88, 0x16, 0x67 |
| 182 | }; |
| 183 | |
| 184 | /* CMIO Hardware Plugin Interface UUID: 6D343053-93BF-11D8-8534-000A95881667 */ |
| 185 | static const CFUUIDBytes kCMIOHardwarePlugInInterfaceUUID = { |
| 186 | 0x6d, 0x34, 0x30, 0x53, 0x93, 0xbf, 0x11, 0xd8, |
| 187 | 0x85, 0x34, 0x00, 0x0a, 0x95, 0x88, 0x16, 0x67 |
| 188 | }; |
| 189 | |
| 190 | #endif /* AVX_OS_MACOS */ |
| 191 | |
| 192 | #endif /* AVX_COMPAT_CMIO_HARDWARE_PLUGIN_H */ |