Skip to content

Commit

Permalink
use Vec instead of HashSet for ssrcs
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrtc committed Mar 2, 2024
1 parent ccdd11d commit 8e507be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/description/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use sdp::util::ConnectionRole;
use sdp::{MediaDescription, SessionDescription};
use serde::{Deserialize, Serialize};
use shared::error::{Error, Result};
use std::collections::{HashMap, HashSet};
use std::collections::HashMap;
use std::io::{BufReader, Cursor};
use std::net::SocketAddr;
use url::Url;
Expand Down Expand Up @@ -633,20 +633,22 @@ pub(crate) fn get_ssrc_groups(media: &MediaDescription) -> Result<Vec<SsrcGroup>
Ok(ssrc_groups)
}

pub(crate) fn get_ssrcs(media: &MediaDescription) -> Result<HashSet<SSRC>> {
let mut ssrc_set = HashSet::new();
pub(crate) fn get_ssrcs(media: &MediaDescription) -> Result<Vec<SSRC>> {
let mut ssrcs = Vec::new();
for a in &media.attributes {
if a.key == "ssrc" {
if let Some(value) = a.value.as_ref() {
let fields: Vec<&str> = value.split_whitespace().collect();
if !fields.is_empty() {
let ssrc = fields[0].parse::<u32>()?;
ssrc_set.insert(ssrc);
if !ssrcs.iter().any(|&s| s == ssrc) {
ssrcs.push(ssrc);
};
}
}
}
}
Ok(ssrc_set)
Ok(ssrcs)
}

pub(crate) fn extract_fingerprint(desc: &SessionDescription) -> Result<(String, String)> {
Expand Down
3 changes: 1 addition & 2 deletions src/description/rtp_transceiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::description::{
rtp_codec::{RTCRtpParameters, RTPCodecType},
rtp_transceiver_direction::RTCRtpTransceiverDirection,
};
use std::collections::HashSet;

/// SSRC represents a synchronization source
/// A synchronization source is a randomly chosen
Expand Down Expand Up @@ -63,7 +62,7 @@ pub(crate) struct SsrcGroup {
pub(crate) struct RTCRtpSender {
pub(crate) cname: String,
pub(crate) msid: MediaStreamId,
pub(crate) ssrcs: HashSet<SSRC>,
pub(crate) ssrcs: Vec<SSRC>,
pub(crate) ssrc_groups: Vec<SsrcGroup>,
}

Expand Down

0 comments on commit 8e507be

Please sign in to comment.