Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
b8a3ae1b
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,发现更多精彩内容 >>
提交
b8a3ae1b
编写于
10月 04, 2018
作者:
J
jp9000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libobs: Add multi-track support to non-encoded outputs
上级
8b98568b
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
119 addition
and
17 deletion
+119
-17
docs/sphinx/reference-outputs.rst
docs/sphinx/reference-outputs.rst
+25
-1
libobs/obs-internal.h
libobs/obs-internal.h
+1
-1
libobs/obs-module.c
libobs/obs-module.c
+9
-3
libobs/obs-output.c
libobs/obs-output.c
+75
-12
libobs/obs-output.h
libobs/obs-output.h
+3
-0
libobs/obs.h
libobs/obs.h
+6
-0
未找到文件。
docs/sphinx/reference-outputs.rst
浏览文件 @
b8a3ae1b
...
@@ -117,6 +117,18 @@ Output Definition Structure (obs_output_info)
...
@@ -117,6 +117,18 @@ Output Definition Structure (obs_output_info)
This is called when the output recieves raw audio data. Only applies
This is called when the output recieves raw audio data. Only applies
to outputs that are not encoded.
to outputs that are not encoded.
**This callback must be used with single-track raw outputs.**
:param frames: The raw audio frames
.. member:: void (*obs_output_info.raw_audio2)(void *data, size_t idx, struct audio_data *frames)
This is called when the output recieves raw audio data. Only applies
to outputs that are not encoded.
**This callback must be used with multi-track raw outputs.**
:param idx: The audio track index
:param frames: The raw audio frames
:param frames: The raw audio frames
.. member:: void (*obs_output_info.encoded_packet)(void *data, struct encoder_packet *packet)
.. member:: void (*obs_output_info.encoded_packet)(void *data, struct encoder_packet *packet)
...
@@ -472,7 +484,19 @@ General Output Functions
...
@@ -472,7 +484,19 @@ General Output Functions
.. function:: void obs_output_set_mixer(obs_output_t *output, size_t mixer_idx)
.. function:: void obs_output_set_mixer(obs_output_t *output, size_t mixer_idx)
size_t obs_output_get_mixer(const obs_output_t *output)
size_t obs_output_get_mixer(const obs_output_t *output)
Sets/gets the current audio mixer for non-encoded outputs.
Sets/gets the current audio mixer for non-encoded outputs. For
multi-track outputs, this would be the equivalent of setting the mask
only for the specified mixer index.
---------------------
.. function:: void obs_output_set_mixers(obs_output_t *output, size_t mixers)
size_t obs_output_get_mixers(const obs_output_t *output)
Sets/gets the current audio mixers (via mask) for non-encoded
multi-track outputs. If used with single-track outputs, the
single-track output will use either the first set mixer track in the
bitmask, or the first track if none is set in the bitmask.
---------------------
---------------------
...
...
libobs/obs-internal.h
浏览文件 @
b8a3ae1b
...
@@ -863,7 +863,7 @@ struct obs_output {
...
@@ -863,7 +863,7 @@ struct obs_output {
obs_encoder_t
*
video_encoder
;
obs_encoder_t
*
video_encoder
;
obs_encoder_t
*
audio_encoders
[
MAX_AUDIO_MIXES
];
obs_encoder_t
*
audio_encoders
[
MAX_AUDIO_MIXES
];
obs_service_t
*
service
;
obs_service_t
*
service
;
size_t
mixer_
idx
;
size_t
mixer_
mask
;
uint32_t
scaled_width
;
uint32_t
scaled_width
;
uint32_t
scaled_height
;
uint32_t
scaled_height
;
...
...
libobs/obs-module.c
浏览文件 @
b8a3ae1b
...
@@ -675,10 +675,16 @@ void obs_register_output_s(const struct obs_output_info *info, size_t size)
...
@@ -675,10 +675,16 @@ void obs_register_output_s(const struct obs_output_info *info, size_t size)
CHECK_REQUIRED_VAL_
(
info
,
raw_video
,
CHECK_REQUIRED_VAL_
(
info
,
raw_video
,
obs_register_output
);
obs_register_output
);
if
(
info
->
flags
&
OBS_OUTPUT_AUDIO
)
if
(
info
->
flags
&
OBS_OUTPUT_AUDIO
)
{
if
(
info
->
flags
&
OBS_OUTPUT_MULTI_TRACK
)
{
CHECK_REQUIRED_VAL_
(
info
,
raw_audio2
,
obs_register_output
);
}
else
{
CHECK_REQUIRED_VAL_
(
info
,
raw_audio
,
CHECK_REQUIRED_VAL_
(
info
,
raw_audio
,
obs_register_output
);
obs_register_output
);
}
}
}
}
#undef CHECK_REQUIRED_VAL_
#undef CHECK_REQUIRED_VAL_
REGISTER_OBS_DEF
(
size
,
obs_output_info
,
obs
->
output_types
,
info
);
REGISTER_OBS_DEF
(
size
,
obs_output_info
,
obs
->
output_types
,
info
);
...
...
libobs/obs-output.c
浏览文件 @
b8a3ae1b
...
@@ -544,19 +544,46 @@ audio_t *obs_output_audio(const obs_output_t *output)
...
@@ -544,19 +544,46 @@ audio_t *obs_output_audio(const obs_output_t *output)
output
->
audio
:
NULL
;
output
->
audio
:
NULL
;
}
}
static
inline
size_t
get_first_mixer
(
const
obs_output_t
*
output
)
{
for
(
size_t
i
=
0
;
i
<
MAX_AUDIO_MIXES
;
i
++
)
{
if
((((
size_t
)
1
<<
i
)
&
output
->
mixer_mask
)
!=
0
)
{
return
i
;
}
}
return
0
;
}
void
obs_output_set_mixer
(
obs_output_t
*
output
,
size_t
mixer_idx
)
void
obs_output_set_mixer
(
obs_output_t
*
output
,
size_t
mixer_idx
)
{
{
if
(
!
obs_output_valid
(
output
,
"obs_output_set_mixer"
))
if
(
!
obs_output_valid
(
output
,
"obs_output_set_mixer"
))
return
;
return
;
if
(
!
active
(
output
))
if
(
!
active
(
output
))
output
->
mixer_
idx
=
mixer_idx
;
output
->
mixer_
mask
=
(
size_t
)
1
<<
mixer_idx
;
}
}
size_t
obs_output_get_mixer
(
const
obs_output_t
*
output
)
size_t
obs_output_get_mixer
(
const
obs_output_t
*
output
)
{
{
return
obs_output_valid
(
output
,
"obs_output_get_mixer"
)
?
if
(
!
obs_output_valid
(
output
,
"obs_output_get_mixer"
))
output
->
mixer_idx
:
0
;
return
0
;
return
get_first_mixer
(
output
);
}
void
obs_output_set_mixers
(
obs_output_t
*
output
,
size_t
mixers
)
{
if
(
!
obs_output_valid
(
output
,
"obs_output_set_mixers"
))
return
;
output
->
mixer_mask
=
mixers
;
}
size_t
obs_output_get_mixers
(
const
obs_output_t
*
output
)
{
return
obs_output_valid
(
output
,
"obs_output_get_mixers"
)
?
output
->
mixer_mask
:
0
;
}
}
void
obs_output_remove_encoder
(
struct
obs_output
*
output
,
void
obs_output_remove_encoder
(
struct
obs_output
*
output
,
...
@@ -1476,6 +1503,7 @@ static void default_raw_video_callback(void *param, struct video_data *frame)
...
@@ -1476,6 +1503,7 @@ static void default_raw_video_callback(void *param, struct video_data *frame)
output
->
total_frames
++
;
output
->
total_frames
++
;
}
}
static
void
default_raw_audio_callback
(
void
*
param
,
size_t
mix_idx
,
static
void
default_raw_audio_callback
(
void
*
param
,
size_t
mix_idx
,
struct
audio_data
*
frames
)
struct
audio_data
*
frames
)
{
{
...
@@ -1483,9 +1511,10 @@ static void default_raw_audio_callback(void *param, size_t mix_idx,
...
@@ -1483,9 +1511,10 @@ static void default_raw_audio_callback(void *param, size_t mix_idx,
if
(
!
data_active
(
output
))
if
(
!
data_active
(
output
))
return
;
return
;
if
(
output
->
info
.
raw_audio2
)
output
->
info
.
raw_audio2
(
output
->
context
.
data
,
mix_idx
,
frames
);
else
output
->
info
.
raw_audio
(
output
->
context
.
data
,
frames
);
output
->
info
.
raw_audio
(
output
->
context
.
data
,
frames
);
UNUSED_PARAMETER
(
mix_idx
);
}
}
static
inline
void
start_audio_encoders
(
struct
obs_output
*
output
,
static
inline
void
start_audio_encoders
(
struct
obs_output
*
output
,
...
@@ -1499,6 +1528,25 @@ static inline void start_audio_encoders(struct obs_output *output,
...
@@ -1499,6 +1528,25 @@ static inline void start_audio_encoders(struct obs_output *output,
}
}
}
}
static
inline
void
start_raw_audio
(
obs_output_t
*
output
)
{
if
(
output
->
info
.
raw_audio2
)
{
for
(
int
idx
=
0
;
idx
<
MAX_AUDIO_MIXES
;
idx
++
)
{
if
((
output
->
mixer_mask
&
((
size_t
)
1
<<
idx
))
!=
0
)
{
audio_output_connect
(
output
->
audio
,
idx
,
get_audio_conversion
(
output
),
default_raw_audio_callback
,
output
);
}
}
}
else
{
audio_output_connect
(
output
->
audio
,
get_first_mixer
(
output
),
get_audio_conversion
(
output
),
default_raw_audio_callback
,
output
);
}
}
static
void
reset_packet_data
(
obs_output_t
*
output
)
static
void
reset_packet_data
(
obs_output_t
*
output
)
{
{
output
->
received_audio
=
false
;
output
->
received_audio
=
false
;
...
@@ -1557,9 +1605,7 @@ static void hook_data_capture(struct obs_output *output, bool encoded,
...
@@ -1557,9 +1605,7 @@ static void hook_data_capture(struct obs_output *output, bool encoded,
get_video_conversion
(
output
),
get_video_conversion
(
output
),
default_raw_video_callback
,
output
);
default_raw_video_callback
,
output
);
if
(
has_audio
)
if
(
has_audio
)
audio_output_connect
(
output
->
audio
,
output
->
mixer_idx
,
start_raw_audio
(
output
);
get_audio_conversion
(
output
),
default_raw_audio_callback
,
output
);
}
}
}
}
...
@@ -1786,6 +1832,25 @@ static inline void stop_audio_encoders(obs_output_t *output,
...
@@ -1786,6 +1832,25 @@ static inline void stop_audio_encoders(obs_output_t *output,
}
}
}
}
static
inline
void
stop_raw_audio
(
obs_output_t
*
output
)
{
if
(
output
->
info
.
raw_audio2
)
{
for
(
int
idx
=
0
;
idx
<
MAX_AUDIO_MIXES
;
idx
++
)
{
if
((
output
->
mixer_mask
&
((
size_t
)
1
<<
idx
))
!=
0
)
{
audio_output_disconnect
(
output
->
audio
,
idx
,
default_raw_audio_callback
,
output
);
}
}
}
else
{
audio_output_disconnect
(
output
->
audio
,
get_first_mixer
(
output
),
default_raw_audio_callback
,
output
);
}
}
static
void
*
end_data_capture_thread
(
void
*
data
)
static
void
*
end_data_capture_thread
(
void
*
data
)
{
{
bool
encoded
,
has_video
,
has_audio
,
has_service
;
bool
encoded
,
has_video
,
has_audio
,
has_service
;
...
@@ -1812,9 +1877,7 @@ static void *end_data_capture_thread(void *data)
...
@@ -1812,9 +1877,7 @@ static void *end_data_capture_thread(void *data)
stop_raw_video
(
output
->
video
,
stop_raw_video
(
output
->
video
,
default_raw_video_callback
,
output
);
default_raw_video_callback
,
output
);
if
(
has_audio
)
if
(
has_audio
)
audio_output_disconnect
(
output
->
audio
,
stop_raw_audio
(
output
);
output
->
mixer_idx
,
default_raw_audio_callback
,
output
);
}
}
if
(
has_service
)
if
(
has_service
)
...
...
libobs/obs-output.h
浏览文件 @
b8a3ae1b
...
@@ -71,6 +71,9 @@ struct obs_output_info {
...
@@ -71,6 +71,9 @@ struct obs_output_info {
/* only used with encoded outputs, separated with semicolon */
/* only used with encoded outputs, separated with semicolon */
const
char
*
encoded_video_codecs
;
const
char
*
encoded_video_codecs
;
const
char
*
encoded_audio_codecs
;
const
char
*
encoded_audio_codecs
;
/* raw audio callback for multi track outputs */
void
(
*
raw_audio2
)(
void
*
data
,
size_t
idx
,
struct
audio_data
*
frames
);
};
};
EXPORT
void
obs_register_output_s
(
const
struct
obs_output_info
*
info
,
EXPORT
void
obs_register_output_s
(
const
struct
obs_output_info
*
info
,
...
...
libobs/obs.h
浏览文件 @
b8a3ae1b
...
@@ -1632,6 +1632,12 @@ EXPORT void obs_output_set_mixer(obs_output_t *output, size_t mixer_idx);
...
@@ -1632,6 +1632,12 @@ EXPORT void obs_output_set_mixer(obs_output_t *output, size_t mixer_idx);
/** Gets the current audio mixer for non-encoded outputs */
/** Gets the current audio mixer for non-encoded outputs */
EXPORT
size_t
obs_output_get_mixer
(
const
obs_output_t
*
output
);
EXPORT
size_t
obs_output_get_mixer
(
const
obs_output_t
*
output
);
/** Sets the current audio mixes (mask) for a non-encoded multi-track output */
EXPORT
void
obs_output_set_mixers
(
obs_output_t
*
output
,
size_t
mixers
);
/** Gets the current audio mixes (mask) for a non-encoded multi-track output */
EXPORT
size_t
obs_output_get_mixers
(
const
obs_output_t
*
output
);
/**
/**
* Sets the current video encoder associated with this output,
* Sets the current video encoder associated with this output,
* required for encoded outputs
* required for encoded outputs
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录