Mohan Kumar
Mohan Kumar

Reputation: 334

VOIP dialler tone for outgoing call iOS webrtc

I am working on VOIP in iOS using webrtc.

How to produce dialer tone for outgoing call , i.e. how to produce the ringer sound in ear speaker till the outgoing call connected?

Upvotes: 5

Views: 1654

Answers (3)

iCodes
iCodes

Reputation: 1457

Based on Maverick's answer.This will play ringtone in ear speaker like in a phone call (works on iOS 10.3).

NSError *av_error = nil;
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/digitalphone.caf", [[NSBundle mainBundle] resourcePath]]];
av_Player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&av_error];
NSError *sesionError = nil;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:kAudioSessionProperty_OverrideAudioRoute error:&sesionError];
av_Player.numberOfLoops = -1;
[av_Player play];

Upvotes: 0

Maverick King
Maverick King

Reputation: 85

NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/TEST.aif", [[NSBundle mainBundle] resourcePath]]];
AVAudioPlayer * keepAwakePlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];

UInt32 doSetProperty = TRUE;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil];   AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(doSetProperty), &doSetProperty);        
keepAwakePlayer.numberOfLoops = -1;
   [keepAwakePlayer play];

Upvotes: 1

Guilherme
Guilherme

Reputation: 7949

I can think of two ways to do that.

  1. Play a recorded audio file.
  2. Create a sound wave on demand. AFAIK, telephones play a sine wave of the musical note A, which is 440 Hz. You can create the wave and add a lot of zeros at the end to add the silence. Then play it on loop until the call is answered.

Upvotes: 0

Related Questions