diff --git a/docs/sphinx/reference-libobs-media-io.rst b/docs/sphinx/reference-libobs-media-io.rst index 2880722f9dacae..0a067b6c140e24 100644 --- a/docs/sphinx/reference-libobs-media-io.rst +++ b/docs/sphinx/reference-libobs-media-io.rst @@ -178,6 +178,17 @@ Video Handler --------------------- +.. function:: bool video_output_disconnect2(video_t *video, void (*callback)(void *param, struct video_data *frame), void *param) + + Disconnects a raw video callback from the video output handler. + + :param video: Video output handler object + :param callback: Callback + :param param: Private data + :return: *true* if callback was removed, *false* otherwise (e.g. already removed) + +--------------------- + .. function:: const struct video_output_info *video_output_get_info(const video_t *video) Gets the full video information of the video output handler. diff --git a/libobs/media-io/video-io.c b/libobs/media-io/video-io.c index 6801451f20d91b..ec6b4243fa92ac 100644 --- a/libobs/media-io/video-io.c +++ b/libobs/media-io/video-io.c @@ -463,9 +463,14 @@ static void log_skipped(video_t *video) } void video_output_disconnect(video_t *video, void (*callback)(void *param, struct video_data *frame), void *param) +{ + video_output_disconnect2(video, callback, param); +} + +bool video_output_disconnect2(video_t *video, void (*callback)(void *param, struct video_data *frame), void *param) { if (!video || !callback) - return; + return false; video = get_root(video); @@ -485,6 +490,8 @@ void video_output_disconnect(video_t *video, void (*callback)(void *param, struc } pthread_mutex_unlock(&video->input_mutex); + + return idx != DARRAY_INVALID; } bool video_output_active(const video_t *video) diff --git a/libobs/media-io/video-io.h b/libobs/media-io/video-io.h index 84f8a1a8269a06..fde6ca7c593c67 100644 --- a/libobs/media-io/video-io.h +++ b/libobs/media-io/video-io.h @@ -305,6 +305,8 @@ EXPORT bool video_output_connect2(video_t *video, const struct video_scale_info void *param); EXPORT void video_output_disconnect(video_t *video, void (*callback)(void *param, struct video_data *frame), void *param); +EXPORT bool video_output_disconnect2(video_t *video, void (*callback)(void *param, struct video_data *frame), + void *param); EXPORT bool video_output_active(const video_t *video);