mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-10-06 08:46:57 +08:00
Fix WebRTC active producer with backchannel
This commit is contained in:
@@ -8,13 +8,24 @@ import (
|
||||
|
||||
func (c *Conn) CreateOffer(medias []*streamer.Media) (string, error) {
|
||||
for _, media := range medias {
|
||||
switch media.Direction {
|
||||
case streamer.DirectionRecvonly:
|
||||
if _, err := c.pc.AddTransceiverFromKind(
|
||||
webrtc.NewRTPCodecType(media.Kind), webrtc.RTPTransceiverInit{
|
||||
Direction: webrtc.NewRTPTransceiverDirection(media.Direction),
|
||||
},
|
||||
webrtc.NewRTPCodecType(media.Kind),
|
||||
webrtc.RTPTransceiverInit{Direction: webrtc.RTPTransceiverDirectionRecvonly},
|
||||
); err != nil {
|
||||
return "", err
|
||||
}
|
||||
case streamer.DirectionSendonly:
|
||||
if _, err := c.pc.AddTransceiverFromTrack(
|
||||
NewTrack(media.Kind),
|
||||
webrtc.RTPTransceiverInit{Direction: webrtc.RTPTransceiverDirectionSendonly},
|
||||
); err != nil {
|
||||
return "", err
|
||||
}
|
||||
case streamer.DirectionSendRecv:
|
||||
panic("not implemented")
|
||||
}
|
||||
}
|
||||
|
||||
desc, err := c.pc.CreateOffer(nil)
|
||||
|
@@ -23,6 +23,9 @@ func (c *Conn) GetTrack(media *streamer.Media, codec *streamer.Codec) *streamer.
|
||||
track = streamer.NewTrack(media, codec)
|
||||
} else {
|
||||
track = c.getProducerSendTrack(media, codec)
|
||||
if track == nil {
|
||||
panic("getProducerSendTrack return nil track")
|
||||
}
|
||||
}
|
||||
|
||||
c.tracks = append(c.tracks, track)
|
||||
|
Reference in New Issue
Block a user