-
liblinphone
实现电话拨
打及接听<
/p>
分
类
:
voip
2012-03-12 14:48
831
人
阅读
评论
(0)
收藏
举报
示范了通
过调
用
liblinphone
拨
打
电话<
/p>
的
过
程,原程序
/nongnu/linphone/docs/liblinphone/group
__basic__call__t
代
码
中增加了接听部分
[cpp]
view
plaincopyprint?
1.
/*
2.
* linphone-
call.c
3.
*
liblinphone
拨
打示例
4.
* */
5.
#include
6.
#include
7.
8.
static bool_t
running=TRUE;
9.
static void stop(int signum){
10.
running=FALSE;
11.
}
12.
13.
/*
14.
*
定
义
回
调
函数,用于
获
取
拨
打
电话过
程状
态
通知
15.
*/
16.
static void
call_state_changed(LinphoneCore *lc, LinphoneCall
*call, Linp
honeCallState cstate, const
char *msg){
17.
printf(
18.
switch(cstate){
19.
case
LinphoneCallIncomingReceived:
20.
printf(
21.
char s = getchar();
22.
if(s == 'y')
23.
{
24.
printf(
25.
linphone_core_accept_call(lc, call);
//
接听
电
话
26.
}
27.
else {
28.
printf(
29.
linphone_core_terminate_call(lc, call);
30.
}
31.
break;
32.
default:
33.
printf(
34.
}
35.
}
36.
37.
/*
38.
*
主函数
39.
*/
40.
int main(int
argc, char *argv[]){
41.
LinphoneCoreVTable vtable={0};
42.
LinphoneCore *lc;
43.
LinphoneCall *call=NULL;
44.
const
char *dest=NULL;
45.
46.
/*
命令行参数目的地址,如
sip:name@192.168.1.1*/
47.
if
(argc>1){
48.
dest=argv[1];
49.
}
50.
51.
signal(SIGINT,stop); //
获
取
Ctrl-C
信号,
以
结
束程序
52.
53.
/* 1.
用回
调
函数表
LinphoneCoreVTable
,
实
< br>例化一个
LinphoneCore
对
< br>像。
54.
* LinphoneCoreVTable
中所有
项
都是可
选
< br>的,
这
里
仅仅设
置了
call_state_changed
,用于<
/p>
获
取
拨
打
时
的状
态
通知。
p>
55.
*/
56.
_state_changed=call_state_changed;
57.
58.
lc=linphone_core_new(&vtable,NULL,NULL,NULL);
59.
60.
61.
/*
62.
*
2.
拨
打
电话
63.
*
*/
64.
if (dest){
65.
66.
call=linphone_core_invite(lc,dest);
67.
if (call==NULL){
68.
printf(
69.
goto end;
70.
}else printf(
71.
//linphone_call_ref(call); //
增加
call
的引用
计
数,<
/p>
72.
}
73.
/*
74.
* 3.
接收通知的主循
环
,
调
用
linphone_core_itera
te
函数完成后台
处
理
工作
75.
*/
76.
while(running){
77.
linphone_core_iterate(lc);
-
-
-
-
-
-
-
-
-
上一篇:基于linphone实现视频通话小结
下一篇:四年级上册四字词语及日积月累