AlexKMDev / WebRTC

Unofficial builds of Google WebRTC iOS Framework
https://webrtc.org/native-code/ios/
Other
291 stars 76 forks source link

Problem with audio via CallKit call #10

Closed x3mall1986 closed 7 years ago

x3mall1986 commented 7 years ago

If I make a call via CallKit, the connection occurs, the video is working, but the audio does not work. If you make a second call without closing the application video and audio works fine. After restarting, the problem persists again.

In the console on the first connection this error:

[Aurioc] 889: failed: 'ent?' (Enable 3, outf <1 ch, 48000 Hz, Int16> inf <1 ch, 48000 Hz, Int16>)
 [Aurioc] 889: failed: 'ent?' (Enable 3, outf <1 ch, 48000 Hz, Int16> inf <1 ch, 48000 Hz, Int16>)
[Aurioc] 889: failed: 'ent?' (Enable 3, outf <1 ch, 48000 Hz, Int16> inf <1 ch, 48000 Hz, Int16>)
 [Aurioc] 889: failed: 'ent?' (Enable 3, outf <1 ch, 48000 Hz, Int16> inf <1 ch, 48000 Hz, Int16>)
[Aurioc] 889: failed: 'ent?' (Enable 3, outf <1 ch, 48000 Hz, Int16> inf <1 ch, 48000 Hz, Int16>)

If I make a call without using CallKit - everything works fine.

Are there any ideas? Thanks in advance for your answers.

AlexKMDev commented 7 years ago

I have never worked with CallKit and audio (only video and data channel), so I don't know what can be a problem. You probably should ask in the discussion group.

AlexKMDev commented 7 years ago

It should be reported to the bug tracker, because it relates to code rather than build. https://bugs.chromium.org/p/webrtc/issues/list

bmaslakov commented 7 years ago

@x3mall1986 Have you managed to find the issue? I am facing the same problem.

x3mall1986 commented 7 years ago

@bmaslakov yes, you need use configureAudioSession from apple's example source. It takes time, so you need to call this method before answer the call.

multybuq commented 7 years ago

to enable audio and mic in CallKit you should configure audioSession properly, like in apple's sample app "Speakerbox". You should configure it not in accept call method of CallKit delegate, but in reportIncomingCallWithUUID.

Swift code sample provider.reportNewIncomingCall(with: uuid, update: update) { error in if error == nil { configureAudioSession() } }

objc example [self.callKitProvider reportNewIncomingCallWithUUID:uuid update:callUpdate completion:^(NSError *error) { if (!error) { [AudioRouter configureAudioSession]; } }];

obaskanderi commented 7 years ago

During the Kranky Geek event there was a talk where they described audio issues with webrtc and callkit.

https://youtu.be/JB2MdcY1MKs?t=6m19s

Jeyhey commented 7 years ago

@multybuq Does moving configureAudioSession() to reportNewIncomingCall not leads to a permanent red status bar when the incoming call is a) declined or b) hung up by caller before answered? This is what I could observe in my implementation.

x3mall1986 commented 7 years ago

I have problem with red bar too. How can I hide it?

Jeyhey commented 7 years ago

The issue seems to be in handleInterruption (audio is started when interruption ends). What I did is I removed the observer for audio interruptions in provider(_ provider: CXProvider, perform action: CXEndCallAction).

x3mall1986 commented 7 years ago

If I release audioController in provider(_ provider: CXProvider, perform action: CXEndCallAction) with self.audioController = nil will it give the same effect?

ismaiI1 commented 7 years ago

Hi guys, @x3mall1986 is your app Swift or Objective-C ? if Swift, do you know how can i configure audioSession in Objective-C? Tagged for notification : @multybuq , @Jeyhey , @bmaslakov :)

x3mall1986 commented 7 years ago

@invisible66 sample from Apple contains the configuration of the audioSession.

ismaiI1 commented 7 years ago

@x3mall1986 but it swift :) i need Objective-C.

x3mall1986 commented 7 years ago

@invisible66 It works well for obj-c and need only initialize AudioController, implement and call methods:

- (void)startAudio {
    if ([self.audioController startIOUnit] == kAudioServicesNoError) {
        self.audioController.muteAudio = NO;
    }
}

- (void)stopAudio {
    if ([self.audioController stopIOUnit] != kAudioServicesNoError) {
        NSLog(@"audio error");
    }
}
ismaiI1 commented 7 years ago

@x3mall1986 i think i am noob :( plsease can you give me AudioController initialize code and where i put it :( thank you for answers.

x3mall1986 commented 7 years ago

Initialize in this method:

- (void)configureAudioSession {
    if (!self.audioController) {
        self.audioController = [[AudioController alloc] init];
    }
}

and call from block:

[self.provider reportNewIncomingCallWithUUID:uuid update:update completion:^(NSError * _Nullable error) {
        if (!error) {
            ...
            [self configureAudioSession];
        }
    }];
ismaiI1 commented 7 years ago

@x3mall1986 I got this error.

AVAudioSession error activating: Error Domain=NSOSStatusErrorDomain Code=561017449 "(null)" 2017-03-09 18:17:48.830893 Netgsm[1620:971182] [aurioc] 892: failed: '!pri' (enable 3, outf< 1 ch, 16000 Hz, Int16> inf< 1 ch, 16000 Hz, Int16>) 2017-03-09 18:17:48.841301 Netgsm[1620:971182] [aurioc] 892: failed: '!pri' (enable 3, outf< 1 ch, 44100 Hz, Int16> inf< 1 ch, 44100 Hz, Int16>) 2017-03-09 18:17:48.850282 Netgsm[1620:971182] [aurioc] 892: failed: '!pri' (enable 3, outf< 1 ch, 48000 Hz, Int16> inf< 1 ch, 48000 Hz, Int16>) . . .