Skip to content

Commit

Permalink
Make setMid of Transceiver public
Browse files Browse the repository at this point in the history
in some case like session migration from one sfu node
to another, we need manual set mid of transceiver instead of
auto generate, to make mid consistent between to sfu node.
  • Loading branch information
cnderrauber committed Jan 6, 2022
1 parent 425f5c6 commit 41e2571
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions peerconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ func (pc *PeerConnection) CreateOffer(options *OfferOptions) (SessionDescription
continue
}
pc.greaterMid++
err = t.setMid(strconv.Itoa(pc.greaterMid))
err = t.SetMid(strconv.Itoa(pc.greaterMid))
if err != nil {
return SessionDescription{}, err
}
Expand Down Expand Up @@ -1092,7 +1092,7 @@ func (pc *PeerConnection) SetRemoteDescription(desc SessionDescription) error {
}

if t.Mid() == "" {
if err := t.setMid(midValue); err != nil {
if err := t.SetMid(midValue); err != nil {
return err
}
}
Expand Down
5 changes: 3 additions & 2 deletions rtptransceiver.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !js
// +build !js

package webrtc
Expand Down Expand Up @@ -115,8 +116,8 @@ func (t *RTPTransceiver) Receiver() *RTPReceiver {
return nil
}

// setMid sets the RTPTransceiver's mid. If it was already set, will return an error.
func (t *RTPTransceiver) setMid(mid string) error {
// SetMid sets the RTPTransceiver's mid. If it was already set, will return an error.
func (t *RTPTransceiver) SetMid(mid string) error {
if currentMid := t.Mid(); currentMid != "" {
return fmt.Errorf("%w: %s to %s", errRTPTransceiverCannotChangeMid, currentMid, mid)
}
Expand Down

0 comments on commit 41e2571

Please sign in to comment.