memset(&vTable, 0, sizeof(vTable));
vTable.global_state_changed = CLinphoneProxyConfig::global_state_changed;
vTable.registration_state_changed = CLinphoneProxyConfig::registration_state_changed;
vTable.call_state_changed = CLinphoneProxyConfig::call_state_changed;
vTable.auth_info_requested = CLinphoneProxyConfig::auth_info_requested;
vTable.dtmf_received = CLinphoneProxyConfig::dtmf_received;
vTable.call_encryption_changed = CLinphoneProxyConfig::call_encryption_changed;
vTable.call_stats_updated = CLinphoneProxyConfig::call_stats_updated;
vTable.message_received = CLinphoneProxyConfig::message_received;
vTable.is_composing_received = CLinphoneProxyConfig::composing_received;
vTable.file_transfer_progress_indication = CLinphoneProxyConfig::file_transfer_progress_indication;
vTable.log_collection_upload_progress_indication = CLinphoneProxyConfig::log_collection_upload_progress_indication;
vTable.log_collection_upload_state_changed = CLinphoneProxyConfig::log_collection_upload_state_changed;
vTable.text_received = CLinphoneProxyConfig::MessageReach;
CString path;
GetModuleFileName(NULL, path.GetBufferSetLength(MAX_PATH + 1), MAX_PATH);
path.ReleaseBuffer();
int nPos;
nPos = path.ReverseFind('\\');
path = path.Left(nPos);
path += "\\ini\\libsipua2.ini";
config_file = (char*)path.GetString();
factoryConfig = (char*)path.GetString();
the_core = linphone_core_new(&vTable
, config_file
, factoryConfig
, NULL);
linphone_core_set_playback_gain_db(the_core, 1.0);
{//摄像头列表
const char **video_devices = linphone_core_get_video_devices(the_core);
const char *curdev = linphone_core_get_video_device(the_core);
const char *dev = NULL;
int i = 0;
int selected = -1;
CString strCurdev(curdev);
for (; dev = video_devices[i]; i++) {
CString tmp = CString(dev);
//mCamera.AddString(tmp);
if (curdev && strlen(curdev) && strCurdev == tmp)
{
selected = i;
linphone_core_set_video_device(the_core, dev);
}
}
//mCamera.SetCurSel(selected);
}
//设置本地视频窗口
int i = 1;
linphone_core_set_native_video_window_id(the_core, &i);
m_running = true;
DWORD dwThread;
if (the_core)
{
HANDLE hThread = CreateThread(NULL, 0, IterateThreadProc, NULL, 0, &dwThread);
if (hThread == INVALID_HANDLE_VALUE)
{
CloseHandle(hThread);
return;
}
CloseHandle(hThread);
}
/****************************/
while (run)
{
//该处在挂电话时,可能会挂掉;原因是linphone内部已经释放了core ;再次释放挂掉,
//可以修改 内部代码;/sleep > 300 毫秒
linphone_core_iterate(the_core);
Sleep(30);
}
return 0;