Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
6edcd456
O
obs-studio
项目概览
尘离序散
/
obs-studio
与 Fork 源项目一致
从无法访问的项目Fork
通知
30
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obs-studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6edcd456
编写于
12月 26, 2013
作者:
J
jp9000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implement signal/procedure handling into libobs and individual sources
上级
3b48f794
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
89 addition
and
14 deletion
+89
-14
libobs/callback/proc.c
libobs/callback/proc.c
+5
-7
libobs/callback/proc.h
libobs/callback/proc.h
+11
-7
libobs/obs-data.h
libobs/obs-data.h
+3
-0
libobs/obs-source.c
libobs/obs-source.c
+26
-0
libobs/obs-source.h
libobs/obs-source.h
+5
-0
libobs/obs.c
libobs/obs.c
+25
-0
libobs/obs.h
libobs/obs.h
+14
-0
未找到文件。
libobs/callback/proc.c
浏览文件 @
6edcd456
...
...
@@ -20,6 +20,7 @@
struct
proc_info
{
char
*
name
;
void
*
data
;
void
(
*
proc
)(
calldata_t
,
void
*
);
};
...
...
@@ -29,16 +30,13 @@ static inline void proc_info_free(struct proc_info *pi)
}
struct
proc_handler
{
void
*
data
;
/* TODO: replace with hash table lookup? */
DARRAY
(
struct
proc_info
)
procs
;
};
proc_handler_t
proc_handler_create
(
void
*
data
)
proc_handler_t
proc_handler_create
(
void
)
{
struct
proc_handler
*
handler
=
bmalloc
(
sizeof
(
struct
proc_handler
));
handler
->
data
=
data
;
da_init
(
handler
->
procs
);
return
handler
;
}
...
...
@@ -54,9 +52,9 @@ void proc_handler_destroy(proc_handler_t handler)
}
void
proc_handler_add
(
proc_handler_t
handler
,
const
char
*
name
,
void
(
*
proc
)(
calldata_t
,
void
*
))
void
(
*
proc
)(
calldata_t
,
void
*
)
,
void
*
data
)
{
struct
proc_info
pi
=
{
bstrdup
(
name
),
proc
};
struct
proc_info
pi
=
{
bstrdup
(
name
),
data
,
proc
};
da_push_back
(
handler
->
procs
,
&
pi
);
}
...
...
@@ -67,7 +65,7 @@ bool proc_handler_call(proc_handler_t handler, const char *name,
struct
proc_info
*
info
=
handler
->
procs
.
array
+
i
;
if
(
strcmp
(
info
->
name
,
name
)
==
0
)
{
info
->
proc
(
params
,
handler
->
data
);
info
->
proc
(
params
,
info
->
data
);
return
true
;
}
}
...
...
libobs/callback/proc.h
浏览文件 @
6edcd456
...
...
@@ -24,18 +24,22 @@
* Dynamic procedure handler
*
* This handler is used to allow dynamic access to one or more procedures
* that can be
called without having to have direct access to declarations
* or procedure callback pointers.
* that can be
dynamically added and called without having to have direct
*
access to declarations
or procedure callback pointers.
*/
struct
proc_handler
;
typedef
struct
proc_handler
*
proc_handler_t
;
proc_handler_t
proc_handler_create
(
void
*
data
);
void
proc_handler_destroy
(
proc_handler_t
handler
);
EXPORT
proc_handler_t
proc_handler_create
(
void
);
EXPORT
void
proc_handler_destroy
(
proc_handler_t
handler
);
void
proc_handler_add
(
proc_handler_t
handler
,
const
char
*
name
,
void
(
*
proc
)(
calldata_t
,
void
*
));
EXPORT
void
proc_handler_add
(
proc_handler_t
handler
,
const
char
*
name
,
void
(
*
proc
)(
calldata_t
,
void
*
)
,
void
*
data
);
bool
proc_handler_call
(
proc_handler_t
handler
,
const
char
*
name
,
/**
* Calls a function in a procedure handler. Returns false if the named
* procedure is not found.
*/
EXPORT
bool
proc_handler_call
(
proc_handler_t
handler
,
const
char
*
name
,
calldata_t
params
);
libobs/obs-data.h
浏览文件 @
6edcd456
...
...
@@ -88,6 +88,9 @@ struct obs_subsystem {
media_t
media
;
signal_handler_t
signals
;
proc_handler_t
procs
;
/* segmented into multiple sub-structures to keep things a bit more
* clean and organized */
struct
obs_video
video
;
...
...
libobs/obs-source.c
浏览文件 @
6edcd456
...
...
@@ -85,6 +85,16 @@ static inline const struct source_info *find_source(struct darray *list,
return
NULL
;
}
static
inline
bool
obs_source_init_handlers
(
struct
obs_source
*
source
)
{
source
->
signals
=
signal_handler_create
();
if
(
!
source
->
signals
)
return
false
;
source
->
procs
=
proc_handler_create
();
return
(
source
->
procs
!=
NULL
);
}
/* internal initialization */
bool
obs_source_init
(
struct
obs_source
*
source
,
const
char
*
settings
,
const
struct
source_info
*
info
)
...
...
@@ -143,6 +153,9 @@ obs_source_t obs_source_create(enum obs_source_type type, const char *id,
source
=
bmalloc
(
sizeof
(
struct
obs_source
));
memset
(
source
,
0
,
sizeof
(
struct
obs_source
));
if
(
!
obs_source_init_handlers
(
source
))
goto
fail
;
source
->
name
=
bstrdup
(
name
);
source
->
type
=
type
;
source
->
data
=
info
->
create
(
settings
,
source
);
...
...
@@ -186,6 +199,9 @@ static void obs_source_destroy(obs_source_t source)
audio_line_destroy
(
source
->
audio_line
);
audio_resampler_destroy
(
source
->
resampler
);
proc_handler_destroy
(
source
->
procs
);
signal_handler_destroy
(
source
->
signals
);
da_free
(
source
->
video_frames
);
da_free
(
source
->
audio_wait_buffer
);
da_free
(
source
->
filters
);
...
...
@@ -1004,3 +1020,13 @@ void obs_source_process_filter(obs_source_t filter, texrender_t texrender,
render_filter_tex
(
texrender_gettexture
(
texrender
),
effect
,
width
,
height
,
yuv
);
}
signal_handler_t
obs_source_signalhandler
(
obs_source_t
source
)
{
return
source
->
signals
;
}
proc_handler_t
obs_source_prochandler
(
obs_source_t
source
)
{
return
source
->
procs
;
}
libobs/obs-source.h
浏览文件 @
6edcd456
...
...
@@ -23,6 +23,8 @@
#include "util/threading.h"
#include "media-io/media-io.h"
#include "media-io/audio-resampler.h"
#include "callback/signal.h"
#include "callback/proc.h"
/*
* ===========================================
...
...
@@ -210,6 +212,9 @@ struct obs_source {
void
*
data
;
struct
source_info
callbacks
;
signal_handler_t
signals
;
proc_handler_t
procs
;
/* used to indicate that the source has been removed and all
* references to it should be released (not exactly how I would prefer
* to handle things but it's the best option) */
...
...
libobs/obs.c
浏览文件 @
6edcd456
...
...
@@ -252,6 +252,16 @@ static void obs_free_data(void)
pthread_mutex_unlock
(
&
obs
->
data
.
sources_mutex
);
}
static
inline
bool
obs_init_handlers
(
void
)
{
obs
->
signals
=
signal_handler_create
();
if
(
!
obs
->
signals
)
return
false
;
obs
->
procs
=
proc_handler_create
();
return
(
obs
->
procs
!=
NULL
);
}
static
bool
obs_init
(
void
)
{
obs
=
bmalloc
(
sizeof
(
struct
obs_subsystem
));
...
...
@@ -259,6 +269,9 @@ static bool obs_init(void)
memset
(
obs
,
0
,
sizeof
(
struct
obs_subsystem
));
obs_init_data
();
if
(
!
obs_init_handlers
())
return
false
;
obs
->
media
=
media_open
();
if
(
!
obs
->
media
)
return
false
;
...
...
@@ -300,6 +313,8 @@ void obs_shutdown(void)
obs_free_graphics
();
obs_free_audio
();
media_close
(
obs
->
media
);
proc_handler_destroy
(
obs
->
procs
);
signal_handler_destroy
(
obs
->
signals
);
for
(
i
=
0
;
i
<
obs
->
modules
.
num
;
i
++
)
free_module
(
obs
->
modules
.
array
+
i
);
...
...
@@ -489,3 +504,13 @@ effect_t obs_get_default_effect(void)
{
return
obs
->
video
.
default_effect
;
}
signal_handler_t
obs_signalhandler
(
void
)
{
return
obs
->
signals
;
}
proc_handler_t
obs_prochandler
(
void
)
{
return
obs
->
procs
;
}
libobs/obs.h
浏览文件 @
6edcd456
...
...
@@ -21,6 +21,8 @@
#include "graphics/graphics.h"
#include "graphics/vec2.h"
#include "media-io/media-io.h"
#include "callback/signal.h"
#include "callback/proc.h"
#include "obs-defs.h"
...
...
@@ -272,6 +274,12 @@ EXPORT char *obs_find_plugin_file(const char *file);
/** Returns the default effect for generic RGB/YUV drawing */
EXPORT
effect_t
obs_get_default_effect
(
void
);
/** Returns the primary obs signal handler */
EXPORT
signal_handler_t
obs_signalhandler
(
void
);
/** Returns the primary obs procedure handler */
EXPORT
proc_handler_t
obs_prochandler
(
void
);
/* ------------------------------------------------------------------------- */
/* Display context */
...
...
@@ -393,6 +401,12 @@ EXPORT void obs_source_setname(obs_source_t source, const char *name);
EXPORT
void
obs_source_getid
(
obs_source_t
source
,
enum
obs_source_type
*
type
,
const
char
**
id
);
/** Returns the signal handler for a source */
EXPORT
signal_handler_t
obs_source_signalhandler
(
obs_source_t
source
);
/** Returns the procedure handler for a source */
EXPORT
proc_handler_t
obs_source_prochandler
(
obs_source_t
source
);
/* ------------------------------------------------------------------------- */
/* Functions used by sources */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录