Răsfoiți Sursa

libobs,docs: Add protocol to Services API

tytan652 3 ani în urmă
părinte
comite
813b3b2763
5 a modificat fișierele cu 24 adăugiri și 0 ștergeri
  1. 10 0
      docs/sphinx/reference-services.rst
  2. 1 0
      libobs/obs-module.c
  3. 8 0
      libobs/obs-service.c
  4. 2 0
      libobs/obs-service.h
  5. 3 0
      libobs/obs.h

+ 10 - 0
docs/sphinx/reference-services.rst

@@ -148,6 +148,10 @@ Service Definition Structure
             the data manually (typically best to use strlist_split to
             generate this)
 
+.. member:: const char *(*obs_service_info.get_protocol)(void *data)
+
+   :return: The protocol used by the service
+
 
 General Service Functions
 -------------------------
@@ -305,6 +309,12 @@ General Service Functions
             for the service, terminated with a *NULL* pointer. Does not
             need to be freed
 
+---------------------
+
+.. function:: const char *obs_service_get_protocol(const obs_service_t *service)
+
+   :return: Protocol currently used for this service
+
 .. ---------------------------------------------------------------------------
 
 .. _libobs/obs-service.h: https://github.com/obsproject/obs-studio/blob/master/libobs/obs-service.h

+ 1 - 0
libobs/obs-module.c

@@ -928,6 +928,7 @@ void obs_register_service_s(const struct obs_service_info *info, size_t size)
 	CHECK_REQUIRED_VAL_(info, get_name, obs_register_service);
 	CHECK_REQUIRED_VAL_(info, create, obs_register_service);
 	CHECK_REQUIRED_VAL_(info, destroy, obs_register_service);
+	CHECK_REQUIRED_VAL_(info, get_protocol, obs_register_service);
 #undef CHECK_REQUIRED_VAL_
 
 	REGISTER_OBS_DEF(size, obs_service_info, obs->service_types, info);

+ 8 - 0
libobs/obs-service.c

@@ -477,3 +477,11 @@ obs_service_get_supported_video_codecs(const obs_service_t *service)
 			service->context.data);
 	return NULL;
 }
+
+const char *obs_service_get_protocol(const obs_service_t *service)
+{
+	if (!obs_service_valid(service, "obs_service_get_protocol"))
+		return NULL;
+
+	return service->info.get_protocol(service->context.data);
+}

+ 2 - 0
libobs/obs-service.h

@@ -88,6 +88,8 @@ struct obs_service_info {
 				int *audio_bitrate);
 
 	const char **(*get_supported_video_codecs)(void *data);
+
+	const char *(*get_protocol)(void *data);
 };
 
 EXPORT void obs_register_service_s(const struct obs_service_info *info,

+ 3 - 0
libobs/obs.h

@@ -2539,6 +2539,9 @@ obs_service_get_supported_video_codecs(const obs_service_t *service);
  * date. */
 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);
+
 /* ------------------------------------------------------------------------- */
 /* Source frame allocation functions */
 EXPORT void obs_source_frame_init(struct obs_source_frame *frame,