gpt4 book ai didi

ios - 在 webRTC iOS 中设置视频大小

转载 作者:行者123 更新时间:2023-11-28 17:52:32 27 4
gpt4 key购买 nike

我正在使用 RTCMediaConstraints 来创建 RTCPeerConnection 和发送 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]];
}

当我为 RTCVideoSource 添加约束时,我只看到没有视频的黑屏。

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的RTCMediaConstraints.h文件,没有kKeyOfferToReceiveAudio和kKeyOfferToReceiveVideo的 key 。 RTCMediaConstraints 不支持这些语句,这可能是一个问题。

关于ios - 在 webRTC iOS 中设置视频大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28233370/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com