Re: Pjsip answer call not working from main thread ios

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

 



Hello!

I am using pjsip separately from UI with custom Account, Call and Sip mangers. That managers working in own thread. From UI  I am only call required functions and that work fine. Try something like this.

14 авг. 2019 г., в 19:31, Anuran Barman <anuranbarman@xxxxxxxxx> написал(а):

I am trying to with pjsip. Everything was working before but after i add some additional feature like showing a view controller for incoming call with username it is not able to accept the call.

If i put the accept function in the same same thread it was then its able to pick up the call. But after I switch to main thread to show some UI and come back when tapping the accept call button its not able to accept the call. What i meant by this is like below

- (void)acceptCall:(char *)callID _ :(pjsua_call_id)call_id {

    

    self.call_id = call_id;

    

    NSString *callid = [NSString stringWithUTF8String:callID];
    NSString *finalName;

    

    NSArray *arr = [callid componentsSeparatedByString:@" "];
    finalName = [arr[0] stringByReplacingOccurrencesOfString:@"\"" withString:@""];

    

    CXProviderConfiguration *configuration = [[CXProviderConfiguration alloc] initWithLocalizedName:@"SIP Phone"];
    configuration.supportsVideo = YES;
    configuration.maximumCallsPerCallGroup = 1;
    configuration.supportedHandleTypes = [NSSet setWithObject:@(CXHandleTypePhoneNumber)];
    _provider = [[CXProvider alloc] initWithConfiguration:configuration];
    [_provider setDelegate:self queue:nil];
    CXCallUpdate *update = [[CXCallUpdate alloc] init];
    update.hasVideo = YES;
    update.supportsDTMF = YES;
    update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:finalName];
    self.current_call_uuid = [[NSUUID alloc] init];

    self.thread = pj_thread_this();

    

// FROM THIS POINT I MOVE TO MAIN THREAD TO SHOW THE VIEW CONTROLLER
    dispatch_async(dispatch_get_main_queue(), ^{
        NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
        [dict setObject:finalName forKey:@"username"];
        [NSNotificationCenter.defaultCenter postNotificationName:@"ShowIncomingCallVC" object:NULL userInfo:dict];
    });
}

When I am tapping the accept button there is another function in this file which is supposed to accept the call. This is a shared instance class I am using

-(void) handleIncomingCall:(int)statusCode {

    

    long *desc = 0;
    pj_thread_t *thisThread = pj_thread_this();
    pj_thread_register(pj_thread_get_name(self.thread), desc, &thisThread);

    

    pjsua_call_setting opt;

    

    pjsua_call_setting_default(&opt);

    

    opt.vid_cnt = 1;
    opt.aud_cnt = 1;

    

    pj_status_t status = pjsua_call_answer2(self.call_id, &opt, statusCode, NULL, NULL);
    if(status == PJ_SUCCESS) {
        NSLog(@"anuran call picked up from delegate");
        self.is_call_active = statusCode == 200 ? YES : NO;
    }else {
        NSLog(@"anuran call could not be picked up from delegate");

        

    }

}


this handleIncomingCall function is called from MAIN THREAD as obviously but pjsip is not able to accept the call. The line
    if(status == PJ_SUCCESS) {
actually never reaches when I put breakpoint there. I am storing a instance of the CURRENT THREAD above as you can see when I am just about to move to MAIN THREAD but how can I use that to go back to that thread? Please help. Stuck for hour behind this.

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

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

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

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[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