In trying to establish and WebRTC data channel using the Objective C API, I can't get any of the RTCDataChannelDelegate callbacks to actually catch. Everything appears to go fine regarding the peer connection, but I only get to a point where the peer connection stream has been added successfully.
My steps are roughly:
Create offer:
_channel = [_connection createDataChannelWithLabel: @"offer-1"
config: [[RTCDataChannelInit alloc] init]];
_channel.delegate = _stateMachine;
[_connection createOfferWithDelegate: _stateMachine constraints: [[RTCMediaConstraints alloc] init]];
The SDP of client 1 is sent to client 2 where an answer is created:
[_connection setRemoteDescriptionWithDelegate: _stateMachine sessionDescription: [[RTCSessionDescription alloc] initWithType: @"offer" sdp: sdp]];
[_connection createAnswerWithDelegate: _stateMachine constraints: [[RTCMediaConstraints alloc] init]];
The SDP of client 2 is sent back to client 1:
[_connection setRemoteDescriptionWithDelegate: _stateMachine sessionDescription: [[RTCSessionDescription alloc] initWithType: @"answer" sdp: sdp]];
After that I get the media stream being added with signaling stable. Previously, during my POC, I was able to get the data channel callbacks but I'm not quite sure what I'm missing here.
Here is the peer connection setup:
RTCPeerConnectionFactory* _cfactory = [[RTCPeerConnectionFactory alloc] init];
NSArray* mandatory = @[
[[RTCPair alloc] initWithKey:@"DtlsSrtpKeyAgreement" value:@"true"],
[[RTCPair alloc] initWithKey:@"internalSctpDataChannels" value:@"true"],
];
RTCMediaConstraints* pcConstraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints: mandatory
optionalConstraints: nil];
RTCICEServer* server = [[RTCICEServer alloc] initWithURI:[NSURL URLWithString:@"stun:stun.l.google.com:19302"]
username: @""
password: @""];
NSArray* servers = @[server];
_connection = [_cfactory peerConnectionWithICEServers: servers
constraints: pcConstraints
delegate: _stateMachine];
My state machine implements the following with all methods present:
@protocol DelegateAggregator
<RTCPeerConnectionDelegate, RTCSessionDescriptionDelegate, RTCDataChannelDelegate, RTCStatsDelegate>
@end
Is there something I'm missing here? It seems the channel is being established and a media stream is added (I only want data), but without any of the callbacks. Can I enable more logging? Any help would be much appreciated!