Просмотр исходного кода

libobs: Add API to get encoder sample rate

In case the encoder has to use a different sample rate (due to the
sample rate being unsupported), we need an API function for the encoder
to get the sample rate that the encoder is actually running at.
jp9000 10 лет назад
Родитель
Сommit
9f96e691ae
2 измененных файлов с 14 добавлено и 0 удалено
  1. 11 0
      libobs/obs-encoder.c
  2. 3 0
      libobs/obs.h

+ 11 - 0
libobs/obs-encoder.c

@@ -503,6 +503,17 @@ uint32_t obs_encoder_get_height(const obs_encoder_t *encoder)
 		video_output_get_height(encoder->media);
 		video_output_get_height(encoder->media);
 }
 }
 
 
+uint32_t obs_encoder_get_sample_rate(const obs_encoder_t *encoder)
+{
+	if (!encoder || !encoder->media ||
+	    encoder->info.type != OBS_ENCODER_AUDIO)
+		return 0;
+
+	return encoder->samplerate != 0 ?
+		encoder->samplerate :
+		audio_output_get_sample_rate(encoder->media);
+}
+
 void obs_encoder_set_video(obs_encoder_t *encoder, video_t *video)
 void obs_encoder_set_video(obs_encoder_t *encoder, video_t *video)
 {
 {
 	const struct video_output_info *voi;
 	const struct video_output_info *voi;

+ 3 - 0
libobs/obs.h

@@ -1385,6 +1385,9 @@ EXPORT uint32_t obs_encoder_get_width(const obs_encoder_t *encoder);
 /** For video encoders, returns the height of the encoded image */
 /** For video encoders, returns the height of the encoded image */
 EXPORT uint32_t obs_encoder_get_height(const obs_encoder_t *encoder);
 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);
+
 /**
 /**
  * Sets the preferred video format for a video encoder.  If the encoder can use
  * 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
  * the format specified, it will force a conversion to that format if the