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

Update to webrtc_track_id function for handling case without msid-semantic #887

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dguerizec
Copy link

This pull request updates the webrtc_track_id function in the SessionDescription class, found within sdp.py.

The main change implemented is an additional check for the scenario where msid-semantic is not provided. The updated code adds a check for this scenario, and in such cases, it directly returns bits[1] as the track id.

Prior to this update, the function would return None in scenarios where msid-semantic is not present in OFFER, as it strictly expected at least a msid-semantic to return a track id when an msid was present. This change thus enhances the function's flexibility and robustness in handling cases where media streams have an msid but no msid-semantic field is present.

This change was needed on my side to be able to connect an aiortc peer to Livekit SFU: Livekit does provide an msid for each track, but does not provide the msid-semantic field.

After some research, I found that it seems that the msid-semantic is not required (and may have been obsoleted between draft 08 and 09 of RFC-8830, see references below).

Here's a breakdown of the changes:

Added a condition to check if self.msid_semantic is non-empty.
If self.msid_semantic is empty, bits[1] (track id) is directly returned.
If self.msid_semantic is non-empty, the existing behavior is retained.

This update ensures that the webrtc_track_id function can handle all scenarios more effectively, returning a valid track id even in cases where msid-semantic is not present.

References:

@dguerizec
Copy link
Author

dguerizec commented Jun 13, 2023

I also pushed some new fixes to make it work with Livekit SFU:

  • Ensure the tracks are closed when they go in "inactive" state
  • Recycle receiver with ssrc update
  • Update msid on track if it changed for this mid

@jlaine
Copy link
Collaborator

jlaine commented Oct 25, 2023

Could we please have some unit tests, which might also help to clarify the usecase?

@jlaine jlaine added the changes requested Some changes are required before the PR can be merged. label Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested Some changes are required before the PR can be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants