EricssonResearch / openwebrtc-examples

Examples apps showing how to use OpenWebRTC
BSD 2-Clause "Simplified" License
336 stars 209 forks source link

How to run openwebrtc on iOS in the background #76

Open oney opened 9 years ago

oney commented 9 years ago

I have already run ios/NativeDemo app in my iPhone, it works perfectly. However, when I press home button and the app enters the background mode, the connection is closed. How to continue running openwebrtc in the background? Thanks.

superdump commented 9 years ago

I think @stefanalund and @Rugvip can probably figure this out. It's platform specific and we need to document how on Android and iOS.

stefanalund commented 9 years ago

iOS stops the camera when an app is put in to the background, but audio should be possible to keep alive. There's a specific background mode that needs to be enabled in the App Settings.

oney commented 9 years ago

Yes, I expect that the app keeps audio talking in the background. I add key Required background modes that has App plays audio and App provides Voice over IP services item to Info.plist. Unfortunately, it's not working. image

oney commented 9 years ago

It's interesting. I modify the code like this to use audio only, and when entering background mode, the app will keep audio connection. I can listen and send voice with each other.

[nativeHandler startGetCaptureSourcesForAudio:YES video:NO];

However, when entering background, iPhone won't show using audio view on the top. When I test Talky.io app, it will show like this. image

stefanalund commented 9 years ago

So audio is running when in the background now?

oney commented 9 years ago

Yes, it is.

superdump commented 9 years ago

We use OpenGL for video rendering in hybrid and native applications in case that gives any clues.

It could possibly be as simple as deregistering the nsview against the tag. And then reregistering again when coming back into focus. I think @rugvip has done something like that on Android but I'm not sure.

superdump commented 9 years ago

Perhaps I should ask if display of video resumes when you resume the app.

stefanalund commented 9 years ago

Sorry for all the questions and few answers, but did audio start working in the background when you went audio-only?

oney commented 9 years ago

Yes, it did. Audio worked in the background when the app went audio-only.