From c4b482efefdc5ed5c69431486ca2481aa988fc89 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Mon, 23 Apr 2018 09:05:32 -0700 Subject: [PATCH] libobs: Add functions to get raw video output Adds obs_add_raw_video_callback() and obs_remove_raw_video_callback() functions which allow the ability to get raw video frames without necessarily needing to create an output. --- docs/sphinx/reference-core.rst | 12 ++++++++++++ libobs/obs.c | 21 +++++++++++++++++++++ libobs/obs.h | 8 ++++++++ 3 files changed, 41 insertions(+) diff --git a/docs/sphinx/reference-core.rst b/docs/sphinx/reference-core.rst index d5655b8c2..bc4408340 100644 --- a/docs/sphinx/reference-core.rst +++ b/docs/sphinx/reference-core.rst @@ -433,6 +433,18 @@ Video, Audio, and Graphics Adds/removes a main rendering callback. Allows custom rendering to the main stream/recording output. +--------------------- + +.. function:: void obs_add_raw_video_callback(const struct video_scale_info *conversion, void (*callback)(void *param, struct video_data *frame), void *param) + void obs_remove_raw_video_callback(void (*callback)(void *param, struct video_data *frame), void *param) + + Adds/removes a raw video callback. Allows the ability to obtain raw + video frames without necessarily using an output. + + :param conversion: Specifies conversion requirements. Can be NULL. + :param callback: The callback that receives raw video frames. + :param param: The private data associated with the callback. + Primary signal/procedure handlers --------------------------------- diff --git a/libobs/obs.c b/libobs/obs.c index d5a53a3c5..da6840fc3 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -2089,3 +2089,24 @@ void stop_raw_video(video_t *v, os_atomic_dec_long(&video->raw_active); video_output_disconnect(v, callback, param); } + +void obs_add_raw_video_callback( + const struct video_scale_info *conversion, + void (*callback)(void *param, struct video_data *frame), + void *param) +{ + struct obs_core_video *video = &obs->video; + if (!obs) + return; + start_raw_video(video->video, conversion, callback, param); +} + +void obs_remove_raw_video_callback( + void (*callback)(void *param, struct video_data *frame), + void *param) +{ + struct obs_core_video *video = &obs->video; + if (!obs) + return; + stop_raw_video(video->video, callback, param); +} diff --git a/libobs/obs.h b/libobs/obs.h index 497abc634..9c61fd74b 100644 --- a/libobs/obs.h +++ b/libobs/obs.h @@ -628,6 +628,14 @@ EXPORT void obs_remove_main_render_callback( void (*draw)(void *param, uint32_t cx, uint32_t cy), void *param); +EXPORT void obs_add_raw_video_callback( + const struct video_scale_info *conversion, + void (*callback)(void *param, struct video_data *frame), + void *param); +EXPORT void obs_remove_raw_video_callback( + void (*callback)(void *param, struct video_data *frame), + void *param); + /* ------------------------------------------------------------------------- */ /* View context */