Skip to content

Commit

Permalink
libobs: Add obs_encoder_parent_video() method
Browse files Browse the repository at this point in the history
Allows parent video object of an encoder with an FPS divisor to be
fetched.
  • Loading branch information
tt2468 authored and Lain-B committed May 3, 2024
1 parent 64caf04 commit d584aed
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/sphinx/reference-encoders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,14 @@ General Encoder Functions
---------------------

.. function:: video_t *obs_encoder_video(const obs_encoder_t *encoder)
video_t *obs_encoder_parent_video(const obs_encoder_t *encoder)
audio_t *obs_encoder_audio(const obs_encoder_t *encoder)
:return: The video/audio handler associated with this encoder, or
*NULL* if none or not a matching encoder type
*NULL* if none or not a matching encoder type.
*parent_video* returns the "original" video handler
associated with this encoder, regardless of whether an FPS
divisor is set.

---------------------

Expand Down
15 changes: 15 additions & 0 deletions libobs/obs-encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,21 @@ video_t *obs_encoder_video(const obs_encoder_t *encoder)
return encoder->fps_override ? encoder->fps_override : encoder->media;
}

video_t *obs_encoder_parent_video(const obs_encoder_t *encoder)
{
if (!obs_encoder_valid(encoder, "obs_encoder_parent_video"))
return NULL;
if (encoder->info.type != OBS_ENCODER_VIDEO) {
blog(LOG_WARNING,
"obs_encoder_parent_video: "
"encoder '%s' is not a video encoder",
obs_encoder_get_name(encoder));
return NULL;
}

return encoder->media;
}

audio_t *obs_encoder_audio(const obs_encoder_t *encoder)
{
if (!obs_encoder_valid(encoder, "obs_encoder_audio"))
Expand Down
7 changes: 7 additions & 0 deletions libobs/obs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2558,6 +2558,13 @@ EXPORT void obs_encoder_set_audio(obs_encoder_t *encoder, audio_t *audio);
*/
EXPORT video_t *obs_encoder_video(const obs_encoder_t *encoder);

/**
* Returns the parent video output context used with this encoder, or NULL if not
* a video context. Used when an FPS divisor is set, where the original video
* context would not otherwise be gettable.
*/
EXPORT video_t *obs_encoder_parent_video(const obs_encoder_t *encoder);

/**
* Returns the audio output context used with this encoder, or NULL if not
* a audio context
Expand Down

0 comments on commit d584aed

Please sign in to comment.