Skip to content

Commit

Permalink
generate_matched_sdp
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrtc committed Jan 8, 2024
1 parent 3b7cb10 commit 4fe3fb7
Show file tree
Hide file tree
Showing 10 changed files with 786 additions and 105 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ rcgen = { version = "0.11", features = ["pem", "x509-parser"] }
ring = "0.17.7"
sha2 = "0.10.8"
rustls = "0.21.7"
url = { version = "2", features = [] }

# RTC protocols
shared = { path = "rtc/shared"}
Expand Down
2 changes: 1 addition & 1 deletion src/server/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::server::certificate::RTCCertificate;

#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct ServerConfig {
pub certificate: RTCCertificate,
}
18 changes: 9 additions & 9 deletions src/server/endpoint/candidate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::server::certificate::RTCDtlsFingerprint;
use crate::server::certificate::{RTCCertificate, RTCDtlsFingerprint};
use crate::server::session::description::RTCSessionDescription;
use crate::shared::types::{EndpointId, SessionId, UserName};
use base64::{prelude::BASE64_STANDARD, Engine};
Expand All @@ -9,14 +9,14 @@ use shared::error::{Error, Result};

#[derive(Default, Debug, Clone, Eq, PartialEq)]
pub struct ConnectionCredentials {
ice_ufrag: String,
ice_pwd: String,
fingerprint: RTCDtlsFingerprint,
role: ConnectionRole,
pub(crate) ice_ufrag: String,
pub(crate) ice_pwd: String,
pub(crate) fingerprint: RTCDtlsFingerprint,
pub(crate) role: ConnectionRole,
}

impl ConnectionCredentials {
pub(crate) fn new(fingerprint: &RTCDtlsFingerprint, remote_role: ConnectionRole) -> Self {
pub(crate) fn new(certificate: &RTCCertificate, remote_role: ConnectionRole) -> Self {
let rng = SystemRandom::new();

let mut user = [0u8; 9];
Expand All @@ -27,7 +27,7 @@ impl ConnectionCredentials {
Self {
ice_ufrag: BASE64_STANDARD.encode(&user[..]),
ice_pwd: BASE64_STANDARD.encode(&password[..]),
fingerprint: fingerprint.clone(),
fingerprint: certificate.get_fingerprints().first().unwrap().clone(),
role: if remote_role == ConnectionRole::Active {
ConnectionRole::Passive
} else {
Expand Down Expand Up @@ -92,14 +92,14 @@ impl Candidate {
pub(crate) fn new(
session_id: SessionId,
endpoint_id: EndpointId,
fingerprint: &RTCDtlsFingerprint,
certificate: &RTCCertificate,
remote_conn_cred: ConnectionCredentials,
remote_description: RTCSessionDescription,
) -> Self {
Self {
session_id,
endpoint_id,
local_conn_cred: ConnectionCredentials::new(fingerprint, remote_conn_cred.role),
local_conn_cred: ConnectionCredentials::new(certificate, remote_conn_cred.role),
remote_conn_cred,
remote_description,
local_description: None,
Expand Down
4 changes: 2 additions & 2 deletions src/server/session/description/fmtp/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod generic;
mod h264;
pub(crate) mod generic;
pub(crate) mod h264;

use std::any::Any;
use std::collections::HashMap;
Expand Down
Loading

0 comments on commit 4fe3fb7

Please sign in to comment.