Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: crash when set custom ext #6

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading