diff --git a/onvif/src/discovery/mod.rs b/onvif/src/discovery/mod.rs index acbc43e..fe871c0 100644 --- a/onvif/src/discovery/mod.rs +++ b/onvif/src/discovery/mod.rs @@ -35,7 +35,9 @@ pub enum Error { pub struct Device { /// The WS-Discovery UUID / address reference pub address: String, + pub hardware: Option, pub name: Option, + pub types: Vec, pub urls: Vec, } @@ -229,12 +231,20 @@ fn device_from_envelope(envelope: probe_matches::Envelope) -> Option { let name = onvif_probe_match.name(); let urls = onvif_probe_match.x_addrs(); + let hardware = onvif_probe_match.hardware(); let address = onvif_probe_match.endpoint_reference_address(); + let types = onvif_probe_match + .types() + .into_iter() + .map(Into::into) + .collect(); Some(Device { name, urls, address, + hardware, + types, }) } @@ -315,7 +325,9 @@ fn test_xaddrs_extraction() { Url::parse("http://addr_22").unwrap(), ], name: Some("MyCamera2000".to_string()), + hardware: None, address: DEVICE_ADDRESS.to_string(), + types: vec![] }] ); } diff --git a/wsdl_rs/ws_discovery/src/lib.rs b/wsdl_rs/ws_discovery/src/lib.rs index 08c700e..4da10a5 100644 --- a/wsdl_rs/ws_discovery/src/lib.rs +++ b/wsdl_rs/ws_discovery/src/lib.rs @@ -139,7 +139,16 @@ pub mod probe_matches { impl ProbeMatch { pub fn types(&self) -> Vec<&str> { - self.types.split_whitespace().collect() + self.types + .split_whitespace() + .map(|t: &str| { + // Remove WSDL prefixes + match t.find(':') { + Some(idx) => t.split_at(idx + 1).1, + None => t, + } + }) + .collect() } pub fn scopes(&self) -> Vec { @@ -221,5 +230,7 @@ pub mod probe_matches { Url::parse("http://10.0.0.200:80/onvif/device_service").unwrap(), ] ); + + assert_eq!(de.types(), vec!["NetworkVideoTransmitter", "Device"]); } }