Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
c727b985
提交
c727b985
authored
7月 30, 2015
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7908 FS-7092 refactor #comment test
上级
ab7f83c6
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
90 行增加
和
28 行删除
+90
-28
switch_core_media.h
src/include/switch_core_media.h
+2
-0
switch_core_media.c
src/switch_core_media.c
+88
-28
没有找到文件。
src/include/switch_core_media.h
浏览文件 @
c727b985
...
@@ -141,6 +141,8 @@ typedef struct switch_core_media_params_s {
...
@@ -141,6 +141,8 @@ typedef struct switch_core_media_params_s {
switch_payload_t
te
;
switch_payload_t
te
;
switch_payload_t
recv_te
;
switch_payload_t
recv_te
;
unsigned
long
te_rate
;
unsigned
long
cng_rate
;
char
*
adv_sdp_audio_ip
;
char
*
adv_sdp_audio_ip
;
...
...
src/switch_core_media.c
浏览文件 @
c727b985
...
@@ -185,6 +185,8 @@ struct switch_media_handle_s {
...
@@ -185,6 +185,8 @@ struct switch_media_handle_s {
const
switch_codec_implementation_t
*
negotiated_codecs
[
SWITCH_MAX_CODECS
];
const
switch_codec_implementation_t
*
negotiated_codecs
[
SWITCH_MAX_CODECS
];
int
num_negotiated_codecs
;
int
num_negotiated_codecs
;
switch_payload_t
ianacodes
[
SWITCH_MAX_CODECS
];
switch_payload_t
ianacodes
[
SWITCH_MAX_CODECS
];
switch_payload_t
dtmf_ianacodes
[
SWITCH_MAX_CODECS
];
switch_payload_t
cng_ianacodes
[
SWITCH_MAX_CODECS
];
char
*
fmtps
[
SWITCH_MAX_CODECS
];
char
*
fmtps
[
SWITCH_MAX_CODECS
];
int
video_count
;
int
video_count
;
...
@@ -3514,6 +3516,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
...
@@ -3514,6 +3516,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
uint8_t
match
=
0
;
uint8_t
match
=
0
;
uint8_t
vmatch
=
0
;
uint8_t
vmatch
=
0
;
switch_payload_t
best_te
=
0
,
te
=
0
,
cng_pt
=
0
;
switch_payload_t
best_te
=
0
,
te
=
0
,
cng_pt
=
0
;
unsigned
long
best_te_rate
=
8000
,
cng_rate
=
8000
;
sdp_media_t
*
m
;
sdp_media_t
*
m
;
sdp_attribute_t
*
attr
;
sdp_attribute_t
*
attr
;
int
ptime
=
0
,
dptime
=
0
,
maxptime
=
0
,
dmaxptime
=
0
;
int
ptime
=
0
,
dptime
=
0
,
maxptime
=
0
,
dmaxptime
=
0
;
...
@@ -3996,7 +3999,8 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
...
@@ -3996,7 +3999,8 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
if
(
!
strcasecmp
(
rm_encoding
,
"telephone-event"
))
{
if
(
!
strcasecmp
(
rm_encoding
,
"telephone-event"
))
{
if
(
!
best_te
||
map
->
rm_rate
==
a_engine
->
cur_payload_map
->
rm_rate
)
{
if
(
!
best_te
||
map
->
rm_rate
==
a_engine
->
cur_payload_map
->
rm_rate
)
{
best_te
=
(
switch_payload_t
)
map
->
rm_pt
;
best_te
=
(
switch_payload_t
)
map
->
rm_pt
;
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Set telephone-event payload to %u
\n
"
,
best_te
);
best_te_rate
=
map
->
rm_rate
;
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Set telephone-event payload to %u@%ld
\n
"
,
best_te
,
best_te_rate
);
}
}
continue
;
continue
;
}
}
...
@@ -4327,7 +4331,46 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
...
@@ -4327,7 +4331,46 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
match
=
0
;
match
=
0
;
}
}
}
}
for
(
map
=
m
->
m_rtpmaps
;
map
;
map
=
map
->
rm_next
)
{
const
char
*
rm_encoding
;
if
(
!
(
rm_encoding
=
map
->
rm_encoding
))
{
rm_encoding
=
""
;
}
if
(
!
strcasecmp
(
rm_encoding
,
"telephone-event"
))
{
if
(
!
best_te
||
map
->
rm_rate
==
a_engine
->
cur_payload_map
->
rm_rate
)
{
best_te
=
(
switch_payload_t
)
map
->
rm_pt
;
best_te_rate
=
map
->
rm_rate
;
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Set telephone-event payload to %u@%lu
\n
"
,
best_te
,
best_te_rate
);
}
continue
;
}
if
(
!
switch_media_handle_test_media_flag
(
smh
,
SCMF_SUPPRESS_CNG
)
&&
!
strcasecmp
(
rm_encoding
,
"CN"
))
{
if
(
!
cng_pt
||
map
->
rm_rate
==
a_engine
->
cur_payload_map
->
rm_rate
)
{
cng_pt
=
(
switch_payload_t
)
map
->
rm_pt
;
cng_rate
=
map
->
rm_rate
;
if
(
a_engine
->
rtp_session
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Set comfort noise payload to %u@%lu
\n
"
,
cng_pt
,
cng_rate
);
switch_rtp_set_cng_pt
(
a_engine
->
rtp_session
,
smh
->
mparams
->
cng_pt
);
}
}
continue
;
}
}
if
(
cng_rate
!=
a_engine
->
cur_payload_map
->
rm_rate
)
{
cng_rate
=
8000
;
}
if
(
best_te_rate
!=
a_engine
->
cur_payload_map
->
rm_rate
)
{
best_te_rate
=
8000
;
}
if
(
!
best_te
&&
(
switch_media_handle_test_media_flag
(
smh
,
SCMF_LIBERAL_DTMF
)
||
if
(
!
best_te
&&
(
switch_media_handle_test_media_flag
(
smh
,
SCMF_LIBERAL_DTMF
)
||
switch_channel_test_flag
(
session
->
channel
,
CF_LIBERAL_DTMF
)))
{
switch_channel_test_flag
(
session
->
channel
,
CF_LIBERAL_DTMF
)))
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
...
@@ -4347,6 +4390,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
...
@@ -4347,6 +4390,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
}
}
}
else
{
}
else
{
te
=
smh
->
mparams
->
recv_te
=
smh
->
mparams
->
te
=
(
switch_payload_t
)
best_te
;
te
=
smh
->
mparams
->
recv_te
=
smh
->
mparams
->
te
=
(
switch_payload_t
)
best_te
;
smh
->
mparams
->
te_rate
=
best_te_rate
;
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Set 2833 dtmf send/recv payload to %u
\n
"
,
te
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Set 2833 dtmf send/recv payload to %u
\n
"
,
te
);
switch_channel_set_variable
(
session
->
channel
,
"dtmf_type"
,
"rfc2833"
);
switch_channel_set_variable
(
session
->
channel
,
"dtmf_type"
,
"rfc2833"
);
smh
->
mparams
->
dtmf_type
=
DTMF_2833
;
smh
->
mparams
->
dtmf_type
=
DTMF_2833
;
...
@@ -4612,6 +4656,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
...
@@ -4612,6 +4656,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
}
}
smh
->
mparams
->
cng_pt
=
cng_pt
;
smh
->
mparams
->
cng_pt
=
cng_pt
;
smh
->
mparams
->
cng_rate
=
cng_rate
;
return
match
;
return
match
;
}
}
...
@@ -6701,13 +6746,18 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen,
...
@@ -6701,13 +6746,18 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen,
if
(
smh
->
mparams
->
dtmf_type
==
DTMF_2833
&&
smh
->
mparams
->
te
>
95
)
{
if
(
smh
->
mparams
->
dtmf_type
==
DTMF_2833
&&
smh
->
mparams
->
te
>
95
)
{
int
i
;
int
i
;
for
(
i
=
0
;
i
<
smh
->
num_rates
;
i
++
)
{
for
(
i
=
0
;
i
<
smh
->
num_rates
;
i
++
)
{
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
" %d"
,
smh
->
ianacodes
[
smh
->
mparams
->
num_codecs
+
i
]);
if
(
smh
->
dtmf_ianacodes
[
i
])
{
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
" %d"
,
smh
->
dtmf_ianacodes
[
i
]);
}
if
(
smh
->
cng_ianacodes
[
i
]
&&
!
switch_media_handle_test_media_flag
(
smh
,
SCMF_SUPPRESS_CNG
)
&&
cng_type
&&
use_cng
)
{
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
" %d"
,
smh
->
cng_ianacodes
[
i
]);
}
}
}
}
}
if
(
!
switch_media_handle_test_media_flag
(
smh
,
SCMF_SUPPRESS_CNG
)
&&
cng_type
&&
use_cng
)
{
//
if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && cng_type && use_cng) {
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
" %d"
,
cng_type
);
//
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), " %d", cng_type);
}
//
}
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
"
\n
"
);
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
"
\n
"
);
...
@@ -6787,10 +6837,10 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen,
...
@@ -6787,10 +6837,10 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen,
for
(
i
=
0
;
i
<
smh
->
num_rates
;
i
++
)
{
for
(
i
=
0
;
i
<
smh
->
num_rates
;
i
++
)
{
if
(
switch_channel_test_flag
(
session
->
channel
,
CF_AVPF
))
{
if
(
switch_channel_test_flag
(
session
->
channel
,
CF_AVPF
))
{
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
"a=rtpmap:%d telephone-event/%d
\n
"
,
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
"a=rtpmap:%d telephone-event/%d
\n
"
,
smh
->
ianacodes
[
smh
->
mparams
->
num_codecs
+
i
],
smh
->
rates
[
i
]);
smh
->
dtmf_ianacodes
[
i
],
smh
->
rates
[
i
]);
}
else
{
}
else
{
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
"a=rtpmap:%d telephone-event/%d
\n
a=fmtp:%d 0-16
\n
"
,
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
"a=rtpmap:%d telephone-event/%d
\n
a=fmtp:%d 0-16
\n
"
,
smh
->
ianacodes
[
smh
->
mparams
->
num_codecs
+
i
],
smh
->
rates
[
i
],
smh
->
ianacodes
[
smh
->
mparams
->
num_codecs
+
i
]);
smh
->
dtmf_ianacodes
[
i
],
smh
->
rates
[
i
],
smh
->
dtmf_ianacodes
[
i
]);
}
}
}
}
}
}
...
@@ -6898,9 +6948,15 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen,
...
@@ -6898,9 +6948,15 @@ static void generate_m(switch_core_session_t *session, char *buf, size_t buflen,
//switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=encryption:optional\n");
//switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=encryption:optional\n");
}
}
if
(
!
cng_type
)
{
if
(
cng_type
)
{
//switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=rtpmap:%d CN/8000\n", cng_type);
for
(
i
=
0
;
i
<
smh
->
num_rates
;
i
++
)
{
//} else {
//if (smh->rates[i] == 8000) {
// switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=rtpmap:%d CN/%d\n", cng_type, smh->rates[i]);
//} else {
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
"a=rtpmap:%d CN/%d
\n
"
,
smh
->
cng_ianacodes
[
i
],
smh
->
rates
[
i
]);
//}
}
}
else
{
if
(
switch_media_handle_test_media_flag
(
smh
,
SCMF_SUPPRESS_CNG
))
{
if
(
switch_media_handle_test_media_flag
(
smh
,
SCMF_SUPPRESS_CNG
))
{
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
"a=silenceSupp:off - - - -
\n
"
);
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
"a=silenceSupp:off - - - -
\n
"
);
}
}
...
@@ -7184,22 +7240,24 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
...
@@ -7184,22 +7240,24 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
int
j
;
int
j
;
smh
->
ianacodes
[
i
]
=
smh
->
codecs
[
i
]
->
ianacode
;
smh
->
ianacodes
[
i
]
=
smh
->
codecs
[
i
]
->
ianacode
;
for
(
j
=
0
;
j
<
SWITCH_MAX_CODECS
;
j
++
)
{
if
(
smh
->
codecs
[
i
]
->
codec_type
!=
SWITCH_CODEC_TYPE_AUDIO
)
{
if
(
smh
->
rates
[
j
]
==
0
)
{
continue
;
break
;
}
}
if
(
smh
->
codecs
[
i
]
->
codec_type
!=
SWITCH_CODEC_TYPE_AUDIO
)
{
goto
do_next
;
}
if
(
smh
->
rates
[
j
]
==
smh
->
codecs
[
i
]
->
samples_per_second
)
{
if
(
sdp_type
==
SDP_TYPE_REQUEST
)
{
goto
do_next
;
for
(
j
=
0
;
j
<
SWITCH_MAX_CODECS
;
j
++
)
{
if
(
smh
->
rates
[
j
]
==
0
)
{
break
;
}
if
(
smh
->
rates
[
j
]
==
smh
->
codecs
[
i
]
->
samples_per_second
)
{
goto
do_next
;
}
}
}
smh
->
rates
[
smh
->
num_rates
++
]
=
smh
->
codecs
[
i
]
->
samples_per_second
;
}
}
smh
->
rates
[
smh
->
num_rates
++
]
=
smh
->
codecs
[
i
]
->
samples_per_second
;
do_next
:
do_next
:
continue
;
continue
;
}
}
...
@@ -7258,9 +7316,11 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
...
@@ -7258,9 +7316,11 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
for
(
i
=
0
;
i
<
smh
->
num_rates
;
i
++
)
{
for
(
i
=
0
;
i
<
smh
->
num_rates
;
i
++
)
{
if
(
smh
->
rates
[
i
]
==
8000
||
smh
->
num_rates
==
1
)
{
if
(
smh
->
rates
[
i
]
==
8000
||
smh
->
num_rates
==
1
)
{
smh
->
ianacodes
[
smh
->
mparams
->
num_codecs
+
i
]
=
smh
->
mparams
->
te
;
smh
->
dtmf_ianacodes
[
i
]
=
smh
->
mparams
->
te
;
smh
->
cng_ianacodes
[
i
]
=
smh
->
mparams
->
cng_pt
;
}
else
{
}
else
{
smh
->
ianacodes
[
smh
->
mparams
->
num_codecs
+
i
]
=
(
switch_payload_t
)
smh
->
payload_space
++
;
smh
->
dtmf_ianacodes
[
i
]
=
(
switch_payload_t
)
smh
->
payload_space
++
;
smh
->
cng_ianacodes
[
i
]
=
(
switch_payload_t
)
smh
->
payload_space
++
;
}
}
}
}
...
@@ -7442,17 +7502,17 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
...
@@ -7442,17 +7502,17 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
if
(
switch_channel_test_flag
(
session
->
channel
,
CF_AVPF
))
{
if
(
switch_channel_test_flag
(
session
->
channel
,
CF_AVPF
))
{
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
"a=rtpmap:%d telephone-event/%d
\n
"
,
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
"a=rtpmap:%d telephone-event/%d
\n
"
,
smh
->
mparams
->
te
,
rate
);
smh
->
mparams
->
te
,
smh
->
mparams
->
te_
rate
);
}
else
{
}
else
{
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
"a=rtpmap:%d telephone-event/%d
\n
a=fmtp:%d 0-16
\n
"
,
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
"a=rtpmap:%d telephone-event/%d
\n
a=fmtp:%d 0-16
\n
"
,
smh
->
mparams
->
te
,
rate
,
smh
->
mparams
->
te
);
smh
->
mparams
->
te
,
smh
->
mparams
->
te_
rate
,
smh
->
mparams
->
te
);
}
}
}
}
if
(
switch_media_handle_test_media_flag
(
smh
,
SCMF_SUPPRESS_CNG
))
{
if
(
switch_media_handle_test_media_flag
(
smh
,
SCMF_SUPPRESS_CNG
))
{
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
"a=silenceSupp:off - - - -
\n
"
);
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
"a=silenceSupp:off - - - -
\n
"
);
}
else
if
(
smh
->
mparams
->
cng_pt
&&
use_cng
)
{
}
else
if
(
smh
->
mparams
->
cng_pt
&&
use_cng
)
{
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
"a=rtpmap:%d CN/
8000
\n
"
,
smh
->
mparams
->
cng_pt
);
switch_snprintf
(
buf
+
strlen
(
buf
),
SDPBUFLEN
-
strlen
(
buf
),
"a=rtpmap:%d CN/
%lu
\n
"
,
smh
->
mparams
->
cng_pt
,
smh
->
mparams
->
cng_rate
);
if
(
!
a_engine
->
codec_negotiated
)
{
if
(
!
a_engine
->
codec_negotiated
)
{
smh
->
mparams
->
cng_pt
=
0
;
smh
->
mparams
->
cng_pt
=
0
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论