How to avoid opening of audio source?

157 views
Skip to first unread message

j...@tutpro.com

unread,
Nov 16, 2021, 6:00:04 AM11/16/21
to baresip
In Android, if user has not granted microphone permission then during a call audio can only be received, not sent, and the app does not have access to microphone as audio source device.

When such a user makes a call, my baresip makes API call:

ua_connect_dir(ua, &call, uri, VIDMODE_OFF,  SDP_RECVONLY, SDP_INACTIVE);

Thus audio dir is SDP_RECVONLY and INVITE's sdp has attribute

a=recvonly

The callee answers and 200 OK has attribute

a=sendonly

When caller receives the 200 OK, I get to log:

call: update media
stream: update 'audio'
stream: audio: starting RTCP with remote 192.168.109.95:26205
audio: update
audio: start
opensles: opening player 16000Hz, 1channels
audio: player started with sample format S16LE
audio: Set audio encoder: AMR-WB 16000Hz 1ch
audio: start
webrtc_aecm: creating shared state: [16000 Hz, 1 channels, subframe 160 samples, num_bands 1]
opensles: opening recorder 16000Hz, 1channels
audio: start_source failed (opensles.nil): No such device

Why is baresip trying to start audio source even when it is only supposed to receive audio?

Is there a way to prevent access to the audio source device?


j...@tutpro.com

unread,
Nov 16, 2021, 7:38:03 AM11/16/21
to baresip
I looked at the source and found that call.c calls audio_start() that starts both player and source:

err  = start_player(&a->rx, a, baresip_auplayl());
err |= start_source(&a->tx, a, baresip_ausrcl());

How to fix this?  Should enum sdp_dir dir param be added to audio_start:

int audio_start(struct audio *a, enum sdp_dir dir)

so that it would know what to do?  

Or should call.c make separate audio_start_source() and audio_start_player() calls depending on audio dir?
Currently of those two only audio_start_source() exists.

Juha Heinanen

unread,
Nov 16, 2021, 8:32:51 AM11/16/21
to baresip
'j...@tutpro.com' via baresip writes:

> I looked at the source and found that call.c calls audio_start() that
> starts both player and source:
>
> err = start_player(&a->rx, a, baresip_auplayl());
> err |= start_source(&a->tx, a, baresip_ausrcl());

I made a test where I commented out the latter line and later references
to &a->tx. With those mods call without microphone permission worked
fine. Audio source was not started and caller was able receive audio.

So what is the proper fix?
Reply all
Reply to author
Forward
0 new messages