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

ReplaceTrack resets all track encodings #2617

Merged
Merged
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
22 changes: 14 additions & 8 deletions rtpsender.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,21 +237,26 @@

var replacedTrack TrackLocal
var context *baseTrackLocalContext
if len(r.trackEncodings) != 0 {
replacedTrack = r.trackEncodings[0].track
context = r.trackEncodings[0].context
}
if r.hasSent() && replacedTrack != nil {
if err := replacedTrack.Unbind(context); err != nil {
return err
for _, e := range r.trackEncodings {
replacedTrack = e.track
context = e.context

if r.hasSent() && replacedTrack != nil {
if err := replacedTrack.Unbind(context); err != nil {
return err
}

Check warning on line 247 in rtpsender.go

View check run for this annotation

Codecov / codecov/patch

rtpsender.go#L246-L247

Added lines #L246 - L247 were not covered by tests
}

if !r.hasSent() || track == nil {
e.track = track
}
}

if !r.hasSent() || track == nil {
r.trackEncodings[0].track = track
return nil
}

// If we reach this point in the routine, there is only 1 track encoding
codec, err := track.Bind(&baseTrackLocalContext{
id: context.ID(),
params: r.api.mediaEngine.getRTPParametersByKind(track.Kind(), []RTPTransceiverDirection{RTPTransceiverDirectionSendonly}),
Expand All @@ -274,6 +279,7 @@
}

r.trackEncodings[0].track = track

return nil
}

Expand Down
Loading