pjsip audio session not recovered on iOS after interruption from youtube video

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks again a lot Michael!

So if I understand correctly you are suggesting me to manage the audio session interruption at app level and not let it do to pjsip. Correct?

But I am afraid that I will be missing something that pjsip is doing to handle the audio?. For example when pjsip receive the EndInterruption notification it calls ca_stream_start in core_audio_dev.c that do the following:

static pj_status_t ca_stream_start(pjmedia_aud_stream *strm)
{
    struct coreaudio_stream *stream = (struct coreaudio_stream*)strm;
    OSStatus ostatus;
    UInt32 i;

    if (stream->running)
return PJ_SUCCESS;

    stream->quit_flag = 0;
    stream->interrupted = PJ_FALSE;
    stream->rec_buf_count = 0;
    stream->play_buf_count = 0;
    stream->resample_buf_count = 0;

    if (stream->resample) {
ostatus = AudioConverterReset(stream->resample);
if (ostatus != noErr)
    return PJMEDIA_AUDIODEV_ERRNO_FROM_COREAUDIO(ostatus);
    }

#if !COREAUDIO_MAC
    AudioSessionSetActive(true);
#endif



    for (i = 0; i < 2; i++) {
if (stream->io_units[i] == NULL) break;
ostatus = AudioOutputUnitStart(stream->io_units[i]);
if (ostatus != noErr) {
    if (i == 1)
AudioOutputUnitStop(stream->io_units[0]);
    return PJMEDIA_AUDIODEV_ERRNO_FROM_COREAUDIO(ostatus);
}
    }

    stream->running = PJ_TRUE;

    PJ_LOG(4, (THIS_FILE, "core audio stream started"));

    return PJ_SUCCESS;
}


But at application level I will be able just to call the AudioSessionSetActive(TRUE). Is this enough to restore audio correctly???

Thanks,
Silvia



On Jun 12, 2012, at 4:47 PM, Michael Fortson wrote:

You should just be able to call AudioSessionSetActive(true); at the app level on important call events. Doing it too often is not a problem.

That said, since pjsip's audio session handling is not appropriate for an iOS app to begin with (it is not a well-behaved, peacefully co-existing background app for long-term usage), we just moved all audio session configuration, initialization, and event handling into our app. Only the Audio Units should be managed within pjsip.

Then we:
- initialize the audio session only once, on app launch
- set playandrecord mode
- override allow mixing
- allow bluetooth
- set active

Then the callbacks can be used at the app level; you still won't always get the endInterruption call, but you can set the session active when needed as a workaround.



On Tuesday, June 12, 2012 at 5:09 AM, Cataldo Silvia wrote:

Hi Michael,
thanks for your reply!

Yes from debugging I saw that the endInterruption is not called always: (
And in fact this is my issue?.  How can I know from pjsip that the interruption begun? There is no callback from pjsip about this state? and how can I tell to pjsip to recover audio?

Thanks,
Silvia


On Jun 12, 2012, at 12:51 PM, Michael Fortson wrote:

There's no guarantee you will receive an endInterruption call (it is often skipped depending on the situation); it's better to use application states and just reactivate the audio session anytime you need it. Extra setActive:YES calls are for audioSession not harmful.


Cheers,
Michael


On Monday, June 11, 2012 at 1:56 AM, Cataldo Silvia wrote:

Hi EveryBody,
I'm using pjsip to implement a VoIP application on iOS and I am facing a weird issue.

While pjsip  is correctly recovering audio if interrupted by a GSM Call, it does not recover correctly if the VoIP call is interrupted by a multimedia file, let's say  youtube video for example.

The problem is that (from the log) I can see that pjsip correctly receives the BeginInterruption notification but does not receive the EndInterruption.

Is this a known issue?

Or there is something I have to implement in my application in order to manage this scenario?
In addition, how can the app being notified by pjsip  of the interruption in order to put on hold the VoIP call?

Please note that the GSM call interruption is correctly handled, so I already put in my app the following lines of code:


- (BOOL) canBecomeFirstResponder {
    return YES;
}

-(void) viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [[UIApplication sharedApplication]
     beginReceivingRemoteControlEvents];
    [self becomeFirstResponder];
}


Thanks a lot in advance!

Silvia






Silvia Cataldo

<concept.png>
Via Cardinal Massaia, 83
10147 - Torino - ITALY
phone: +39 011 29100
s.cataldo at reply.it
www.reply.it




Silvia Cataldo

[Concept]
Via Cardinal Massaia, 83
10147 - Torino - ITALY
phone: +39 011 29100
s.cataldo at reply.it
www.reply.it


________________________________

--
The information transmitted is intended for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
_______________________________________________
Visit our blog: http://blog.pjsip.org<http://blog.pjsip.org/>

pjsip mailing list
pjsip at lists.pjsip.org<mailto:pjsip at lists.pjsip.org>
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

_______________________________________________
Visit our blog: http://blog.pjsip.org<http://blog.pjsip.org/>

pjsip mailing list
pjsip at lists.pjsip.org<mailto:pjsip at lists.pjsip.org>
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org


________________________________

--
The information transmitted is intended for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
_______________________________________________
Visit our blog: http://blog.pjsip.org<http://blog.pjsip.org/>

pjsip mailing list
pjsip at lists.pjsip.org<mailto:pjsip at lists.pjsip.org>
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip at lists.pjsip.org<mailto:pjsip at lists.pjsip.org>
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org


________________________________

--
The information transmitted is intended for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20120612/39d18cdb/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: concept.png
Type: image/png
Size: 3142 bytes
Desc: concept.png
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20120612/39d18cdb/attachment-0001.png>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux