Webrtc on a Standalone Mobile App

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

Thanks!

4

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!

4

You could use WebRTC with native apps, but it requires a bit of work.

If you look at the image you can see a red rectangle at the bottom. That's the native C++ libraries of WebRTC. The WebRTC classes and WebRTC objects for audio and Video can also be found as part of the WebRTC project.What you would need to add is an API for your app to be able to setup calls(The VOIP interface), a signaling stack and NAT traversal utilities(Core Protocol- For SIP this could be something like PJSIP and PJNATH) and an adapter from your signaling stack to webrtc, telling it when to open channels for video and audio and when to stop them etc.

See also:

As of today, WebRTC officially is available natively on Android/iOS.

Although under the hood, it is just a Java/Objective C wrapper around the C++ APIs.

You can still use them without going through JavaScript.

The Java wrapper API :

The Objective C wrapper API :

1

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.

1

Let me summarize the answer, on Android Firefox actually has WebRTC support I believe, on the other hand there is a bunch of companies out there providing the full stack for building an WebRTC Product. If you are after just WebRTC and building the other stuff (addressing etc) your self you probably have to Build a couple of wrappers yourself. (Disclaimer I work for sinch)

[
[
[
[
[ (I think)

There is some more out there, but these are the main ones

We all have our different benefits and weaknesses. if you are interested send an email and I can talk about sinch.

1

It is possible to work with WebRTC in mobile applications with the use of 3rd-party API's like OpenTok (iOS only, as of January 2014 Android in beta) and Addlive (iOS and Android)

0

SightCall has a WebRTC-compatible SDK for Android that lets Android-native apps connect to WebRTC in a browser. You can get the SDK here

As of March 2014, here is a way to do that, indeed:

That would be if you're interested in having a native client. If you don't mind using a mobile browser, the following ones are currently supported:

  • Google Chrome 28 (Enabled by default since 29)
  • Mozilla Firefox 24
  • Opera Mobile 12

Source:

0

I don't know what do you mean by "use WebRTC libraries on mobile applications directly". But there is something that I'm already done. Build WebRTC NS/AEC/AECM/AGC/VAD modules with JNI + NDK, and use the shared library on android. or you can build whole WebRTC VoE and ViE for both android and iOS.

3

One resource you might want to look at is this article: how to get started with webrtc and ios without wasting 10 hours of your life

One problem I am having is making sense of all the WebRTC/Libjingle library files. At the moment, I can get the example app running but I wish there was a "Hello World" example out there.

1

Not yet, it is only supported in Firefox's nightly and Chrome, both desktop versions. See

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

4

For now you have two options:

  • Either you will build libWebRTC for your device. You need to know how to work with Android NDK and native C code on iOS. It is non trivial but it's perfectly doable
  • Use work of others who did this for you. E.g. already mentioned AddLive (yip, I work there) or even OpenTok.

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 which also includes a step by step guide for both platforms

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.

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.

If you are targeting android >= L you can build a native webRTC app pretty easily by embedding a (chrome) webview - which supports WebRTC - into your app.

See chrome webview

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest