From f61654a4673307b5e5f8578bc155faa833965bd5 Mon Sep 17 00:00:00 2001 From: Aleksandr Voitenko Date: Mon, 18 Nov 2024 16:13:18 +0000 Subject: [PATCH] Changed a little API for video mixes to be compatible with new virtual camera custom sources --- libobs/obs-output.c | 15 ++------------- libobs/obs-source-transition.c | 2 +- libobs/obs-view.c | 4 ++-- libobs/obs.c | 11 ++++++++++- libobs/obs.h | 8 +++++--- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libobs/obs-output.c b/libobs/obs-output.c index 102a56ed2f0fb2..22d1fefdd31b20 100644 --- a/libobs/obs-output.c +++ b/libobs/obs-output.c @@ -888,8 +888,7 @@ proc_handler_t *obs_output_get_proc_handler(const obs_output_t *output) : NULL; } -void obs_output_set_media(obs_output_t *output, obs_core_video_mix_t *mix, - audio_t *audio) +void obs_output_set_media(obs_output_t *output, video_t *video, audio_t *audio) { if (!obs_output_valid(output, "obs_output_set_media")) return; @@ -897,21 +896,11 @@ void obs_output_set_media(obs_output_t *output, obs_core_video_mix_t *mix, return; if (flag_video(output)) - output->video = mix->video; + output->video = video; if (flag_audio(output)) output->audio = audio; } -void obs_output_set_video_mix(obs_output_t *output, obs_core_video_mix_t *mix, - audio_t *audio) -{ - if (!obs_output_valid(output, "obs_output_set_media")) - return; - - output->video = mix->video; - output->audio = audio; -} - video_t *obs_output_video(const obs_output_t *output) { if (!obs_output_valid(output, "obs_output_video")) diff --git a/libobs/obs-source-transition.c b/libobs/obs-source-transition.c index 167ddc6d91a224..43cc24fc44c300 100644 --- a/libobs/obs-source-transition.c +++ b/libobs/obs-source-transition.c @@ -1181,7 +1181,7 @@ bool obs_transition_audio_render_do(obs_source_t *transition, uint64_t *ts_out, if (!transition_valid(transition, "obs_transition_audio_render")) return false; - blog(LOG_INFO, "[AUDIO_CANVAS] obs_transition_audio_render_do started"); + //blog(LOG_INFO, "[AUDIO_CANVAS] obs_transition_audio_render_do started"); lock_transition(transition); sources[0] = transition->transition_sources[0]; diff --git a/libobs/obs-view.c b/libobs/obs-view.c index 8c6968edabc95c..915996e9c30c7b 100644 --- a/libobs/obs-view.c +++ b/libobs/obs-view.c @@ -160,9 +160,9 @@ static inline void set_main_mix() obs->video.main_mix = mix; } -video_t *obs_view_add(obs_view_t *view, struct obs_video_info *ovi) +video_t *obs_view_add(obs_view_t *view) { - return obs_view_add2(view, ovi); + return obs_view_add2(view, obs->video.main_mix->ovi); } video_t *obs_view_add2(obs_view_t *view, struct obs_video_info *ovi) diff --git a/libobs/obs.c b/libobs/obs.c index e3f9e4c260db65..495af0f7bed130 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -802,7 +802,7 @@ static int obs_init_video() if (!ovi->initialized) continue; - if (!obs_view_add(&obs->data.main_view, ovi)) + if (!obs_view_add2(&obs->data.main_view, ovi)) return OBS_VIDEO_FAIL; if (!obs_stream_view_add(&obs->data.stream_view, ovi)) @@ -2727,6 +2727,15 @@ obs_core_video_mix_t *obs_video_mix_get(struct obs_video_info *ovi, return NULL; } +video_t *obs_video_mix_get_video(struct obs_core_video_mix *mix) +{ + if (mix) { + return mix->video; + } + + return NULL; +} + void obs_set_audio_rendering_mode(enum obs_audio_rendering_mode mode) { if (!obs) diff --git a/libobs/obs.h b/libobs/obs.h index e98f933cf53e65..fa21ebf525299c 100644 --- a/libobs/obs.h +++ b/libobs/obs.h @@ -1061,7 +1061,7 @@ EXPORT obs_source_t *obs_view_get_source(obs_view_t *view, uint32_t channel); EXPORT void obs_view_render(obs_view_t *view); /** Adds a view to the main render loop */ -EXPORT video_t *obs_view_add(obs_view_t *view, struct obs_video_info *ovi); +EXPORT video_t *obs_view_add(obs_view_t *view); /** Adds a view to the main render loop */ EXPORT video_t *obs_stream_view_add(obs_view_t *view, @@ -2308,8 +2308,8 @@ EXPORT proc_handler_t *obs_output_get_proc_handler(const obs_output_t *output); * Sets the current audio/video media contexts associated with this output, * required for non-encoded outputs. Can be null. */ -EXPORT void obs_output_set_media(obs_output_t *output, - obs_core_video_mix_t *mix, audio_t *audio); +EXPORT void obs_output_set_media(obs_output_t *output, video_t *video, + audio_t *audio); /** Returns the video media context associated with this output */ EXPORT video_t *obs_output_video(const obs_output_t *output); @@ -2593,6 +2593,8 @@ EXPORT const char *obs_encoder_get_name(const obs_encoder_t *encoder); EXPORT void obs_encoder_set_video_mix(obs_encoder_t *encoder, struct obs_core_video_mix *video); +EXPORT video_t *obs_video_mix_get_video(struct obs_core_video_mix *mix); + EXPORT obs_core_video_mix_t * obs_video_mix_get(struct obs_video_info *ovi, enum obs_video_rendering_mode mode);