From d45e92c10c90f3f951040cbae6684c40d3355fe9 Mon Sep 17 00:00:00 2001 From: Clayton Groeneveld Date: Wed, 17 Nov 2021 01:01:46 -0600 Subject: [PATCH] libobs: Add raw audio callback function This complements the already existing raw video callback function. --- docs/sphinx/reference-core.rst | 12 ++++++++++++ libobs/obs.c | 16 ++++++++++++++++ libobs/obs.h | 8 ++++++++ 3 files changed, 36 insertions(+) diff --git a/docs/sphinx/reference-core.rst b/docs/sphinx/reference-core.rst index 8d19beada..0dd6a0b70 100644 --- a/docs/sphinx/reference-core.rst +++ b/docs/sphinx/reference-core.rst @@ -473,6 +473,18 @@ Video, Audio, and Graphics :param callback: The callback that receives raw video frames. :param param: The private data associated with the callback. +--------------------- + +.. function:: void obs_add_raw_audio_callback(size_t mix_idx, const struct audio_convert_info *conversion, audio_output_callback_t callback, void *param) + void obs_remove_raw_raw_callback(size_t track, audio_output_callback_t callback, void *param) + + Adds/removes a raw audio callback. Allows the ability to obtain raw + audio data without necessarily using an output. + + :param mix_idx: Specifies audio track to get data from. + :param conversion: Specifies conversion requirements. Can be NULL. + :param callback: The callback that receives raw audio data. + :param param: The private data associated with the callback. Primary signal/procedure handlers --------------------------------- diff --git a/libobs/obs.c b/libobs/obs.c index f37314717..fc7dbf9ba 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -2389,6 +2389,22 @@ void obs_remove_raw_video_callback(void (*callback)(void *param, stop_raw_video(video->video, callback, param); } +void obs_add_raw_audio_callback(size_t mix_idx, + const struct audio_convert_info *conversion, + audio_output_callback_t callback, void *param) +{ + struct obs_core_audio *audio = &obs->audio; + audio_output_connect(audio, mix_idx, conversion, callback, param); +} + +void obs_remove_raw_audio_callback(size_t mix_idx, + audio_output_callback_t callback, + void *param) +{ + struct obs_core_audio *audio = &obs->audio; + audio_output_disconnect(audio, mix_idx, callback, param); +} + void obs_apply_private_data(obs_data_t *settings) { if (!settings) diff --git a/libobs/obs.h b/libobs/obs.h index 4bbc78b24..bc45ab79f 100644 --- a/libobs/obs.h +++ b/libobs/obs.h @@ -768,6 +768,14 @@ EXPORT void obs_add_raw_video_callback( EXPORT void obs_remove_raw_video_callback( void (*callback)(void *param, struct video_data *frame), void *param); +EXPORT void +obs_add_raw_audio_callback(size_t mix_idx, + const struct audio_convert_info *conversion, + audio_output_callback_t callback, void *param); +EXPORT void obs_remove_raw_audio_callback(size_t mix_idx, + audio_output_callback_t callback, + void *param); + EXPORT uint64_t obs_get_video_frame_time(void); EXPORT double obs_get_active_fps(void);