Android 原生 webrtc 应用流质量
Android native webrtc app stream quality
我对使用 WebRTC 的 android 应用程序有疑问。一般来说,一切正常,但在某些设备上,流的质量很糟糕。我正在使用 io.pristine:libjingle:9127@aar lib 建立 webrtc 连接——它是官方 webrtc android lib 的编译版本。
例如,在 Nexus 5 上,视频质量非常好,CPU 的使用率为 20-25%。
在 SE SP 质量很糟糕,CPU 大约 50%(所以仍然有一些可用的功率)。
两个设备都在同一个 WiFi 网络上工作。
据我所知,WebRTC 应该自己选择视频质量,但是有什么办法可以手动选择吗?
我在 IOS 上使用以下内容来限制帧速率和分辨率,从而为库提供更多空间来缩放比特率。
// initialize video constraints
NSMutableArray *m = [[NSMutableArray alloc] init];
NSMutableArray *o = [[NSMutableArray alloc] init];
[m addObject:[[RTCPair alloc] initWithKey:@"minWidth" value:@"640"]];
[m addObject:[[RTCPair alloc] initWithKey:@"minHeight" value:@"480"]];
[m addObject:[[RTCPair alloc] initWithKey:@"maxFrameRate" value:@"20"]];
// init the constraints object
APP.videoConstraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:m optionalConstraints:o];
现在似乎不赞成通过约束来控制带宽。
因此,至少在版本 GoogleWebRTC (1.1.31999) 中 iOS 和 org.webrtc:google -webrtc:1.0.22672 for android PeerConnection 实例中有方法。
对于iOS:
let updateBitrateSuccessful = pc.setBweMinBitrateBps(300000, currentBitrateBps: 1000000, maxBitrateBps: 3000000)
print("Update rtc connection bitrate " + (updateBitrateSuccessful ? "successful" : "failed"))
分别为Android:
boolean updateBitrateSuccessful = pc.setBitrate(300000, 1000000, 3000000);
Log.d("AppLog", "Update rtc connection bitrate " + (updateBitrateSuccessful ? "successful" : "failed"));
我对使用 WebRTC 的 android 应用程序有疑问。一般来说,一切正常,但在某些设备上,流的质量很糟糕。我正在使用 io.pristine:libjingle:9127@aar lib 建立 webrtc 连接——它是官方 webrtc android lib 的编译版本。
例如,在 Nexus 5 上,视频质量非常好,CPU 的使用率为 20-25%。 在 SE SP 质量很糟糕,CPU 大约 50%(所以仍然有一些可用的功率)。 两个设备都在同一个 WiFi 网络上工作。
据我所知,WebRTC 应该自己选择视频质量,但是有什么办法可以手动选择吗?
我在 IOS 上使用以下内容来限制帧速率和分辨率,从而为库提供更多空间来缩放比特率。
// initialize video constraints
NSMutableArray *m = [[NSMutableArray alloc] init];
NSMutableArray *o = [[NSMutableArray alloc] init];
[m addObject:[[RTCPair alloc] initWithKey:@"minWidth" value:@"640"]];
[m addObject:[[RTCPair alloc] initWithKey:@"minHeight" value:@"480"]];
[m addObject:[[RTCPair alloc] initWithKey:@"maxFrameRate" value:@"20"]];
// init the constraints object
APP.videoConstraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:m optionalConstraints:o];
现在似乎不赞成通过约束来控制带宽。
因此,至少在版本 GoogleWebRTC (1.1.31999) 中 iOS 和 org.webrtc:google -webrtc:1.0.22672 for android PeerConnection 实例中有方法。
对于iOS:
let updateBitrateSuccessful = pc.setBweMinBitrateBps(300000, currentBitrateBps: 1000000, maxBitrateBps: 3000000)
print("Update rtc connection bitrate " + (updateBitrateSuccessful ? "successful" : "failed"))
分别为Android:
boolean updateBitrateSuccessful = pc.setBitrate(300000, 1000000, 3000000);
Log.d("AppLog", "Update rtc connection bitrate " + (updateBitrateSuccessful ? "successful" : "failed"));