Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
18388dcf
提交
18388dcf
authored
3月 30, 2018
作者:
Brian West
提交者:
Mike Jerris
4月 02, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-11081: [mod_video_filter] Teleportation #resolve
上级
246976b0
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
128 行增加
和
4 行删除
+128
-4
mod_video_filter.c
src/mod/applications/mod_video_filter/mod_video_filter.c
+128
-4
没有找到文件。
src/mod/applications/mod_video_filter/mod_video_filter.c
浏览文件 @
18388dcf
...
...
@@ -38,7 +38,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_video_filter_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_video_filter_shutdown
);
SWITCH_MODULE_DEFINITION
(
mod_video_filter
,
mod_video_filter_load
,
mod_video_filter_shutdown
,
NULL
);
typedef
struct
chromakey_context_s
{
int
threshold
;
switch_image_t
*
bgimg
;
...
...
@@ -60,8 +59,18 @@ typedef struct chromakey_context_s {
int
mod
;
switch_chromakey_t
*
ck
;
switch_core_video_filter_t
video_filters
;
switch_queue_t
*
child_queue
;
char
*
child_uuid
;
switch_media_bug_t
*
child_bug
;
}
chromakey_context_t
;
typedef
struct
chromakey_child_context_s
{
chromakey_context_t
*
parent
;
char
*
master_uuid
;
}
chromakey_child_context_t
;
static
void
init_context
(
chromakey_context_t
*
context
)
{
switch_color_set_rgb
(
&
context
->
bgcolor
,
"#000000"
);
...
...
@@ -79,6 +88,11 @@ static void uninit_context(chromakey_context_t *context)
switch_img_free
(
&
context
->
imgbg
);
switch_img_free
(
&
context
->
imgfg
);
if
(
context
->
child_bug
)
{
switch_core_media_bug_close
(
&
context
->
child_bug
,
SWITCH_TRUE
);
context
->
child_uuid
=
NULL
;
}
if
(
switch_test_flag
(
&
context
->
vfh
,
SWITCH_FILE_OPEN
))
{
switch_core_file_close
(
&
context
->
vfh
);
memset
(
&
context
->
vfh
,
0
,
sizeof
(
context
->
vfh
));
...
...
@@ -94,6 +108,61 @@ static void uninit_context(chromakey_context_t *context)
switch_chromakey_destroy
(
&
context
->
ck
);
}
static
int
flush_video_queue
(
switch_queue_t
*
q
,
int
min
)
{
void
*
pop
;
if
(
switch_queue_size
(
q
)
>
min
)
{
while
(
switch_queue_trypop
(
q
,
&
pop
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_image_t
*
img
=
(
switch_image_t
*
)
pop
;
switch_img_free
(
&
img
);
if
(
min
&&
switch_queue_size
(
q
)
<=
min
)
{
break
;
}
}
}
return
switch_queue_size
(
q
);
}
static
switch_bool_t
chromakey_child_bug_callback
(
switch_media_bug_t
*
bug
,
void
*
user_data
,
switch_abc_type_t
type
)
{
chromakey_child_context_t
*
child_context
=
(
chromakey_child_context_t
*
)
user_data
;
switch
(
type
)
{
case
SWITCH_ABC_TYPE_INIT
:
{
}
break
;
case
SWITCH_ABC_TYPE_CLOSE
:
{
}
break
;
case
SWITCH_ABC_TYPE_READ_VIDEO_PING
:
case
SWITCH_ABC_TYPE_VIDEO_PATCH
:
{
switch_image_t
*
img
=
NULL
;
switch_frame_t
*
frame
=
switch_core_media_bug_get_video_ping_frame
(
bug
);
if
(
frame
&&
frame
->
img
)
{
switch_img_copy
(
frame
->
img
,
&
img
);
if
(
switch_queue_trypush
(
child_context
->
parent
->
child_queue
,
img
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_img_free
(
&
img
);
}
img
=
NULL
;
}
}
break
;
default:
break
;
}
return
SWITCH_TRUE
;
}
static
void
parse_params
(
chromakey_context_t
*
context
,
int
start
,
int
argc
,
char
**
argv
,
const
char
**
function
,
switch_media_bug_flag_t
*
flags
)
{
int
n
=
argc
-
start
;
...
...
@@ -151,6 +220,12 @@ static void parse_params(chromakey_context_t *context, int start, int argc, char
if
(
n
>
2
&&
argv
[
i
])
{
if
(
context
->
child_bug
)
{
printf
(
"WTF CLOSE IT
\n
"
);
switch_core_media_bug_close
(
&
context
->
child_bug
,
SWITCH_TRUE
);
context
->
child_uuid
=
NULL
;
}
if
(
switch_test_flag
(
&
context
->
vfh
,
SWITCH_FILE_OPEN
))
{
switch_core_file_close
(
&
context
->
vfh
);
memset
(
&
context
->
vfh
,
0
,
sizeof
(
context
->
vfh
));
...
...
@@ -175,6 +250,37 @@ static void parse_params(chromakey_context_t *context, int start, int argc, char
if
(
argv
[
i
][
0
]
==
'#'
)
{
// bgcolor
switch_color_set_rgb
(
&
context
->
bgcolor
,
argv
[
i
]);
}
else
if
(
!
strncasecmp
(
argv
[
i
],
"uuid:"
,
5
))
{
char
*
uuid
=
argv
[
i
]
+
5
;
switch_core_session_t
*
bsession
;
switch_status_t
status
;
if
(
!
zstr
(
uuid
)
&&
(
bsession
=
switch_core_session_locate
(
uuid
)))
{
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
bsession
);
chromakey_child_context_t
*
child_context
;
switch_media_bug_flag_t
flags
=
SMBF_READ_VIDEO_PING
|
SMBF_READ_VIDEO_PATCH
;
switch_channel_wait_for_flag
(
channel
,
CF_VIDEO_READY
,
SWITCH_TRUE
,
10000
,
NULL
);
child_context
=
(
chromakey_child_context_t
*
)
switch_core_session_alloc
(
bsession
,
sizeof
(
*
child_context
));
child_context
->
master_uuid
=
switch_core_session_strdup
(
bsession
,
switch_core_session_get_uuid
(
context
->
session
));
if
((
status
=
switch_core_media_bug_add
(
bsession
,
"chromakey_child"
,
NULL
,
chromakey_child_bug_callback
,
child_context
,
0
,
flags
,
&
context
->
child_bug
))
==
SWITCH_STATUS_SUCCESS
)
{
switch_queue_create
(
&
context
->
child_queue
,
200
,
switch_core_session_get_pool
(
context
->
session
));
child_context
->
parent
=
context
;
context
->
child_uuid
=
switch_core_session_strdup
(
context
->
session
,
switch_core_session_get_uuid
(
bsession
));
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
bsession
),
SWITCH_LOG_ERROR
,
"Failure! %d
\n
"
,
status
);
}
switch_core_session_rwunlock
(
bsession
);
}
}
else
if
(
switch_stristr
(
".png"
,
argv
[
i
]))
{
if
(
!
(
context
->
bgimg_orig
=
switch_img_read_png
(
argv
[
i
],
SWITCH_IMG_FMT_ARGB
)))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Error opening png
\n
"
);
...
...
@@ -382,7 +488,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
}
}
}
else
if
(
switch_test_flag
(
&
context
->
vfh
,
SWITCH_FILE_OPEN
))
{
}
else
if
(
switch_test_flag
(
&
context
->
vfh
,
SWITCH_FILE_OPEN
)
||
!
zstr
(
context
->
child_uuid
)
)
{
switch_image_t
*
use_img
=
NULL
;
switch_frame_t
file_frame
=
{
0
};
switch_status_t
status
;
...
...
@@ -390,8 +496,26 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
context
->
vfh
.
mm
.
scale_w
=
frame
->
img
->
d_w
;
context
->
vfh
.
mm
.
scale_h
=
frame
->
img
->
d_h
;
status
=
switch_core_file_read_video
(
&
context
->
vfh
,
&
file_frame
,
SVR_FLUSH
);
switch_core_file_command
(
&
context
->
vfh
,
SCFC_FLUSH_AUDIO
);
if
(
!
zstr
(
context
->
child_uuid
))
{
void
*
pop
=
NULL
;
flush_video_queue
(
context
->
child_queue
,
1
);
if
((
status
=
switch_queue_trypop
(
context
->
child_queue
,
&
pop
))
==
SWITCH_STATUS_SUCCESS
&&
pop
)
{
file_frame
.
img
=
(
switch_image_t
*
)
pop
;
if
(
file_frame
.
img
->
d_w
!=
context
->
vfh
.
mm
.
scale_w
||
file_frame
.
img
->
d_h
!=
context
->
vfh
.
mm
.
scale_h
)
{
switch_img_fit
(
&
file_frame
.
img
,
context
->
vfh
.
mm
.
scale_w
,
context
->
vfh
.
mm
.
scale_h
,
SWITCH_FIT_SIZE_AND_SCALE
);
if
(
file_frame
.
img
->
d_w
!=
context
->
vfh
.
mm
.
scale_w
||
file_frame
.
img
->
d_h
!=
context
->
vfh
.
mm
.
scale_h
)
{
switch_img_free
(
&
file_frame
.
img
);
}
}
}
}
else
{
status
=
switch_core_file_read_video
(
&
context
->
vfh
,
&
file_frame
,
SVR_FLUSH
);
switch_core_file_command
(
&
context
->
vfh
,
SCFC_FLUSH_AUDIO
);
}
if
(
file_frame
.
img
)
{
switch_img_free
(
&
context
->
bgimg_scaled
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论