Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Obs Studio
提交
cec94b04
O
Obs Studio
项目概览
小白菜888
/
Obs Studio
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Obs Studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cec94b04
编写于
12月 28, 2013
作者:
J
jp9000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implement scene adding callbacks, make a few API tweaks
上级
fe8559a7
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
83 addition
and
24 deletion
+83
-24
libobs/callback/proc.c
libobs/callback/proc.c
+2
-2
libobs/callback/proc.h
libobs/callback/proc.h
+1
-1
libobs/callback/signal.c
libobs/callback/signal.c
+4
-4
libobs/callback/signal.h
libobs/callback/signal.h
+2
-2
libobs/obs-scene.c
libobs/obs-scene.c
+12
-1
libobs/obs-source.c
libobs/obs-source.c
+3
-3
libobs/obs.c
libobs/obs.c
+6
-0
libobs/obs.h
libobs/obs.h
+5
-2
obs/window-main-basic.cpp
obs/window-main-basic.cpp
+41
-5
obs/window-main-basic.hpp
obs/window-main-basic.hpp
+5
-2
test/osx/test.mm
test/osx/test.mm
+1
-1
test/win/test.cpp
test/win/test.cpp
+1
-1
未找到文件。
libobs/callback/proc.c
浏览文件 @
cec94b04
...
...
@@ -52,7 +52,7 @@ 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
*
data
)
void
(
*
proc
)(
void
*
,
calldata_t
),
void
*
data
)
{
struct
proc_info
pi
=
{
bstrdup
(
name
),
data
,
proc
};
da_push_back
(
handler
->
procs
,
&
pi
);
...
...
@@ -65,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
,
info
->
data
);
info
->
proc
(
info
->
data
,
params
);
return
true
;
}
}
...
...
libobs/callback/proc.h
浏览文件 @
cec94b04
...
...
@@ -39,7 +39,7 @@ EXPORT proc_handler_t proc_handler_create(void);
EXPORT
void
proc_handler_destroy
(
proc_handler_t
handler
);
EXPORT
void
proc_handler_add
(
proc_handler_t
handler
,
const
char
*
name
,
void
(
*
proc
)(
calldata_t
,
void
*
),
void
*
data
);
void
(
*
proc
)(
void
*
,
calldata_t
),
void
*
data
);
/**
* Calls a function in a procedure handler. Returns false if the named
...
...
libobs/callback/signal.c
浏览文件 @
cec94b04
...
...
@@ -60,7 +60,7 @@ static inline void signal_info_destroy(struct signal_info *si)
}
static
inline
size_t
signal_get_callback_idx
(
struct
signal_info
*
si
,
void
(
*
callback
)(
calldata_t
,
void
*
),
void
*
data
)
void
(
*
callback
)(
void
*
,
calldata_t
),
void
*
data
)
{
for
(
size_t
i
=
0
;
i
<
si
->
callbacks
.
num
;
i
++
)
{
struct
signal_callback
*
sc
=
si
->
callbacks
.
array
+
i
;
...
...
@@ -129,7 +129,7 @@ void signal_handler_destroy(signal_handler_t handler)
}
void
signal_handler_connect
(
signal_handler_t
handler
,
const
char
*
signal
,
void
(
*
callback
)(
calldata_t
,
void
*
),
void
*
data
)
void
(
*
callback
)(
void
*
,
calldata_t
),
void
*
data
)
{
struct
signal_info
*
sig
,
*
last
;
struct
signal_callback
cb_data
=
{
callback
,
data
};
...
...
@@ -174,7 +174,7 @@ static inline struct signal_info *getsignal_locked(signal_handler_t handler,
}
void
signal_handler_disconnect
(
signal_handler_t
handler
,
const
char
*
signal
,
void
(
*
callback
)(
calldata_t
,
void
*
),
void
*
data
)
void
(
*
callback
)(
void
*
,
calldata_t
),
void
*
data
)
{
struct
signal_info
*
sig
=
getsignal_locked
(
handler
,
signal
);
size_t
idx
;
...
...
@@ -203,7 +203,7 @@ void signal_handler_signal(signal_handler_t handler, const char *signal,
for
(
size_t
i
=
0
;
i
<
sig
->
callbacks
.
num
;
i
++
)
{
struct
signal_callback
*
cb
=
sig
->
callbacks
.
array
+
i
;
cb
->
callback
(
params
,
cb
->
data
);
cb
->
callback
(
cb
->
data
,
params
);
}
pthread_mutex_unlock
(
&
sig
->
mutex
);
...
...
libobs/callback/signal.h
浏览文件 @
cec94b04
...
...
@@ -38,9 +38,9 @@ EXPORT signal_handler_t signal_handler_create(void);
EXPORT
void
signal_handler_destroy
(
signal_handler_t
handler
);
EXPORT
void
signal_handler_connect
(
signal_handler_t
handler
,
const
char
*
signal
,
void
(
*
callback
)(
calldata_t
,
void
*
),
void
*
data
);
void
(
*
callback
)(
void
*
,
calldata_t
),
void
*
data
);
EXPORT
void
signal_handler_disconnect
(
signal_handler_t
handler
,
const
char
*
signal
,
void
(
*
callback
)(
calldata_t
,
void
*
),
const
char
*
signal
,
void
(
*
callback
)(
void
*
,
calldata_t
),
void
*
data
);
EXPORT
void
signal_handler_signal
(
signal_handler_t
handler
,
const
char
*
signal
,
...
...
libobs/obs-scene.c
浏览文件 @
cec94b04
...
...
@@ -97,7 +97,7 @@ static const struct source_info scene_info =
.
getheight
=
scene_getsize
,
};
obs_scene_t
obs_scene_create
(
void
)
obs_scene_t
obs_scene_create
(
const
char
*
name
)
{
struct
obs_source
*
source
=
bmalloc
(
sizeof
(
struct
obs_source
));
struct
obs_scene
*
scene
=
scene_create
(
NULL
,
source
);
...
...
@@ -110,6 +110,9 @@ obs_scene_t obs_scene_create(void)
return
NULL
;
}
source
->
name
=
bstrdup
(
name
);
source
->
type
=
SOURCE_SCENE
;
scene
->
source
=
source
;
obs_source_init
(
source
,
NULL
,
&
scene_info
);
memcpy
(
&
source
->
callbacks
,
&
scene_info
,
sizeof
(
struct
source_info
));
...
...
@@ -127,6 +130,14 @@ obs_source_t obs_scene_getsource(obs_scene_t scene)
return
scene
->
source
;
}
obs_scene_t
obs_scene_fromsource
(
obs_source_t
source
)
{
if
(
source
->
type
!=
SOURCE_SCENE
)
return
NULL
;
return
source
->
data
;
}
obs_sceneitem_t
obs_scene_add
(
obs_scene_t
scene
,
obs_source_t
source
)
{
struct
obs_scene_item
*
item
=
bmalloc
(
sizeof
(
struct
obs_scene_item
));
...
...
libobs/obs-source.c
浏览文件 @
cec94b04
...
...
@@ -954,11 +954,11 @@ void obs_source_setname(obs_source_t source, const char *name)
source
->
name
=
bstrdup
(
name
);
}
void
obs_source_get
id
(
obs_source_t
source
,
enum
obs_source_type
*
type
,
void
obs_source_get
type
(
obs_source_t
source
,
enum
obs_source_type
*
type
,
const
char
**
id
)
{
*
type
=
source
->
type
;
*
id
=
source
->
callbacks
.
id
;
if
(
type
)
*
type
=
source
->
type
;
if
(
id
)
*
id
=
source
->
callbacks
.
id
;
}
static
inline
void
render_filter_bypass
(
obs_source_t
target
,
effect_t
effect
,
...
...
libobs/obs.c
浏览文件 @
cec94b04
...
...
@@ -433,11 +433,17 @@ media_t obs_media(void)
bool
obs_add_source
(
obs_source_t
source
)
{
struct
calldata
params
=
{
0
};
pthread_mutex_lock
(
&
obs
->
data
.
sources_mutex
);
da_push_back
(
obs
->
data
.
sources
,
&
source
);
obs_source_addref
(
source
);
pthread_mutex_unlock
(
&
obs
->
data
.
sources_mutex
);
calldata_setptr
(
&
params
,
"source"
,
source
);
signal_handler_signal
(
obs
->
signals
,
"source-add"
,
&
params
);
calldata_free
(
&
params
);
return
true
;
}
...
...
libobs/obs.h
浏览文件 @
cec94b04
...
...
@@ -398,7 +398,7 @@ EXPORT const char *obs_source_getname(obs_source_t source);
EXPORT
void
obs_source_setname
(
obs_source_t
source
,
const
char
*
name
);
/** Gets the source type and identifier */
EXPORT
void
obs_source_get
id
(
obs_source_t
source
,
enum
obs_source_type
*
type
,
EXPORT
void
obs_source_get
type
(
obs_source_t
source
,
enum
obs_source_type
*
type
,
const
char
**
id
);
/** Returns the signal handler for a source */
...
...
@@ -444,12 +444,15 @@ EXPORT void obs_source_process_filter(obs_source_t filter,
* A scene is a source which is a container of other sources with specific
* display oriantations. Scenes can also be used like any other source.
*/
EXPORT
obs_scene_t
obs_scene_create
(
void
);
EXPORT
obs_scene_t
obs_scene_create
(
const
char
*
name
);
EXPORT
void
obs_scene_destroy
(
obs_scene_t
scene
);
/** Gets the scene's source context */
EXPORT
obs_source_t
obs_scene_getsource
(
obs_scene_t
scene
);
/** Gets the scene from its source, or NULL if not a scene */
EXPORT
obs_scene_t
obs_scene_fromsource
(
obs_source_t
source
);
/** Adds/creates a new scene item for a source */
EXPORT
obs_sceneitem_t
obs_scene_add
(
obs_scene_t
scene
,
obs_source_t
source
);
...
...
obs/window-main-basic.cpp
浏览文件 @
cec94b04
...
...
@@ -22,6 +22,37 @@
#include "window-settings-basic.hpp"
#include "window-main-basic.hpp"
void
OBSBasic
::
SceneAdded
(
obs_source_t
source
)
{
const
char
*
name
=
obs_source_getname
(
source
);
obs_scene_t
scene
=
obs_scene_fromsource
(
source
);
scenes
->
Append
(
wxString
(
name
,
wxConvUTF8
),
scene
);
}
void
OBSBasic
::
SourceAdded
(
void
*
data
,
calldata_t
params
)
{
OBSBasic
*
window
=
(
OBSBasic
*
)
data
;
obs_source_t
source
;
calldata_getptr
(
params
,
"source"
,
(
void
**
)
&
source
);
obs_source_type
type
;
obs_source_gettype
(
source
,
&
type
,
NULL
);
if
(
type
==
SOURCE_SCENE
)
window
->
SceneAdded
(
source
);
}
void
OBSBasic
::
SourceDestroyed
(
void
*
data
,
calldata_t
params
)
{
OBSBasic
*
window
=
(
OBSBasic
*
)
data
;
obs_source_t
source
;
calldata_getptr
(
params
,
"source"
,
(
void
**
)
&
source
);
/* TODO */
}
bool
OBSBasic
::
Init
()
{
if
(
!
obs_startup
())
...
...
@@ -29,6 +60,16 @@ bool OBSBasic::Init()
if
(
!
InitGraphics
())
return
false
;
signal_handler_connect
(
obs_signalhandler
(),
"source-add"
,
OBSBasic
::
SourceAdded
,
this
);
signal_handler_connect
(
obs_signalhandler
(),
"source-destroy"
,
OBSBasic
::
SourceDestroyed
,
this
);
//obs_scene_t scene = obs_scene_create("test scene");
//obs_add_source(obs_scene_getsource(scene));
//obs_load_module("test-input");
return
true
;
}
...
...
@@ -67,11 +108,6 @@ bool OBSBasic::InitGraphics()
return
true
;
}
bool
OBSBasic
::
AddScene
(
const
char
*
name
)
{
return
false
;
}
void
OBSBasic
::
OnClose
(
wxCloseEvent
&
event
)
{
wxGetApp
().
ExitMainLoop
();
...
...
obs/window-main-basic.hpp
浏览文件 @
cec94b04
...
...
@@ -25,6 +25,11 @@
using
namespace
std
;
class
OBSBasic
:
public
OBSBasicBase
{
void
SceneAdded
(
obs_source_t
scene
);
static
void
SourceAdded
(
void
*
data
,
calldata_t
params
);
static
void
SourceDestroyed
(
void
*
data
,
calldata_t
params
);
bool
InitGraphics
();
void
NewProject
();
...
...
@@ -60,8 +65,6 @@ public:
bool
Init
();
bool
AddScene
(
const
char
*
name
);
inline
wxPanel
*
GetPreviewPanel
()
{
return
previewPanel
;}
inline
wxSizer
*
GetPreviewContainer
()
{
return
previewContainer
;}
};
test/osx/test.mm
浏览文件 @
cec94b04
...
...
@@ -163,7 +163,7 @@ static void test()
/* ------------------------------------------------------ */
/* create scene and add source to scene (twice) */
SceneContext
scene
{
obs_scene_create
()};
SceneContext
scene
{
obs_scene_create
(
"test scene"
)};
if
(
!
scene
)
throw
"Couldn't create scene"
;
...
...
test/win/test.cpp
浏览文件 @
cec94b04
...
...
@@ -167,7 +167,7 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdLine,
/* ------------------------------------------------------ */
/* create scene and add source to scene (twice) */
SceneContext
scene
=
obs_scene_create
();
SceneContext
scene
=
obs_scene_create
(
"test scene"
);
if
(
!
scene
)
throw
"Couldn't create scene"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录