mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Use sendonly transceiver for down tracks, embed receiver in track.
This commit is contained in:
parent
63cfce9eec
commit
efb298f002
2 changed files with 22 additions and 16 deletions
|
@ -354,6 +354,7 @@ func (down *rtpDownConnection) flushICECandidates() error {
|
|||
|
||||
type rtpUpTrack struct {
|
||||
track *webrtc.TrackRemote
|
||||
receiver *webrtc.RTPReceiver
|
||||
conn *rtpUpConnection
|
||||
rate *estimator.Estimator
|
||||
cache *packetcache.Cache
|
||||
|
@ -630,6 +631,7 @@ func newUpConn(c group.Client, id string, label string, offer string) (*rtpUpCon
|
|||
|
||||
track := &rtpUpTrack{
|
||||
track: remote,
|
||||
receiver: receiver,
|
||||
conn: up,
|
||||
cache: packetcache.New(minPacketCache(remote)),
|
||||
rate: estimator.New(time.Second),
|
||||
|
@ -642,7 +644,7 @@ func newUpConn(c group.Client, id string, label string, offer string) (*rtpUpCon
|
|||
|
||||
go readLoop(track)
|
||||
|
||||
go rtcpUpListener(up, track, receiver)
|
||||
go rtcpUpListener(track)
|
||||
|
||||
up.mu.Unlock()
|
||||
|
||||
|
@ -769,12 +771,12 @@ func (track *rtpUpTrack) GetPacket(seqno uint16, result []byte, nack bool) uint1
|
|||
return 0
|
||||
}
|
||||
|
||||
func rtcpUpListener(conn *rtpUpConnection, track *rtpUpTrack, r *webrtc.RTPReceiver) {
|
||||
func rtcpUpListener(track *rtpUpTrack) {
|
||||
buf := make([]byte, 1500)
|
||||
|
||||
for {
|
||||
firstSR := false
|
||||
n, _, err := r.ReadSimulcast(buf, track.track.RID())
|
||||
n, _, err := track.receiver.ReadSimulcast(buf, track.track.RID())
|
||||
if err != nil {
|
||||
if err != io.EOF && err != io.ErrClosedPipe {
|
||||
log.Printf("Read RTCP: %v", err)
|
||||
|
@ -825,7 +827,7 @@ func rtcpUpListener(conn *rtpUpConnection, track *rtpUpTrack, r *webrtc.RTPRecei
|
|||
if firstSR {
|
||||
// this is the first SR we got for at least one track,
|
||||
// quickly propagate the time offsets downstream
|
||||
local := conn.getLocal()
|
||||
local := track.conn.getLocal()
|
||||
for _, l := range local {
|
||||
l, ok := l.(*rtpDownConnection)
|
||||
if ok {
|
||||
|
@ -1093,13 +1095,13 @@ func (track *rtpDownTrack) updateRate(loss uint8, now uint64) {
|
|||
track.maxBitrate.Set(rate, now)
|
||||
}
|
||||
|
||||
func rtcpDownListener(track *rtpDownTrack, s *webrtc.RTPSender) {
|
||||
func rtcpDownListener(track *rtpDownTrack) {
|
||||
lastFirSeqno := uint8(0)
|
||||
|
||||
buf := make([]byte, 1500)
|
||||
|
||||
for {
|
||||
n, _, err := s.Read(buf)
|
||||
n, _, err := track.sender.Read(buf)
|
||||
if err != nil {
|
||||
if err != io.EOF && err != io.ErrClosedPipe {
|
||||
log.Printf("Read RTCP: %v", err)
|
||||
|
|
|
@ -380,19 +380,23 @@ func addDownTrackUnlocked(conn *rtpDownConnection, remoteTrack *rtpUpTrack, remo
|
|||
return err
|
||||
}
|
||||
|
||||
sender, err := conn.pc.AddTrack(local)
|
||||
transceiver, err := conn.pc.AddTransceiverFromTrack(local,
|
||||
webrtc.RTPTransceiverInit{
|
||||
Direction: webrtc.RTPTransceiverDirectionSendonly,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
parms := sender.GetParameters()
|
||||
parms := transceiver.Sender().GetParameters()
|
||||
if len(parms.Encodings) != 1 {
|
||||
return errors.New("got multiple encodings")
|
||||
}
|
||||
|
||||
track := &rtpDownTrack{
|
||||
track: local,
|
||||
sender: sender,
|
||||
sender: transceiver.Sender(),
|
||||
ssrc: parms.Encodings[0].SSRC,
|
||||
conn: conn,
|
||||
remote: remoteTrack,
|
||||
|
@ -405,7 +409,7 @@ func addDownTrackUnlocked(conn *rtpDownConnection, remoteTrack *rtpUpTrack, remo
|
|||
|
||||
conn.tracks = append(conn.tracks, track)
|
||||
|
||||
go rtcpDownListener(track, sender)
|
||||
go rtcpDownListener(track)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue