Working on implementing the A2DP Sink profile on macOS based off of this proof of concept.
Problem is I cannot seem to get the service registered on the local SDP server. Specifically:
- (void)load
{
NSString *dictionaryPath = nil;
NSMutableDictionary *sdpEntries = nil;
dictionaryPath = [[NSBundle mainBundle] pathForResource:@"A2DP-SNK" ofType:@"plist"];
if(dictionaryPath)
{
sdpEntries = [NSMutableDictionary dictionaryWithContentsOfFile:dictionaryPath];
if(sdpEntries)
{
DLog(@"Loading A2DP Sink...");
[sdpEntries setObject:@"Audio Sink" forKey:@"0100 - ServiceName*"];
self.loadedServiceRecord = [IOBluetoothSDPServiceRecord publishedServiceRecordWithDictionary:sdpEntries];
DLog(@"serviceRecord attributes: %@", [self.loadedServiceRecord attributes]);
In the above, self.loadedServiceRecord is supposed to hold the plist of the registered service. It is always nil in practice, however. Other users have it working on prior macOS versions; I have no idea what changed in newer macOS versions.
Edit: Using a SDP record with UUID of 110A (for A2DP Source, which is obviously natively supported) instead of 110B (for A2DP Sink) allows the record to be published. Seems like macOS no longer allows the bluetooth controller to advertise itself as an A2DP sink or as non-supported profiles in general.