Ver Fonte

libobs,docs: Add preferred output type to Service API

tytan652 há 3 anos atrás
pai
commit
1e0f4a6ebf
4 ficheiros alterados com 30 adições e 12 exclusões
  1. 7 1
      docs/sphinx/reference-services.rst
  2. 17 10
      libobs/obs-service.c
  3. 1 0
      libobs/obs-service.h
  4. 5 1
      libobs/obs.h

+ 7 - 1
docs/sphinx/reference-services.rst

@@ -137,7 +137,7 @@ Service Definition Structure
 
    (Optional)
 
-   :return: The output type that should be used with this service
+   :return: The output type that should be preferred with this service
 
 .. member:: const char **(*get_supported_video_codecs)(void *data)
 
@@ -315,6 +315,12 @@ General Service Functions
 
    :return: Protocol currently used for this service
 
+---------------------
+
+.. function:: const char *obs_service_get_preferred_output_type(const obs_service_t *service)
+
+   :return: The output type that should be preferred with this service
+
 .. ---------------------------------------------------------------------------
 
 .. _libobs/obs-service.h: https://github.com/obsproject/obs-studio/blob/master/libobs/obs-service.h

+ 17 - 10
libobs/obs-service.c

@@ -411,16 +411,6 @@ const char *obs_service_get_id(const obs_service_t *service)
 		       : NULL;
 }
 
-const char *obs_service_get_output_type(const obs_service_t *service)
-{
-	if (!obs_service_valid(service, "obs_service_get_output_type"))
-		return NULL;
-
-	if (service->info.get_output_type)
-		return service->info.get_output_type(service->context.data);
-	return NULL;
-}
-
 void obs_service_get_supported_resolutions(
 	const obs_service_t *service,
 	struct obs_service_resolution **resolutions, size_t *count)
@@ -485,3 +475,20 @@ const char *obs_service_get_protocol(const obs_service_t *service)
 
 	return service->info.get_protocol(service->context.data);
 }
+
+/* OBS_DEPRECATED */
+const char *obs_service_get_output_type(const obs_service_t *service)
+{
+	return obs_service_get_preferred_output_type(service);
+}
+
+const char *obs_service_get_preferred_output_type(const obs_service_t *service)
+{
+	if (!obs_service_valid(service,
+			       "obs_service_get_preferred_output_type"))
+		return NULL;
+
+	if (service->info.get_output_type)
+		return service->info.get_output_type(service->context.data);
+	return NULL;
+}

+ 1 - 0
libobs/obs-service.h

@@ -77,6 +77,7 @@ struct obs_service_info {
 	void *type_data;
 	void (*free_type_data)(void *type_data);
 
+	/* TODO: Rename to 'get_preferred_output_type' once a API/ABI break happen */
 	const char *(*get_output_type)(void *data);
 
 	void (*get_supported_resolutions)(

+ 5 - 1
libobs/obs.h

@@ -2547,11 +2547,15 @@ obs_service_get_supported_video_codecs(const obs_service_t *service);
 
 /* NOTE: This function is temporary and should be removed/replaced at a later
  * date. */
-EXPORT const char *obs_service_get_output_type(const obs_service_t *service);
+OBS_DEPRECATED EXPORT const char *
+obs_service_get_output_type(const obs_service_t *service);
 
 /** Returns the protocol for this service context */
 EXPORT const char *obs_service_get_protocol(const obs_service_t *service);
 
+EXPORT const char *
+obs_service_get_preferred_output_type(const obs_service_t *service);
+
 /* ------------------------------------------------------------------------- */
 /* Source frame allocation functions */
 EXPORT void obs_source_frame_init(struct obs_source_frame *frame,