@@ -119,7 +119,7 @@ func appendCryptoProfiles(attrs []sdp.Attribute, profiles []srtp.Profile) []sdp.
119119}
120120
121121// OfferMediaWith creates a new SDP media description with a given codec set, public IP address and listening port.
122- func OfferMediaWith (s * media.CodecSet , rtpListenerPort int , encrypted Encryption ) (MediaDesc , * sdp.MediaDescription , error ) {
122+ func OfferMediaWith (s * media.CodecSet , rtpListenerPort int , encrypted Encryption , dir sdp. Direction ) (MediaDesc , * sdp.MediaDescription , error ) {
123123 // Static compiler check for frame duration hardcoded below.
124124 var _ = [1 ]struct {}{}[20 * time .Millisecond - rtp .DefFrameDur ]
125125
@@ -153,9 +153,12 @@ func OfferMediaWith(s *media.CodecSet, rtpListenerPort int, encrypted Encryption
153153 attrs = appendCryptoProfiles (attrs , cryptoProfiles )
154154 }
155155
156+ if dir == 0 {
157+ dir = sdp .DirectionSendRecv
158+ }
156159 attrs = append (attrs , []sdp.Attribute {
157160 {Key : "ptime" , Value : "20" },
158- {Key : "sendrecv" },
161+ {Key : dir . String () },
159162 }... )
160163
161164 proto := "AVP"
@@ -182,7 +185,7 @@ func OfferMediaWith(s *media.CodecSet, rtpListenerPort int, encrypted Encryption
182185//
183186// Deprecated: use OfferMediaWith
184187func OfferMedia (rtpListenerPort int , encrypted Encryption ) (MediaDesc , * sdp.MediaDescription , error ) {
185- return OfferMediaWith (media .GlobalCodecs (), rtpListenerPort , encrypted )
188+ return OfferMediaWith (media .GlobalCodecs (), rtpListenerPort , encrypted , sdp . DirectionSendRecv )
186189}
187190
188191// AnswerMedia creates a new SDP media description for an answer.
@@ -208,6 +211,9 @@ func AnswerMedia(rtpListenerPort int, audio *AudioConfig, crypt *srtp.Profile, d
208211 proto = "SAVP"
209212 attrs = appendCryptoProfiles (attrs , []srtp.Profile {* crypt })
210213 }
214+ if dir == 0 {
215+ dir = sdp .DirectionSendRecv
216+ }
211217 attrs = append (attrs , []sdp.Attribute {
212218 {Key : "ptime" , Value : "20" },
213219 {Key : dir .String ()},
@@ -252,7 +258,7 @@ type Answer Description
252258func NewOfferWith (s * media.CodecSet , publicIp netip.Addr , rtpListenerPort int , encrypted Encryption ) (* Offer , error ) {
253259 sessId := rand .Uint64 () // TODO: do we need to track these?
254260
255- m , mediaDesc , err := OfferMediaWith (s , rtpListenerPort , encrypted )
261+ m , mediaDesc , err := OfferMediaWith (s , rtpListenerPort , encrypted , sdp . DirectionSendRecv )
256262 if err != nil {
257263 return nil , err
258264 }
0 commit comments