/* scorpiox-scorpioplayer-dlna-upnp-media-server — DLNA/UPnP Digital Media Server (spdms_). * * SCORPIO PLAYER 2027 engine. Pure C99, zero external deps (vendored yyjson only). * See SPEC.md for every decision (D1..D22) referenced below. * * Process singleton. One server per process. The string returns point at static buffers: * valid until the next call of the same function, so copy them immediately. */ #ifndef SPDMS_H #define SPDMS_H #ifdef _WIN32 # ifdef SPDMS_BUILD # define SPDMS_API __declspec(dllexport) # else # define SPDMS_API __declspec(dllimport) # endif #else # define SPDMS_API __attribute__((visibility("default"))) #endif #ifdef __cplusplus extern "C" { #endif #define SPDMS_OK 0 #define SPDMS_E_ARG (-1) #define SPDMS_E_STATE (-2) #define SPDMS_E_NET (-3) #define SPDMS_E_NOENT (-4) #define SPDMS_E_NOMEM (-5) #define SPDMS_E_LIMIT (-6) #define SPDMS_E_TYPE (-7) /* ---- lifecycle ---- */ SPDMS_API const char *spdms_version(void); /* keys: ssdp_group, ssdp_port, ssdp_disable, max_age, uuid, event_moderation_ms, http_workers. * Must be called before spdms_start (except event_moderation_ms). NULL value = reset to default. */ SPDMS_API int spdms_config(const char *key, const char *value); /* bind_ip: an IPv4 literal of ONE interface (0.0.0.0 refused, D1). http_port 0 = ephemeral. */ SPDMS_API int spdms_start(const char *bind_ip, int http_port, const char *friendly_name, const char *const *roots, int nroots); SPDMS_API void spdms_stop(void); /* sends ssdp:byebye, clears roots */ SPDMS_API int spdms_is_running(void); SPDMS_API const char *spdms_udn(void); /* "uuid:..." */ SPDMS_API const char *spdms_description_url(void); SPDMS_API int spdms_http_port(void); /* ---- content (works before start too, for the pure tests) ---- */ SPDMS_API int spdms_add_path(const char *path); /* root index >= 0, or <0 */ SPDMS_API int spdms_remove_path(const char *path); /* 0 ok */ SPDMS_API int spdms_root_count(void); SPDMS_API const char *spdms_root_json(int i); /* {"path","kind":"file|folder","object_id","entries"} */ SPDMS_API int spdms_subscriber_count(void); SPDMS_API int spdms_rescan(void); /* number of containers bumped, <0 err */ SPDMS_API int spdms_system_update_id(void); /* ---- pure / socket-free ---- */ SPDMS_API const char *spdms_didl_for(const char *object_id, int start, int count); /* BrowseDirectChildren */ SPDMS_API const char *spdms_didl_metadata(const char *object_id); /* BrowseMetadata */ SPDMS_API const char *spdms_object_id_for_path(const char *key); /* FNV-1a 64, 16 hex (D7) */ SPDMS_API const char *spdms_mime_for(const char *filename); /* "" if not media */ SPDMS_API const char *spdms_upnp_class_for(const char *filename); /* "" if not media */ SPDMS_API const char *spdms_protocol_info_for(const char *filename); /* "" if not media */ /* 0 = satisfiable (*a..*b inclusive), 416 = unsatisfiable, -1 = ignore header (serve 200) */ SPDMS_API int spdms_parse_range(const char *hdr, long long size, long long *a, long long *b); SPDMS_API int spdms_natural_compare(const char *a, const char *b); /* SOAP control, no socket: service "cds" | "cms". Returns the response envelope (or fault). * spdms_last_code(): 0 ok, else the UPnP error code (401/402/701/706/720) or HTTP 400. */ SPDMS_API const char *spdms_soap_invoke(const char *service, const char *soapaction, const char *body); /* Map an HTTP request path to the local file it serves; "" = 404 (D14). */ SPDMS_API const char *spdms_resolve_url(const char *url_path); SPDMS_API const char *spdms_description_xml(void); SPDMS_API const char *spdms_scpd_xml(const char *service); /* "cds" | "cms" */ /* The SSDP responses an M-SEARCH packet would get (D3), "\n\n"-separated; last_code = count. */ SPDMS_API const char *spdms_ssdp_responses(const char *msearch); SPDMS_API int spdms_last_code(void); SPDMS_API const char *spdms_last_error(void); #ifdef __cplusplus } #endif #endif