如何在ios

时间:2018-01-11 13:08:13

标签: ios pjsip

使用正常工作的pjsip实现音频通话但不能正常工作。

我应用了以下更改:

// Sip init

pj_status_t sip_startup(app_config_t *app_config) 
{

pjsua_config cfg;
pjsua_config_default (&cfg);

cfg.cb.on_incoming_call = &on_incoming_call;
cfg.cb.on_call_media_state = &on_call_media_state;
cfg.cb.on_call_state = &on_call_state;
cfg.cb.on_reg_state2 = &on_reg_state2;
cfg.cb.on_call_media_event = &on_call_media_event;

// Init the logging config structure
pjsua_logging_config log_cfg;
pjsua_logging_config_default(&log_cfg);
log_cfg.console_level = 4;

// Init PJ Media
pjsua_media_config me_cfg;
pjsua_media_config_default(&me_cfg);


// Init the pjsua
status = pjsua_init(&cfg, &log_cfg, &me_cfg);
if (status != PJ_SUCCESS) error_exit("Error in pjsua_init()", status);

}

//在应用sip连接时添加以下代码

pjsua_call_setting _call_setting;
 pjsua_call_setting_default(&_call_setting);

_call_setting.aud_cnt = 1;
_call_setting.vid_cnt = 1;

//当应用程序中的通话按钮调用此功能进行视频通话时。

pj_status_t sip_dial(pjsua_acc_id acc_id, const char *number, 
 pjsua_call_id *call_id)
{
    pj_status_t status;
    pj_str_t uri = pj_str(destUri);

     status = pjsua_call_make_call(_acc_id, &uri, &(_call_setting), 
     NULL, NULL, NULL);
     if (status != PJ_SUCCESS) 
     error_exit("Error making call",  status);
}

//应用与视频代码相关的更改

static void on_call_media_state(pjsua_call_id call_id)
{
   pjsua_call_info ci;

   unsigned mi;

    pjsua_call_get_info(call_id, &ci);
    sip_ring_stop([SharedAppDelegate.aVoipManager pjsipConfig]);

    if(ci.media_status == PJMEDIA_TYPE_VIDEO)
    {
       NSLog(@"windows id : %d",ci.media[mi].stream.vid.win_in);
       NSLog(@"media id : %d",mi);
       if (ci.media_status != PJSUA_CALL_MEDIA_ACTIVE)
         return;
         [[XCPjsua sharedXCPjsua] 
         displayWindow:ci.media[mi].stream.vid.win_in];

    }
}

我应用了以上代码但未使用pjsip进行视频通话。

任何人都有与视频通话相关的想法或步骤,请帮助我。

谢谢

1 个答案:

答案 0 :(得分:1)

This subject is too large, I think you need to refine your questions to a smaller more specific question if you wish to get a good answer.

Make sure you have read and understood the pjsip video support: PJSip Video_Users_Guide PJSIP IOS Video Support

I would look for what other people have done (even if it's on another platform, e.g. Android, Windows, etc.) and the look into the pjsip pjsua sample which I believe has video support but I'm not sure if it support ios video.

Get a known good examples of pjsip video calls going so you know that it looks like and what the logs look like when it works.

Then try against your ios code against the known good example clients to see where they differ. If you can't figure it out at least you should have enough info to be able to ask a more specific question about a specific situation that is not working for you.