forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1553011 - update import of Rust SDP parser - r=drno
update import of Rust SDP parser Differential Revision: https://phabricator.services.mozilla.com/D31943
- Loading branch information
Showing
58 changed files
with
3,272 additions
and
1,965 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
[package] | ||
name = "rsdparsa" | ||
name = "webrtc-sdp" | ||
version = "0.1.0" | ||
authors = ["Nils Ohlmeier <github@ohlmeier.org>"] | ||
description = "This create parses strings in the format of the Session Description Protocol according to RFC4566. It specifically supports the subset of features required to support WebRTC according to the JSEP draft." | ||
homepage = "https://github.com/nils-ohlmeier/rsdparsa" | ||
readme = "README.md" | ||
keywords = ["webrtc", "sdp", "jsep"] | ||
categories = ["parsing", "network-programming"] | ||
license = "MPL-2.0" | ||
|
||
[badges] | ||
travis-ci = { repository = "nils-ohlmeier/rsdparsa", branch = "master" } | ||
codecov = { repository = "nils-ohlmeier/rsdparsa", branch = "master", service = "github" } | ||
|
||
[features] | ||
default = [] | ||
# serializability | ||
serialize = ["serde", "serde_derive"] | ||
|
||
[dependencies] | ||
# clippy = {version = "*", optional = true} | ||
log = "0.4" | ||
log = {version = "0.4.6"} | ||
serde = {version = "1.0" , optional = true} | ||
serde_derive = {version = "1.0" , optional = true} | ||
|
||
[dev-dependencies] | ||
# serde_json = {version = "1.0"} | ||
serde_json = {version = "1.0"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,61 @@ | ||
# rsdparsa | ||
# webrtc-sdp | ||
|
||
[](https://crates.io/crates/webrtc-sdp) | ||
[](https://travis-ci.org/nils-ohlmeier/rsdparsa) | ||
[](https://codecov.io/gh/nils-ohlmeier/rsdparsa) | ||
[](#License) | ||
[](https://deps.rs/repo/github/nils-ohlmeier/rsdparsa) | ||
|
||
A SDP parser written in Rust specifically aimed for WebRTC | ||
A SDP parser written in Rust specifically aimed to handle WebRTC SDP offers and answers. | ||
|
||
Requires minimum Rust 1.17 | ||
## Dependecies | ||
|
||
* Rust >= 1.17.0 | ||
* log module | ||
* serde module | ||
* serde-derive module | ||
|
||
Cargo installs the missing modules automatically when building webrtc-sdp for the first time. | ||
|
||
## The webrtc-sdp API | ||
|
||
The main function is: | ||
``` | ||
fn parse_sdp(sdp: &str, fail_on_warning: bool) -> Result<SdpSession, SdpParserError> | ||
``` | ||
The `sdp` parameter is the string which will get parsed. The `fail_on_warning` parameter determines how to treat warnings encountered during parsing. Any problems encountered during are stored until the whole string has been parsed. Any problem during parsing falls into two catgeories: | ||
|
||
* Fatal error preventing further parsing or processing of the SDP | ||
* Warning which don't block further processing of the SDP | ||
|
||
Warnings will be for example unknown parameters in attributes. Setting `fail_on_warning` to `true` makes most sense during development, when you want to be aware of all potential problems. In production `fail_on_warning` is expected to be `false`. | ||
|
||
`parse_sdp()` returns either an `SdpSession` struct ([code](https://github.com/nils-ohlmeier/rsdparsa/blob/master/src/lib.rs#L137)) which contains all the parsed information. Or in case a fatal error was encountered (or if `fail_on_warning` was set to `true` and any warnings were encountered) an `SdpParserError` ([code](https://github.com/nils-ohlmeier/rsdparsa/blob/master/src/error.rs#L117)) will be returned as a `Result`. | ||
|
||
## Examples | ||
|
||
The [file parser](https://github.com/nils-ohlmeier/rsdparsa/blob/master/src/bin/file_parser.rs) in the webrtc-sdp package gives you an easy example of how to invoke the webrtc-sdp parser. | ||
|
||
## Contributing | ||
|
||
As the Travis CI runs are checking for code formating and clippy warnings please run the following commands locally, before submitting a Pull Request. | ||
|
||
If you haven't clippy and Rust format installed already you add them like this: | ||
``` | ||
rustup component add rustfmt-preview | ||
rustup component add clippy | ||
``` | ||
|
||
Check with clippy for warnings in the code: | ||
``` | ||
cargo clippy --all-targets --all-features | ||
``` | ||
|
||
And format all of the code according to Rust code style convention: | ||
``` | ||
cargo fmt --all | ||
``` | ||
|
||
## License | ||
|
||
Licensed under [MPL](https://www.mozilla.org/MPL/2.0/). | ||
Licensed under [MPL-2.0](https://www.mozilla.org/MPL/2.0/) |
22 changes: 9 additions & 13 deletions
22
...g/src/sdp/rsdparsa/src/bin/file_parser.rs → .../src/sdp/rsdparsa/examples/file_parser.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,31 @@ | ||
use std::env; | ||
use std::error::Error; | ||
use std::io::prelude::*; | ||
use std::fs::File; | ||
use std::io::prelude::*; | ||
use std::path::Path; | ||
use std::env; | ||
extern crate rsdparsa; | ||
extern crate webrtc_sdp; | ||
|
||
fn main() { | ||
let filename = match env::args().nth(1) { | ||
None => { | ||
println!("Missing file name argument!"); | ||
return; | ||
}, | ||
} | ||
Some(x) => x, | ||
}; | ||
let path = Path::new(filename.as_str()); | ||
let display = path.display(); | ||
|
||
let mut file = match File::open(&path) { | ||
Err(why) => panic!("Failed to open {}: {}", | ||
display, | ||
why.description()), | ||
Ok(file) => file | ||
Err(why) => panic!("Failed to open {}: {}", display, why.description()), | ||
Ok(file) => file, | ||
}; | ||
|
||
let mut s = String::new(); | ||
match file.read_to_string(&mut s) { | ||
Err(why) => panic!("couldn't read {}: {}", | ||
display, | ||
why.description()), | ||
Ok(s) => s | ||
Err(why) => panic!("couldn't read {}: {}", display, why.description()), | ||
Ok(s) => s, | ||
}; | ||
|
||
rsdparsa::parse_sdp(&s, true).is_ok(); | ||
webrtc_sdp::parse_sdp(&s, true).is_ok(); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.