Initial import

This commit is contained in:
2026-07-15 18:00:11 +02:00
parent 02d961e53d
commit c6954f5109
29 changed files with 3062 additions and 2 deletions
+53
View File
@@ -0,0 +1,53 @@
#lang racket/base
;; Typed interface for the UPnP ConnectionManager service.
(require racket/list
racket/string
"../service.rkt")
(provide connection-manager?
device-connection-manager
connection-manager-protocols
connection-manager-source-protocols
connection-manager-sink-protocols
connection-manager-connection-ids)
(define (connection-manager? value)
(and (upnp-service? value)
(eq? (upnp-service-kind value) 'connection-manager)))
(define (check-connection-manager who value)
(unless (connection-manager? value)
(raise-argument-error who "connection-manager?" value)))
(define (device-connection-manager device)
(upnp-device-service device 'connection-manager))
(define (csv-values value)
(if (or (not value) (string=? (string-trim value) ""))
'()
(for/list ([item (in-list (string-split value ","))])
(string-trim item))))
;; Return two values: the source protocol-info list and the sink protocol-info
;; list advertised by the device.
(define (connection-manager-protocols manager)
(check-connection-manager 'connection-manager-protocols manager)
(let ([result (upnp-service-call manager "GetProtocolInfo")])
(values (csv-values (hash-ref result "Source" ""))
(csv-values (hash-ref result "Sink" "")))))
(define (connection-manager-source-protocols manager)
(let-values ([(source sink) (connection-manager-protocols manager)])
source))
(define (connection-manager-sink-protocols manager)
(let-values ([(source sink) (connection-manager-protocols manager)])
sink))
(define (connection-manager-connection-ids manager)
(check-connection-manager 'connection-manager-connection-ids manager)
(let ([result (upnp-service-call manager "GetCurrentConnectionIDs")])
(filter-map string->number
(csv-values (hash-ref result "ConnectionIDs" "")))))