raj yadav raj yadav - 4 months ago 61
Objective-C Question

How to add new call as conference PJSIP with siphon

Whats my project .


  1. voice calling .



Whats library in my project .


  1. Asterisk server (version 11.0)

  2. pjsip 2.5.1

  3. siphon for UI



My achievement


  1. One-to-One call working fine



My issues :-

I need to implement add new buddy feature so that we can do conference .

Whats My problems


  1. I am unable to get conference Voice call . scenarios is A called to B voice working fine ,but when B add new buddy C then B and C communicate but A and C Unable to communicate .



This my code which i am using for calling One-toOne

if (([[_label text] length] > 0) &&
([phoneCallDelegate respondsToSelector:@selector(dialup:number:)]))
{
_lastNumber = [[NSString alloc] initWithString: [_label text]];
[_label setText:@""];
}
else
{
_lcd.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"lcd_top_simple.png"]];
[_label setText:_lastNumber];
[_lastNumber release];
}

}

Call.m file calling this below method .

status = pjsua_call_make_call(acc_id, &pj_uri, 0, NULL, NULL, call_id);
if (status != PJ_SUCCESS)
{
pjsua_perror(THIS_FILE, "Error making call", status);
}

Answer
static void on_call_media_state(pjsua_call_id call_id)
{
    pjsua_call_info ci;
  SiphonApplication *app = (SiphonApplication *)[SiphonApplication sharedApplication];

    pjsua_call_get_info(call_id, &ci);
//    PJ_LOG(3,(THIS_FILE,"on_call_media_state status %d count %d",
//      ci.media_status
//      pjmedia_conf_get_connect_count()));

  /* FIXME: Stop ringback */
  sip_ring_stop([app pjsipConfig]); 

  /* Connect ports appropriately when media status is ACTIVE or REMOTE HOLD,
   * otherwise we should NOT connect the ports.
   */
  if (ci.media_status == PJSUA_CALL_MEDIA_ACTIVE ||
      ci.media_status == PJSUA_CALL_MEDIA_REMOTE_HOLD) 
  {
    // When media is active, connect call to sound device.
    pjsua_conf_connect(ci.conf_slot, 0);
    pjsua_conf_connect(0, ci.conf_slot);

    //pjsua_conf_adjust_rx_level(0, 3.0);
    //pjsua_conf_adjust_tx_level(0, 5.0);
  }


    if (ci.media_status == PJSUA_CALL_MEDIA_ACTIVE) { //    When media is active, connect call to sound device.
        pjsua_conf_port_id slotOne = ci.conf_slot;
        //        pjsua_conf_connect(slotOne, 0);
        //        pjsua_conf_connect(0, slotOne);
        //mergeCalls=true;


        int max=pjsua_call_get_count();
        if (max==2) {
            mergeCalls=true;
        }

        if (mergeCalls == true) {
            pjsua_conf_port_id slotTwo = pjsua_call_get_conf_port(activeCallID);
            pjsua_conf_connect(slotOne, slotTwo);
            pjsua_conf_connect(slotTwo, slotOne);

            // since the "activeCallID" is already  talking, its conf_port is already connected to "0" (and vice versa) ...

        } else {
            activeCallID = call_id;
        }
    } else if (ci.media_status == PJSUA_CALL_MEDIA_LOCAL_HOLD) {
        // … callSuspended(callID);
    }

}