libobs: Add API to get encoder frame size

When muxing to some format, duration of the packet is used. We need an
API for encoder to return the frame size.
master
Norihiro Kamae 2021-12-23 21:03:11 +09:00 committed by Jim
parent 29b8df97a6
commit d1b87e1642
3 changed files with 24 additions and 0 deletions

View File

@ -400,6 +400,12 @@ General Encoder Functions
---------------------
.. function:: uint32_t obs_encoder_get_frame_size(const obs_encoder_t *encoder)
:return: The frame size of the audio packet
---------------------
.. function:: void obs_encoder_set_preferred_video_format(obs_encoder_t *encoder, enum video_format format)
enum video_format obs_encoder_get_preferred_video_format(const obs_encoder_t *encoder)

View File

@ -760,6 +760,21 @@ uint32_t obs_encoder_get_sample_rate(const obs_encoder_t *encoder)
: audio_output_get_sample_rate(encoder->media);
}
uint32_t obs_encoder_get_frame_size(const obs_encoder_t *encoder)
{
if (!obs_encoder_valid(encoder, "obs_encoder_get_frame_size"))
return 0;
if (encoder->info.type != OBS_ENCODER_AUDIO) {
blog(LOG_WARNING,
"obs_encoder_get_frame_size: "
"encoder '%s' is not an audio encoder",
obs_encoder_get_name(encoder));
return 0;
}
return encoder->framesize != 0 ? encoder->framesize : 0;
}
void obs_encoder_set_video(obs_encoder_t *encoder, video_t *video)
{
const struct video_output_info *voi;

View File

@ -2209,6 +2209,9 @@ EXPORT uint32_t obs_encoder_get_height(const obs_encoder_t *encoder);
/** For audio encoders, returns the sample rate of the audio */
EXPORT uint32_t obs_encoder_get_sample_rate(const obs_encoder_t *encoder);
/** For audio encoders, returns the frame size of the audio packet */
EXPORT uint32_t obs_encoder_get_frame_size(const obs_encoder_t *encoder);
/**
* Sets the preferred video format for a video encoder. If the encoder can use
* the format specified, it will force a conversion to that format if the