internal and external speaker in webrtc ios

4,324 views
Skip to first unread message

Yura Lapytko

unread,
May 4, 2014, 4:59:07 PM5/4/14
to discuss...@googlegroups.com
Hi.

This question is when i run webrtc ios application on iphone only internal speker works. 
I should put iphone to my ear if i want to hear. 
How to switch on load speaker?

Thanks.

aaroncray

unread,
May 5, 2014, 3:54:50 AM5/5/14
to discuss...@googlegroups.com
you need to change the audio path:

AVAudioSession* session = [AVAudioSession sharedInstance];

BOOL success;

NSError* error;

success = [session setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];    

if (error)

    NSLog(@"AVAudioSession error setting category:%@",error);

success = [session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&error];

if(error)

    NSLog(@" AVAudioSession error changing route:%@",error);

Yura Lapytko

unread,
May 5, 2014, 1:26:15 PM5/5/14
to discuss...@googlegroups.com
Thanks.

Yura Lapytko

unread,
Oct 7, 2014, 3:26:48 AM10/7/14
to discuss...@googlegroups.com

It worked in previous version but now it doesn't work. I try to use AVAudioSession in the last AppRTCDemo for ios and nothing.
Please help.

chinahu

unread,
Oct 8, 2014, 9:48:05 PM10/8/14
to discuss...@googlegroups.com
webrtc::VoEHardware->SetLoudspeakerStatus(true)
can you call it?

Yura Lapytko

unread,
Oct 9, 2014, 12:14:38 PM10/9/14
to discuss...@googlegroups.com

No, how to call it and where do you call it?

chinahu

unread,
Oct 9, 2014, 9:01:09 PM10/9/14
to discuss...@googlegroups.com
oh. i had buit webrtc native code . so i can call it from UI.
you can search 'SetLoudspeakerStatus' from source code.

On Monday, May 5, 2014 4:59:07 AM UTC+8, Yura Lapytko wrote:

Adrian Ursu

unread,
Nov 10, 2014, 9:01:39 AM11/10/14
to discuss...@googlegroups.com
Just use :

    AVAudioSession *audioSession = [AVAudioSession sharedInstance];

    [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error:nil];

    [audioSession setActive:YES error:nil];


This will also let you use headphones when plugged in.

Josip Bernat

unread,
Dec 4, 2014, 5:58:23 AM12/4/14
to discuss...@googlegroups.com
This doesn't work any more. Is there some other solution for this problem?

Stephen Liu

unread,
Dec 10, 2014, 5:28:32 AM12/10/14
to discuss...@googlegroups.com
I manually export the AudioDeviceModule interface and its SetLoudSpeakerStatus function from VoEBaseImpl, but it doen's work also.

Cameron Cooke

unread,
Dec 10, 2014, 9:35:41 AM12/10/14
to discuss...@googlegroups.com
I'm having the same issue. Is there no way to to route audio to the iPhone loud speaker?

wangz...@gmail.com

unread,
Dec 16, 2014, 9:18:47 PM12/16/14
to discuss...@googlegroups.com
I tried to use AVAudioSession sharedInstance to re-route to speaker. But it doesn't work. Anyone has a solution for this?

Kaiduan Xie

unread,
Dec 17, 2014, 10:06:20 AM12/17/14
to discuss...@googlegroups.com
- (void) toggleAudioOutput:(NSString *)message {
if ([message isEqualToString:@"speaker"]) {
NSError* __autoreleasing err = nil;
AVAudioSession* audioSession = [AVAudioSession sharedInstance];
[audioSession
overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&err];
} else if ([message isEqualToString:@"handset"]) {
NSError* __autoreleasing err = nil;
AVAudioSession* audioSession = [AVAudioSession sharedInstance];
[audioSession
overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:&err];
}
}

/Kaiduan
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "discuss-webrtc" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to discuss-webrt...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Josip Bernat

unread,
Dec 18, 2014, 4:12:42 AM12/18/14
to discuss...@googlegroups.com
Still not working when mute switch is ON. Testing on iPhone 5C.



You received this message because you are subscribed to a topic in the Google Groups "discuss-webrtc" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/discuss-webrtc/MWaKZahH1i8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to discuss-webrt...@googlegroups.com.

Josip Bernat

unread,
Jan 26, 2015, 8:48:42 AM1/26/15
to discuss...@googlegroups.com
Finally I've found a solution for this problem.

You need to set AVAudioSession category to AVAudioSessionCategoryPlayback but for some reason it gets back to AVAudioSessionCategoryPlayAndRecord.
So I added listener to AVAudioSessionRouteChangeNotification notification and set AVAudioSessionCategoryPlayback if it was changed. A bit of hack but worked in the end.

Stephen Liu

unread,
Jan 30, 2015, 10:02:39 AM1/30/15
to discuss...@googlegroups.com
I tried your solution, but it still didn't work. I doubt that the code where I call "self.onRouteToSpeaker(self)" isn't proper, could you please show me where you call with detail. Thank you a lot.

在 2015年1月26日星期一 UTC+8下午9:48:42,Josip Bernat写道:

hu

unread,
Jan 30, 2015, 9:55:57 PM1/30/15
to discuss...@googlegroups.com

 AVAudioSession* session = [AVAudioSession sharedInstance];        

 [session setCategory:AVAudioSessionCategoryPlayAndRecord error: &error];

 // [session setCategory:AVAudioSessionCategoryPlayback error: &error];

 [session setActive:TRUE error:&error];

it works for me. i have test on iphone5 and iphone5s

but there are errors in console. details as follow:

2015-01-31 10:36:09.613 rtc.iPhone[4583:b917] 10:36:09.613 ERROR:     [0x994d000] AVAudioSessionUtilities.h:88: GetProperty_DefaultToZero: AudioSessionGetProperty ('tlic') failed with error: 'tac!'

Josip Bernat

unread,
Feb 2, 2015, 7:52:56 AM2/2/15
to discuss...@googlegroups.com
I've updated source code on github. Be sure to call JBSoundRouter.routeSound(JBSoundRoute.Speaker) after you receive RTCMediaStream from other peer.

Antonis Tsakiridis

unread,
Jun 9, 2015, 6:58:02 AM6/9/15
to discuss...@googlegroups.com
Isn't the webrtc implementation supposed to honour the AVAudioSession setting or am I missing something?

I mean I had the same issue and had to resort to http://stackoverflow.com/questions/24595579/how-to-redirect-audio-to-speakers-in-the-apprtc-ios-example, which works fine but isn't the best way to go.

Best regards
Reply all
Reply to author
Forward
0 new messages