@@ -43,7 +43,7 @@ pub struct Meta {
43
43
pub struct Video {
44
44
width : u32 ,
45
45
height : u32 ,
46
- frame_rate : u32 ,
46
+ frame_rate : f64 ,
47
47
codec : String ,
48
48
profile : Option < String > ,
49
49
compat : Option < u32 > ,
@@ -52,7 +52,7 @@ pub struct Video {
52
52
53
53
#[ derive( Deserialize , Debug ) ]
54
54
pub struct Audio {
55
- codec : String ,
55
+ codec : Option < String > ,
56
56
profile : Option < String > ,
57
57
channels : Option < u32 > ,
58
58
sample_rate : Option < u32 > ,
@@ -186,7 +186,7 @@ impl StreamServersCommands for Nginx {
186
186
187
187
let a_info = format ! (
188
188
"{} {} {}Hz, {} channels" ,
189
- audio. codec,
189
+ audio. codec. unwrap_or_default ( ) ,
190
190
audio. profile. unwrap_or_default( ) ,
191
191
audio. sample_rate. unwrap_or_default( ) ,
192
192
audio. channels. unwrap_or_default( ) ,
@@ -210,3 +210,81 @@ impl Bsl for Nginx {}
210
210
// }
211
211
// }
212
212
// }
213
+ //
214
+
215
+ #[ cfg( test) ]
216
+ mod tests {
217
+ use super :: * ;
218
+
219
+ #[ test]
220
+ fn invalid_digit ( ) {
221
+ let text = r#"
222
+ <?xml version="1.0" encoding="utf-8" ?>
223
+ <?xml-stylesheet type="text/xsl" href="/stat.xsl" ?>
224
+ <rtmp>
225
+ <nginx_version>1.17.6</nginx_version>
226
+ <nginx_rtmp_version>1.1.7.11-dev</nginx_rtmp_version>
227
+ <compiler>gcc 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) </compiler>
228
+ <built>Feb 15 2021 01:06:01</built>
229
+ <pid>944</pid>
230
+ <uptime>1781693</uptime>
231
+ <naccepted>262</naccepted>
232
+ <bw_in>0</bw_in>
233
+ <bytes_in>1185796040</bytes_in>
234
+ <bw_out>0</bw_out>
235
+ <bytes_out>646442932</bytes_out>
236
+ <server>
237
+ <application>
238
+ <name>publish</name>
239
+ <live>
240
+ <stream>
241
+ <name>test</name>
242
+ <time>1832</time>
243
+ <bw_in>0</bw_in>
244
+ <bytes_in>766897</bytes_in>
245
+ <bw_out>0</bw_out>
246
+ <bytes_out>0</bytes_out>
247
+ <bw_audio>0</bw_audio>
248
+ <bw_video>0</bw_video>
249
+ <bw_data>0</bw_data>
250
+ <client>
251
+ <id>3192</id>
252
+ <address>123.123.123.123</address>
253
+ <port>59796</port>
254
+ <time>2008</time>
255
+ <flashver>FMLE/3.0 (compatible; Larix/nul</flashver>
256
+ <bytes_in>768181</bytes_in>
257
+ <bytes_out>409</bytes_out>
258
+ <dropped>0</dropped>
259
+ <avsync></avsync>
260
+ <timestamp>3361</timestamp>
261
+ <publishing/>
262
+ <active/>
263
+ </client>
264
+ <meta>
265
+ <video>
266
+ <width>1280</width>
267
+ <height>720</height>
268
+ <frame_rate>0.000</frame_rate>
269
+ <codec>H264</codec>
270
+ <profile>Baseline</profile>
271
+ <compat>192</compat>
272
+ <level>3.1</level>
273
+ </video>
274
+ <audio></audio>
275
+ </meta>
276
+ <nclients>1</nclients>
277
+ <publishing/>
278
+ <active/>
279
+ </stream>
280
+ <nclients>1</nclients>
281
+ </live>
282
+ </application>
283
+ </server>
284
+ </rtmp>
285
+ "# ;
286
+
287
+ let parsed: NginxRtmpStats = quick_xml:: de:: from_str ( & text) . unwrap ( ) ;
288
+ println ! ( "{:#?}" , parsed) ;
289
+ }
290
+ }
0 commit comments