mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-10-15 21:00:56 +08:00
Update WebRTC passive producer handling
This commit is contained in:
@@ -33,6 +33,31 @@ func (c *Conn) SetOffer(offer string) (err error) {
|
||||
}
|
||||
|
||||
func (c *Conn) GetAnswer() (answer string, err error) {
|
||||
if c.Mode == streamer.ModePassiveProducer {
|
||||
// init all Sender(s) for passive producer or they will be nil
|
||||
// sender for passive producer is backchannel
|
||||
sd := &sdp.SessionDescription{}
|
||||
if err = sd.Unmarshal([]byte(c.offer)); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, md := range sd.MediaDescriptions {
|
||||
for _, attr := range md.Attributes {
|
||||
switch attr.Key {
|
||||
case "recvonly":
|
||||
_, _ = c.pc.AddTransceiverFromKind(
|
||||
webrtc.NewRTPCodecType(md.MediaName.Media),
|
||||
webrtc.RTPTransceiverInit{Direction: webrtc.RTPTransceiverDirectionSendonly},
|
||||
)
|
||||
case "sendrecv":
|
||||
_, _ = c.pc.AddTransceiverFromKind(
|
||||
webrtc.NewRTPCodecType(md.MediaName.Media),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// we need to process remote offer after we create transeivers
|
||||
desc := webrtc.SessionDescription{Type: webrtc.SDPTypeOffer, SDP: c.offer}
|
||||
if err = c.pc.SetRemoteDescription(desc); err != nil {
|
||||
|
Reference in New Issue
Block a user