mirror of
https://github.com/pion/webrtc.git
synced 2025-12-24 11:51:03 +08:00
Add currentDirection to RTPTransceiver
add currentDirection to RTPTransceiver, don't reuse transceiver if its currentDirection is sendrecv or sendonly
This commit is contained in:
@@ -13,10 +13,11 @@ import (
|
||||
|
||||
// RTPTransceiver represents a combination of an RTPSender and an RTPReceiver that share a common mid.
|
||||
type RTPTransceiver struct {
|
||||
mid atomic.Value // string
|
||||
sender atomic.Value // *RTPSender
|
||||
receiver atomic.Value // *RTPReceiver
|
||||
direction atomic.Value // RTPTransceiverDirection
|
||||
mid atomic.Value // string
|
||||
sender atomic.Value // *RTPSender
|
||||
receiver atomic.Value // *RTPReceiver
|
||||
direction atomic.Value // RTPTransceiverDirection
|
||||
currentDirection atomic.Value // RTPTransceiverDirection
|
||||
|
||||
codecs []RTPCodecParameters // User provided codecs via SetCodecPreferences
|
||||
|
||||
@@ -38,6 +39,7 @@ func newRTPTransceiver(
|
||||
t.setReceiver(receiver)
|
||||
t.setSender(sender)
|
||||
t.setDirection(direction)
|
||||
t.setCurrentDirection(RTPTransceiverDirection(Unknown))
|
||||
return t
|
||||
}
|
||||
|
||||
@@ -160,6 +162,7 @@ func (t *RTPTransceiver) Stop() error {
|
||||
}
|
||||
|
||||
t.setDirection(RTPTransceiverDirectionInactive)
|
||||
t.setCurrentDirection(RTPTransceiverDirectionInactive)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -179,6 +182,17 @@ func (t *RTPTransceiver) setDirection(d RTPTransceiverDirection) {
|
||||
t.direction.Store(d)
|
||||
}
|
||||
|
||||
func (t *RTPTransceiver) setCurrentDirection(d RTPTransceiverDirection) {
|
||||
t.currentDirection.Store(d)
|
||||
}
|
||||
|
||||
func (t *RTPTransceiver) getCurrentDirection() RTPTransceiverDirection {
|
||||
if v, ok := t.currentDirection.Load().(RTPTransceiverDirection); ok {
|
||||
return v
|
||||
}
|
||||
return RTPTransceiverDirection(Unknown)
|
||||
}
|
||||
|
||||
func (t *RTPTransceiver) setSendingTrack(track TrackLocal) error {
|
||||
if err := t.Sender().ReplaceTrack(track); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user