Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
f094bf19
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,发现更多精彩内容 >>
提交
f094bf19
编写于
5月 04, 2015
作者:
P
Palana
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
(API Change) libobs: Make obs_output refcounted
上级
a563fbc0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
132 addition
and
3 deletion
+132
-3
libobs/obs-internal.h
libobs/obs-internal.h
+8
-0
libobs/obs-output.c
libobs/obs-output.c
+78
-0
libobs/obs.c
libobs/obs.c
+6
-1
libobs/obs.h
libobs/obs.h
+18
-1
libobs/obs.hpp
libobs/obs.hpp
+17
-1
obs/window-basic-main-outputs.cpp
obs/window-basic-main-outputs.cpp
+5
-0
未找到文件。
libobs/obs-internal.h
浏览文件 @
f094bf19
...
...
@@ -444,9 +444,15 @@ extern float obs_source_get_target_volume(obs_source_t *source,
/* ------------------------------------------------------------------------- */
/* outputs */
struct
obs_weak_output
{
struct
obs_weak_ref
ref
;
struct
obs_output
*
output
;
};
struct
obs_output
{
struct
obs_context_data
context
;
struct
obs_output_info
info
;
struct
obs_weak_output
*
control
;
bool
received_video
;
bool
received_audio
;
...
...
@@ -495,6 +501,8 @@ extern const struct obs_output_info *find_output(const char *id);
extern
void
obs_output_remove_encoder
(
struct
obs_output
*
output
,
struct
obs_encoder
*
encoder
);
void
obs_output_destroy
(
obs_output_t
*
output
);
/* ------------------------------------------------------------------------- */
/* encoders */
...
...
libobs/obs-output.c
浏览文件 @
f094bf19
...
...
@@ -95,6 +95,9 @@ obs_output_t *obs_output_create(const char *id, const char *name,
output
->
reconnect_retry_max
=
20
;
output
->
valid
=
true
;
output
->
control
=
bzalloc
(
sizeof
(
obs_weak_output_t
));
output
->
control
->
output
=
output
;
obs_context_data_insert
(
&
output
->
context
,
&
obs
->
data
.
outputs_mutex
,
&
obs
->
data
.
first_output
);
...
...
@@ -1273,3 +1276,78 @@ void obs_output_signal_stop(obs_output_t *output, int code)
else
signal_stop
(
output
,
code
);
}
void
obs_output_addref
(
obs_output_t
*
output
)
{
if
(
!
output
)
return
;
obs_ref_addref
(
&
output
->
control
->
ref
);
}
void
obs_output_release
(
obs_output_t
*
output
)
{
if
(
!
output
)
return
;
obs_weak_output_t
*
control
=
output
->
control
;
if
(
obs_ref_release
(
&
control
->
ref
))
{
// The order of operations is important here since
// get_context_by_name in obs.c relies on weak refs
// being alive while the context is listed
obs_output_destroy
(
output
);
obs_weak_output_release
(
control
);
}
}
void
obs_weak_output_addref
(
obs_weak_output_t
*
weak
)
{
if
(
!
weak
)
return
;
obs_weak_ref_addref
(
&
weak
->
ref
);
}
void
obs_weak_output_release
(
obs_weak_output_t
*
weak
)
{
if
(
!
weak
)
return
;
if
(
obs_weak_ref_release
(
&
weak
->
ref
))
bfree
(
weak
);
}
obs_output_t
*
obs_output_get_ref
(
obs_output_t
*
output
)
{
if
(
!
output
)
return
NULL
;
return
obs_weak_output_get_output
(
output
->
control
);
}
obs_weak_output_t
*
obs_output_get_weak_output
(
obs_output_t
*
output
)
{
if
(
!
output
)
return
NULL
;
obs_weak_output_t
*
weak
=
output
->
control
;
obs_weak_output_addref
(
weak
);
return
weak
;
}
obs_output_t
*
obs_weak_output_get_output
(
obs_weak_output_t
*
weak
)
{
if
(
!
weak
)
return
NULL
;
if
(
obs_weak_ref_get_ref
(
&
weak
->
ref
))
return
weak
->
output
;
return
NULL
;
}
bool
obs_weak_output_references_output
(
obs_weak_output_t
*
weak
,
obs_output_t
*
output
)
{
return
weak
&&
output
&&
weak
->
output
==
output
;
}
libobs/obs.c
浏览文件 @
f094bf19
...
...
@@ -1184,6 +1184,11 @@ static inline void *get_context_by_name(void *vfirst, const char *name,
return
context
;
}
static
inline
void
*
obs_output_addref_safe_
(
void
*
ref
)
{
return
obs_output_get_ref
(
ref
);
}
static
inline
void
*
obs_id_
(
void
*
data
)
{
return
data
;
...
...
@@ -1193,7 +1198,7 @@ obs_output_t *obs_get_output_by_name(const char *name)
{
if
(
!
obs
)
return
NULL
;
return
get_context_by_name
(
&
obs
->
data
.
first_output
,
name
,
&
obs
->
data
.
outputs_mutex
,
obs_
id
_
);
&
obs
->
data
.
outputs_mutex
,
obs_
output_addref_safe
_
);
}
obs_encoder_t
*
obs_get_encoder_by_name
(
const
char
*
name
)
...
...
libobs/obs.h
浏览文件 @
f094bf19
...
...
@@ -63,6 +63,7 @@ typedef struct obs_fader obs_fader_t;
typedef
struct
obs_volmeter
obs_volmeter_t
;
typedef
struct
obs_weak_source
obs_weak_source_t
;
typedef
struct
obs_weak_output
obs_weak_output_t
;
#include "obs-source.h"
#include "obs-encoder.h"
...
...
@@ -1089,7 +1090,23 @@ EXPORT const char *obs_output_get_display_name(const char *id);
*/
EXPORT
obs_output_t
*
obs_output_create
(
const
char
*
id
,
const
char
*
name
,
obs_data_t
*
settings
);
EXPORT
void
obs_output_destroy
(
obs_output_t
*
output
);
/**
* Adds/releases a reference to an output. When the last reference is
* released, the output is destroyed.
*/
EXPORT
void
obs_output_addref
(
obs_output_t
*
output
);
EXPORT
void
obs_output_release
(
obs_output_t
*
output
);
EXPORT
void
obs_weak_output_addref
(
obs_weak_output_t
*
weak
);
EXPORT
void
obs_weak_output_release
(
obs_weak_output_t
*
weak
);
EXPORT
obs_output_t
*
obs_output_get_ref
(
obs_output_t
*
output
);
EXPORT
obs_weak_output_t
*
obs_output_get_weak_output
(
obs_output_t
*
output
);
EXPORT
obs_output_t
*
obs_weak_output_get_output
(
obs_weak_output_t
*
weak
);
EXPORT
bool
obs_weak_output_references_output
(
obs_weak_output_t
*
weak
,
obs_output_t
*
output
);
EXPORT
const
char
*
obs_output_get_name
(
const
obs_output_t
*
output
);
...
...
libobs/obs.hpp
浏览文件 @
f094bf19
...
...
@@ -33,9 +33,12 @@ using OBSSceneItem = OBSRef<obs_sceneitem_t*, obs_sceneitem_addref,
using
OBSData
=
OBSRef
<
obs_data_t
*
,
obs_data_addref
,
obs_data_release
>
;
using
OBSDataArray
=
OBSRef
<
obs_data_array_t
*
,
obs_data_array_addref
,
obs_data_array_release
>
;
using
OBSOutput
=
OBSRef
<
obs_output_t
*
,
obs_output_addref
,
obs_output_release
>
;
using
OBSWeakSource
=
OBSRef
<
obs_weak_source_t
*
,
obs_weak_source_addref
,
obs_weak_source_release
>
;
using
OBSWeakOutput
=
OBSRef
<
obs_weak_output_t
*
,
obs_weak_output_addref
,
obs_weak_output_release
>
;
template
<
typename
T
,
void
addref
(
T
),
void
release
(
T
)>
class
OBSRef
{
...
...
@@ -81,6 +84,9 @@ public:
friend
OBSSource
OBSGetStrongRef
(
obs_weak_source_t
*
weak
);
friend
OBSWeakSource
OBSGetWeakRef
(
obs_source_t
*
source
);
friend
OBSOutput
OBSGetStrongRef
(
obs_weak_output_t
*
weak
);
friend
OBSWeakOutput
OBSGetWeakRef
(
obs_output_t
*
output
);
};
inline
OBSSource
OBSGetStrongRef
(
obs_weak_source_t
*
weak
)
...
...
@@ -94,6 +100,17 @@ inline OBSWeakSource OBSGetWeakRef(obs_source_t *source)
OBSWeakSource
::
TakeOwnership
()};
}
inline
OBSOutput
OBSGetStrongRef
(
obs_weak_output_t
*
weak
)
{
return
{
obs_weak_output_get_output
(
weak
),
OBSOutput
::
TakeOwnership
()};
}
inline
OBSWeakOutput
OBSGetWeakRef
(
obs_output_t
*
output
)
{
return
{
obs_output_get_weak_output
(
output
),
OBSWeakOutput
::
TakeOwnership
()};
}
/* objects that are not meant to be instanced */
template
<
typename
T
,
void
destroy
(
T
)>
class
OBSObj
{
T
obj
;
...
...
@@ -132,7 +149,6 @@ public:
using
OBSDisplay
=
OBSObj
<
obs_display_t
*
,
obs_display_destroy
>
;
using
OBSEncoder
=
OBSObj
<
obs_encoder_t
*
,
obs_encoder_destroy
>
;
using
OBSView
=
OBSObj
<
obs_view_t
*
,
obs_view_destroy
>
;
using
OBSOutput
=
OBSObj
<
obs_output_t
*
,
obs_output_destroy
>
;
/* signal handler connection */
class
OBSSignal
{
...
...
obs/window-basic-main-outputs.cpp
浏览文件 @
f094bf19
...
...
@@ -68,11 +68,13 @@ SimpleOutput::SimpleOutput(OBSBasic *main_) : BasicOutputHandler(main_)
nullptr
);
if
(
!
streamOutput
)
throw
"Failed to create stream output (simple output)"
;
obs_output_release
(
streamOutput
);
fileOutput
=
obs_output_create
(
"flv_output"
,
"simple_file_output"
,
nullptr
);
if
(
!
fileOutput
)
throw
"Failed to create recording output (simple output)"
;
obs_output_release
(
fileOutput
);
h264
=
obs_video_encoder_create
(
"obs_x264"
,
"simple_h264"
,
nullptr
);
if
(
!
h264
)
...
...
@@ -321,6 +323,7 @@ AdvancedOutput::AdvancedOutput(OBSBasic *main_) : BasicOutputHandler(main_)
nullptr
);
if
(
!
streamOutput
)
throw
"Failed to create stream output (advanced output)"
;
obs_output_release
(
streamOutput
);
if
(
ffmpegRecording
)
{
fileOutput
=
obs_output_create
(
"ffmpeg_output"
,
...
...
@@ -328,12 +331,14 @@ AdvancedOutput::AdvancedOutput(OBSBasic *main_) : BasicOutputHandler(main_)
if
(
!
fileOutput
)
throw
"Failed to create recording FFmpeg output "
"(advanced output)"
;
obs_output_release
(
fileOutput
);
}
else
{
fileOutput
=
obs_output_create
(
"flv_output"
,
"adv_file_output"
,
nullptr
);
if
(
!
fileOutput
)
throw
"Failed to create recording output "
"(advanced output)"
;
obs_output_release
(
fileOutput
);
if
(
!
useStreamEncoder
)
{
h264Recording
=
obs_video_encoder_create
(
recordEncoder
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录