Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Commit

Permalink
Make class names more unique to prevent namespace collisions (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnboiles authored Nov 27, 2020
1 parent d8aee76 commit d6b5db2
Show file tree
Hide file tree
Showing 21 changed files with 602 additions and 178 deletions.
14 changes: 0 additions & 14 deletions src/dal-plugin/CMSampleBufferUtils.h

This file was deleted.

34 changes: 17 additions & 17 deletions src/dal-plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ include_directories(${AVFOUNDATION}
set(dal-plugin_SOURCES
Defines.generated.h
Logging.h
PlugInMain.mm
PlugInInterface.h
PlugInInterface.mm
ObjectStore.h
ObjectStore.mm
PlugIn.h
PlugIn.mm
Device.h
Device.mm
Stream.h
Stream.mm
CMSampleBufferUtils.h
CMSampleBufferUtils.mm
MachClient.h
MachClient.mm
TestCard.h
TestCard.mm
OBSDALPlugInMain.mm
OBSDALPlugInInterface.h
OBSDALPlugInInterface.mm
OBSDALObjectStore.h
OBSDALObjectStore.mm
OBSDALPlugIn.h
OBSDALPlugIn.mm
OBSDALDevice.h
OBSDALDevice.mm
OBSDALStream.h
OBSDALStream.mm
OBSDALCMSampleBufferUtils.h
OBSDALCMSampleBufferUtils.mm
OBSDALMachClient.h
OBSDALMachClient.mm
OBSDALTestCard.h
OBSDALTestCard.mm
../common/MachProtocol.h)

add_library(dal-plugin MODULE
Expand Down
2 changes: 1 addition & 1 deletion src/dal-plugin/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<key>CFPlugInFactories</key>
<dict>
<key>35FDFF29-BFCF-4644-AB77-B759DE932ABE</key>
<string>PlugInMain</string>
<string>OBSDALPlugInMain</string>
</dict>
<key>CFPlugInTypes</key>
<dict>
Expand Down
14 changes: 14 additions & 0 deletions src/dal-plugin/OBSDALCMSampleBufferUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// OBSDALCMSampleBufferUtils.h
// dal-plugin
//
// Created by John Boiles on 5/8/20.
//

#include <CoreMediaIO/CMIOSampleBuffer.h>

OSStatus OBSDALCMSampleBufferCreateFromData(NSSize size, CMSampleTimingInfo timingInfo, UInt64 sequenceNumber, NSData *data, CMSampleBufferRef *sampleBuffer);

OSStatus OBSDALCMSampleBufferCreateFromDataNoCopy(NSSize size, CMSampleTimingInfo timingInfo, UInt64 sequenceNumber, NSData *data, CMSampleBufferRef *sampleBuffer);

CMSampleTimingInfo OBSDALCMSampleTimingInfoForTimestamp(uint64_t timestampNanos, uint32_t fpsNumerator, uint32_t fpsDenominator);
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
// Created by John Boiles on 5/8/20.
//

#import "CMSampleBufferUtils.h"
#import "OBSDALCMSampleBufferUtils.h"

#include "Logging.h"

/*!
CMSampleBufferCreateFromData
OBSDALCMSampleBufferCreateFromData
Creates a CMSampleBuffer by copying bytes from NSData into a CVPixelBuffer.
*/
OSStatus CMSampleBufferCreateFromData(NSSize size, CMSampleTimingInfo timingInfo, UInt64 sequenceNumber, NSData *data, CMSampleBufferRef *sampleBuffer) {
OSStatus OBSDALCMSampleBufferCreateFromData(NSSize size, CMSampleTimingInfo timingInfo, UInt64 sequenceNumber, NSData *data, CMSampleBufferRef *sampleBuffer) {
OSStatus err = noErr;

// Create an empty pixel buffer
Expand Down Expand Up @@ -94,12 +94,12 @@ OSStatus createReadonlyBlockBuffer(CMBlockBufferRef *result, NSData *data) {
}

/*!
CMSampleBufferCreateFromDataNoCopy
OBSDALCMSampleBufferCreateFromDataNoCopy
Creates a CMSampleBuffer by using the bytes directly from NSData (without copying them).
Seems to mostly work but does not work at full resolution in OBS for some reason (which prevents loopback testing).
*/
OSStatus CMSampleBufferCreateFromDataNoCopy(NSSize size, CMSampleTimingInfo timingInfo, UInt64 sequenceNumber, NSData *data, CMSampleBufferRef *sampleBuffer) {
OSStatus OBSDALCMSampleBufferCreateFromDataNoCopy(NSSize size, CMSampleTimingInfo timingInfo, UInt64 sequenceNumber, NSData *data, CMSampleBufferRef *sampleBuffer) {
OSStatus err = noErr;

CMBlockBufferRef dataBuffer;
Expand Down Expand Up @@ -137,7 +137,7 @@ OSStatus CMSampleBufferCreateFromDataNoCopy(NSSize size, CMSampleTimingInfo timi
return noErr;
}

CMSampleTimingInfo CMSampleTimingInfoForTimestamp(uint64_t timestampNanos, uint32_t fpsNumerator, uint32_t fpsDenominator) {
CMSampleTimingInfo OBSDALCMSampleTimingInfoForTimestamp(uint64_t timestampNanos, uint32_t fpsNumerator, uint32_t fpsDenominator) {
// The timing here is quite important. For frames to be delivered correctly and successfully be recorded by apps
// like QuickTime Player, we need to be accurate in both our timestamps _and_ have a sensible scale. Using large
// timestamps and scales like mach_absolute_time() and NSEC_PER_SEC will work for display, but will error out
Expand Down
6 changes: 3 additions & 3 deletions src/dal-plugin/Device.h → src/dal-plugin/OBSDALDevice.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Device.h
// OBSDALDevice.h
// obs-mac-virtualcam
//
// Created by John Boiles on 4/10/20.
Expand All @@ -19,11 +19,11 @@

#import <Foundation/Foundation.h>

#import "ObjectStore.h"
#import "OBSDALObjectStore.h"

NS_ASSUME_NONNULL_BEGIN

@interface Device : NSObject <CMIOObject>
@interface OBSDALDevice : NSObject <CMIOObject>

@property CMIOObjectID objectId;
@property CMIOObjectID pluginId;
Expand Down
20 changes: 10 additions & 10 deletions src/dal-plugin/Device.mm → src/dal-plugin/OBSDALDevice.mm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Device.mm
// OBSDALDevice.mm
// obs-mac-virtualcam
//
// Created by John Boiles on 4/10/20.
Expand All @@ -17,21 +17,21 @@
// You should have received a copy of the GNU General Public License
// along with obs-mac-virtualcam. If not, see <http://www.gnu.org/licenses/>.

#import "Device.h"
#import "OBSDALDevice.h"

#import <CoreFoundation/CoreFoundation.h>
#include <IOKit/audio/IOAudioTypes.h>

#import "PlugIn.h"
#import "OBSDALPlugIn.h"
#import "Logging.h"

@interface Device ()
@interface OBSDALDevice ()
@property BOOL excludeNonDALAccess;
@property pid_t masterPid;
@end


@implementation Device
@implementation OBSDALDevice

// Note that the DAL's API calls HasProperty before calling GetPropertyDataSize. This means that it can be assumed that address is valid for the property involved.
- (UInt32)getPropertyDataSizeWithAddress:(CMIOObjectPropertyAddress)address qualifierDataSize:(UInt32)qualifierDataSize qualifierData:(nonnull const void *)qualifierData {
Expand Down Expand Up @@ -84,7 +84,7 @@ - (UInt32)getPropertyDataSizeWithAddress:(CMIOObjectPropertyAddress)address qual
case kCMIODevicePropertyDeviceMaster:
return sizeof(pid_t);
default:
DLog(@"Device unhandled getPropertyDataSizeWithAddress for %@", [ObjectStore StringFromPropertySelector:address.mSelector]);
DLog(@"OBSDALDevice unhandled getPropertyDataSizeWithAddress for %@", [OBSDALObjectStore StringFromPropertySelector:address.mSelector]);
};

return 0;
Expand Down Expand Up @@ -178,7 +178,7 @@ - (void)getPropertyDataWithAddress:(CMIOObjectPropertyAddress)address qualifierD
*dataUsed = sizeof(pid_t);
break;
default:
DLog(@"Device unhandled getPropertyDataWithAddress for %@", [ObjectStore StringFromPropertySelector:address.mSelector]);
DLog(@"OBSDALDevice unhandled getPropertyDataWithAddress for %@", [OBSDALObjectStore StringFromPropertySelector:address.mSelector]);
*dataUsed = 0;
break;
};
Expand Down Expand Up @@ -211,7 +211,7 @@ - (BOOL)hasPropertyWithAddress:(CMIOObjectPropertyAddress)address {
case kCMIODevicePropertyLinkedCoreAudioDeviceUID:
return false;
default:
DLog(@"Device unhandled hasPropertyWithAddress for %@", [ObjectStore StringFromPropertySelector:address.mSelector]);
DLog(@"OBSDALDevice unhandled hasPropertyWithAddress for %@", [OBSDALObjectStore StringFromPropertySelector:address.mSelector]);
return false;
};
}
Expand Down Expand Up @@ -243,7 +243,7 @@ - (BOOL)isPropertySettableWithAddress:(CMIOObjectPropertyAddress)address {
case kCMIODevicePropertyDeviceMaster:
return true;
default:
DLog(@"Device unhandled isPropertySettableWithAddress for %@", [ObjectStore StringFromPropertySelector:address.mSelector]);
DLog(@"OBSDALDevice unhandled isPropertySettableWithAddress for %@", [OBSDALObjectStore StringFromPropertySelector:address.mSelector]);
return false;
};
}
Expand All @@ -258,7 +258,7 @@ - (void)setPropertyDataWithAddress:(CMIOObjectPropertyAddress)address qualifierD
self.masterPid = *static_cast<const pid_t*>(data);
break;
default:
DLog(@"Device unhandled setPropertyDataWithAddress for %@", [ObjectStore StringFromPropertySelector:address.mSelector]);
DLog(@"OBSDALDevice unhandled setPropertyDataWithAddress for %@", [OBSDALObjectStore StringFromPropertySelector:address.mSelector]);
break;
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// MachClient.h
// OBSDALMachClient.h
// dal-plugin
//
// Created by John Boiles on 5/5/20.
Expand All @@ -9,17 +9,17 @@

NS_ASSUME_NONNULL_BEGIN

@protocol MachClientDelegate
@protocol OBSDALMachClientDelegate

- (void)receivedFrameWithSize:(NSSize)size timestamp:(uint64_t)timestamp fpsNumerator:(uint32_t)fpsNumerator fpsDenominator:(uint32_t)fpsDenominator frameData:(NSData *)frameData;
- (void)receivedStop;

@end


@interface MachClient : NSObject
@interface OBSDALMachClient : NSObject

@property (nullable, weak) id<MachClientDelegate> delegate;
@property (nullable, weak) id<OBSDALMachClientDelegate> delegate;

- (BOOL)isServerAvailable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
//
// MachClient.m
// OBSDALMachClient.m
// dal-plugin
//
// Created by John Boiles on 5/5/20.
//

#import "MachClient.h"
#import "OBSDALMachClient.h"
#import "MachProtocol.h"
#import "Logging.h"

@interface MachClient () <NSPortDelegate> {
@interface OBSDALMachClient () <NSPortDelegate> {
NSPort *_receivePort;
}
@end


@implementation MachClient
@implementation OBSDALMachClient

- (void)dealloc {
DLogFunc(@"");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ObjectStore.h
// OBSDALObjectStore.h
// obs-mac-virtualcam
//
// Created by John Boiles on 4/10/20.
Expand Down Expand Up @@ -32,9 +32,9 @@ NS_ASSUME_NONNULL_BEGIN

@end

@interface ObjectStore : NSObject
@interface OBSDALObjectStore : NSObject

+ (ObjectStore *)SharedObjectStore;
+ (OBSDALObjectStore *)SharedOBSDALObjectStore;

+ (NSObject<CMIOObject> *)GetObjectWithId:(CMIOObjectID)objectId;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ObjectStore.mm
// OBSDALObjectStore.mm
// obs-mac-virtualcam
//
// Created by John Boiles on 4/10/20.
Expand All @@ -17,13 +17,13 @@
// You should have received a copy of the GNU General Public License
// along with obs-mac-virtualcam. If not, see <http://www.gnu.org/licenses/>.

#import "ObjectStore.h"
#import "OBSDALObjectStore.h"

@interface ObjectStore ()
@interface OBSDALObjectStore ()
@property NSMutableDictionary *objectMap;
@end

@implementation ObjectStore
@implementation OBSDALObjectStore

// 4-byte selectors to string for easy debugging
+ (NSString *)StringFromPropertySelector:(CMIOObjectPropertySelector)selector {
Expand Down Expand Up @@ -241,17 +241,17 @@ + (BOOL)IsBridgedTypeForSelector:(CMIOObjectPropertySelector)selector {
}
}

+ (ObjectStore *)SharedObjectStore {
static ObjectStore *sObjectStore = nil;
+ (OBSDALObjectStore *)SharedOBSDALObjectStore {
static OBSDALObjectStore *sOBSDALObjectStore = nil;
static dispatch_once_t sOnceToken;
dispatch_once(&sOnceToken, ^{
sObjectStore = [[self alloc] init];
sOBSDALObjectStore = [[self alloc] init];
});
return sObjectStore;
return sOBSDALObjectStore;
}

+ (NSObject<CMIOObject> *)GetObjectWithId:(CMIOObjectID)objectId {
return [[ObjectStore SharedObjectStore] getObject:objectId];
return [[OBSDALObjectStore SharedOBSDALObjectStore] getObject:objectId];
}

- (id)init {
Expand Down
16 changes: 8 additions & 8 deletions src/dal-plugin/PlugIn.h → src/dal-plugin/OBSDALPlugIn.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// PlugIn.h
// OBSDALPlugIn.h
// obs-mac-virtualcam
//
// Created by John Boiles on 4/9/20.
Expand All @@ -20,23 +20,23 @@
#import <Foundation/Foundation.h>
#import <CoreMediaIO/CMIOHardwarePlugIn.h>

#import "ObjectStore.h"
#import "MachClient.h"
#import "Stream.h"
#import "OBSDALObjectStore.h"
#import "OBSDALMachClient.h"
#import "OBSDALStream.h"

#define kTestCardWidthKey @"obs-mac-virtualcam-test-card-width"
#define kTestCardHeightKey @"obs-mac-virtualcam-test-card-height"
#define kTestCardFPSKey @"obs-mac-virtualcam-test-card-fps"

NS_ASSUME_NONNULL_BEGIN

@interface PlugIn : NSObject <CMIOObject>
@interface OBSDALPlugIn : NSObject <CMIOObject>

@property CMIOObjectID objectId;
@property (readonly) MachClient *machClient;
@property Stream *stream;
@property (readonly) OBSDALMachClient *machClient;
@property OBSDALStream *stream;

+ (PlugIn *)SharedPlugIn;
+ (OBSDALPlugIn *)SharedOBSDALPlugIn;

- (void)initialize;

Expand Down
Loading

0 comments on commit d6b5db2

Please sign in to comment.