WebRTC iOS 最新修订本机应用音频问题
WebRTC iOS Native app audio problems with latest revisions
我正在尝试构建 iOS 本地 audio/video 聊天并卡在音频上。声音滞后,缺少某些部分并失真。我用 r9919 和由原始构建脚本构建的最新版本 (r10184) 进行了尝试。但是当我尝试使用从 PerchRTC 演示项目(https://github.com/perchco/perchrtc - fat lib 和 public headers)中获取的旧版本(r8444、r8926、r9132 和 r9137)时,一切似乎都正常(除了小回声).我应该执行哪些预操作以至少达到与(r8444、r8926、r9132 和 r9137)提供的相同的流媒体质量?
我也尝试过使用不同的音频编解码器和不同的媒体限制,但仍然没有成功。
我用这种方式创建音频连接
RTCMediaStream *localStream = [_pcFactory mediaStreamWithLabel:@"ARDAMS"];
RTCAudioTrack *localAudioTrack = [_pcFactory audioTrackWithID:@"ARDAMSa0"];
localAudioTrack.delegate = self;
[localStream addAudioTrack:localAudioTrack];
[self.peerConnection addStream:localStream];
[self.peerConnection createOfferWithDelegate:self constraints:_constraints];
使用此约束(尝试不同的组合)
mandatoryConstraints = @[
[[RTCPair alloc] initWithKey:@"OfferToReceiveAudio" value:@"true"]
];
optionalConstraints = @[
[[RTCPair alloc] initWithKey:@"internalSctpDataChannels" value:@"true"],
[[RTCPair alloc] initWithKey:@"DtlsSrtpKeyAgreement" value:@"true"]
];
我还尝试了 AVAudioSession 的不同操作,然后才获得 audioTrack,但没有成功:
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&categoryError];
[audioSession setMode:AVAudioSessionModeVoiceChat error:&modeError];
[audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:&overrideError];
[audioSession setActive:YES withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&activeError];
SDP 描述在滞后和不滞后构建中看起来相似(这是提供 - a=setup:actpass,答案有 a=setup:active):
sdp = "v=0
o=- 7772121714021031999 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE audio
a=msid-semantic: WMS ARDAMS
m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 102 0 8 106 105 13 127 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:XLpFvB+JEaSN7tww
a=ice-pwd:9hoMfb7AJ9jC6Weej7qqTWkT
a=fingerprint:sha-256 AE:73:33:DD:31:CA:84:5A:96:4D:68:27:A0:23:82:3C:08:3B:7F:7B:A2:FE:91:1D:A7:3A:1F:2A:58:4B:FF:A2
a=setup:actpass
a=mid:audio
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=sendrecv
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=fmtp:111 minptime=10; useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:102 ILBC/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:127 red/8000
a=rtpmap:126 telephone-event/8000
a=maxptime:60
a=ssrc:2797474154 cname:43zbAmj6VvYHT31F
a=ssrc:2797474154 msid:ARDAMS ARDAMSa0
a=ssrc:2797474154 mslabel:ARDAMS
a=ssrc:2797474154 label:ARDAMSa0
有什么建议吗?
Demo默认使用顶部扬声器。您需要使用如下代码设置为主扬声器:
AVAudioSessionPortOverride override = AVAudioSessionPortOverrideSpeaker;
[RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeAudioSession
block:^{
RTCAudioSession *session = [RTCAudioSession sharedInstance];
[session lockForConfiguration];
NSError *error = nil;
if ([session overrideOutputAudioPort:override error:&error]) {
_portOverride = override;
} else {
RTCLogError(@"Error overriding output port: %@",
error.localizedDescription);
}
[session unlockForConfiguration];
}];
我正在尝试构建 iOS 本地 audio/video 聊天并卡在音频上。声音滞后,缺少某些部分并失真。我用 r9919 和由原始构建脚本构建的最新版本 (r10184) 进行了尝试。但是当我尝试使用从 PerchRTC 演示项目(https://github.com/perchco/perchrtc - fat lib 和 public headers)中获取的旧版本(r8444、r8926、r9132 和 r9137)时,一切似乎都正常(除了小回声).我应该执行哪些预操作以至少达到与(r8444、r8926、r9132 和 r9137)提供的相同的流媒体质量? 我也尝试过使用不同的音频编解码器和不同的媒体限制,但仍然没有成功。 我用这种方式创建音频连接
RTCMediaStream *localStream = [_pcFactory mediaStreamWithLabel:@"ARDAMS"];
RTCAudioTrack *localAudioTrack = [_pcFactory audioTrackWithID:@"ARDAMSa0"];
localAudioTrack.delegate = self;
[localStream addAudioTrack:localAudioTrack];
[self.peerConnection addStream:localStream];
[self.peerConnection createOfferWithDelegate:self constraints:_constraints];
使用此约束(尝试不同的组合)
mandatoryConstraints = @[
[[RTCPair alloc] initWithKey:@"OfferToReceiveAudio" value:@"true"]
];
optionalConstraints = @[
[[RTCPair alloc] initWithKey:@"internalSctpDataChannels" value:@"true"],
[[RTCPair alloc] initWithKey:@"DtlsSrtpKeyAgreement" value:@"true"]
];
我还尝试了 AVAudioSession 的不同操作,然后才获得 audioTrack,但没有成功:
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&categoryError];
[audioSession setMode:AVAudioSessionModeVoiceChat error:&modeError];
[audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:&overrideError];
[audioSession setActive:YES withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&activeError];
SDP 描述在滞后和不滞后构建中看起来相似(这是提供 - a=setup:actpass,答案有 a=setup:active):
sdp = "v=0
o=- 7772121714021031999 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE audio
a=msid-semantic: WMS ARDAMS
m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 102 0 8 106 105 13 127 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:XLpFvB+JEaSN7tww
a=ice-pwd:9hoMfb7AJ9jC6Weej7qqTWkT
a=fingerprint:sha-256 AE:73:33:DD:31:CA:84:5A:96:4D:68:27:A0:23:82:3C:08:3B:7F:7B:A2:FE:91:1D:A7:3A:1F:2A:58:4B:FF:A2
a=setup:actpass
a=mid:audio
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=sendrecv
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=fmtp:111 minptime=10; useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:102 ILBC/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:127 red/8000
a=rtpmap:126 telephone-event/8000
a=maxptime:60
a=ssrc:2797474154 cname:43zbAmj6VvYHT31F
a=ssrc:2797474154 msid:ARDAMS ARDAMSa0
a=ssrc:2797474154 mslabel:ARDAMS
a=ssrc:2797474154 label:ARDAMSa0
有什么建议吗?
Demo默认使用顶部扬声器。您需要使用如下代码设置为主扬声器:
AVAudioSessionPortOverride override = AVAudioSessionPortOverrideSpeaker;
[RTCDispatcher dispatchAsyncOnType:RTCDispatcherTypeAudioSession
block:^{
RTCAudioSession *session = [RTCAudioSession sharedInstance];
[session lockForConfiguration];
NSError *error = nil;
if ([session overrideOutputAudioPort:override error:&error]) {
_portOverride = override;
} else {
RTCLogError(@"Error overriding output port: %@",
error.localizedDescription);
}
[session unlockForConfiguration];
}];