Skip to content

Commit

Permalink
Backed out changeset b6559295ac78 (bug 1553011) for bustages on Stati…
Browse files Browse the repository at this point in the history
…cAnalysisFunctions.h. CLOSED TREE
  • Loading branch information
nbeleuzu committed Jun 14, 2019
1 parent 22d52a6 commit fe9afd5
Show file tree
Hide file tree
Showing 65 changed files with 2,869 additions and 5,054 deletions.
21 changes: 10 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions media/webrtc/signaling/gtest/sdp_unittests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4015,22 +4015,12 @@ TEST(NewSdpTestNoFixture, CheckParsingResultComparer)
auto check_comparison = [](const std::string sdp_string) {
SipccSdpParser sipccParser;
RsdparsaSdpParser rustParser;
auto print_errors = [](const SdpErrorHolder& holder, const char* name) {
for (const auto& e : holder.GetParseErrors()) {
std::cerr << name << " Line " << e.first << ": " << e.second;
}
};

auto sipccSdp = sipccParser.Parse(sdp_string);
print_errors(sipccParser, "sipcc");

auto rustSdp = rustParser.Parse(sdp_string);
print_errors(rustParser, "webrtc-sdp");

ParsingResultComparer comparer;
return sipccSdp && rustSdp
? comparer.Compare(*rustSdp, *sipccSdp, sdp_string)
: false;
return comparer.Compare(*rustSdp, *sipccSdp, sdp_string);
};

ASSERT_TRUE(check_comparison(kBasicAudioVideoOffer));
Expand Down
2 changes: 1 addition & 1 deletion media/webrtc/signaling/src/sdp/ParsingResultComparer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool ParsingResultComparer::Compare(const Sdp& rsdparsaSdp, const Sdp& sipccSdp,
const std::string& originalSdp,
const SdpComparisonResult expect) {
mOriginalSdp = originalSdp;
MOZ_ASSERT(&rsdparsaSdp);

const std::string sipccSdpStr = sipccSdp.ToString();
const std::string rsdparsaSdpStr = rsdparsaSdp.ToString();

Expand Down
3 changes: 0 additions & 3 deletions media/webrtc/signaling/src/sdp/RsdparsaSdpInc.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ enum class RustSdpProtocolValue {
kRustDtlsSctp,
kRustUdpDtlsSctp,
kRustTcpDtlsSctp,
kRustRtpAvp,
kRustRtpAvpf,
kRustRtpSavp,
};

enum class RustSdpFormatType { kRustIntegers, kRustStrings };
Expand Down
7 changes: 1 addition & 6 deletions media/webrtc/signaling/src/sdp/RsdparsaSdpMediaSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,8 @@ SdpMediaSection::Protocol RsdparsaSdpMediaSection::GetProtocol() const {
return kUdpDtlsSctp;
case RustSdpProtocolValue::kRustTcpDtlsSctp:
return kTcpDtlsSctp;
case RustSdpProtocolValue::kRustRtpAvp:
return kRtpAvp;
case RustSdpProtocolValue::kRustRtpAvpf:
return kRtpAvpf;
case RustSdpProtocolValue::kRustRtpSavp:
return kRtpSavp;
}

MOZ_CRASH("invalid media protocol");
}

Expand Down
4 changes: 2 additions & 2 deletions media/webrtc/signaling/src/sdp/RsdparsaSdpParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ namespace mozilla {

UniquePtr<Sdp> RsdparsaSdpParser::Parse(const std::string& sdpText) {
ClearParseErrors();
RustSdpSession* result = nullptr;
RustSdpError* err = nullptr;
RustSdpSession* result;
RustSdpError* err;
StringView sdpTextView{sdpText.c_str(), sdpText.length()};
nsresult rv = parse_sdp(sdpTextView, false, &result, &err);
if (rv != NS_OK) {
Expand Down
49 changes: 18 additions & 31 deletions media/webrtc/signaling/src/sdp/rsdparsa/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ cache: cargo
sudo: true
os:
- linux
- osx
# Taken out temporarily because it's to slow
# - osx

env:
- FEATURES=""
- FEATURES="serialize"
rust:
- nightly
- beta
Expand All @@ -19,12 +17,13 @@ matrix:
allow_failures:
- rust: nightly

before_install:
- sudo apt-get update

addons:
apt:
packages:
- libcurl4-openssl-dev
- zlib1g-dev
- libiberty-dev
- libelf-dev
- libdw-dev
- cmake
Expand All @@ -35,46 +34,34 @@ addons:
before_script:
- export PATH=$PATH:~/.cargo/bin
- |
if [[ "$TRAVIS_RUST_VERSION" == "stable" ]]; then
rustup component add rustfmt-preview
rustup component add clippy
if [[ "$TRAVIS_RUST_VERSION" == "nightly" ]]; then
cargo install --force clippy;
fi
script:
- echo FEATURES="$FEATURES"
- |
if [[ "$TRAVIS_RUST_VERSION" == "stable" ]]; then
cargo fmt --all -- --check
fi
- cargo build --verbose --all --features="$FEATURES"
- cargo build --verbose --all
- |
if [[ "$TRAVIS_RUST_VERSION" == "stable" ]]; then
cargo clippy --all-targets --all-features -- -D warnings;
if [[ "$TRAVIS_RUST_VERSION" == "nightly" &&
-f ~/.cargo/bin/cargo-clippy ]]; then
cargo clippy;
fi
- |
if [[ "$TRAVIS_RUST_VERSION" == "1.17.0" ]]; then
cargo test --all-features --verbose --all
else
cargo test --all-targets --all-features --verbose --all
fi
- cargo test --verbose --all

after_success:
- |
if [[ "$TRAVIS_OS_NAME" == "linux" && "$TRAVIS_RUST_VERSION" == "stable" && "$FEATURES" == "serialize" ]]; then
wget https://github.com/SimonKagstrom/kcov/archive/v34.tar.gz &&
tar xzf v34.tar.gz &&
cd kcov-34 &&
if [[ "$TRAVIS_OS_NAME" == "linux" && "$TRAVIS_RUST_VERSION" == "stable" ]]; then
wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz &&
tar xzf master.tar.gz &&
cd kcov-master &&
mkdir build &&
cd build &&
cmake .. &&
make &&
sudo make install &&
cd ../.. &&
rm -rf kcov-34 &&
rm -rf kcov-master &&
kcov --version &&
(cd target/debug/ && ls -al) &&
for file in target/debug/webrtc_sdp-*[^\.d]; do echo "$file"; mkdir -p "target/cov/$(basename $file)"; kcov --verify --exclude-pattern=/.cargo,/usr/lib "target/cov/$(basename $file)" "$file"; done &&
for file in target/debug/rsdparsa-*[^\.d]; do echo "$file"; mkdir -p "target/cov/$(basename $file)"; kcov --verify --exclude-pattern=/.cargo,/usr/lib "target/cov/$(basename $file)" "$file"; done &&
for file in target/debug/unit_tests-*[^\.d]; do echo "$file"; mkdir -p "target/cov/$(basename $file)"; kcov --verify --exclude-pattern=/.cargo,/usr/lib "target/cov/$(basename $file)" "$file"; done &&
bash <(curl -s https://codecov.io/bash) &&
echo "Uploaded code coverage"
Expand Down
17 changes: 4 additions & 13 deletions media/webrtc/signaling/src/sdp/rsdparsa/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
[package]
name = "webrtc-sdp"
name = "rsdparsa"
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]
log = {version = "0.4.6"}
# clippy = {version = "*", optional = true}
log = "0.4"
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"}
56 changes: 4 additions & 52 deletions media/webrtc/signaling/src/sdp/rsdparsa/README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,13 @@
# webrtc-sdp
# rsdparsa

[![Crates.io](https://img.shields.io/crates/v/webrtc-sdp.svg)](https://crates.io/crates/webrtc-sdp)
[![Build Status](https://travis-ci.org/nils-ohlmeier/rsdparsa.svg?branch=master)](https://travis-ci.org/nils-ohlmeier/rsdparsa)
[![Codecov coverage status](https://codecov.io/gh/nils-ohlmeier/rsdparsa/branch/master/graph/badge.svg)](https://codecov.io/gh/nils-ohlmeier/rsdparsa)
[![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](#License)
[![dependency status](https://deps.rs/repo/github/nils-ohlmeier/rsdparsa/status.svg)](https://deps.rs/repo/github/nils-ohlmeier/rsdparsa)

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

## Dependecies

* Rust >= 1.30.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/examples/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
```
Requires minimum Rust 1.17

## License

Licensed under [MPL-2.0](https://www.mozilla.org/MPL/2.0/)
Licensed under [MPL](https://www.mozilla.org/MPL/2.0/).
Loading

0 comments on commit fe9afd5

Please sign in to comment.