Changes to be committed:
modified: cmd/pmomusic/main.go new file: internal/netutils/ip_detect.go new file: internal/netutils/list_all_ip.go modified: internal/soap/soap.go modified: internal/ssdp/responder.go modified: internal/ssdp/ssdp.go modified: internal/upnp/http.go new file: internal/upnp/server.go new file: internal/upnp/xml/AVTransport.xml new file: internal/upnp/xml/ConnectionManager.xml new file: internal/upnp/xml/RenderingControl.xml
This commit is contained in:
@@ -2,30 +2,16 @@ package upnp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"gargoton.petite-maison-orange.fr/eric/pmomusic/internal/soap"
|
||||
)
|
||||
|
||||
func StartHTTPServer(usn string) {
|
||||
http.HandleFunc("/description.xml", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/xml")
|
||||
w.Write([]byte(generateDeviceDescription(usn)))
|
||||
})
|
||||
|
||||
http.HandleFunc("/upnp/control/AVTransport", soap.HandleSOAP)
|
||||
|
||||
log.Fatal(http.ListenAndServe(":1400", nil))
|
||||
}
|
||||
|
||||
func generateDeviceDescription(usn string) string {
|
||||
func generateDeviceDescription(usn, ip string, port uint) string {
|
||||
return fmt.Sprintf(`<?xml version="1.0"?>
|
||||
<root xmlns="urn:schemas-upnp-org:device-1-0">
|
||||
<specVersion>
|
||||
<major>1</major>
|
||||
<minor>0</minor>
|
||||
</specVersion>
|
||||
<URLBase>http://%s:%d/</URLBase>
|
||||
<device>
|
||||
<deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType>
|
||||
<friendlyName>pmomusic Fake Renderer</friendlyName>
|
||||
@@ -36,7 +22,7 @@ func generateDeviceDescription(usn string) string {
|
||||
<modelNumber>1.0</modelNumber>
|
||||
<modelURL>http://example.com/model</modelURL>
|
||||
<UDN>%s</UDN>
|
||||
<presentationURL>http://%s</presentationURL>
|
||||
<presentationURL>http://%s:%d</presentationURL>
|
||||
<serviceList>
|
||||
<service>
|
||||
<serviceType>urn:schemas-upnp-org:service:AVTransport:1</serviceType>
|
||||
@@ -61,5 +47,5 @@ func generateDeviceDescription(usn string) string {
|
||||
</service>
|
||||
</serviceList>
|
||||
</device>
|
||||
</root>`, usn, "127.0.0.1:1400") // à adapter à ton IP:port réel
|
||||
</root>`, ip, port, usn, ip, port)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user