Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
fd7bf0ea
提交
fd7bf0ea
authored
4月 15, 2006
作者:
Michael Jerris
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@1171
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
c69c7416
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
201 行增加
和
136 行删除
+201
-136
libdingaling.c
libs/libdingaling/src/libdingaling.c
+6
-2
mod_dingaling.c
src/mod/endpoints/mod_dingaling/mod_dingaling.c
+193
-132
switch_rtp.c
src/switch_rtp.c
+2
-2
没有找到文件。
libs/libdingaling/src/libdingaling.c
浏览文件 @
fd7bf0ea
...
...
@@ -237,6 +237,7 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from,
ldl_session_t
*
session
=
NULL
;
ldl_signal_t
signal
=
LDL_SIGNAL_NONE
;
char
*
initiator
=
iks_find_attrib
(
xml
,
"initiator"
);
char
*
msg
=
NULL
;
if
(
!
(
session
=
apr_hash_get
(
handle
->
sessions
,
id
,
APR_HASH_KEY_STRING
)))
{
ldl_session_create
(
&
session
,
handle
,
id
,
from
,
initiator
);
...
...
@@ -261,10 +262,13 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from,
iks
*
tag
;
if
(
type
)
{
if
(
!
strcasecmp
(
type
,
"initiate"
)
||
!
strcasecmp
(
type
,
"accept"
))
{
signal
=
LDL_SIGNAL_INITIATE
;
if
(
!
strcasecmp
(
type
,
"accept"
))
{
msg
=
"accept"
;
}
if
(
!
session
->
initiator
&&
initiator
)
{
session
->
initiator
=
apr_pstrdup
(
session
->
pool
,
initiator
);
}
...
...
@@ -382,7 +386,7 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from,
}
if
(
handle
->
session_callback
&&
signal
)
{
handle
->
session_callback
(
handle
,
session
,
signal
,
NULL
);
handle
->
session_callback
(
handle
,
session
,
signal
,
msg
);
}
return
LDL_STATUS_SUCCESS
;
...
...
src/mod/endpoints/mod_dingaling/mod_dingaling.c
浏览文件 @
fd7bf0ea
...
...
@@ -49,7 +49,8 @@ typedef enum {
TFLAG_VOICE
=
(
1
<<
6
),
TFLAG_RTP_READY
=
(
1
<<
7
),
TFLAG_CODEC_READY
=
(
1
<<
8
),
TFLAG_INIT
=
(
1
<<
9
),
TFLAG_TRANSPORT
=
(
1
<<
9
),
TFLAG_ANSWER
=
(
1
<<
10
),
}
TFLAGS
;
typedef
enum
{
...
...
@@ -105,6 +106,7 @@ struct private_object {
switch_port_t
local_port
;
switch_port_t
remote_port
;
char
local_user
[
17
];
char
local_pass
[
17
];
char
*
remote_user
;
unsigned
int
cand_id
;
unsigned
int
desc_id
;
...
...
@@ -123,7 +125,7 @@ struct private_object {
uint32_t
last_read
;
char
*
codec_name
;
uint8_t
codec_num
;
switch_time_t
last_cand
;
switch_time_t
next_desc
;
switch_time_t
next_cand
;
char
*
stun_ip
;
uint16_t
stun_port
;
...
...
@@ -218,89 +220,87 @@ static void handle_thread_launch(ldl_handle_t *handle)
}
static
void
*
SWITCH_THREAD_FUNC
negotiate_thread_run
(
switch_thread
*
thread
,
void
*
obj
)
static
int
activate_rtp
(
struct
private_object
*
tech_pvt
)
{
switch_core_session
*
session
=
obj
;
switch_channel
*
channel
;
struct
private_object
*
tech_pvt
=
NULL
;
switch_time_t
started
;
switch_time_t
now
;
unsigned
int
elapsed
;
tech_pvt
=
switch_core_session_get_private
(
session
);
assert
(
tech_pvt
!=
NULL
);
channel
=
switch_core_session_get_channel
(
session
);
assert
(
channel
!=
NULL
);
switch_set_flag
(
tech_pvt
,
TFLAG_IO
);
started
=
switch_time_now
();
switch_channel
*
channel
=
switch_core_session_get_channel
(
tech_pvt
->
session
);
const
char
*
err
;
if
(
tech_pvt
->
rtp_session
)
{
return
0
;
}
if
(
switch_test_flag
(
tech_pvt
,
TFLAG_OUTBOUND
))
{
tech_pvt
->
last_cand
=
switch_time_now
();
tech_pvt
->
next_cand
=
tech_pvt
->
last_cand
;
}
else
{
tech_pvt
->
next_cand
=
tech_pvt
->
last_cand
+
DL_CAND_WAIT
;
if
(
switch_core_codec_init
(
&
tech_pvt
->
read_codec
,
tech_pvt
->
codec_name
,
8000
,
20
,
1
,
SWITCH_CODEC_FLAG_ENCODE
|
SWITCH_CODEC_FLAG_DECODE
,
NULL
,
switch_core_session_get_pool
(
tech_pvt
->
session
))
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Can't load codec?
\n
"
);
switch_channel_hangup
(
channel
);
return
1
;
}
tech_pvt
->
read_frame
.
rate
=
tech_pvt
->
read_codec
.
implementation
->
samples_per_second
;
tech_pvt
->
read_frame
.
codec
=
&
tech_pvt
->
read_codec
;
while
(
!
(
switch_test_flag
(
tech_pvt
,
TFLAG_CODEC_READY
)
&&
switch_test_flag
(
tech_pvt
,
TFLAG_RTP_READY
)
&&
switch_test_flag
(
tech_pvt
,
TFLAG_INIT
)))
{
now
=
switch_time_now
();
elapsed
=
(
unsigned
int
)((
now
-
started
)
/
1000
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Set Read Codec to %s
\n
"
,
tech_pvt
->
codec_name
);
if
(
switch_channel_get_state
(
channel
)
>=
CS_HANGUP
||
switch_test_flag
(
tech_pvt
,
TFLAG_BYE
))
{
return
NULL
;
if
(
switch_core_codec_init
(
&
tech_pvt
->
write_codec
,
tech_pvt
->
codec_name
,
8000
,
20
,
1
,
SWITCH_CODEC_FLAG_ENCODE
|
SWITCH_CODEC_FLAG_DECODE
,
NULL
,
switch_core_session_get_pool
(
tech_pvt
->
session
))
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Can't load codec?
\n
"
);
switch_channel_hangup
(
channel
);
return
-
1
;
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Set Write Codec to %s
\n
"
,
tech_pvt
->
codec_name
);
switch_core_session_set_read_codec
(
tech_pvt
->
session
,
&
tech_pvt
->
read_codec
);
switch_core_session_set_write_codec
(
tech_pvt
->
session
,
&
tech_pvt
->
write_codec
);
if
(
now
>=
tech_pvt
->
next_cand
)
{
ldl_payload_t
payloads
[
5
];
tech_pvt
->
next_cand
+=
DL_CAND_WAIT
;
memset
(
payloads
,
0
,
sizeof
(
payloads
));
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"SETUP RTP %s:%d -> %s:%d
\n
"
,
tech_pvt
->
profile
->
ip
,
tech_pvt
->
local_port
,
tech_pvt
->
remote_ip
,
tech_pvt
->
remote_port
);
if
(
!
switch_test_flag
(
tech_pvt
,
TFLAG_CODEC_READY
))
{
if
(
!
tech_pvt
->
num_codecs
)
{
get_codecs
(
tech_pvt
);
if
(
!
tech_pvt
->
num_codecs
)
{
if
(
!
(
tech_pvt
->
rtp_session
=
switch_rtp_new
(
tech_pvt
->
profile
->
ip
,
tech_pvt
->
local_port
,
tech_pvt
->
remote_ip
,
tech_pvt
->
remote_port
,
tech_pvt
->
codec_num
,
tech_pvt
->
read_codec
.
implementation
->
encoded_bytes_per_frame
,
tech_pvt
->
read_codec
.
implementation
->
microseconds_per_frame
,
SWITCH_RTP_FLAG_USE_TIMER
,
NULL
,
&
err
,
switch_core_session_get_pool
(
tech_pvt
->
session
))))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"RTP ERROR %s
\n
"
,
err
);
switch_channel_hangup
(
channel
);
switch_set_flag
(
tech_pvt
,
TFLAG_BYE
);
switch_clear_flag
(
tech_pvt
,
TFLAG_IO
);
return
NULL
;
}
return
-
1
;
}
switch_rtp_activate_ice
(
tech_pvt
->
rtp_session
,
tech_pvt
->
remote_user
,
tech_pvt
->
local_user
);
if
(
tech_pvt
->
codec_index
<
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Don't have my codec yet here's one
\n
"
);
tech_pvt
->
codec_name
=
tech_pvt
->
codecs
[
0
]
->
iananame
;
tech_pvt
->
codec_num
=
tech_pvt
->
codecs
[
0
]
->
ianacode
;
tech_pvt
->
codec_index
=
0
;
switch_set_flag
(
tech_pvt
,
TFLAG_CODEC_READY
);
return
0
;
}
payloads
[
0
].
name
=
tech_pvt
->
codecs
[
0
]
->
iananame
;
payloads
[
0
].
id
=
tech_pvt
->
codecs
[
0
]
->
ianacode
;
}
else
{
payloads
[
0
].
name
=
tech_pvt
->
codecs
[
tech_pvt
->
codec_index
]
->
iananame
;
payloads
[
0
].
id
=
tech_pvt
->
codecs
[
tech_pvt
->
codec_index
]
->
ianacode
;
}
switch_set_flag
(
tech_pvt
,
TFLAG_CODEC_READY
);
payloads
[
0
].
name
=
tech_pvt
->
codecs
[
0
]
->
iananame
;
payloads
[
0
].
id
=
tech_pvt
->
codecs
[
0
]
->
ianacode
;
tech_pvt
->
desc_id
=
ldl_session_describe
(
tech_pvt
->
dlsession
,
payloads
,
1
,
switch_test_flag
(
tech_pvt
,
TFLAG_OUTBOUND
)
?
LDL_DESCRIPTION_INITIATE
:
LDL_DESCRIPTION_ACCEPT
);
}
if
(
!
switch_test_flag
(
tech_pvt
,
TFLAG_RTP_READY
))
{
static
int
do_candidates
(
struct
private_object
*
tech_pvt
,
int
force
)
{
switch_channel
*
channel
=
switch_core_session_get_channel
(
tech_pvt
->
session
);
assert
(
channel
!=
NULL
);
tech_pvt
->
next_cand
+=
DL_CAND_WAIT
;
if
(
force
||
!
switch_test_flag
(
tech_pvt
,
TFLAG_RTP_READY
))
{
ldl_candidate_t
cand
[
1
];
char
*
advip
=
tech_pvt
->
profile
->
extip
?
tech_pvt
->
profile
->
extip
:
tech_pvt
->
profile
->
ip
;
char
*
err
;
memset
(
cand
,
0
,
sizeof
(
cand
));
switch_stun_random_string
(
tech_pvt
->
local_user
,
16
,
NULL
);
switch_stun_random_string
(
tech_pvt
->
local_pass
,
16
,
NULL
);
cand
[
0
].
port
=
tech_pvt
->
local_port
;
...
...
@@ -316,7 +316,7 @@ static void *SWITCH_THREAD_FUNC negotiate_thread_run(switch_thread *thread, void
if
(
!
stun_ip
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Stun Failed! NO STUN SERVER!
\n
"
);
switch_channel_hangup
(
channel
);
break
;
return
-
1
;
}
cand
[
0
].
address
=
tech_pvt
->
profile
->
ip
;
...
...
@@ -329,7 +329,7 @@ static void *SWITCH_THREAD_FUNC negotiate_thread_run(switch_thread *thread, void
switch_core_session_get_pool
(
tech_pvt
->
session
))
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Stun Failed! %s:%d [%s]
\n
"
,
stun_ip
,
SWITCH_STUN_DEFAULT_PORT
,
err
);
switch_channel_hangup
(
channel
);
break
;
return
-
1
;
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Stun Success %s:%d
\n
"
,
cand
[
0
].
address
,
cand
[
0
].
port
);
}
...
...
@@ -342,87 +342,134 @@ static void *SWITCH_THREAD_FUNC negotiate_thread_run(switch_thread *thread, void
cand
[
0
].
name
=
"rtp"
;
cand
[
0
].
username
=
tech_pvt
->
local_user
;
cand
[
0
].
password
=
tech_pvt
->
local_
user
;
cand
[
0
].
password
=
tech_pvt
->
local_
pass
;
cand
[
0
].
pref
=
1
;
cand
[
0
].
protocol
=
"udp"
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Send Candidate %s:%d [%s]
\n
"
,
cand
[
0
].
address
,
cand
[
0
].
port
,
cand
[
0
].
username
);
tech_pvt
->
cand_id
=
ldl_session_candidates
(
tech_pvt
->
dlsession
,
cand
,
1
);
switch_set_flag
(
tech_pvt
,
TFLAG_RTP_READY
);
}
}
if
(
elapsed
>
60000
)
{
return
0
;
}
static
int
do_describe
(
struct
private_object
*
tech_pvt
,
int
force
)
{
ldl_payload_t
payloads
[
5
];
switch_channel
*
channel
=
switch_core_session_get_channel
(
tech_pvt
->
session
);
assert
(
channel
!=
NULL
);
tech_pvt
->
next_desc
+=
DL_CAND_WAIT
;
memset
(
payloads
,
0
,
sizeof
(
payloads
));
if
(
!
tech_pvt
->
num_codecs
)
{
get_codecs
(
tech_pvt
);
if
(
!
tech_pvt
->
num_codecs
)
{
switch_channel_hangup
(
channel
);
switch_set_flag
(
tech_pvt
,
TFLAG_BYE
);
switch_clear_flag
(
tech_pvt
,
TFLAG_IO
);
return
NULL
;
return
-
1
;
}
if
(
switch_test_flag
(
tech_pvt
,
TFLAG_BYE
)
||
!
switch_test_flag
(
tech_pvt
,
TFLAG_IO
))
{
return
NULL
;
}
switch_yield
(
1000
);
//printf("WAIT %s %d %d %d\n", switch_channel_get_name(channel), switch_test_flag(tech_pvt, TFLAG_INIT), switch_test_flag(tech_pvt, TFLAG_CODEC_READY), switch_test_flag(tech_pvt, TFLAG_RTP_READY));
if
(
force
||
!
switch_test_flag
(
tech_pvt
,
TFLAG_CODEC_READY
))
{
if
(
tech_pvt
->
codec_index
<
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Don't have my codec yet here's one
\n
"
);
tech_pvt
->
codec_name
=
tech_pvt
->
codecs
[
0
]
->
iananame
;
tech_pvt
->
codec_num
=
tech_pvt
->
codecs
[
0
]
->
ianacode
;
tech_pvt
->
codec_index
=
0
;
payloads
[
0
].
name
=
tech_pvt
->
codecs
[
0
]
->
iananame
;
payloads
[
0
].
id
=
tech_pvt
->
codecs
[
0
]
->
ianacode
;
}
else
{
payloads
[
0
].
name
=
tech_pvt
->
codecs
[
tech_pvt
->
codec_index
]
->
iananame
;
payloads
[
0
].
id
=
tech_pvt
->
codecs
[
tech_pvt
->
codec_index
]
->
ianacode
;
}
if
(
switch_channel_get_state
(
channel
)
>=
CS_HANGUP
||
switch_test_flag
(
tech_pvt
,
TFLAG_BYE
))
{
return
NULL
;
payloads
[
0
].
name
=
tech_pvt
->
codecs
[
0
]
->
iananame
;
payloads
[
0
].
id
=
tech_pvt
->
codecs
[
0
]
->
ianacode
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Send Describe [%s]
\n
"
,
payloads
[
0
].
name
);
tech_pvt
->
desc_id
=
ldl_session_describe
(
tech_pvt
->
dlsession
,
payloads
,
1
,
switch_test_flag
(
tech_pvt
,
TFLAG_OUTBOUND
)
?
LDL_DESCRIPTION_INITIATE
:
LDL_DESCRIPTION_ACCEPT
);
switch_set_flag
(
tech_pvt
,
TFLAG_CODEC_READY
);
}
if
(
switch_core_codec_init
(
&
tech_pvt
->
read_codec
,
tech_pvt
->
codec_name
,
8000
,
20
,
1
,
SWITCH_CODEC_FLAG_ENCODE
|
SWITCH_CODEC_FLAG_DECODE
,
NULL
,
switch_core_session_get_pool
(
tech_pvt
->
session
))
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Can't load codec?
\n
"
);
switch_channel_hangup
(
channel
);
return
NULL
;
return
0
;
}
static
void
*
SWITCH_THREAD_FUNC
negotiate_thread_run
(
switch_thread
*
thread
,
void
*
obj
)
{
switch_core_session
*
session
=
obj
;
switch_channel
*
channel
;
struct
private_object
*
tech_pvt
=
NULL
;
switch_time_t
started
;
switch_time_t
now
;
unsigned
int
elapsed
;
tech_pvt
=
switch_core_session_get_private
(
session
);
assert
(
tech_pvt
!=
NULL
);
channel
=
switch_core_session_get_channel
(
session
);
assert
(
channel
!=
NULL
);
switch_set_flag
(
tech_pvt
,
TFLAG_IO
);
started
=
switch_time_now
();
if
(
switch_test_flag
(
tech_pvt
,
TFLAG_OUTBOUND
))
{
tech_pvt
->
next_desc
=
switch_time_now
();
}
else
{
tech_pvt
->
next_cand
=
switch_time_now
()
+
DL_CAND_WAIT
;
tech_pvt
->
next_desc
=
switch_time_now
()
+
DL_CAND_WAIT
;
}
tech_pvt
->
read_frame
.
rate
=
tech_pvt
->
read_codec
.
implementation
->
samples_per_second
;
tech_pvt
->
read_frame
.
codec
=
&
tech_pvt
->
read_codec
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Set Read Codec to %s
\n
"
,
tech_pvt
->
codec_name
);
while
(
!
(
switch_test_flag
(
tech_pvt
,
TFLAG_CODEC_READY
)
&&
switch_test_flag
(
tech_pvt
,
TFLAG_RTP_READY
)
&&
switch_test_flag
(
tech_pvt
,
TFLAG_ANSWER
)
&&
switch_test_flag
(
tech_pvt
,
TFLAG_TRANSPORT
)))
{
now
=
switch_time_now
();
elapsed
=
(
unsigned
int
)((
now
-
started
)
/
1000
);
if
(
switch_core_codec_init
(
&
tech_pvt
->
write_codec
,
tech_pvt
->
codec_name
,
8000
,
20
,
1
,
SWITCH_CODEC_FLAG_ENCODE
|
SWITCH_CODEC_FLAG_DECODE
,
NULL
,
switch_core_session_get_pool
(
tech_pvt
->
session
))
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Can't load codec?
\n
"
);
switch_channel_hangup
(
channel
);
if
(
switch_channel_get_state
(
channel
)
>=
CS_HANGUP
||
switch_test_flag
(
tech_pvt
,
TFLAG_BYE
))
{
return
NULL
;
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Set Write Codec to %s
\n
"
,
tech_pvt
->
codec_name
);
switch_core_session_set_read_codec
(
session
,
&
tech_pvt
->
read_codec
);
switch_core_session_set_write_codec
(
session
,
&
tech_pvt
->
write_codec
);
if
(
!
tech_pvt
->
rtp_session
)
{
const
char
*
err
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"SETUP RTP %s:%d -> %s:%d
\n
"
,
tech_pvt
->
profile
->
ip
,
tech_pvt
->
local_port
,
tech_pvt
->
remote_ip
,
tech_pvt
->
remote_port
);
if
(
now
>=
tech_pvt
->
next_desc
)
{
if
(
do_describe
(
tech_pvt
,
0
)
<
0
)
{
break
;
}
}
if
(
!
(
tech_pvt
->
rtp_session
=
switch_rtp_new
(
tech_pvt
->
profile
->
ip
,
tech_pvt
->
local_port
,
tech_pvt
->
remote_ip
,
tech_pvt
->
remote_port
,
tech_pvt
->
codec_num
,
tech_pvt
->
read_codec
.
implementation
->
encoded_bytes_per_frame
,
tech_pvt
->
read_codec
.
implementation
->
microseconds_per_frame
,
SWITCH_RTP_FLAG_USE_TIMER
,
NULL
,
&
err
,
switch_core_session_get_pool
(
tech_pvt
->
session
))))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"RTP ERROR %s
\n
"
,
err
);
if
(
tech_pvt
->
next_cand
&&
now
>=
tech_pvt
->
next_cand
)
{
if
(
do_candidates
(
tech_pvt
,
0
)
<
0
)
{
break
;
}
}
if
(
elapsed
>
60000
)
{
switch_channel_hangup
(
channel
);
switch_set_flag
(
tech_pvt
,
TFLAG_BYE
);
switch_clear_flag
(
tech_pvt
,
TFLAG_IO
);
return
NULL
;
}
switch_rtp_activate_ice
(
tech_pvt
->
rtp_session
,
tech_pvt
->
remote_user
,
tech_pvt
->
local_user
);
if
(
switch_test_flag
(
tech_pvt
,
TFLAG_BYE
)
||
!
switch_test_flag
(
tech_pvt
,
TFLAG_IO
))
{
return
NULL
;
}
switch_yield
(
1000
);
//printf("WAIT %s %d %d %d %d\n", switch_channel_get_name(channel), switch_test_flag(tech_pvt, TFLAG_TRANSPORT), switch_test_flag(tech_pvt, TFLAG_CODEC_READY), switch_test_flag(tech_pvt, TFLAG_RTP_READY), switch_test_flag(tech_pvt, TFLAG_ANSWER));
}
if
(
switch_channel_get_state
(
channel
)
>=
CS_HANGUP
||
switch_test_flag
(
tech_pvt
,
TFLAG_BYE
))
{
return
NULL
;
}
//printf("WAIT %s %d\n", switch_channel_get_name(channel), switch_test_flag(tech_pvt, TFLAG_OUTBOUND)
);
activate_rtp
(
tech_pvt
);
if
(
switch_test_flag
(
tech_pvt
,
TFLAG_OUTBOUND
))
{
do_candidates
(
tech_pvt
,
0
);
switch_channel_answer
(
channel
);
//printf("***************************ANSWER\n");
}
else
{
...
...
@@ -966,7 +1013,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
ldl_session_set_private
(
dlsession
,
*
new_session
);
tech_pvt
->
dlsession
=
dlsession
;
get_codecs
(
tech_pvt
);
tech_pvt
->
desc_id
=
ldl_session_describe
(
dlsession
,
NULL
,
0
,
LDL_DESCRIPTION_INITIATE
);
//
tech_pvt->desc_id = ldl_session_describe(dlsession, NULL, 0, LDL_DESCRIPTION_INITIATE);
negotiate_thread_launch
(
*
new_session
);
return
SWITCH_STATUS_SUCCESS
;
...
...
@@ -1181,6 +1228,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
tech_pvt
->
codec_index
=
-
1
;
tech_pvt
->
profile
=
profile
;
tech_pvt
->
local_port
=
switch_rtp_request_port
();
switch_set_flag
(
tech_pvt
,
TFLAG_ANSWER
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Hey where is my memory pool?
\n
"
);
switch_core_session_destroy
(
&
session
);
...
...
@@ -1231,6 +1279,12 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
ldl_payload_t
*
payloads
;
unsigned
int
len
=
0
;
if
(
switch_test_flag
(
tech_pvt
,
TFLAG_OUTBOUND
))
{
if
(
!
strcasecmp
(
msg
,
"accept"
))
{
switch_set_flag
(
tech_pvt
,
TFLAG_ANSWER
);
do_candidates
(
tech_pvt
,
0
);
}
}
if
(
tech_pvt
->
codec_index
>
-
1
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Already decided on a codec
\n
"
);
...
...
@@ -1244,6 +1298,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
}
}
if
(
ldl_session_get_payloads
(
dlsession
,
&
payloads
,
&
len
)
==
LDL_STATUS_SUCCESS
)
{
unsigned
int
x
,
y
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"%u payloads
\n
"
,
len
);
...
...
@@ -1255,13 +1310,17 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Choosing Payload index %u %s %u
\n
"
,
y
,
payloads
[
x
].
name
,
payloads
[
x
].
id
);
tech_pvt
->
codec_name
=
tech_pvt
->
codecs
[
y
]
->
iananame
;
tech_pvt
->
codec_num
=
tech_pvt
->
codecs
[
y
]
->
ianacode
;
switch_set_flag
(
tech_pvt
,
TFLAG_CODEC_READY
);
if
(
!
switch_test_flag
(
tech_pvt
,
TFLAG_OUTBOUND
))
{
do_describe
(
tech_pvt
,
0
);
}
return
LDL_STATUS_SUCCESS
;
}
}
}
}
}
break
;
case
LDL_SIGNAL_CANDIDATES
:
if
(
signal
)
{
...
...
@@ -1301,7 +1360,6 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Acceptable Candidate %s:%d
\n
"
,
candidates
[
x
].
address
,
candidates
[
x
].
port
);
if
(
!
tech_pvt
->
num_codecs
)
{
get_codecs
(
tech_pvt
);
if
(
!
tech_pvt
->
num_codecs
)
{
...
...
@@ -1313,8 +1371,11 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
ldl_session_set_ip
(
dlsession
,
tech_pvt
->
remote_ip
);
tech_pvt
->
remote_port
=
candidates
[
x
].
port
;
tech_pvt
->
remote_user
=
switch_core_session_strdup
(
session
,
candidates
[
x
].
username
);
switch_set_flag
(
tech_pvt
,
TFLAG_INIT
);
tech_pvt
->
next_cand
=
switch_time_now
();
if
(
!
switch_test_flag
(
tech_pvt
,
TFLAG_OUTBOUND
))
{
do_candidates
(
tech_pvt
,
0
);
}
switch_set_flag
(
tech_pvt
,
TFLAG_TRANSPORT
);
return
LDL_STATUS_SUCCESS
;
}
}
...
...
src/switch_rtp.c
浏览文件 @
fd7bf0ea
...
...
@@ -155,8 +155,8 @@ static void handle_ice(switch_rtp *rtp_session, void *data, switch_size_t len)
}
}
while
(
switch_stun_packet_next_attribute
(
attr
));
if
(
packet
->
header
.
type
==
SWITCH_STUN_BINDING_REQUEST
)
{
//
&& !strcmp(rtp_session->user_ice, username)) {
//printf("[%s] [%s] [%s]\n", rtp_session->user_ice, username, !strcmp(rtp_session->user_ice, username) ? "yes" : "no");
if
(
(
packet
->
header
.
type
==
SWITCH_STUN_BINDING_REQUEST
)
&&
!
strcmp
(
rtp_session
->
user_ice
,
username
))
{
uint8_t
buf
[
512
];
switch_stun_packet_t
*
rpacket
;
char
*
remote_ip
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论