Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
078d9632
提交
078d9632
authored
12月 23, 2012
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MILESTONE: all the crap out of tech_pvt and sofia in general related to media shit
上级
85308861
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
158 行增加
和
282 行删除
+158
-282
switch_core_media.h
src/include/switch_core_media.h
+7
-6
mod_sofia.h
src/mod/endpoints/mod_sofia/mod_sofia.h
+2
-185
sofia.c
src/mod/endpoints/mod_sofia/sofia.c
+2
-2
sofia_media.c
src/mod/endpoints/mod_sofia/sofia_media.c
+0
-63
switch_core_media.c
src/switch_core_media.c
+147
-26
没有找到文件。
src/include/switch_core_media.h
浏览文件 @
078d9632
...
...
@@ -134,14 +134,14 @@ typedef struct switch_core_media_params_s {
switch_mutex_t
*
mutex
;
switch_payload_t
te
;
//x:tp
switch_payload_t
recv_te
;
//x:tp
switch_payload_t
te
;
switch_payload_t
recv_te
;
char
*
adv_sdp_audio_ip
;
int
num_codecs
;
//x:tp
int
hold_laps
;
//x:tp
switch_core_media_dtmf_t
dtmf_type
;
//x:tp
int
num_codecs
;
int
hold_laps
;
switch_core_media_dtmf_t
dtmf_type
;
}
switch_core_media_params_t
;
...
...
@@ -238,7 +238,8 @@ SWITCH_DECLARE(switch_rtp_stats_t *) switch_core_media_get_stats(switch_core_ses
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_DECLARE
(
void
)
switch_core_media_check_outgoing_proxy
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
switch_status_t
)
switch_core_media_codec_chosen
(
switch_core_session_t
*
session
,
switch_media_type_t
media
);
SWITCH_END_EXTERN_C
#endif
...
...
src/mod/endpoints/mod_sofia/mod_sofia.h
浏览文件 @
078d9632
...
...
@@ -667,164 +667,19 @@ struct sofia_profile {
switch_core_media_vflag_t
vflags
;
};
#if 0
struct private_object {
sofia_private_t *sofia_private;
uint8_t flags[TFLAG_MAX];
// switch_payload_t agreed_pt;
// switch_payload_t audio_recv_pt;
// switch_payload_t video_recv_pt;
switch_core_session_t *session;
switch_channel_t *channel;
switch_media_handle_t *media_handle;
switch_core_media_params_t mparams;
//switch_frame_t read_frame;
char *codec_order[SWITCH_MAX_CODECS];
//int codec_order_last;
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
const switch_codec_implementation_t *negotiated_codecs[SWITCH_MAX_CODECS];
//int num_negotiated_codecs;
//switch_codec_t read_codec;
//switch_codec_t write_codec;
//uint32_t codec_ms;
// uint32_t bitrate;
switch_caller_profile_t *caller_profile;
//uint32_t timestamp_send;
// switch_rtp_t *rtp_session;
// uint32_t video_ssrc;
sofia_profile_t *profile;
char *reply_contact;
char *from_uri;
char *to_uri;
char *from_address;
char *to_address;
char *callid;
char *contact_url;
char *from_str;
char *rpid;
char *asserted_id;
char *preferred_id;
char *privacy;
char *gateway_from_str;
char *rm_encoding;
char *iananame;
char *rm_fmtp;
char *fmtp_out;
char *dest;
char *dest_to;
char *key;
char *xferto;
char *kick;
char *origin;
char *hash_key;
char *chat_from;
char *chat_to;
char *e_dest;
char *call_id;
char *invite_contact;
char *local_url;
char *gateway_name;
char *record_route;
char *route_uri;
char *x_freeswitch_support_remote;
char *x_freeswitch_support_local;
char *last_sent_callee_id_name;
char *last_sent_callee_id_number;
//unsigned long rm_rate;
//switch_payload_t pt;
switch_mutex_t *flag_mutex;
switch_mutex_t *sofia_mutex;
////switch_payload_t te;
////switch_payload_t recv_te;
//switch_payload_t bte;
//switch_payload_t cng_pt;
//switch_payload_t bcng_pt;
sofia_transport_t transport;
nua_handle_t *nh;
nua_handle_t *nh2;
sip_contact_t *contact;
//uint32_t max_missed_packets;
//uint32_t max_missed_hold_packets;
/** VIDEO **/
// 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_port_t adv_sdp_video_port;
// switch_port_t local_sdp_video_port;
// char *video_rm_encoding;
// switch_payload_t video_pt;
// unsigned long video_rm_rate;
// uint32_t video_codec_ms;
// char *video_rm_fmtp;
// switch_payload_t video_agreed_pt;
// char *video_fmtp_out;
// uint32_t video_count;
//switch_core_media_dtmf_t dtmf_type;
int q850_cause;
int got_bye;
//int hold_laps;
switch_thread_id_t locker;
//switch_size_t last_ts;
//uint32_t check_frames;
//uint32_t mismatch_count;
//uint32_t last_codec_ms;
//uint8_t codec_reinvites;
nua_event_t want_event;
switch_rtp_bug_flag_t rtp_bugs;
// switch_rtp_bug_flag_t video_rtp_bugs;
//switch_codec_implementation_t read_impl;
//switch_codec_implementation_t write_impl;
char *user_via;
char *redirected;
sofia_cid_type_t cid_type;
switch_payload_t payload_space;
switch_payload_t ianacodes[SWITCH_MAX_CODECS];
uint32_t session_timeout;
enum nua_session_refresher session_refresher;
char *respond_phrase;
int respond_code;
char *respond_dest;
};
#else
struct
private_object
{
sofia_private_t
*
sofia_private
;
uint8_t
flags
[
TFLAG_MAX
];
switch_payload_t
agreed_pt
;
switch_payload_t
audio_recv_pt
;
switch_payload_t
video_recv_pt
;
switch_core_session_t
*
session
;
switch_channel_t
*
channel
;
switch_media_handle_t
*
media_handle
;
switch_core_media_params_t
mparams
;
switch_frame_t
read_frame
;
char
*
codec_order
[
SWITCH_MAX_CODECS
];
int
codec_order_last
;
const
switch_codec_implementation_t
*
codecs
[
SWITCH_MAX_CODECS
];
const
switch_codec_implementation_t
*
negotiated_codecs
[
SWITCH_MAX_CODECS
];
int
num_negotiated_codecs
;
switch_codec_t
read_codec
;
switch_codec_t
write_codec
;
uint32_t
codec_ms
;
uint32_t
bitrate
;
switch_caller_profile_t
*
caller_profile
;
uint32_t
timestamp_send
;
switch_rtp_t
*
rtp_session
;
uint32_t
video_ssrc
;
sofia_profile_t
*
profile
;
char
*
reply_contact
;
char
*
from_uri
;
char
*
to_uri
;
char
*
from_address
;
char
*
to_address
;
char
*
callid
;
char
*
contact_url
;
char
*
from_str
;
...
...
@@ -833,14 +688,9 @@ struct private_object {
char
*
preferred_id
;
char
*
privacy
;
char
*
gateway_from_str
;
char
*
rm_encoding
;
char
*
iananame
;
char
*
rm_fmtp
;
char
*
fmtp_out
;
char
*
dest
;
char
*
dest_to
;
char
*
key
;
char
*
xferto
;
char
*
kick
;
char
*
origin
;
char
*
hash_key
;
...
...
@@ -857,9 +707,6 @@ struct private_object {
char
*
x_freeswitch_support_local
;
char
*
last_sent_callee_id_name
;
char
*
last_sent_callee_id_number
;
unsigned
long
rm_rate
;
switch_payload_t
pt
;
switch_mutex_t
*
flag_mutex
;
switch_mutex_t
*
sofia_mutex
;
switch_payload_t
te
;
...
...
@@ -871,50 +718,20 @@ struct private_object {
nua_handle_t
*
nh
;
nua_handle_t
*
nh2
;
sip_contact_t
*
contact
;
uint32_t
max_missed_packets
;
uint32_t
max_missed_hold_packets
;
/** VIDEO **/
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_port_t
adv_sdp_video_port
;
switch_port_t
local_sdp_video_port
;
char
*
video_rm_encoding
;
switch_payload_t
video_pt
;
unsigned
long
video_rm_rate
;
uint32_t
video_codec_ms
;
char
*
video_rm_fmtp
;
switch_payload_t
video_agreed_pt
;
char
*
video_fmtp_out
;
uint32_t
video_count
;
switch_core_media_dtmf_t
dtmf_type
;
int
q850_cause
;
int
got_bye
;
int
hold_laps
;
switch_thread_id_t
locker
;
switch_size_t
last_ts
;
uint32_t
check_frames
;
uint32_t
mismatch_count
;
uint32_t
last_codec_ms
;
uint8_t
codec_reinvites
;
nua_event_t
want_event
;
switch_rtp_bug_flag_t
rtp_bugs
;
switch_rtp_bug_flag_t
video_rtp_bugs
;
switch_codec_implementation_t
read_impl
;
switch_codec_implementation_t
write_impl
;
char
*
user_via
;
char
*
redirected
;
sofia_cid_type_t
cid_type
;
switch_payload_t
payload_space
;
switch_payload_t
ianacodes
[
SWITCH_MAX_CODECS
];
uint32_t
session_timeout
;
enum
nua_session_refresher
session_refresher
;
char
*
respond_phrase
;
int
respond_code
;
char
*
respond_dest
;
};
#endif
struct
callback_t
{
char
*
val
;
...
...
@@ -1252,7 +1069,7 @@ switch_bool_t sofia_glue_profile_exists(const char *key);
void
sofia_glue_global_siptrace
(
switch_bool_t
on
);
void
sofia_glue_global_capture
(
switch_bool_t
on
);
void
sofia_glue_global_watchdog
(
switch_bool_t
on
);
void
sofia_media_proxy_codec
(
switch_core_session_t
*
session
,
const
char
*
r_sdp
);
void
sofia_glue_build_vid_refresh_message
(
switch_core_session_t
*
session
,
const
char
*
pl
);
char
*
sofia_glue_gen_contact_str
(
sofia_profile_t
*
profile
,
sip_t
const
*
sip
,
nua_handle_t
*
nh
,
sofia_dispatch_event_t
*
de
,
sofia_nat_parse_t
*
np
);
void
sofia_glue_pause_jitterbuffer
(
switch_core_session_t
*
session
,
switch_bool_t
on
);
...
...
src/mod/endpoints/mod_sofia/sofia.c
浏览文件 @
078d9632
...
...
@@ -4920,11 +4920,11 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
sip->sip_payload && sip->sip_payload->pl_data && !strcasecmp(tech_pvt->iananame, "PROXY")) {
switch_core_session_t *other_session;
s
ofia
_media_proxy_codec(session, sip->sip_payload->pl_data);
s
witch_core
_media_proxy_codec(session, sip->sip_payload->pl_data);
if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
if (switch_core_session_compare(session, other_session)) {
s
ofia
_media_proxy_codec(other_session, sip->sip_payload->pl_data);
s
witch_core
_media_proxy_codec(other_session, sip->sip_payload->pl_data);
}
switch_core_session_rwunlock(other_session);
}
...
...
src/mod/endpoints/mod_sofia/sofia_media.c
浏览文件 @
078d9632
...
...
@@ -34,69 +34,6 @@
void
sofia_media_proxy_codec
(
switch_core_session_t
*
session
,
const
char
*
r_sdp
)
{
sdp_media_t
*
m
;
sdp_parser_t
*
parser
=
NULL
;
sdp_session_t
*
sdp
;
private_object_t
*
tech_pvt
=
switch_core_session_get_private
(
session
);
sdp_attribute_t
*
attr
;
int
ptime
=
0
,
dptime
=
0
;
if
(
!
(
parser
=
sdp_parse
(
NULL
,
r_sdp
,
(
int
)
strlen
(
r_sdp
),
0
)))
{
return
;
}
if
(
!
(
sdp
=
sdp_session
(
parser
)))
{
sdp_parser_free
(
parser
);
return
;
}
switch_assert
(
tech_pvt
!=
NULL
);
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
);
}
}
for
(
m
=
sdp
->
sdp_media
;
m
;
m
=
m
->
m_next
)
{
ptime
=
dptime
;
//maxptime = dmaxptime;
if
(
m
->
m_proto
==
sdp_proto_rtp
)
{
sdp_rtpmap_t
*
map
;
for
(
attr
=
m
->
m_attributes
;
attr
;
attr
=
attr
->
a_next
)
{
if
(
!
strcasecmp
(
attr
->
a_name
,
"ptime"
)
&&
attr
->
a_value
)
{
ptime
=
atoi
(
attr
->
a_value
);
}
else
if
(
!
strcasecmp
(
attr
->
a_name
,
"maxptime"
)
&&
attr
->
a_value
)
{
//maxptime = atoi(attr->a_value);
}
}
for
(
map
=
m
->
m_rtpmaps
;
map
;
map
=
map
->
rm_next
)
{
tech_pvt
->
iananame
=
switch_core_session_strdup
(
tech_pvt
->
session
,
map
->
rm_encoding
);
tech_pvt
->
rm_rate
=
map
->
rm_rate
;
tech_pvt
->
codec_ms
=
ptime
;
switch_core_media_set_codec
(
tech_pvt
->
session
,
0
,
tech_pvt
->
profile
->
codec_flags
);
break
;
}
break
;
}
}
sdp_parser_free
(
parser
);
}
uint8_t
sofia_media_negotiate_sdp
(
switch_core_session_t
*
session
,
const
char
*
r_sdp
)
{
uint8_t
t
,
p
=
0
;
...
...
src/switch_core_media.c
浏览文件 @
078d9632
...
...
@@ -95,22 +95,22 @@ typedef struct switch_rtp_engine_s {
switch_secure_settings_t
ssec
;
switch_media_type_t
type
;
switch_rtp_t
*
rtp_session
;
//x:tp
switch_frame_t
read_frame
;
//x:tp
switch_codec_t
read_codec
;
//x:tp
switch_codec_t
write_codec
;
//x:tp
switch_codec_implementation_t
read_impl
;
//x:tp
switch_codec_implementation_t
write_impl
;
//x:tp
uint32_t
codec_ms
;
//x:tp
switch_size_t
last_ts
;
//x:tp
uint32_t
check_frames
;
//x:tp
uint32_t
mismatch_count
;
//x:tp
uint32_t
last_codec_ms
;
//x:tp
uint8_t
codec_reinvites
;
//x:tp
uint32_t
max_missed_packets
;
//x:tp
uint32_t
max_missed_hold_packets
;
//x:tp
switch_rtp_t
*
rtp_session
;
switch_frame_t
read_frame
;
switch_codec_t
read_codec
;
switch_codec_t
write_codec
;
switch_codec_implementation_t
read_impl
;
switch_codec_implementation_t
write_impl
;
uint32_t
codec_ms
;
switch_size_t
last_ts
;
uint32_t
check_frames
;
uint32_t
mismatch_count
;
uint32_t
last_codec_ms
;
uint8_t
codec_reinvites
;
uint32_t
max_missed_packets
;
uint32_t
max_missed_hold_packets
;
uint32_t
ssrc
;
switch_rtp_bug_flag_t
rtp_bugs
;
...
...
@@ -133,19 +133,19 @@ struct switch_media_handle_s {
smh_flag_t
flags
;
switch_rtp_engine_t
engines
[
SWITCH_MEDIA_TYPE_TOTAL
];
char
*
codec_order
[
SWITCH_MAX_CODECS
];
//x:tp
int
codec_order_last
;
//x:tp
const
switch_codec_implementation_t
*
codecs
[
SWITCH_MAX_CODECS
];
//x:tp
char
*
codec_order
[
SWITCH_MAX_CODECS
];
int
codec_order_last
;
const
switch_codec_implementation_t
*
codecs
[
SWITCH_MAX_CODECS
];
int
payload_space
;
//x:tp
char
*
origin
;
//x:tp
int
payload_space
;
char
*
origin
;
switch_payload_t
cng_pt
;
//x:tp
switch_payload_t
cng_pt
;
const
switch_codec_implementation_t
*
negotiated_codecs
[
SWITCH_MAX_CODECS
];
//x:tp
int
num_negotiated_codecs
;
//x:tp
switch_payload_t
ianacodes
[
SWITCH_MAX_CODECS
];
//x:tp
int
video_count
;
//x:tp
const
switch_codec_implementation_t
*
negotiated_codecs
[
SWITCH_MAX_CODECS
];
int
num_negotiated_codecs
;
switch_payload_t
ianacodes
[
SWITCH_MAX_CODECS
];
int
video_count
;
uint32_t
owner_id
;
uint32_t
session_id
;
...
...
@@ -5730,6 +5730,127 @@ SWITCH_DECLARE(void) switch_core_media_set_r_sdp_codec_string(switch_core_sessio
}
}
//?
SWITCH_DECLARE
(
switch_status_t
)
switch_core_media_codec_chosen
(
switch_core_session_t
*
session
,
switch_media_type_t
type
)
{
switch_rtp_engine_t
*
engine
;
switch_media_handle_t
*
smh
;
if
(
!
(
smh
=
session
->
media_handle
))
{
return
SWITCH_STATUS_FALSE
;
}
engine
=
&
smh
->
engines
[
type
];
if
(
engine
->
codec_params
.
iananame
)
{
return
SWITCH_STATUS_SUCCESS
;
}
return
SWITCH_STATUS_FALSE
;
}
//?
SWITCH_DECLARE
(
void
)
switch_core_media_check_outgoing_proxy
(
switch_core_session_t
*
session
)
{
switch_rtp_engine_t
*
a_engine
,
*
v_engine
;
switch_media_handle_t
*
smh
;
if
(
!
(
smh
=
session
->
media_handle
))
{
return
;
}
a_engine
=
&
smh
->
engines
[
SWITCH_MEDIA_TYPE_AUDIO
];
v_engine
=
&
smh
->
engines
[
SWITCH_MEDIA_TYPE_VIDEO
];
a_engine
->
codec_params
.
iananame
=
switch_core_session_strdup
(
session
,
"PROXY"
);
a_engine
->
codec_params
.
rm_rate
=
8000
;
a_engine
->
codec_params
.
codec_ms
=
20
;
if
(
switch_channel_test_flag
(
session
->
channel
,
CF_PROXY_MEDIA
))
{
const
char
*
r_sdp
=
switch_channel_get_variable
(
session
->
channel
,
SWITCH_R_SDP_VARIABLE
);
if
(
switch_stristr
(
"m=video"
,
r_sdp
))
{
switch_core_media_choose_port
(
session
,
SWITCH_MEDIA_TYPE_VIDEO
,
1
);
v_engine
->
codec_params
.
rm_encoding
=
"PROXY-VID"
;
v_engine
->
codec_params
.
rm_rate
=
90000
;
v_engine
->
codec_params
.
codec_ms
=
0
;
switch_channel_set_flag
(
session
->
channel
,
CF_VIDEO
);
switch_channel_set_flag
(
session
->
channel
,
CF_VIDEO_POSSIBLE
);
}
}
}
//?
SWITCH_DECLARE
(
void
)
switch_core_media_proxy_codec
(
switch_core_session_t
*
session
,
const
char
*
r_sdp
)
{
sdp_media_t
*
m
;
sdp_parser_t
*
parser
=
NULL
;
sdp_session_t
*
sdp
;
sdp_attribute_t
*
attr
;
int
ptime
=
0
,
dptime
=
0
;
switch_rtp_engine_t
*
a_engine
;
switch_media_handle_t
*
smh
;
if
(
!
(
smh
=
session
->
media_handle
))
{
return
;
}
a_engine
=
&
smh
->
engines
[
SWITCH_MEDIA_TYPE_AUDIO
];
if
(
!
(
parser
=
sdp_parse
(
NULL
,
r_sdp
,
(
int
)
strlen
(
r_sdp
),
0
)))
{
return
;
}
if
(
!
(
sdp
=
sdp_session
(
parser
)))
{
sdp_parser_free
(
parser
);
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
);
}
}
for
(
m
=
sdp
->
sdp_media
;
m
;
m
=
m
->
m_next
)
{
ptime
=
dptime
;
//maxptime = dmaxptime;
if
(
m
->
m_proto
==
sdp_proto_rtp
)
{
sdp_rtpmap_t
*
map
;
for
(
attr
=
m
->
m_attributes
;
attr
;
attr
=
attr
->
a_next
)
{
if
(
!
strcasecmp
(
attr
->
a_name
,
"ptime"
)
&&
attr
->
a_value
)
{
ptime
=
atoi
(
attr
->
a_value
);
}
else
if
(
!
strcasecmp
(
attr
->
a_name
,
"maxptime"
)
&&
attr
->
a_value
)
{
//maxptime = atoi(attr->a_value);
}
}
for
(
map
=
m
->
m_rtpmaps
;
map
;
map
=
map
->
rm_next
)
{
a_engine
->
codec_params
.
iananame
=
switch_core_session_strdup
(
session
,
map
->
rm_encoding
);
a_engine
->
codec_params
.
rm_rate
=
map
->
rm_rate
;
a_engine
->
codec_params
.
codec_ms
=
ptime
;
switch_core_media_set_codec
(
session
,
0
,
smh
->
mparams
->
codec_flags
);
break
;
}
break
;
}
}
sdp_parser_free
(
parser
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论