0
我設法在A和B之間共享視頻和音頻,並且我發現RTCDataChannelState已更改爲kRTCDataChannelStateOpen。在iOS上使用RTCDataChannel發送消息失敗
- (void)channelDidChangeState:(RTCDataChannel*)channel
sendData
也可以返回YES,但我不能接受
- (void)peerConnection:(RTCPeerConnection*)peerConnection
didOpenDataChannel:(RTCDataChannel*)dataChannel
從未called.I想以後冰狀態轉變爲RTCICEConnectionConnected
它應該被稱爲然而,它沒有消息和
創建datachannel:
RTCDataChannelInit *DataChannelInit = [[RTCDataChannelInit alloc] init];
DataChannelInit.maxRetransmits = 0;
DataChannelInit.isOrdered=false;
DataChannelInit.maxRetransmitTimeMs = -1;
DataChannelInit.isNegotiated = false;
DataChannelInit.streamId = 25;
RTCDataChannel *dataChannel =[_peerConnection createDataChannelWithLabel:@"commands" config:DataChannelInit];
dataChannel.delegate=self;
self.datachannel = dataChannel;
我的報價和anwser:
- (RTCMediaConstraints *)defaultOfferConstraints {
NSArray *mandatoryConstraints = @[
[[RTCPair alloc] initWithKey:@"OfferToReceiveAudio" value:@"true"],
[[RTCPair alloc] initWithKey:@"OfferToReceiveVideo" value:@"true"]
];
NSArray *optionalConstraints = @[
[[RTCPair alloc] initWithKey:@"internalSctpDataChannels" value:@"true"],
[[RTCPair alloc] initWithKey:@"DtlsSrtpKeyAgreement" value:@"true"]
];
RTCMediaConstraints *constraints =
[[RTCMediaConstraints alloc]
initWithMandatoryConstraints:mandatoryConstraints
optionalConstraints:optionalConstraints];
return constraints;
}
我在創建數據通道後創建要約,但在設置RemoteDescription後沒有調用'didOpenDataChannel'。 – potato
你可以提供帶有pastebin的報價嗎? – Ajay
感謝您的幫助,這裏是我的[offer sdp](https://pastebin.com/embed_js/iY9h0SVS) – potato