Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
62d42821
提交
62d42821
authored
12月 02, 2014
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7500: improvement for conf vid
上级
82b2c18f
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
80 行增加
和
15 行删除
+80
-15
switch_core_media.h
src/include/switch_core_media.h
+5
-0
mod_conference.c
src/mod/applications/mod_conference/mod_conference.c
+21
-6
mod_vpx.c
src/mod/codecs/mod_vpx/mod_vpx.c
+9
-9
switch_core_media.c
src/switch_core_media.c
+45
-0
没有找到文件。
src/include/switch_core_media.h
浏览文件 @
62d42821
...
@@ -314,6 +314,11 @@ SWITCH_DECLARE(void) switch_core_media_end_video_function(switch_core_session_t
...
@@ -314,6 +314,11 @@ SWITCH_DECLARE(void) switch_core_media_end_video_function(switch_core_session_t
SWITCH_DECLARE
(
switch_status_t
)
switch_core_session_start_video_thread
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
switch_status_t
)
switch_core_session_start_video_thread
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
int
)
switch_core_media_check_video_function
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
int
)
switch_core_media_check_video_function
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
void
)
switch_core_session_video_reinit
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
void
)
switch_core_session_video_reinit
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
switch_status_t
)
switch_core_media_read_lock_unlock
(
switch_core_session_t
*
session
,
switch_media_type_t
type
,
switch_bool_t
lock
);
#define switch_core_media_read_lock(_s, _t) switch_core_media_read_lock_unlock(_s, _t, SWITCH_TRUE)
#define switch_core_media_read_unlock(_s, _t) switch_core_media_read_lock_unlock(_s, _t, SWITCH_FALSE)
SWITCH_END_EXTERN_C
SWITCH_END_EXTERN_C
#endif
#endif
...
...
src/mod/applications/mod_conference/mod_conference.c
浏览文件 @
62d42821
...
@@ -2922,13 +2922,17 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr
...
@@ -2922,13 +2922,17 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr
int
want_refresh
=
0
;
int
want_refresh
=
0
;
int
yield
=
0
;
int
yield
=
0
;
switch_core_session_t
*
session
;
switch_core_session_t
*
session
;
char
buf
[
65536
];
//
char buf[65536];
conference_member_t
*
floor_holder
=
NULL
;
conference_member_t
*
floor_holder
=
NULL
;
int
locked
=
0
;
conference
->
video_running
=
1
;
conference
->
video_running
=
1
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Video thread started for conference %s
\n
"
,
conference
->
name
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Video thread started for conference %s
\n
"
,
conference
->
name
);
while
(
conference
->
video_running
==
1
&&
globals
.
running
&&
!
switch_test_flag
(
conference
,
CFLAG_DESTRUCT
))
{
while
(
conference
->
video_running
==
1
&&
globals
.
running
&&
!
switch_test_flag
(
conference
,
CFLAG_DESTRUCT
))
{
locked
=
0
;
session
=
NULL
;
if
(
yield
)
{
if
(
yield
)
{
switch_yield
(
yield
);
switch_yield
(
yield
);
yield
=
0
;
yield
=
0
;
...
@@ -2957,10 +2961,15 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr
...
@@ -2957,10 +2961,15 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr
if
((
status
=
switch_core_session_read_lock
(
session
))
==
SWITCH_STATUS_SUCCESS
)
{
if
((
status
=
switch_core_session_read_lock
(
session
))
==
SWITCH_STATUS_SUCCESS
)
{
switch_mutex_unlock
(
conference
->
mutex
);
switch_mutex_unlock
(
conference
->
mutex
);
if
(
!
switch_channel_ready
(
switch_core_session_get_channel
(
session
)))
{
if
((
switch_core_media_read_lock
(
session
,
SWITCH_MEDIA_TYPE_VIDEO
)
==
SWITCH_STATUS_SUCCESS
))
{
status
=
SWITCH_STATUS_FALSE
;
locked
=
1
;
if
(
!
switch_channel_ready
(
switch_core_session_get_channel
(
session
)))
{
status
=
SWITCH_STATUS_FALSE
;
}
else
{
status
=
switch_core_session_read_video_frame
(
session
,
&
vid_frame
,
SWITCH_IO_FLAG_NONE
,
0
);
}
}
else
{
}
else
{
status
=
switch_core_session_read_video_frame
(
session
,
&
vid_frame
,
SWITCH_IO_FLAG_NONE
,
0
)
;
status
=
SWITCH_STATUS_FALSE
;
}
}
switch_mutex_lock
(
conference
->
mutex
);
switch_mutex_lock
(
conference
->
mutex
);
switch_core_session_rwunlock
(
session
);
switch_core_session_rwunlock
(
session
);
...
@@ -2976,7 +2985,7 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr
...
@@ -2976,7 +2985,7 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr
goto
do_continue
;
goto
do_continue
;
}
}
memcpy
(
buf
,
vid_frame
->
packet
,
vid_frame
->
packetlen
);
//
memcpy(buf, vid_frame->packet, vid_frame->packetlen);
switch_mutex_unlock
(
conference
->
mutex
);
switch_mutex_unlock
(
conference
->
mutex
);
switch_mutex_lock
(
conference
->
mutex
);
switch_mutex_lock
(
conference
->
mutex
);
...
@@ -3002,7 +3011,7 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr
...
@@ -3002,7 +3011,7 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr
}
}
if
(
isession
&&
switch_channel_test_flag
(
ichannel
,
CF_VIDEO
))
{
if
(
isession
&&
switch_channel_test_flag
(
ichannel
,
CF_VIDEO
))
{
memcpy
(
vid_frame
->
packet
,
buf
,
vid_frame
->
packetlen
);
//
memcpy(vid_frame->packet, buf, vid_frame->packetlen);
switch_core_session_write_video_frame
(
imember
->
session
,
vid_frame
,
SWITCH_IO_FLAG_NONE
,
0
);
switch_core_session_write_video_frame
(
imember
->
session
,
vid_frame
,
SWITCH_IO_FLAG_NONE
,
0
);
}
}
...
@@ -3032,6 +3041,12 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr
...
@@ -3032,6 +3041,12 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr
}
}
do_continue:
do_continue:
if
(
session
&&
locked
)
{
switch_core_media_read_unlock
(
session
,
SWITCH_MEDIA_TYPE_VIDEO
);
locked
=
0
;
}
switch_mutex_unlock
(
conference
->
mutex
);
switch_mutex_unlock
(
conference
->
mutex
);
}
}
...
...
src/mod/codecs/mod_vpx/mod_vpx.c
浏览文件 @
62d42821
...
@@ -74,6 +74,7 @@ struct vpx_context {
...
@@ -74,6 +74,7 @@ struct vpx_context {
uint8_t
decoder_init
;
uint8_t
decoder_init
;
switch_buffer_t
*
vpx_packet_buffer
;
switch_buffer_t
*
vpx_packet_buffer
;
int
got_key_frame
;
int
got_key_frame
;
int
key_count
;
switch_size_t
last_received_timestamp
;
switch_size_t
last_received_timestamp
;
switch_bool_t
last_received_complete_picture
;
switch_bool_t
last_received_complete_picture
;
int
need_key_frame
;
int
need_key_frame
;
...
@@ -479,6 +480,7 @@ static switch_status_t buffer_vpx_packets(vpx_context_t *context, switch_frame_t
...
@@ -479,6 +480,7 @@ static switch_status_t buffer_vpx_packets(vpx_context_t *context, switch_frame_t
if
(
is_keyframe
&&
!
context
->
got_key_frame
)
{
if
(
is_keyframe
&&
!
context
->
got_key_frame
)
{
context
->
got_key_frame
=
1
;
context
->
got_key_frame
=
1
;
context
->
key_count
=
0
;
}
}
}
}
...
@@ -529,9 +531,9 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
...
@@ -529,9 +531,9 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
len
=
switch_buffer_inuse
(
context
->
vpx_packet_buffer
);
len
=
switch_buffer_inuse
(
context
->
vpx_packet_buffer
);
if
(
frame
->
m
&&
(
status
!=
SWITCH_STATUS_SUCCESS
||
!
len
))
{
//
if (frame->m && (status != SWITCH_STATUS_SUCCESS || !len)) {
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"WTF????? %d %ld
\n
"
,
status
,
len
);
//
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "WTF????? %d %ld\n", status, len);
}
//
}
if
(
status
==
SWITCH_STATUS_SUCCESS
&&
frame
->
m
&&
len
)
{
if
(
status
==
SWITCH_STATUS_SUCCESS
&&
frame
->
m
&&
len
)
{
...
@@ -572,11 +574,6 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
...
@@ -572,11 +574,6 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
end:
end:
if
(
status
==
SWITCH_STATUS_NOTFOUND
)
{
switch_buffer_zero
(
context
->
vpx_packet_buffer
);
switch_set_flag
(
frame
,
SFF_WAIT_KEY_FRAME
);
}
if
(
status
==
SWITCH_STATUS_RESTART
)
{
if
(
status
==
SWITCH_STATUS_RESTART
)
{
context
->
got_key_frame
=
0
;
context
->
got_key_frame
=
0
;
switch_buffer_zero
(
context
->
vpx_packet_buffer
);
switch_buffer_zero
(
context
->
vpx_packet_buffer
);
...
@@ -589,9 +586,12 @@ end:
...
@@ -589,9 +586,12 @@ end:
}
}
if
(
!
context
->
got_key_frame
)
{
if
(
!
context
->
got_key_frame
)
{
switch_set_flag
(
frame
,
SFF_WAIT_KEY_FRAME
);
if
(
!
(
context
->
key_count
++
%
20
))
{
switch_set_flag
(
frame
,
SFF_WAIT_KEY_FRAME
);
}
}
}
return
status
;
return
status
;
}
}
...
...
src/switch_core_media.c
浏览文件 @
62d42821
...
@@ -1786,6 +1786,50 @@ static void check_jb(switch_core_session_t *session, const char *input)
...
@@ -1786,6 +1786,50 @@ static void check_jb(switch_core_session_t *session, const char *input)
}
}
//?
SWITCH_DECLARE(switch_status_t) switch_core_media_read_lock_unlock(switch_core_session_t *session, switch_media_type_t type, switch_bool_t lock)
{
switch_rtp_engine_t *engine;
switch_media_handle_t *smh;
switch_assert(session);
if (!(smh = session->media_handle)) {
return SWITCH_STATUS_FALSE;
}
if (!smh->media_flags[SCMF_RUNNING]) {
return SWITCH_STATUS_FALSE;
}
engine = &smh->engines[type];
if (!engine->read_codec.implementation || !switch_core_codec_ready(&engine->read_codec)) {
return SWITCH_STATUS_FALSE;
}
switch_assert(engine->rtp_session != NULL);
if (!switch_channel_up_nosig(session->channel) || !switch_rtp_ready(engine->rtp_session) || switch_channel_test_flag(session->channel, CF_NOT_READY)) {
return SWITCH_STATUS_FALSE;
}
if (lock) {
if (engine->read_mutex[type] && switch_mutex_trylock(engine->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]);
}
return SWITCH_STATUS_SUCCESS;
}
//?
//?
SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session_t *session, switch_frame_t **frame,
SWITCH_DECLARE(switch_status_t) switch_core_media_read_frame(switch_core_session_t *session, switch_frame_t **frame,
switch_io_flag_t flags, int stream_id, switch_media_type_t type)
switch_io_flag_t flags, int stream_id, switch_media_type_t type)
...
@@ -9627,6 +9671,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
...
@@ -9627,6 +9671,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
write_frame = *frame;
write_frame = *frame;
frame = &write_frame;
frame = &write_frame;
frame->img = img;
if (!switch_test_flag(frame, SFF_USE_VIDEO_TIMESTAMP)) {
if (!switch_test_flag(frame, SFF_USE_VIDEO_TIMESTAMP)) {
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论