Browse Source

libobs: Add API for getting priming samples from audio encoders

derrod 3 weeks ago
parent
commit
5cbf0c5e6e
3 changed files with 15 additions and 0 deletions
  1. 9 0
      libobs/obs-encoder.c
  2. 3 0
      libobs/obs-encoder.h
  3. 3 0
      libobs/obs.h

+ 9 - 0
libobs/obs-encoder.c

@@ -2165,3 +2165,12 @@ bool obs_encoder_video_tex_active(const obs_encoder_t *encoder, enum video_forma
 
 	return false;
 }
+
+uint32_t obs_encoder_get_priming_samples(const obs_encoder_t *encoder)
+{
+	if (encoder->info.get_priming_samples) {
+		return encoder->info.get_priming_samples(encoder->context.data);
+	}
+
+	return 0;
+}

+ 3 - 0
libobs/obs-encoder.h

@@ -344,6 +344,9 @@ struct obs_encoder_info {
 
 	bool (*encode_texture2)(void *data, struct encoder_texture *texture, int64_t pts, uint64_t lock_key,
 				uint64_t *next_key, struct encoder_packet *packet, bool *received_packet);
+
+	/** Audio encoder only: Returns padding, in samples, that must be skipped at the start of the stream. */
+	uint32_t (*get_priming_samples)(void *data);
 };
 
 EXPORT void obs_register_encoder_s(const struct obs_encoder_info *info, size_t size);

+ 3 - 0
libobs/obs.h

@@ -2349,6 +2349,9 @@ EXPORT size_t obs_encoder_get_frame_size(const obs_encoder_t *encoder);
 /** For audio encoders, returns the mixer index */
 EXPORT size_t obs_encoder_get_mixer_index(const obs_encoder_t *encoder);
 
+/* For audio encoders, returns the number of samples to skip at the beginning of the stream */
+EXPORT uint32_t obs_encoder_get_priming_samples(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