Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
7fab1047
提交
7fab1047
authored
3月 03, 2015
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7500: block overlapping writes
上级
9a7eb47f
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
28 行增加
和
10 行删除
+28
-10
switch_core_media.c
src/switch_core_media.c
+28
-10
没有找到文件。
src/switch_core_media.c
浏览文件 @
7fab1047
...
...
@@ -147,7 +147,7 @@ typedef struct switch_rtp_engine_s {
struct
media_helper
mh
;
switch_thread_t
*
media_thread
;
switch_mutex_t
*
read_mutex
[
2
];
uint8_t
reset_codec
;
uint8_t
codec_negotiated
;
...
...
@@ -167,7 +167,8 @@ struct switch_media_handle_s {
switch_core_media_flag_t
media_flags
[
SCMF_MAX
];
smh_flag_t
flags
;
switch_rtp_engine_t
engines
[
SWITCH_MEDIA_TYPE_TOTAL
];
switch_mutex_t
*
read_mutex
[
2
];
switch_mutex_t
*
write_mutex
[
2
];
char
*
codec_order
[
SWITCH_MAX_CODECS
];
int
codec_order_last
;
const
switch_codec_implementation_t
*
codecs
[
SWITCH_MAX_CODECS
];
...
...
@@ -1893,14 +1894,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_lock_unlock(switch_core_s
}
if
(
lock
)
{
if
(
engine
->
read_mutex
[
type
]
&&
switch_mutex_trylock
(
engine
->
read_mutex
[
type
])
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
smh
->
read_mutex
[
type
]
&&
switch_mutex_trylock
(
smh
->
read_mutex
[
type
])
!=
SWITCH_STATUS_SUCCESS
)
{
/* return CNG, another thread is already reading */
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG1
,
"%s is already being read for %s
\n
"
,
switch_channel_get_name
(
session
->
channel
),
type2str
(
type
));
return
SWITCH_STATUS_INUSE
;
}
}
else
{
switch_mutex_unlock
(
engine
->
read_mutex
[
type
]);
switch_mutex_unlock
(
smh
->
read_mutex
[
type
]);
}
return
SWITCH_STATUS_SUCCESS
;
...
...
@@ -1940,7 +1941,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session
return
SWITCH_STATUS_FALSE
;
}
if
(
engine
->
read_mutex
[
type
]
&&
switch_mutex_trylock
(
engine
->
read_mutex
[
type
])
!=
SWITCH_STATUS_SUCCESS
)
{
if
(
smh
->
read_mutex
[
type
]
&&
switch_mutex_trylock
(
smh
->
read_mutex
[
type
])
!=
SWITCH_STATUS_SUCCESS
)
{
/* return CNG, another thread is already reading */
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG1
,
"%s is already being read for %s
\n
"
,
switch_channel_get_name
(
session
->
channel
),
type2str
(
type
));
...
...
@@ -2288,8 +2289,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session
end
:
if
(
engine
->
read_mutex
[
type
])
{
switch_mutex_unlock
(
engine
->
read_mutex
[
type
]);
if
(
smh
->
read_mutex
[
type
])
{
switch_mutex_unlock
(
smh
->
read_mutex
[
type
]);
}
return
status
;
...
...
@@ -4812,7 +4813,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_start_video_thread(switch_co
switch_thread_cond_create
(
&
v_engine
->
mh
.
cond
,
pool
);
switch_mutex_init
(
&
v_engine
->
mh
.
cond_mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
switch_mutex_init
(
&
v_engine
->
mh
.
file_mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
switch_mutex_init
(
&
v_engine
->
read_mutex
[
SWITCH_MEDIA_TYPE_VIDEO
],
SWITCH_MUTEX_NESTED
,
pool
);
switch_mutex_init
(
&
smh
->
read_mutex
[
SWITCH_MEDIA_TYPE_VIDEO
],
SWITCH_MUTEX_NESTED
,
pool
);
switch_mutex_init
(
&
smh
->
write_mutex
[
SWITCH_MEDIA_TYPE_VIDEO
],
SWITCH_MUTEX_NESTED
,
pool
);
switch_thread_create
(
&
v_engine
->
media_thread
,
thd_attr
,
video_helper_thread
,
&
v_engine
->
mh
,
switch_core_session_get_pool
(
session
));
return
SWITCH_STATUS_SUCCESS
;
...
...
@@ -5695,7 +5697,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
uint8_t
inb
=
switch_channel_direction
(
session
->
channel
)
==
SWITCH_CALL_DIRECTION_INBOUND
;
const
char
*
ssrc
;
switch_mutex_init
(
&
a_engine
->
read_mutex
[
SWITCH_MEDIA_TYPE_AUDIO
],
SWITCH_MUTEX_NESTED
,
switch_core_session_get_pool
(
session
));
switch_mutex_init
(
&
smh
->
read_mutex
[
SWITCH_MEDIA_TYPE_AUDIO
],
SWITCH_MUTEX_NESTED
,
switch_core_session_get_pool
(
session
));
switch_mutex_init
(
&
smh
->
write_mutex
[
SWITCH_MEDIA_TYPE_AUDIO
],
SWITCH_MUTEX_NESTED
,
switch_core_session_get_pool
(
session
));
//switch_core_media_set_rtp_session(session, SWITCH_MEDIA_TYPE_AUDIO, a_engine->rtp_session);
...
...
@@ -10017,6 +10020,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
switch_image_t
*
img
=
frame
->
img
;
switch_status_t
encode_status
;
switch_frame_t
write_frame
=
{
0
};
//switch_rtp_engine_t *v_engine;
switch_assert
(
session
);
...
...
@@ -10041,6 +10045,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
return
SWITCH_STATUS_SUCCESS
;
}
//v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
if
(
smh
->
write_mutex
[
SWITCH_MEDIA_TYPE_VIDEO
]
&&
switch_mutex_lock
(
smh
->
write_mutex
[
SWITCH_MEDIA_TYPE_VIDEO
])
!=
SWITCH_STATUS_SUCCESS
)
{
/* return CNG, another thread is already writing */
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG1
,
"%s is already being written to for %s
\n
"
,
switch_channel_get_name
(
session
->
channel
),
type2str
(
SWITCH_MEDIA_TYPE_VIDEO
));
return
SWITCH_STATUS_INUSE
;
}
if
(
!
smh
->
video_init
&&
smh
->
mparams
->
video_key_first
&&
(
now
-
smh
->
video_last_key_time
)
>
smh
->
mparams
->
video_key_first
)
{
switch_core_media_gen_key_frame
(
session
);
...
...
@@ -10057,7 +10069,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
}
if
(
!
img
)
{
return
switch_core_session_write_encoded_video_frame
(
session
,
frame
,
flags
,
stream_id
);
switch_status_t
vstatus
=
switch_core_session_write_encoded_video_frame
(
session
,
frame
,
flags
,
stream_id
);
switch_goto_status
(
vstatus
,
done
);
}
write_frame
=
*
frame
;
...
...
@@ -10100,6 +10113,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
}
while
(
status
==
SWITCH_STATUS_SUCCESS
&&
encode_status
==
SWITCH_STATUS_MORE_DATA
);
done
:
if
(
smh
->
write_mutex
[
SWITCH_MEDIA_TYPE_VIDEO
])
{
switch_mutex_unlock
(
smh
->
write_mutex
[
SWITCH_MEDIA_TYPE_VIDEO
]);
}
return
status
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论