/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::fs::File; use std::io::prelude::*; use std::panic; use std::path::Path; externcrate webrtc_sdp;
// Takes the filename of a file that contains SDP, and optionally the trailing // flag --expect-failure. // If --expect-failure is passed, then the program will exit with a successful // exit code if the file fails to parse. fn main() { letmut args = std::env::args(); let filename = match args.nth(1) {
None => {
eprintln!("Missing file name argument!");
std::process::exit(1);
}
Some(x) => x,
};
let path = Path::new(filename.as_str()); let display = path.display();
letmut file = match File::open(path) {
Err(why) => panic!("Failed to open {}: {}", display, why),
Ok(file) => file,
};
letmut s = String::new(); match file.read_to_string(&mut s) {
Err(why) => panic!("Couldn't read {}: {}", display, why),
Ok(s) => s,
};
// Hook up the panic handler if it is expected to fail to parse let expect_failure = iflet Some(x) = args.next() { if x.to_lowercase() != "--expect-failure" {
eprintln!("Extra arguments passed!");
std::process::exit(1);
}
panic::set_hook(Box::new(|_| {
println!("Exited with failure, as expected.");
std::process::exit(0);
})); true
} else { false
};
// Remove comment lines let s = s
.lines()
.filter(|&l| !l.trim_start().starts_with(';'))
.collect::<Vec<&str>>()
.join("\r\n");
let res = webrtc_sdp::parse_sdp(&s, true); match res {
Err(why) => panic!("Failed to parse SDP with error: {}", why),
Ok(sdp) => println!("Parsed SDP structure:\n{sdp:#?}"),
}
if expect_failure {
eprintln!("Successfully parsed SDP that was expected to fail. You may need to update the example expectations.");
std::process::exit(1);
}
println!("Successfully parsed SDP");
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-22)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.