Cordova-plugin-iosrtc: Requests microphone even if only listening

Created on 25 Jan 2017  Â·  25Comments  Â·  Source: cordova-rtc/cordova-plugin-iosrtc

I've noticed that my iOS app requests permission to use the microphone, even if I am only receiving and not playing audio.

Is there any way to prevent this?

bug enhancement getUserMedia libwebrtc

Most helpful comment

Unfortunately Apple has disabled getUserMedia in WebViews outside of Safari.

So even though the code is there and works great in a safari tab, it will NOT work if you save a link to that page to your homescreen, nor if you are trying to do it inside a WebView like cordova (I tried and verified both UIWebView and WKWebView)

All 25 comments

How did you call getUserMedia?

In this case I don't call getUserMedia(), I use RTCPeerConnection and bind the audio to the element using URL.createObjectURL().

You must be calling getUserMedia somewhere in order to get that peer
connection established. How are you doing that?

Maybe a code snippet would help here.

On Wed, Jan 25, 2017 at 1:38 AM, dobesv notifications@github.com wrote:

In this case I don't call getUserMedia(), I use RTCPeerConnection and
bind the audio to the element using URL.createObjectURL().

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/eface2face/cordova-plugin-iosrtc/issues/250#issuecomment-275039536,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AATYGMi_4fpi6q34o32i1o7Dfu94k-ASks5rVvwBgaJpZM4Ls6q1
.

--
/Saúl
bettercallsaghul.com

No, I just call the constructor for RTCPeerConnection. getUserMedia is
only needed to access the local microphone or camera.

On Wed, Jan 25, 2017, 7:02 AM Saúl Ibarra Corretgé notifications@github.com
wrote:

You must be calling getUserMedia somewhere in order to get that peer
connection established. How are you doing that?

Maybe a code snippet would help here.

On Wed, Jan 25, 2017 at 1:38 AM, dobesv notifications@github.com wrote:

In this case I don't call getUserMedia(), I use RTCPeerConnection and
bind the audio to the element using URL.createObjectURL().

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<
https://github.com/eface2face/cordova-plugin-iosrtc/issues/250#issuecomment-275039536
,
or mute the thread
<
https://github.com/notifications/unsubscribe-auth/AATYGMi_4fpi6q34o32i1o7Dfu94k-ASks5rVvwBgaJpZM4Ls6q1

.

--
/Saúl
bettercallsaghul.com

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/eface2face/cordova-plugin-iosrtc/issues/250#issuecomment-275130621,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAUAmQDlLQYVpuhHFG1A2QXcxfvwKs6Pks5rV2PngaJpZM4Ls6q1
.

You must be calling getUserMedia somewhere in order to get that peer connection established.

Not at all. getUserMedia is just required to get a local MediaStream and, optionally, attach it into the peerconnection.

I've been digging into this.

In the apple docs it says:

Recording Requires User Permission
Recording audio requires explicit permission from the user. The first time your app’s audio session attempts to use an audio input route while using a category that enables recording, the system automatically prompts the user for permission. You can explicitly ask earlier by calling the requestRecordPermission: method. Until the user grants your app permission to record, your app can record only silence.
When a user responds to a recording permission prompt for your app, the system remembers the choice. If the user has denied recording permission, they can reenable it in Settings > Privacy > Microphone.

And, in the LibWebRTC code, it configures the session using AVAudioSessionCategoryPlayAndRecord, so I think this is probably triggering the microphone request.

Is there a bug tracker for the iOS WebRTC code?

I was hoping I could try and build a hacked libWebRTC.a that had recording disabled, but it doesn't seem like the patch files in the instructions for this repo match the WebRTC source code any more.

I understand this is a problem, but we cannot (should not) hack libwebrtc.a to behave in a different way.

Well, I'm willing to hack it just for my own project, to get around this. I wasn't suggesting I would release my hack officially. In the long term the libWebRTC stuff has to give some access to this I guess. But they don't seem to have any short or medium term plans to do so.

Another approach that would also solve my problem is if I could just play a webm audio stream without using WebRTC. Currently the mobile browsers (& cordova) only support mp4, mp3, and ogg. If somehow I could reuse the WebM + Opus support in libWebRTC to play the audio I wouldn't need a WebRTC session at all.

I'll have to keep an eye on https://github.com/brion/OGVKit and when they support Opus playback I might be able to make a Cordova wrapper.

Has anybody come any closer to solving this? :-)

Apple has said they will support WebRTC in iOS 11, in the fall. I guess we'll see if that comes with a better solution for this problem.

I wondered if the problem is now solved.(Requests microphone even if only listening),
I do not want to apply for microphone permission.

It's not solved. You can follow the discussion in the WebRTC tracker issue I linked to earlier. There was one person who seemed to have been able to compile a build of WebRTC which didn't request the microphone.

How exactly they did it ... or even how exactly to compile WebRTC in such a way that it can be used with this plugin ... is beyond me.

However, iOS 11 has been released, and I believe it supports WebRTC. So it's possible that you can soon use WebRTC without using this plugin. And if we are lucky it won't request the microphone unless it really needs it.

Unfortunately Apple has disabled getUserMedia in WebViews outside of Safari.

So even though the code is there and works great in a safari tab, it will NOT work if you save a link to that page to your homescreen, nor if you are trying to do it inside a WebView like cordova (I tried and verified both UIWebView and WKWebView)

help
open live camera streaming from web-view in react native

@jituumaria

help
open live camera streaming from web-view in react native

Yes, sure, working on it for free for you right now.

This one is not that easy.

See status of related issue:

Long story short, I don't want to have to patch WebRTC anymore, at least for now.

Fix confirmed on master

getUserMedia({video: true, audio: false})

@hthetiot What was the fix? Did they add WebRTC support for WebView ?

I am seeing this same issue with the latest v6.0.16... I am connecting to a webrtc endpoint, and only specifying audio receive. Is the issue resolved for anybody else?
here is my debug log which shows: OfferToReceiveAudio=true; OfferToReceiveVideo=false;

021-01-26 17:05:24.000354+0100 MyApp[13166:5048600] iosrtcPlugin#MediaStreamRenderer_close()
2021-01-26 17:05:24.000450+0100 MyApp[13166:5048600] PluginMediaStreamRenderer#close()
2021-01-26 17:05:24.000571+0100 MyApp[13166:5048600] PluginMediaStreamRenderer#reset()
2021-01-26 17:05:24.000838+0100 MyApp[13166:5049483] PluginRTCPeerConnection#createAnswer()
2021-01-26 17:05:24.000848+0100 MyApp[13166:5048600] PluginMediaStreamRenderer#deinit()
2021-01-26 17:05:24.001153+0100 MyApp[13166:5049483] PluginRTCPeerConnectionConstraints#init()
2021-01-26 17:05:24.001330+0100 MyApp[13166:5049483] PluginRTCPeerConnectionConstraints#init() | [mandatoryConstraints:{
    OfferToReceiveAudio = true;
    OfferToReceiveVideo = false;
}, optionalConstraints:{
}]
2021-01-26 17:05:24.001412+0100 MyApp[13166:5049483] PluginRTCPeerConnectionConstraints#getConstraints()
2021-01-26 17:05:24.001720+0100 MyApp[13166:5049483] PluginRTCPeerConnectionConstraints#deinit()
2021-01-26 17:05:24.001751+0100 MyApp[13166:5048864] PluginRTCPeerConnection#createAnswer() | success callback
2021-01-26 17:05:24.003330+0100 MyApp[13166:5048600] iosrtcPlugin#new_MediaStreamRenderer()
2021-01-26 17:05:24.003393+0100 MyApp[13166:5048600] PluginMediaStreamRenderer#init()
2021-01-26 17:05:24.006884+0100 MyApp[13166:5048600] PluginMediaStreamRenderer#run()
2021-01-26 17:05:24.007067+0100 MyApp[13166:5048600] iosrtcPlugin#MediaStreamRenderer_refresh()
2021-01-26 17:05:24.007165+0100 MyApp[13166:5048600] PluginMediaStreamRenderer#refresh() [elementLeft:0.0, elementTop:0.0, elementWidth:0.0, elementHeight:0.0, videoViewWidth:0.0, videoViewHeight:0.0, visible:false, opacity:1.0, zIndex:0.0, mirrored:false, clip:true, borderRadius:0.0]
2021-01-26 17:05:24.007328+0100 MyApp[13166:5048600] iosrtcPlugin#MediaStreamRenderer_render()
2021-01-26 17:05:24.007383+0100 MyApp[13166:5048600] PluginMediaStreamRenderer#render()

@sreplans 6.0.16 is not the latest, and 6.0.17 fix the issue you have.

Comment on closed issue is bad BTW.

@hthetiot What was the fix? Did they add WebRTC support for WebView ?

@dobesv WKWebview supported WebRTC since 12.2, what it does not support is getUserMedia, since 14.3 is does support getUserMedia but only on https while cordova app are served on file:// or http:// (unless you do it using injection).

This plugin solve that and provide better battery consumption.

Create new issue instead of commenting on old issue that have been fixed and does not reflect the current build.

Was this page helpful?
0 / 5 - 0 ratings