Skip to content

Commit

Permalink
Merge pull request #6 from giangndm/fix-custom-ext-crash
Browse files Browse the repository at this point in the history
fix: crash when set custom ext
  • Loading branch information
giangndm authored Apr 28, 2024
2 parents 0996cfb + 5ffc6d4 commit 24e208c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/change/sdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,14 +1032,13 @@ fn update_media(
media.set_remote_pts(pts);

let mut remote_extmap = ExtensionMap::empty();
for (id, ext) in m.extmaps().into_iter() {
for (id, _ext) in m.extmaps().into_iter() {
// The remapping of extensions should already have happened, which
// means the ID are matching in the session to the remote.
if exts.lookup(id) != Some(ext) {
// Don't set any extensions that aren't enabled in Session.
continue;
// Only set extensions that are enabled in Session.
if let Some(ext) = exts.lookup(id) {
remote_extmap.set(id, ext.clone());
}
remote_extmap.set(id, ext.clone());
}
media.set_remote_extmap(remote_extmap);

Expand Down
7 changes: 5 additions & 2 deletions tests/user-rtp-header-extension.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::net::Ipv4Addr;
use std::time::Duration;

use str0m::change::SdpOffer;
use str0m::format::Codec;
use str0m::media::{Direction, MediaKind};
use str0m::rtp::Extension;
Expand Down Expand Up @@ -89,8 +90,10 @@ pub fn user_rtp_header_extension() -> Result<(), RtcError> {
let mut change = l.sdp_api();
let mid = change.add_media(MediaKind::Audio, Direction::SendRecv, None, None);
let (offer, pending) = change.apply().unwrap();

let answer = r.rtc.sdp_api().accept_offer(offer)?;
let offer_str = offer.to_sdp_string();
let offer_parsed =
SdpOffer::from_sdp_string(&offer_str).expect("Should parse offer from string");
let answer = r.rtc.sdp_api().accept_offer(offer_parsed)?;
l.rtc.sdp_api().accept_answer(pending, answer)?;

// Verify that the extension is negotiated.
Expand Down

0 comments on commit 24e208c

Please sign in to comment.