Skip to content

Commit

Permalink
More fixes for CMIO fake API.
Browse files Browse the repository at this point in the history
  • Loading branch information
hipersayanX committed Feb 9, 2025
1 parent 16cea69 commit 577534a
Show file tree
Hide file tree
Showing 33 changed files with 914 additions and 369 deletions.
32 changes: 31 additions & 1 deletion cmio/FakeAPI/CoreAudio/CoreAudioTypes.h
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
/* akvirtualcamera, virtual camera for Mac and Windows. * Copyright (C) 2024 Gonzalo Exequiel Pedone * * akvirtualcamera is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * akvirtualcamera is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>. * * Web-Site: http://webcamoid.github.io/ */#ifndef COREAUDIO_COREAUDIOTYPES_H#define COREAUDIO_COREAUDIOTYPES_H#endif // COREAUDIO_COREAUDIOTYPES_H
/* akvirtualcamera, virtual camera for Mac and Windows.
* Copyright (C) 2024 Gonzalo Exequiel Pedone
*
* akvirtualcamera is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* akvirtualcamera is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/

#ifndef COREAUDIO_COREAUDIOTYPES_H
#define COREAUDIO_COREAUDIOTYPES_H

#include "CoreFoundation/CFType.h"

struct AudioValueRange
{
Float64 mMaximum;
Float64 mMinimum;
};

#endif // COREAUDIO_COREAUDIOTYPES_H
28 changes: 27 additions & 1 deletion cmio/FakeAPI/CoreFoundation/Allocators.h
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
/* akvirtualcamera, virtual camera for Mac and Windows. * Copyright (C) 2024 Gonzalo Exequiel Pedone * * akvirtualcamera is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * akvirtualcamera is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>. * * Web-Site: http://webcamoid.github.io/ */#ifndef ALLOCATORS_H#define ALLOCATORS_Henum CFAllocatorRef{ kCFAllocatorDefault};#endif // ALLOCATORS_H
/* akvirtualcamera, virtual camera for Mac and Windows.
* Copyright (C) 2024 Gonzalo Exequiel Pedone
*
* akvirtualcamera is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* akvirtualcamera is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/

#ifndef ALLOCATORS_H
#define ALLOCATORS_H

using CFAllocatorRef = void *;

#define kCFAllocatorDefault nullptr

#endif // ALLOCATORS_H
2 changes: 1 addition & 1 deletion cmio/FakeAPI/CoreFoundation/CFArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ inline CFArrayRef CFArrayCreate(CFAllocatorRef allocator,
for (auto &item: self->items)
self->callBacks.release(kCFAllocatorDefault, item);

delete reinterpret_cast<_CFArrayDataRef>(data);
delete self;
};
arrayType->ref = 1;

Expand Down
1 change: 1 addition & 0 deletions cmio/FakeAPI/CoreFoundation/CFDictionary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* akvirtualcamera, virtual camera for Mac and Windows. * Copyright (C) 2024 Gonzalo Exequiel Pedone * * akvirtualcamera is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * akvirtualcamera is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>. * * Web-Site: http://webcamoid.github.io/ */#ifndef CFDICTIONARY_H#define CFDICTIONARY_H#include "Allocators.h"#include "CFType.h"using CFDictionary = CFType;using CFDictionaryRef = CFTypeRef;#endif // CFDICTIONARY_H
Expand Down
13 changes: 13 additions & 0 deletions cmio/FakeAPI/CoreFoundation/CFType.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,24 @@
#define COREFOUNDATION_CFTYPE_H

#include <cstdint>
#include <cstddef>
#include <cstring>
#include <functional>

using CFTypeID = unsigned long;
using CFTypeDeleter = void (*)(void *data);

using SInt32 = int32_t;
using UInt8 = uint8_t;
using UInt32 = uint32_t;
using UInt64 = uint64_t;
using Float32 = float;
using Float64 = double;
using Boolean = bool;
using OSStatus = int32_t;

#define CFTYPE_FOURCC(a, b, c, d) ((int32_t(a) << 24) | (int32_t(b) << 16) | (int32_t(c) << 8) | int32_t(d))

enum OSStatus_status
{
noErr = 0
Expand Down Expand Up @@ -79,4 +85,11 @@ inline CFTypeRef CFRetain(CFTypeRef cf)
return cf;
}

inline Boolean CFEqual(CFTypeRef cf1, CFTypeRef cf2)
{
return (cf1->type == cf2->type)
&& (cf1->size == cf2->size)
&& memcmp(cf1->data, cf2->data, cf1->size) == 0;
}

#endif // COREFOUNDATION_CFTYPE_H
66 changes: 63 additions & 3 deletions cmio/FakeAPI/CoreFoundation/CFUUID.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@

#include <cstdint>

#include "Allocators.h"
#include "CFType.h"

using CFUUID = CFType;
using CFUUIDRef = CFTypeRef;

typedef struct _GUID {
unsigned long Data1;
unsigned short Data2;
Expand Down Expand Up @@ -58,17 +64,71 @@ struct CFRuntimeBase {
uint32_t _rc;
};

struct CFUUID
struct _CFUUIDData
{
CFRuntimeBase base;
CFUUIDBytes bytes;
};

using CFUUIDRef = CFUUID *;
using _CFUUIDDataRef = _CFUUIDData *;

inline CFTypeID CFUUIDGetTypeID()
{
return 0x7;
}

inline CFUUIDRef CFUUIDGetConstantUUIDWithBytes(CFAllocatorRef alloc,
UInt8 byte0,
UInt8 byte1,
UInt8 byte2,
UInt8 byte3,
UInt8 byte4,
UInt8 byte5,
UInt8 byte6,
UInt8 byte7,
UInt8 byte8,
UInt8 byte9,
UInt8 byte10,
UInt8 byte11,
UInt8 byte12,
UInt8 byte13,
UInt8 byte14,
UInt8 byte15)
{
auto uuid = new CFUUID;
uuid->type = CFUUIDGetTypeID();
uuid->data = new _CFUUIDData;
memset(uuid->data, 0, sizeof(_CFUUIDData));
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte0 = byte0 ;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte1 = byte1 ;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte2 = byte2 ;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte3 = byte3 ;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte4 = byte4 ;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte5 = byte5 ;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte6 = byte6 ;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte7 = byte7 ;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte8 = byte8 ;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte9 = byte9 ;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte10 = byte10;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte11 = byte11;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte12 = byte12;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte13 = byte13;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte14 = byte14;
reinterpret_cast<_CFUUIDDataRef>(uuid->data)->bytes.byte15 = byte15;
uuid->size = sizeof(_CFUUIDData);
uuid->deleter = [] (void *data) {
delete reinterpret_cast<CFUUIDRef>(data);
};
uuid->ref = 1;

return uuid;

return uuid;
}

inline CFUUIDBytes CFUUIDGetUUIDBytes(CFUUIDRef uuid)
{
return uuid->bytes;
return reinterpret_cast<_CFUUIDDataRef>(uuid)->bytes;
}

#endif // COREFOUNDATION_CFUUID_H
26 changes: 25 additions & 1 deletion cmio/FakeAPI/CoreGraphics/CGImage.h
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
/* akvirtualcamera, virtual camera for Mac and Windows. * Copyright (C) 2024 Gonzalo Exequiel Pedone * * akvirtualcamera is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * akvirtualcamera is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>. * * Web-Site: http://webcamoid.github.io/ */#ifndef COREGRAPHICS_CGIMAGE_H#define COREGRAPHICS_CGIMAGE_H#include "../CoreMedia/CMFormatDescription.h"#endif // COREGRAPHICS_CGIMAGE_H
/* akvirtualcamera, virtual camera for Mac and Windows.
* Copyright (C) 2024 Gonzalo Exequiel Pedone
*
* akvirtualcamera is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* akvirtualcamera is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/

#ifndef COREGRAPHICS_CGIMAGE_H
#define COREGRAPHICS_CGIMAGE_H

#include "../CoreMedia/CMVideoFormatDescription.h"

#endif // COREGRAPHICS_CGIMAGE_H
15 changes: 6 additions & 9 deletions cmio/FakeAPI/CoreMedia/CMFormatDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
#ifndef COREMEDIA_CMFORMATDESCRIPTION_H
#define COREMEDIA_CMFORMATDESCRIPTION_H

enum FourCharCode
{
kCMPixelFormat_32ARGB,
kCMPixelFormat_24RGB,
kCMPixelFormat_16LE565,
kCMPixelFormat_16LE555,
kCMPixelFormat_422YpCbCr8,
kCMPixelFormat_422YpCbCr8_yuvs
};
#include "CoreFoundation/CFDictionary.h"

using CMFormatDescription = CFType;
using CMFormatDescriptionRef = CFTypeRef;

using FourCharCode = UInt32;

#endif // COREMEDIA_CMFORMATDESCRIPTION_H
1 change: 1 addition & 0 deletions cmio/FakeAPI/CoreMedia/CMSampleBuffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* akvirtualcamera, virtual camera for Mac and Windows. * Copyright (C) 2024 Gonzalo Exequiel Pedone * * akvirtualcamera is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * akvirtualcamera is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>. * * Web-Site: http://webcamoid.github.io/ */#ifndef COREMEDIA_CMSAMPLEBUFFER_H#define COREMEDIA_CMSAMPLEBUFFER_H#include <queue>#include "CoreFoundation/Allocators.h"#include "CoreFoundation/CFType.h"using CMSampleBuffer = CFType;using CMSampleBufferRef = CFTypeRef;#endif // COREMEDIA_CMSAMPLEBUFFER_H
Expand Down
120 changes: 119 additions & 1 deletion cmio/FakeAPI/CoreMedia/CMSimpleQueue.h
Original file line number Diff line number Diff line change
@@ -1 +1,119 @@
/* akvirtualcamera, virtual camera for Mac and Windows. * Copyright (C) 2024 Gonzalo Exequiel Pedone * * akvirtualcamera is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * akvirtualcamera is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>. * * Web-Site: http://webcamoid.github.io/ */#ifndef COREMEDIA_CMSIMPLEQUEUE_H#define COREMEDIA_CMSIMPLEQUEUE_H#endif // COREMEDIA_CMSIMPLEQUEUE_H
/* akvirtualcamera, virtual camera for Mac and Windows.
* Copyright (C) 2024 Gonzalo Exequiel Pedone
*
* akvirtualcamera is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* akvirtualcamera is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/

#ifndef COREMEDIA_CMSIMPLEQUEUE_H
#define COREMEDIA_CMSIMPLEQUEUE_H

#include <queue>

#include "CoreFoundation/Allocators.h"
#include "CoreFoundation/CFType.h"

using CMSimpleQueue = CFType;
using CMSimpleQueueRef = CFTypeRef;

struct _CMSimpleQueueData
{
std::queue<const void *> items;
int32_t capacity;

_CMSimpleQueueData(int32_t capacity):
capacity(capacity)
{
}
};

using _CMSimpleQueueDataRef = _CMSimpleQueueData *;

inline CFTypeID CMSimpleQueueGetTypeID()
{
return 0x5;
}

inline OSStatus CMSimpleQueueCreate(CFAllocatorRef allocator,
int32_t capacity,
CMSimpleQueueRef *queueOut)
{
auto self = new CMSimpleQueue;
self->type = CMSimpleQueueGetTypeID();
self->data = new _CMSimpleQueueData(capacity);
self->size = sizeof(_CMSimpleQueueData);
self->deleter = [] (void *data) {
delete reinterpret_cast<_CMSimpleQueueDataRef>(data);
};
self->ref = 1;
*queueOut = self;

return noErr;
}

inline OSStatus CMSimpleQueueEnqueue(CMSimpleQueueRef queue,
const void *element)
{
auto self = reinterpret_cast<_CMSimpleQueueDataRef>(queue->data);

if (self->items.size() == self->capacity)
return -1;

self->items.push(element);

return noErr;
}

inline const void *CMSimpleQueueDequeue(CMSimpleQueueRef queue)
{
auto self = reinterpret_cast<_CMSimpleQueueDataRef>(queue->data);

if (self->items.empty())
return nullptr;

auto element = self->items.front();
self->items.pop();

return element;
}

inline OSStatus CMSimpleQueueReset(CMSimpleQueueRef queue)
{
auto self = reinterpret_cast<_CMSimpleQueueDataRef>(queue->data);

while (!self->items.empty())
self->items.pop();

return noErr;
}

inline int32_t CMSimpleQueueGetCapacity(CMSimpleQueueRef queue)
{
return reinterpret_cast<_CMSimpleQueueDataRef>(queue->data)->capacity;
}

inline int32_t CMSimpleQueueGetCount(CMSimpleQueueRef queue)
{
return int32_t(reinterpret_cast<_CMSimpleQueueDataRef>(queue->data)->items.size());
}

inline Float32 CMSimpleQueueGetFullness(CMSimpleQueueRef queue)
{
auto self = reinterpret_cast<_CMSimpleQueueDataRef>(queue->data);

return Float32(self->items.size()) / self->capacity;
}

#endif // COREMEDIA_CMSIMPLEQUEUE_H
1 change: 1 addition & 0 deletions cmio/FakeAPI/CoreMedia/CMVideoDimensions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* akvirtualcamera, virtual camera for Mac and Windows. * Copyright (C) 2024 Gonzalo Exequiel Pedone * * akvirtualcamera is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * akvirtualcamera is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with akvirtualcamera. If not, see <http://www.gnu.org/licenses/>. * * Web-Site: http://webcamoid.github.io/ */#ifndef COREMEDIA_CMVIDEODIMENSIONS_H#define COREMEDIA_CMVIDEODIMENSIONS_Hstruct CMVideoDimensions{ int32_t width; int32_t height;};#endif // COREMEDIA_CMVIDEODIMENSIONS_H
Expand Down
Loading

0 comments on commit 577534a

Please sign in to comment.