#web-rtc #sdp #string-parser #string-format #jsep

webrtc-sdp

webrtc-sdp 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.

17 releases

Uses old Rust 2015

0.3.13 Sep 24, 2024
0.3.12 Jun 19, 2024
0.3.11 Jan 17, 2024
0.3.10 Jan 5, 2023
0.1.0 Jan 27, 2019

#56 in Network programming

Download history 852/week @ 2024-08-19 1251/week @ 2024-08-26 657/week @ 2024-09-02 1147/week @ 2024-09-09 916/week @ 2024-09-16 1294/week @ 2024-09-23 1091/week @ 2024-09-30 764/week @ 2024-10-07 1102/week @ 2024-10-14 805/week @ 2024-10-21 915/week @ 2024-10-28 746/week @ 2024-11-04 644/week @ 2024-11-11 1054/week @ 2024-11-18 1114/week @ 2024-11-25 864/week @ 2024-12-02

3,698 downloads per month
Used in 11 crates (6 directly)

MPL-2.0 license

290KB
7K SLoC

webrtc-sdp

Crates.io Build Status Codecov coverage status License: MPL 2.0 dependency status

A SDP parser written in Rust specifically aimed to handle WebRTC SDP offers and answers.

Dependecies

  • Rust >= 1.70.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) 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) will be returned as a Result.

Examples

The file parser 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

And format all of the code according to Rust code style convention:

cargo fmt --all

Fuzzing

Install cargo-fuzz like this:

cargo install cargo-fuzz

With rust nightly you can start fuzzing like this:

cargo fuzz run fuzz_target_parse_sdp

License

Licensed under MPL-2.0

Dependencies

~2–3MB
~57K SLoC