blob: 7a32d404c7000b8f10afbe6770658d7c6a80a99e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
use hyper::{Client, Request};
use hyper::body::Body;
use tokio::runtime::Runtime;
use futures::Future;
const SOAP_ACTION_PREFIX: &'static str = "urn:schemas-upnp-org:service:AVTransport:1#";
const ACTION_SET_URI: &'static str = "SetAVTransportURI";
const ACTION_PLAY: &'static str = "Play";
const ACTION_PAUSE: &'static str = "Pause";
const ACTION_STOP: &'static str = "Stop";
pub const BODY_SET_URI: &'static str = r#"<?xml version='1.0' encoding='utf-8'?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<InstanceID>0</InstanceID>
<CurrentURI>http://10.5.1.243:51497/0</CurrentURI>
<CurrentURIMetaData><DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sec="http://www.sec.co.kr/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"><item id="0" parentID="-1" restricted="false"><upnp:class>object.item.videoItem.movie</upnp:class><dc:title>dlnanow</dc:title><res protocolInfo="http-get:*:video/mp4:*">http://10.5.1.243:51497/0</res></item></DIDL-Lite></CurrentURIMetaData>
</u:SetAVTransportURI>
</s:Body>
</s:Envelope>"#;
pub const BODY_PLAY: &'static str = r#"<?xml version='1.0' encoding='utf-8'?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<u:Play xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<InstanceID>0</InstanceID>
<Speed>1</Speed>
</u:Play>
</s:Body>
</s:Envelope>"#;
pub const BODY_PAUSE: &'static str = r#"<?xml version='1.0' encoding='utf-8'?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<u:Pause xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<InstanceID>0</InstanceID>
</u:Pause>
</s:Body>
</s:Envelope>"#;
pub const BODY_STOP: &'static str = r#"<?xml version='1.0' encoding='utf-8'?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<u:Stop xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
<InstanceID>0</InstanceID>
</u:Stop>
</s:Body>
</s:Envelope>"#;
pub const A_SET: &'static str = "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI";
pub const A_PLAY: &'static str = "urn:schemas-upnp-org:service:AVTransport:1#Play";
pub const A_STOP: &'static str = "urn:schemas-upnp-org:service:AVTransport:1#Stop";
pub const A_PAUSE: &'static str = "urn:schemas-upnp-org:service:AVTransport:1#Pause";
pub fn set_uri(rt: &mut Runtime) {
let req = Request::builder()
.method("POST")
.uri("http://10.5.1.201:38400/serviceControl/AVTransport")
.header("Content-Type", "text/xml")
.header("SOAPACTION", A_SET)
.body(Body::from(BODY_SET_URI))
.unwrap();
let client = Client::new();
let f = client
.request(req)
.map(|_res| {
println!("Request good")
})
.map_err(|_err| {
println!("Request error");
});
rt.spawn(f);
}
pub fn play(rt: &mut Runtime) {
let req = Request::builder()
.method("POST")
.uri("http://10.5.1.201:38400/serviceControl/AVTransport")
.header("Content-Type", "text/xml")
.header("SOAPACTION", A_PLAY)
.body(Body::from(BODY_PLAY))
.unwrap();
let client = Client::new();
let f = client
.request(req)
.map(|_res| {
println!("Request good")
})
.map_err(|_err| {
println!("Request error");
});
rt.spawn(f);
}
pub fn pause(rt: &mut Runtime) {
let req = Request::builder()
.method("POST")
.uri("http://10.5.1.201:38400/serviceControl/AVTransport")
.header("Content-Type", "text/xml")
.header("SOAPACTION", A_PAUSE)
.body(Body::from(BODY_PAUSE))
.unwrap();
let client = Client::new();
let f = client
.request(req)
.map(|_res| {
println!("Request good")
})
.map_err(|_err| {
println!("Request error");
});
rt.spawn(f);
}
pub fn stop(rt: &mut Runtime) {
let req = Request::builder()
.method("POST")
.uri("http://10.5.1.201:38400/serviceControl/AVTransport")
.header("Content-Type", "text/xml")
.header("SOAPACTION", A_STOP)
.body(Body::from(BODY_STOP))
.unwrap();
let client = Client::new();
let f = client
.request(req)
.map(|_res| {
println!("Request good")
})
.map_err(|_err| {
println!("Request error");
});
rt.spawn(f);
}
|