在webRTC iOS中设置视频大小
我正在使用在webRTC iOS中设置视频大小,ios,webrtc,Ios,Webrtc,我正在使用RTCMediaConstraints创建RTPeerConnection并发送SDP,但我觉得我的与视频最大宽度/高度相关的可选约束没有得到遵守 - (RTCMediaConstraints *)mediaConstraints { RTCPair *audioConstraint = [[RTCPair alloc] initWithKey:kKeyOfferToReceiveAudio value:kKeyTrue]; RTCPair *videoConstra
RTCMediaConstraints
创建RTPeerConnection并发送SDP,但我觉得我的与视频最大宽度/高度相关的可选约束没有得到遵守
- (RTCMediaConstraints *)mediaConstraints {
RTCPair *audioConstraint = [[RTCPair alloc] initWithKey:kKeyOfferToReceiveAudio value:kKeyTrue];
RTCPair *videoConstraint = [[RTCPair alloc] initWithKey:kKeyOfferToReceiveVideo value:kKeyTrue];
RTCPair *sctpConstraint = [[RTCPair alloc] initWithKey:kKeyInternalSctpDataChannels value:kKeyTrue];
RTCPair *dtlsConstraint = [[RTCPair alloc] initWithKey:kKeyDtlsSrtpKeyAgreement value:kKeyTrue];
RTCPair *maxWidth = [[RTCPair alloc] initWithKey:kKeyMaxWidth value:@"640"];
RTCPair *minWidth = [[RTCPair alloc] initWithKey:kKeyMinWidth value:@"320"];
RTCPair *maxHeight = [[RTCPair alloc] initWithKey:kKeyMaxHeight value:@"480"];
RTCPair *minHeight = [[RTCPair alloc] initWithKey:kKeyMinHeight value:@"240"];
RTCPair *maxFrameRate = [[RTCPair alloc] initWithKey:kKeyMaxFrameRate value:@"30"];
RTCPair *minFrameRate = [[RTCPair alloc] initWithKey:kKeyMinFrameRate value:@"24"];
RTCPair *minAspectRatio = [[RTCPair alloc] initWithKey:@"minAspectRatio" value:@"4:3"];
RTCPair *maxAspectRatio = [[RTCPair alloc] initWithKey:kKeyMaxAspectRatio value:@"4:3"];
return [[RTCMediaConstraints alloc] initWithMandatoryConstraints:@[audioConstraint, videoConstraint]
optionalConstraints:@[sctpConstraint, dtlsConstraint, maxAspectRatio, minAspectRatio, minFrameRate, maxFrameRate, maxWidth, minWidth, maxHeight, minHeight]];
}
当我包含RTCDeosource的约束时,我只看到没有视频的黑屏
RTCVideoCapturer *capturer = [RTCVideoCapturer capturerWithDeviceName:[device localizedName]];
RTCVideoSource *videoSource = [_peerFactory videoSourceWithCapturer:capturer constraints:[self mediaConstraints]];
RTCVideoTrack *videoTrack = [_peerFactory videoTrackWithID:[[NSUUID UUID] UUIDString] source:videoSource];
[_localMediaStream addVideoTrack:videoTrack];
有人对此有什么建议吗?根据我对WebRTC约束的经验,黑屏表示约束有缺陷 此外,我认为您不应该对视频源施加要约和DTLS约束,如果您正在这样做的话
这就是我所能告诉你的。根据我对WebRTC约束的经验,黑屏意味着约束有缺陷 此外,我认为您不应该对视频源施加要约和DTLS约束,如果您正在这样做的话
这几乎是我能告诉你的全部。看看WebRTC的RTCMediaConstraints.h文件,KKEYOFFERTOCeiveAudio和KKEYOFFERTOCeiveVideo没有键。RTCMediaConstraints不支持这些语句,这可能是一个问题 查看WebRTC的RTCMediaConstraints.h文件,KKEYOFFERTORRECEIVEAUDIO和KKEYOFFERTORRECEIVEVIDEO没有键。RTCMediaConstraints不支持这些语句,这可能是一个问题 我看到Google示例代码对视频使用DTLS约束。这让我觉得没问题。谢谢你的回答。我看到Google示例代码在视频中使用DTLS约束。这让我觉得没问题。谢谢你的回答。