Skip to content

Commit

Permalink
refactor api
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrtc committed Mar 18, 2024
1 parent 62741ba commit 835f947
Show file tree
Hide file tree
Showing 22 changed files with 198 additions and 247 deletions.
4 changes: 2 additions & 2 deletions rtc-sdp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ homepage = "https://webrtc.rs"
repository = "https://github.com/webrtc-rs/rtc"

[dependencies]
shared = { version = "0.2.1", path = "../rtc-shared", package = "rtc-shared", default-features = false, features = [] }

url = "2.5.0"
rand = "0.8.5"
thiserror = "1.0.57"
substring = "1.4.5"

[dev-dependencies]
criterion = "0.5.1"
Expand Down
2 changes: 1 addition & 1 deletion rtc-sdp/src/description/description_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::common::*;
use super::media::*;
use super::session::*;
use crate::error::{Error, Result};
use shared::error::{Error, Result};

use std::io::Cursor;
use url::Url;
Expand Down
2 changes: 1 addition & 1 deletion rtc-sdp/src/description/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};
use std::{fmt, io};
use url::Url;

use crate::error::{Error, Result};
use crate::lexer::*;
use crate::util::*;
use shared::error::{Error, Result};

use super::common::*;
use super::media::*;
Expand Down
56 changes: 0 additions & 56 deletions rtc-sdp/src/error.rs

This file was deleted.

2 changes: 1 addition & 1 deletion rtc-sdp/src/extmap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
mod extmap_test;

use super::direction::*;
use super::error::{Error, Result};
use crate::description::common::*;
use shared::error::{Error, Result};

use std::fmt;
use std::io;
Expand Down
2 changes: 1 addition & 1 deletion rtc-sdp/src/lexer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::description::session::SessionDescription;
use super::error::{Error, Result};
use shared::error::{Error, Result};

use std::io;
use std::io::SeekFrom;
Expand Down
2 changes: 0 additions & 2 deletions rtc-sdp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ pub mod direction;
pub mod extmap;
pub mod util;

mod error;
pub(crate) mod lexer;

pub use description::{media::MediaDescription, session::SessionDescription};
pub use error::Error;
2 changes: 1 addition & 1 deletion rtc-sdp/src/util/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(test)]
mod util_test;

use super::error::{Error, Result};
use shared::error::{Error, Result};

use std::collections::HashMap;
use std::fmt;
Expand Down
1 change: 1 addition & 0 deletions rtc-shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ replay = []

[dependencies]
thiserror = "1.0.58"
substring = "1.4.5"
bytes = "1.5.0"
aes-gcm = { version = "0.10.3", features = ["std"] }
url = "2.5.0"
Expand Down
21 changes: 21 additions & 0 deletions rtc-shared/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::net::SocketAddr;
use std::num::ParseIntError;
use std::string::FromUtf8Error;
use std::time::SystemTimeError;
use substring::Substring;
use thiserror::Error;

pub type Result<T> = std::result::Result<T, Error>;
Expand Down Expand Up @@ -1455,6 +1456,26 @@ pub enum Error {
#[error("not long enough to be a RTP Packet")]
ErrRTPTooShort,

//SDP
#[error("codec not found")]
CodecNotFound,
#[error("missing whitespace")]
MissingWhitespace,
#[error("missing colon")]
MissingColon,
#[error("payload type not found")]
PayloadTypeNotFound,
#[error("SdpInvalidSyntax: {0}")]
SdpInvalidSyntax(String),
#[error("SdpInvalidValue: {0}")]
SdpInvalidValue(String),
#[error("sdp: empty time_descriptions")]
SdpEmptyTimeDescription,
#[error("parse extmap: {0}")]
ParseExtMap(String),
#[error("{} --> {} <-- {}", .s.substring(0,*.p), .s.substring(*.p, *.p+1), .s.substring(*.p+1, .s.len()))]
SyntaxError { s: String, p: usize },

//Third Party Error
#[error("{0}")]
Sec1(#[source] sec1::Error),
Expand Down
Loading

0 comments on commit 835f947

Please sign in to comment.