独立移动应用程序上的 WebRTC [英] WebRTC on a standalone mobile app
问题描述
我知道 WebRTC
是为浏览器设计的,但是否可以直接在移动应用程序上使用 WebRTC 库?
I know that WebRTC
was designed for browsers, but is it possible to use WebRTC libraries on mobile applications directly?
谢谢!
推荐答案
截至 5 月 14 日 这里是一个使用 WebRTC
的安卓项目,效果很好.
As of May 14 here is an android project using WebRTC
that works nicely.
我将整个 android 项目翻译成 Objective-C
for iOS 并让 WebRTC 在 iOS 中工作,但我在 iPhone 4 和 4s 上遇到了问题.仅适用于 iPhone 5 和 5s.
I translated that entire android project to Objective-C
for iOS and got WebRTC working in iOS too but I'm having trouble on iPhone 4 and 4s. Just works in iPhone 5 and 5s.
我认为问题在于性能.当我使用 webrtc 库进行视频通话时,它会占用 iPhone 5 上大约 140% 的 CPU,我想这是很多资源,iPhone 4s 无法处理.
I think the problem is the performance. When I make a videocall with the webrtc libraries it takes about 140% of the CPU on an iPhone 5, which I guess that's a lot of resources and the iPhone 4s can't handle it.
已编辑
在与视频连接苦苦挣扎后(总是在 10 秒后断开连接)我终于让 WebRTC 在 iPhone 4s 上工作了,您要做的就是在创建本地 videoSource 捕获对象时设置正确的约束:
After struggling with the video connection (always disconnected after 10 seconds) I finally got WebRTC working on iPhone 4s, all you have to do is set the right constraints when creating the local videoSource capturing object:
NSString *_width = @"320";
NSString *_height = @"180";
NSString *_maxFrameRate = @"10";
RTCMediaConstraints *videoConstraints = [[RTCMediaConstraints alloc]
initWithMandatoryConstraints:@[[[RTCPair alloc] initWithKey:@"maxHeight" value:_height],
[[RTCPair alloc] initWithKey:@"maxWidth" value:_width],
[[RTCPair alloc] initWithKey:@"maxFrameRate" value:_maxFrameRate]] optionalConstraints:@[[[RTCPair alloc]
initWithKey:@"googCpuOveruseDetection" value:@"true"],
[[RTCPair alloc] initWithKey:@"googCpuLimitedResolution" value:@"true"]]];
RTCVideoSource *videoSource = [factory videoSourceWithCapturer:capturer constraints:videoConstraints];
RTCMediaStream *lms = [factory mediaStreamWithLabel:@"ARDAMS"];
[lms addVideoTrack:[factory videoTrackWithID:@"ARDAMSv0" source:videoSource]];
请注意,这会发送一个非常小的视频,但它可以工作!
Note that this sends a very small video, but it works!
这篇关于独立移动应用程序上的 WebRTC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!