mirror of
https://github.com/pion/webrtc.git
synced 2025-10-23 23:23:10 +08:00
Response now use the same mid value as the offer
When generating responses we were incorrectly using numeric mid values. This works for Unified Plan offers, but was breaking Plan-B
This commit is contained in:
@@ -468,10 +468,11 @@ func (pc *PeerConnection) CreateOffer(options *OfferOptions) (SessionDescription
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, t := range pc.GetTransceivers() {
|
for _, t := range pc.GetTransceivers() {
|
||||||
pc.addTransceiverSDP(d, t, bundleCount, iceParams, candidates, sdp.ConnectionRoleActpass)
|
pc.addTransceiverSDP(d, t, strconv.Itoa(bundleCount), iceParams, candidates, sdp.ConnectionRoleActpass)
|
||||||
appendBundle()
|
appendBundle()
|
||||||
}
|
}
|
||||||
pc.addDataMediaSection(d, bundleCount, iceParams, candidates, sdp.ConnectionRoleActive)
|
|
||||||
|
pc.addDataMediaSection(d, strconv.Itoa(bundleCount), iceParams, candidates, sdp.ConnectionRoleActive)
|
||||||
appendBundle()
|
appendBundle()
|
||||||
|
|
||||||
for _, m := range d.MediaDescriptions {
|
for _, m := range d.MediaDescriptions {
|
||||||
@@ -601,16 +602,24 @@ func (pc *PeerConnection) CreateAnswer(options *AnswerOptions) (SessionDescripti
|
|||||||
}
|
}
|
||||||
|
|
||||||
bundleValue := "BUNDLE"
|
bundleValue := "BUNDLE"
|
||||||
bundleCount := 0
|
appendBundle := func(midValue string) {
|
||||||
appendBundle := func() {
|
bundleValue += " " + midValue
|
||||||
bundleValue += " " + strconv.Itoa(bundleCount)
|
|
||||||
bundleCount++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, media := range pc.RemoteDescription().parsed.MediaDescriptions {
|
for _, media := range pc.RemoteDescription().parsed.MediaDescriptions {
|
||||||
|
midValue := ""
|
||||||
|
for _, attr := range media.Attributes {
|
||||||
|
if attr.Key == "mid" {
|
||||||
|
midValue = attr.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if midValue == "" {
|
||||||
|
return SessionDescription{}, fmt.Errorf("RemoteDescription contained media section without mid value")
|
||||||
|
}
|
||||||
|
|
||||||
if media.MediaName.Media == "application" {
|
if media.MediaName.Media == "application" {
|
||||||
pc.addDataMediaSection(d, bundleCount, iceParams, candidates, sdp.ConnectionRoleActive)
|
pc.addDataMediaSection(d, midValue, iceParams, candidates, sdp.ConnectionRoleActive)
|
||||||
appendBundle()
|
appendBundle(midValue)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,8 +630,8 @@ func (pc *PeerConnection) CreateAnswer(options *AnswerOptions) (SessionDescripti
|
|||||||
}
|
}
|
||||||
|
|
||||||
t := satisfyPeerMedia(kind, direction)
|
t := satisfyPeerMedia(kind, direction)
|
||||||
pc.addTransceiverSDP(d, t, bundleCount, iceParams, candidates, sdp.ConnectionRoleActive)
|
pc.addTransceiverSDP(d, t, midValue, iceParams, candidates, sdp.ConnectionRoleActive)
|
||||||
appendBundle()
|
appendBundle(midValue)
|
||||||
}
|
}
|
||||||
d = d.WithValueAttribute(sdp.AttrKeyGroup, bundleValue)
|
d = d.WithValueAttribute(sdp.AttrKeyGroup, bundleValue)
|
||||||
|
|
||||||
@@ -1491,10 +1500,10 @@ func (pc *PeerConnection) addFingerprint(d *sdp.SessionDescription) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pc *PeerConnection) addTransceiverSDP(d *sdp.SessionDescription, t *RTPTransceiver, midOffset int, iceParams ICEParameters, candidates []ICECandidate, dtlsRole sdp.ConnectionRole) {
|
func (pc *PeerConnection) addTransceiverSDP(d *sdp.SessionDescription, t *RTPTransceiver, midValue string, iceParams ICEParameters, candidates []ICECandidate, dtlsRole sdp.ConnectionRole) {
|
||||||
media := sdp.NewJSEPMediaDescription(t.kind.String(), []string{}).
|
media := sdp.NewJSEPMediaDescription(t.kind.String(), []string{}).
|
||||||
WithValueAttribute(sdp.AttrKeyConnectionSetup, dtlsRole.String()). // TODO: Support other connection types
|
WithValueAttribute(sdp.AttrKeyConnectionSetup, dtlsRole.String()). // TODO: Support other connection types
|
||||||
WithValueAttribute(sdp.AttrKeyMID, strconv.Itoa(midOffset)).
|
WithValueAttribute(sdp.AttrKeyMID, midValue).
|
||||||
WithICECredentials(iceParams.UsernameFragment, iceParams.Password).
|
WithICECredentials(iceParams.UsernameFragment, iceParams.Password).
|
||||||
WithPropertyAttribute(sdp.AttrKeyRTCPMux). // TODO: support RTCP fallback
|
WithPropertyAttribute(sdp.AttrKeyRTCPMux). // TODO: support RTCP fallback
|
||||||
WithPropertyAttribute(sdp.AttrKeyRTCPRsize) // TODO: Support Reduced-Size RTCP?
|
WithPropertyAttribute(sdp.AttrKeyRTCPRsize) // TODO: Support Reduced-Size RTCP?
|
||||||
@@ -1529,7 +1538,7 @@ func (pc *PeerConnection) addTransceiverSDP(d *sdp.SessionDescription, t *RTPTra
|
|||||||
d.WithMedia(media)
|
d.WithMedia(media)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pc *PeerConnection) addDataMediaSection(d *sdp.SessionDescription, midOffset int, iceParams ICEParameters, candidates []ICECandidate, dtlsRole sdp.ConnectionRole) {
|
func (pc *PeerConnection) addDataMediaSection(d *sdp.SessionDescription, midValue string, iceParams ICEParameters, candidates []ICECandidate, dtlsRole sdp.ConnectionRole) {
|
||||||
media := (&sdp.MediaDescription{
|
media := (&sdp.MediaDescription{
|
||||||
MediaName: sdp.MediaName{
|
MediaName: sdp.MediaName{
|
||||||
Media: "application",
|
Media: "application",
|
||||||
@@ -1546,7 +1555,7 @@ func (pc *PeerConnection) addDataMediaSection(d *sdp.SessionDescription, midOffs
|
|||||||
},
|
},
|
||||||
}).
|
}).
|
||||||
WithValueAttribute(sdp.AttrKeyConnectionSetup, dtlsRole.String()). // TODO: Support other connection types
|
WithValueAttribute(sdp.AttrKeyConnectionSetup, dtlsRole.String()). // TODO: Support other connection types
|
||||||
WithValueAttribute(sdp.AttrKeyMID, strconv.Itoa(midOffset)).
|
WithValueAttribute(sdp.AttrKeyMID, midValue).
|
||||||
WithPropertyAttribute(RTPTransceiverDirectionSendrecv.String()).
|
WithPropertyAttribute(RTPTransceiverDirectionSendrecv.String()).
|
||||||
WithPropertyAttribute("sctpmap:5000 webrtc-datachannel 1024").
|
WithPropertyAttribute("sctpmap:5000 webrtc-datachannel 1024").
|
||||||
WithICECredentials(iceParams.UsernameFragment, iceParams.Password)
|
WithICECredentials(iceParams.UsernameFragment, iceParams.Password)
|
||||||
|
Reference in New Issue
Block a user