WebRTC on a standalone mobile app

2020-05-12 04:55发布

I know that WebRTC was designed for browsers, but is it possible to use WebRTC libraries on mobile applications directly?

Thanks!

标签: webrtc
16条回答
我命由我不由天
2楼-- · 2020-05-12 05:31

Not yet, it is only supported in Firefox's nightly and Chrome, both desktop versions. See http://www.webrtc.org

Edit: sorry I thought you were asking for mobile browsers. For native apps it looks like a definite no :(

But there seems some mobile browser support http://www.morbo.org/2013/04/webrtc-support-on-android.html

查看更多
相关推荐>>
3楼-- · 2020-05-12 05:31

For iOS, just add this to your CocoaPods Podfile

pod "libjingle_peerconnection"


# Add this to the bottom so it won't have issues with active architecture
post_install do |installer_representation|
    installer_representation.project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
            config.build_settings['VALID_ARCHS'] = ['armv7', 'i386']
        end
    end
end

Check this for which revisions are available. Revision 6802.X reflects to this from the actual WebRTC code base.

Android will be added to maven central very soon, I'll make an edit to this when happens.

If you want to manually build WebRTC check out github.com/pristineio/webrtc-build-scripts which also includes a step by step guide for both platforms

查看更多
SAY GOODBYE
4楼-- · 2020-05-12 05:32

My team has done quite a bit of work in this area. If you are looking for a Cordova plugin we've been playing with an open source project called PhoneRTC. We have it running on iOS but it's a bit unreliable and the aspect ratio of the video window is fixed in a way that looks unnatural on most devices but it does work.

We've also created an Android demo using libjingle. Libjingle is now part of the WebRTC project and code base. This link is probably out of date now but points to instructions that worked for us at the time.

查看更多
看我几分像从前
5楼-- · 2020-05-12 05:34

We (disclaimer: I work there) have built a set of libraries for doing this @ Frozen Mountain, in IceLink. Full WebRTC implementation for iOS, Android, .NET, etc.

查看更多
我只想做你的唯一
6楼-- · 2020-05-12 05:39

Quite late to answer.. But i just made a framework for adding WebRTC easily in iOS Project. You won't need to build WebRTC framework from the library. This framework will give you built in framework along with a wrapper for easy addition of webRTC to your app. https://github.com/Ankit-Aggarwal/SwiftyWebRTC

查看更多
甜甜的少女心
7楼-- · 2020-05-12 05:41

As of May 14 here is an android project using WebRTC that works nicely.

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.

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.


Edited

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!

查看更多
登录 后发表回答