Browse Source

libobs: Add API to apply service encoder settings

Instead of having services automatically apply encoder settings on
initialization (whether the output wants to or not), instead make it
something that must be explicitly called by the developer.  There are
cases where the developer may not wish to apply the service-specific
settings, or may wish to override them for whatever reason.
jp9000 11 năm trước cách đây
mục cha
commit
4eacb5f3e9
3 tập tin đã thay đổi với 29 bổ sung0 xóa
  1. 16 0
      libobs/obs-service.c
  2. 4 0
      libobs/obs-service.h
  3. 9 0
      libobs/obs.h

+ 16 - 0
libobs/obs-service.c

@@ -235,3 +235,19 @@ bool obs_service_initialize(struct obs_service *service,
 		return service->info.initialize(service->context.data, output);
 	return true;
 }
+
+void obs_service_apply_encoder_settings(obs_service_t *service,
+		obs_encoder_t *video_encoder, obs_encoder_t *audio_encoder)
+{
+	if (!service || !service->info.apply_encoder_settings)
+		return;
+
+	if (video_encoder && video_encoder->info.type != OBS_ENCODER_VIDEO)
+		video_encoder = NULL;
+	if (audio_encoder && audio_encoder->info.type != OBS_ENCODER_AUDIO)
+		audio_encoder = NULL;
+
+	if (video_encoder || audio_encoder)
+		service->info.apply_encoder_settings(service->context.data,
+				video_encoder, audio_encoder);
+}

+ 4 - 0
libobs/obs-service.h

@@ -64,6 +64,10 @@ struct obs_service_info {
 	const char *(*get_password)(void *data);
 
 	bool (*supports_multitrack)(void *data);
+
+	void (*apply_encoder_settings)(void *data, obs_encoder_t *video_encoder,
+			obs_encoder_t *audio_encoder);
+
 	/* TODO: more stuff later */
 };
 

+ 9 - 0
libobs/obs.h

@@ -1315,6 +1315,15 @@ EXPORT const char *obs_service_get_username(const obs_service_t *service);
 /** Returns the password (if any) for this service context */
 EXPORT const char *obs_service_get_password(const obs_service_t *service);
 
+/**
+ * Applies service-specific video encoder settings.
+ *
+ * @param  video_encoder  Video encoder to apply settings to.  Optional.
+ * @param  audio_encoder  Audio encoder to apply settings to.  Optional.
+ */
+EXPORT void obs_service_apply_encoder_settings(obs_service_t *service,
+		obs_encoder_t *video_encoder, obs_encoder_t *audio_encoder);
+
 
 /* ------------------------------------------------------------------------- */
 /* Source frame allocation functions */