Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
85308861
提交
85308861
authored
12月 22, 2012
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
almost rid of crufty tech_pvt members
上级
75c95fa9
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
354 行增加
和
285 行删除
+354
-285
switch_core_media.h
src/include/switch_core_media.h
+8
-0
mod_sofia.h
src/mod/endpoints/mod_sofia/mod_sofia.h
+2
-2
sofia.c
src/mod/endpoints/mod_sofia/sofia.c
+2
-3
sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_glue.c
+1
-1
sofia_media.c
src/mod/endpoints/mod_sofia/sofia_media.c
+0
-263
switch_core_media.c
src/switch_core_media.c
+341
-16
没有找到文件。
src/include/switch_core_media.h
浏览文件 @
85308861
...
...
@@ -141,6 +141,7 @@ typedef struct switch_core_media_params_s {
int
num_codecs
;
//x:tp
int
hold_laps
;
//x:tp
switch_core_media_dtmf_t
dtmf_type
;
//x:tp
}
switch_core_media_params_t
;
...
...
@@ -159,6 +160,7 @@ static inline const char *switch_media_type2str(switch_media_type_t type)
SWITCH_DECLARE
(
switch_status_t
)
switch_media_handle_create
(
switch_media_handle_t
**
smhp
,
switch_core_session_t
*
session
,
switch_core_media_params_t
*
params
);
SWITCH_DECLARE
(
void
)
switch_media_handle_destroy
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
switch_media_handle_t
*
)
switch_core_session_get_media_handle
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
switch_status_t
)
switch_core_session_clear_media_handle
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
switch_status_t
)
switch_core_session_media_handle_ready
(
switch_core_session_t
*
session
);
...
...
@@ -232,6 +234,12 @@ SWITCH_DECLARE(void) switch_core_media_clear_rtp_flag(switch_core_session_t *ses
SWITCH_DECLARE
(
stfu_instance_t
*
)
switch_core_media_get_jb
(
switch_core_session_t
*
session
,
switch_media_type_t
type
);
SWITCH_DECLARE
(
switch_rtp_stats_t
*
)
switch_core_media_get_stats
(
switch_core_session_t
*
session
,
switch_media_type_t
type
,
switch_memory_pool_t
*
pool
);
SWITCH_DECLARE
(
void
)
switch_core_media_set_r_sdp_codec_string
(
switch_core_session_t
*
session
,
const
char
*
codec_string
,
sdp_session_t
*
sdp
);
SWITCH_DECLARE
(
void
)
switch_core_media_set_sdp_codec_string
(
switch_core_session_t
*
session
,
const
char
*
r_sdp
);
SWITCH_DECLARE
(
void
)
switch_core_media_reset_autofix_timing
(
switch_core_session_t
*
session
,
switch_media_type_t
type
);
SWITCH_END_EXTERN_C
#endif
/* For Emacs:
...
...
src/mod/endpoints/mod_sofia/mod_sofia.h
浏览文件 @
85308861
...
...
@@ -692,7 +692,7 @@ struct private_object {
// uint32_t bitrate;
switch_caller_profile_t *caller_profile;
//uint32_t timestamp_send;
switch_rtp_t *rtp_session;
//
switch_rtp_t *rtp_session;
// uint32_t video_ssrc;
sofia_profile_t *profile;
...
...
@@ -753,7 +753,7 @@ struct private_object {
// switch_frame_t video_read_frame;
// switch_codec_t video_read_codec;
// switch_codec_t video_write_codec;
switch_rtp_t *video_rtp_session;
//
switch_rtp_t *video_rtp_session;
// switch_port_t adv_sdp_video_port;
// switch_port_t local_sdp_video_port;
// char *video_rm_encoding;
...
...
src/mod/endpoints/mod_sofia/sofia.c
浏览文件 @
85308861
...
...
@@ -4975,8 +4975,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
sofia_update_callee_id
(
session
,
profile
,
sip
,
SWITCH_FALSE
);
if
(
sofia_test_media_flag
(
tech_pvt
->
profile
,
SCMF_AUTOFIX_TIMING
))
{
tech_pvt
->
check_frames
=
0
;
tech_pvt
->
last_ts
=
0
;
switch_core_media_reset_autofix_timing
(
tech_pvt
->
session
,
SWITCH_MEDIA_TYPE_AUDIO
);
}
}
...
...
@@ -7365,7 +7364,7 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
}
if
(
dtmf
.
digit
)
{
if
(
tech_pvt
->
dtmf_type
==
DTMF_INFO
||
if
(
tech_pvt
->
mparams
.
dtmf_type
==
DTMF_INFO
||
sofia_test_pflag
(
tech_pvt
->
profile
,
PFLAG_LIBERAL_DTMF
)
||
switch_channel_test_flag
(
tech_pvt
->
channel
,
CF_LIBERAL_DTMF
))
{
/* queue it up */
switch_channel_queue_dtmf
(
channel
,
&
dtmf
);
...
...
src/mod/endpoints/mod_sofia/sofia_glue.c
浏览文件 @
85308861
...
...
@@ -107,7 +107,7 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
tech_pvt
->
mparams
.
recv_te
=
tech_pvt
->
mparams
.
te
=
profile
->
te
;
}
tech_pvt
->
dtmf_type
=
tech_pvt
->
profile
->
dtmf_type
;
tech_pvt
->
mparams
.
dtmf_type
=
tech_pvt
->
profile
->
dtmf_type
;
if
(
!
sofia_test_media_flag
(
tech_pvt
->
profile
,
SCMF_SUPPRESS_CNG
))
{
if
(
tech_pvt
->
bcng_pt
)
{
...
...
src/mod/endpoints/mod_sofia/sofia_media.c
浏览文件 @
85308861
...
...
@@ -133,256 +133,6 @@ switch_status_t sofia_media_activate_rtp(private_object_t *tech_pvt)
void
sofia_media_set_sdp_codec_string
(
switch_core_session_t
*
session
,
const
char
*
r_sdp
)
{
sdp_parser_t
*
parser
;
sdp_session_t
*
sdp
;
private_object_t
*
tech_pvt
=
switch_core_session_get_private
(
session
);
if
((
parser
=
sdp_parse
(
NULL
,
r_sdp
,
(
int
)
strlen
(
r_sdp
),
0
)))
{
if
((
sdp
=
sdp_session
(
parser
)))
{
sofia_media_set_r_sdp_codec_string
(
session
,
switch_core_media_get_codec_string
(
tech_pvt
->
session
),
sdp
);
}
sdp_parser_free
(
parser
);
}
}
static
void
add_audio_codec
(
sdp_rtpmap_t
*
map
,
int
ptime
,
char
*
buf
,
switch_size_t
buflen
)
{
int
codec_ms
=
ptime
;
uint32_t
map_bit_rate
=
0
;
char
ptstr
[
20
]
=
""
;
char
ratestr
[
20
]
=
""
;
char
bitstr
[
20
]
=
""
;
switch_codec_fmtp_t
codec_fmtp
=
{
0
};
if
(
!
codec_ms
)
{
codec_ms
=
switch_default_ptime
(
map
->
rm_encoding
,
map
->
rm_pt
);
}
map_bit_rate
=
switch_known_bitrate
((
switch_payload_t
)
map
->
rm_pt
);
if
(
!
ptime
&&
!
strcasecmp
(
map
->
rm_encoding
,
"g723"
))
{
ptime
=
codec_ms
=
30
;
}
if
(
zstr
(
map
->
rm_fmtp
))
{
if
(
!
strcasecmp
(
map
->
rm_encoding
,
"ilbc"
))
{
ptime
=
codec_ms
=
30
;
map_bit_rate
=
13330
;
}
}
else
{
if
((
switch_core_codec_parse_fmtp
(
map
->
rm_encoding
,
map
->
rm_fmtp
,
map
->
rm_rate
,
&
codec_fmtp
))
==
SWITCH_STATUS_SUCCESS
)
{
if
(
codec_fmtp
.
bits_per_second
)
{
map_bit_rate
=
codec_fmtp
.
bits_per_second
;
}
if
(
codec_fmtp
.
microseconds_per_packet
)
{
codec_ms
=
(
codec_fmtp
.
microseconds_per_packet
/
1000
);
}
}
}
if
(
map
->
rm_rate
)
{
switch_snprintf
(
ratestr
,
sizeof
(
ratestr
),
"@%uh"
,
(
unsigned
int
)
map
->
rm_rate
);
}
if
(
codec_ms
)
{
switch_snprintf
(
ptstr
,
sizeof
(
ptstr
),
"@%di"
,
codec_ms
);
}
if
(
map_bit_rate
)
{
switch_snprintf
(
bitstr
,
sizeof
(
bitstr
),
"@%db"
,
map_bit_rate
);
}
switch_snprintf
(
buf
+
strlen
(
buf
),
buflen
-
strlen
(
buf
),
",%s%s%s%s"
,
map
->
rm_encoding
,
ratestr
,
ptstr
,
bitstr
);
}
void
sofia_media_set_r_sdp_codec_string
(
switch_core_session_t
*
session
,
const
char
*
codec_string
,
sdp_session_t
*
sdp
)
{
char
buf
[
1024
]
=
{
0
};
sdp_media_t
*
m
;
sdp_attribute_t
*
attr
;
int
ptime
=
0
,
dptime
=
0
;
sdp_connection_t
*
connection
;
sdp_rtpmap_t
*
map
;
short
int
match
=
0
;
int
i
;
int
already_did
[
128
]
=
{
0
};
int
num_codecs
=
0
;
char
*
codec_order
[
SWITCH_MAX_CODECS
];
const
switch_codec_implementation_t
*
codecs
[
SWITCH_MAX_CODECS
]
=
{
0
};
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
private_object_t
*
tech_pvt
=
switch_core_session_get_private
(
session
);
int
prefer_sdp
=
0
;
const
char
*
var
;
if
((
var
=
switch_channel_get_variable
(
channel
,
"ep_codec_prefer_sdp"
))
&&
switch_true
(
var
))
{
prefer_sdp
=
1
;
}
if
(
!
zstr
(
codec_string
))
{
char
*
tmp_codec_string
;
if
((
tmp_codec_string
=
strdup
(
codec_string
)))
{
num_codecs
=
switch_separate_string
(
tmp_codec_string
,
','
,
codec_order
,
SWITCH_MAX_CODECS
);
num_codecs
=
switch_loadable_module_get_codecs_sorted
(
codecs
,
SWITCH_MAX_CODECS
,
codec_order
,
num_codecs
);
switch_safe_free
(
tmp_codec_string
);
}
}
else
{
num_codecs
=
switch_loadable_module_get_codecs
(
codecs
,
SWITCH_MAX_CODECS
);
}
if
(
!
channel
||
!
num_codecs
)
{
return
;
}
for
(
attr
=
sdp
->
sdp_attributes
;
attr
;
attr
=
attr
->
a_next
)
{
if
(
zstr
(
attr
->
a_name
))
{
continue
;
}
if
(
!
strcasecmp
(
attr
->
a_name
,
"ptime"
))
{
dptime
=
atoi
(
attr
->
a_value
);
break
;
}
}
switch_core_media_find_zrtp_hash
(
session
,
sdp
);
switch_core_media_pass_zrtp_hash
(
session
);
for
(
m
=
sdp
->
sdp_media
;
m
;
m
=
m
->
m_next
)
{
ptime
=
dptime
;
if
(
m
->
m_type
==
sdp_media_image
&&
m
->
m_port
)
{
switch_snprintf
(
buf
+
strlen
(
buf
),
sizeof
(
buf
)
-
strlen
(
buf
),
",t38"
);
}
else
if
(
m
->
m_type
==
sdp_media_audio
&&
m
->
m_port
)
{
for
(
attr
=
m
->
m_attributes
;
attr
;
attr
=
attr
->
a_next
)
{
if
(
zstr
(
attr
->
a_name
))
{
continue
;
}
if
(
!
strcasecmp
(
attr
->
a_name
,
"ptime"
)
&&
attr
->
a_value
)
{
ptime
=
atoi
(
attr
->
a_value
);
break
;
}
}
connection
=
sdp
->
sdp_connection
;
if
(
m
->
m_connections
)
{
connection
=
m
->
m_connections
;
}
if
(
!
connection
)
{
switch_log_printf
(
SWITCH_CHANNEL_CHANNEL_LOG
(
channel
),
SWITCH_LOG_ERROR
,
"Cannot find a c= line in the sdp at media or session level!
\n
"
);
break
;
}
if
(
switch_channel_direction
(
channel
)
==
SWITCH_CALL_DIRECTION_INBOUND
||
prefer_sdp
)
{
for
(
map
=
m
->
m_rtpmaps
;
map
;
map
=
map
->
rm_next
)
{
if
(
map
->
rm_pt
>
127
||
already_did
[
map
->
rm_pt
])
{
continue
;
}
for
(
i
=
0
;
i
<
num_codecs
;
i
++
)
{
const
switch_codec_implementation_t
*
imp
=
codecs
[
i
];
if
((
zstr
(
map
->
rm_encoding
)
||
(
tech_pvt
->
profile
->
ndlb
&
SM_NDLB_ALLOW_BAD_IANANAME
))
&&
map
->
rm_pt
<
96
)
{
match
=
(
map
->
rm_pt
==
imp
->
ianacode
)
?
1
:
0
;
}
else
{
if
(
map
->
rm_encoding
)
{
match
=
strcasecmp
(
map
->
rm_encoding
,
imp
->
iananame
)
?
0
:
1
;
}
else
{
match
=
0
;
}
}
if
(
match
)
{
add_audio_codec
(
map
,
ptime
,
buf
,
sizeof
(
buf
));
break
;
}
}
}
}
else
{
for
(
i
=
0
;
i
<
num_codecs
;
i
++
)
{
const
switch_codec_implementation_t
*
imp
=
codecs
[
i
];
if
(
imp
->
codec_type
!=
SWITCH_CODEC_TYPE_AUDIO
||
imp
->
ianacode
>
127
||
already_did
[
imp
->
ianacode
])
{
continue
;
}
for
(
map
=
m
->
m_rtpmaps
;
map
;
map
=
map
->
rm_next
)
{
if
(
map
->
rm_pt
>
127
||
already_did
[
map
->
rm_pt
])
{
continue
;
}
if
((
zstr
(
map
->
rm_encoding
)
||
(
tech_pvt
->
profile
->
ndlb
&
SM_NDLB_ALLOW_BAD_IANANAME
))
&&
map
->
rm_pt
<
96
)
{
match
=
(
map
->
rm_pt
==
imp
->
ianacode
)
?
1
:
0
;
}
else
{
if
(
map
->
rm_encoding
)
{
match
=
strcasecmp
(
map
->
rm_encoding
,
imp
->
iananame
)
?
0
:
1
;
}
else
{
match
=
0
;
}
}
if
(
match
)
{
add_audio_codec
(
map
,
ptime
,
buf
,
sizeof
(
buf
));
break
;
}
}
}
}
}
else
if
(
m
->
m_type
==
sdp_media_video
&&
m
->
m_port
)
{
connection
=
sdp
->
sdp_connection
;
if
(
m
->
m_connections
)
{
connection
=
m
->
m_connections
;
}
if
(
!
connection
)
{
switch_log_printf
(
SWITCH_CHANNEL_CHANNEL_LOG
(
channel
),
SWITCH_LOG_ERROR
,
"Cannot find a c= line in the sdp at media or session level!
\n
"
);
break
;
}
for
(
i
=
0
;
i
<
num_codecs
;
i
++
)
{
const
switch_codec_implementation_t
*
imp
=
codecs
[
i
];
if
(
imp
->
codec_type
!=
SWITCH_CODEC_TYPE_VIDEO
||
imp
->
ianacode
>
127
||
already_did
[
imp
->
ianacode
])
{
continue
;
}
for
(
map
=
m
->
m_rtpmaps
;
map
;
map
=
map
->
rm_next
)
{
if
(
map
->
rm_pt
>
127
||
already_did
[
map
->
rm_pt
])
{
continue
;
}
if
((
zstr
(
map
->
rm_encoding
)
||
(
tech_pvt
->
profile
->
ndlb
&
SM_NDLB_ALLOW_BAD_IANANAME
))
&&
map
->
rm_pt
<
96
)
{
match
=
(
map
->
rm_pt
==
imp
->
ianacode
)
?
1
:
0
;
}
else
{
if
(
map
->
rm_encoding
)
{
match
=
strcasecmp
(
map
->
rm_encoding
,
imp
->
iananame
)
?
0
:
1
;
}
else
{
match
=
0
;
}
}
if
(
match
)
{
if
(
ptime
>
0
)
{
switch_snprintf
(
buf
+
strlen
(
buf
),
sizeof
(
buf
)
-
strlen
(
buf
),
",%s@%uh@%di"
,
imp
->
iananame
,
(
unsigned
int
)
map
->
rm_rate
,
ptime
);
}
else
{
switch_snprintf
(
buf
+
strlen
(
buf
),
sizeof
(
buf
)
-
strlen
(
buf
),
",%s@%uh"
,
imp
->
iananame
,
(
unsigned
int
)
map
->
rm_rate
);
}
already_did
[
imp
->
ianacode
]
=
1
;
break
;
}
}
}
}
}
if
(
buf
[
0
]
==
','
)
{
switch_channel_set_variable
(
channel
,
"ep_codec_string"
,
buf
+
1
);
}
}
switch_status_t
sofia_media_tech_media
(
private_object_t
*
tech_pvt
,
const
char
*
r_sdp
)
{
uint8_t
match
=
0
;
...
...
@@ -412,19 +162,6 @@ switch_status_t sofia_media_tech_media(private_object_t *tech_pvt, const char *r
}
void
sofia_media_deactivate_rtp
(
private_object_t
*
tech_pvt
)
{
int
loops
=
0
;
while
(
loops
<
10
&&
(
sofia_test_flag
(
tech_pvt
,
TFLAG_READING
)
||
sofia_test_flag
(
tech_pvt
,
TFLAG_WRITING
)))
{
switch_yield
(
10000
);
loops
++
;
}
switch_core_media_deactivate_rtp
(
tech_pvt
->
session
);
}
char
*
sofia_media_get_multipart
(
switch_core_session_t
*
session
,
const
char
*
prefix
,
const
char
*
sdp
,
char
**
mp_type
)
{
char
*
extra_headers
=
NULL
;
...
...
src/switch_core_media.c
浏览文件 @
85308861
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论