Replace Target with params to indicate direction (#955)
* Replace Target with params to indicate direction * Add missed send answer call
This commit is contained in:
+15
-14
@@ -199,24 +199,20 @@ type TransportParams struct {
|
|||||||
ParticipantID livekit.ParticipantID
|
ParticipantID livekit.ParticipantID
|
||||||
ParticipantIdentity livekit.ParticipantIdentity
|
ParticipantIdentity livekit.ParticipantIdentity
|
||||||
ProtocolVersion types.ProtocolVersion
|
ProtocolVersion types.ProtocolVersion
|
||||||
Target livekit.SignalTarget
|
|
||||||
Config *WebRTCConfig
|
Config *WebRTCConfig
|
||||||
|
DirectionConfig DirectionConfig
|
||||||
CongestionControlConfig config.CongestionControlConfig
|
CongestionControlConfig config.CongestionControlConfig
|
||||||
Telemetry telemetry.TelemetryService
|
Telemetry telemetry.TelemetryService
|
||||||
EnabledCodecs []*livekit.Codec
|
EnabledCodecs []*livekit.Codec
|
||||||
Logger logger.Logger
|
Logger logger.Logger
|
||||||
SimTracks map[uint32]SimulcastTrackInfo
|
SimTracks map[uint32]SimulcastTrackInfo
|
||||||
ClientInfo ClientInfo
|
ClientInfo ClientInfo
|
||||||
|
IsOfferer bool
|
||||||
|
IsSendSide bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimator cc.BandwidthEstimator)) (*webrtc.PeerConnection, *webrtc.MediaEngine, error) {
|
func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimator cc.BandwidthEstimator)) (*webrtc.PeerConnection, *webrtc.MediaEngine, error) {
|
||||||
var directionConfig DirectionConfig
|
directionConfig := params.DirectionConfig
|
||||||
if params.Target == livekit.SignalTarget_PUBLISHER {
|
|
||||||
directionConfig = params.Config.Publisher
|
|
||||||
} else {
|
|
||||||
directionConfig = params.Config.Subscriber
|
|
||||||
}
|
|
||||||
|
|
||||||
// enable nack if audio red is not support
|
// enable nack if audio red is not support
|
||||||
if !isCodecEnabled(params.EnabledCodecs, webrtc.RTPCodecCapability{MimeType: sfu.MimeTypeAudioRed}) || !params.ClientInfo.SupportsAudioRED() {
|
if !isCodecEnabled(params.EnabledCodecs, webrtc.RTPCodecCapability{MimeType: sfu.MimeTypeAudioRed}) || !params.ClientInfo.SupportsAudioRED() {
|
||||||
directionConfig.RTCPFeedback.Audio = append(directionConfig.RTCPFeedback.Audio, webrtc.RTCPFeedback{Type: webrtc.TypeRTCPFBNACK})
|
directionConfig.RTCPFeedback.Audio = append(directionConfig.RTCPFeedback.Audio, webrtc.RTCPFeedback{Type: webrtc.TypeRTCPFBNACK})
|
||||||
@@ -260,7 +256,7 @@ func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimat
|
|||||||
}
|
}
|
||||||
|
|
||||||
ir := &interceptor.Registry{}
|
ir := &interceptor.Registry{}
|
||||||
if params.Target == livekit.SignalTarget_SUBSCRIBER {
|
if params.IsSendSide {
|
||||||
isSendSideBWE := false
|
isSendSideBWE := false
|
||||||
for _, ext := range directionConfig.RTPHeaderExtension.Video {
|
for _, ext := range directionConfig.RTPHeaderExtension.Video {
|
||||||
if ext == sdp.TransportCCURI {
|
if ext == sdp.TransportCCURI {
|
||||||
@@ -322,7 +318,7 @@ func NewPCTransport(params TransportParams) (*PCTransport, error) {
|
|||||||
negotiationPending: make(map[livekit.ParticipantID]bool),
|
negotiationPending: make(map[livekit.ParticipantID]bool),
|
||||||
eventCh: make(chan event, 50),
|
eventCh: make(chan event, 50),
|
||||||
}
|
}
|
||||||
if params.Target == livekit.SignalTarget_SUBSCRIBER {
|
if params.IsSendSide {
|
||||||
t.streamAllocator = sfu.NewStreamAllocator(sfu.StreamAllocatorParams{
|
t.streamAllocator = sfu.NewStreamAllocator(sfu.StreamAllocatorParams{
|
||||||
Config: params.CongestionControlConfig,
|
Config: params.CongestionControlConfig,
|
||||||
Logger: params.Logger,
|
Logger: params.Logger,
|
||||||
@@ -1219,7 +1215,7 @@ func (t *PCTransport) handleEvent(e *event) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *PCTransport) handleICEGatheringComplete(e *event) error {
|
func (t *PCTransport) handleICEGatheringComplete(e *event) error {
|
||||||
if t.params.Target == livekit.SignalTarget_SUBSCRIBER {
|
if t.params.IsOfferer {
|
||||||
return t.handleICEGatheringCompleteOfferer()
|
return t.handleICEGatheringCompleteOfferer()
|
||||||
} else {
|
} else {
|
||||||
return t.handleICEGatheringCompleteAnswerer()
|
return t.handleICEGatheringCompleteAnswerer()
|
||||||
@@ -1241,10 +1237,15 @@ func (t *PCTransport) handleICEGatheringCompleteAnswerer() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
t.params.Logger.Debugw("accept remote restart ice offer after ICE gathering")
|
offer := *t.pendingRestartIceOffer
|
||||||
err := t.setRemoteDescription(*t.pendingRestartIceOffer)
|
|
||||||
t.pendingRestartIceOffer = nil
|
t.pendingRestartIceOffer = nil
|
||||||
return err
|
|
||||||
|
t.params.Logger.Debugw("accept remote restart ice offer after ICE gathering")
|
||||||
|
if err := t.setRemoteDescription(offer); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return t.createAndSendAnswer()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *PCTransport) localDescriptionSent() error {
|
func (t *PCTransport) localDescriptionSent() error {
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ func TestMissingAnswerDuringICERestart(t *testing.T) {
|
|||||||
params := TransportParams{
|
params := TransportParams{
|
||||||
ParticipantID: "id",
|
ParticipantID: "id",
|
||||||
ParticipantIdentity: "identity",
|
ParticipantIdentity: "identity",
|
||||||
Target: livekit.SignalTarget_SUBSCRIBER,
|
|
||||||
Config: &WebRTCConfig{},
|
Config: &WebRTCConfig{},
|
||||||
|
IsOfferer: true,
|
||||||
}
|
}
|
||||||
transportA, err := NewPCTransport(params)
|
transportA, err := NewPCTransport(params)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -28,7 +28,7 @@ func TestMissingAnswerDuringICERestart(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
paramsB := params
|
paramsB := params
|
||||||
paramsB.Target = livekit.SignalTarget_PUBLISHER
|
paramsB.IsOfferer = false
|
||||||
transportB, err := NewPCTransport(paramsB)
|
transportB, err := NewPCTransport(paramsB)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -69,8 +69,8 @@ func TestNegotiationTiming(t *testing.T) {
|
|||||||
params := TransportParams{
|
params := TransportParams{
|
||||||
ParticipantID: "id",
|
ParticipantID: "id",
|
||||||
ParticipantIdentity: "identity",
|
ParticipantIdentity: "identity",
|
||||||
Target: livekit.SignalTarget_SUBSCRIBER,
|
|
||||||
Config: &WebRTCConfig{},
|
Config: &WebRTCConfig{},
|
||||||
|
IsOfferer: true,
|
||||||
}
|
}
|
||||||
transportA, err := NewPCTransport(params)
|
transportA, err := NewPCTransport(params)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -78,7 +78,7 @@ func TestNegotiationTiming(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
paramsB := params
|
paramsB := params
|
||||||
paramsB.Target = livekit.SignalTarget_PUBLISHER
|
paramsB.IsOfferer = false
|
||||||
transportB, err := NewPCTransport(params)
|
transportB, err := NewPCTransport(params)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -147,8 +147,8 @@ func TestFirstOfferMissedDuringICERestart(t *testing.T) {
|
|||||||
params := TransportParams{
|
params := TransportParams{
|
||||||
ParticipantID: "id",
|
ParticipantID: "id",
|
||||||
ParticipantIdentity: "identity",
|
ParticipantIdentity: "identity",
|
||||||
Target: livekit.SignalTarget_SUBSCRIBER,
|
|
||||||
Config: &WebRTCConfig{},
|
Config: &WebRTCConfig{},
|
||||||
|
IsOfferer: true,
|
||||||
}
|
}
|
||||||
transportA, err := NewPCTransport(params)
|
transportA, err := NewPCTransport(params)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -156,7 +156,7 @@ func TestFirstOfferMissedDuringICERestart(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
paramsB := params
|
paramsB := params
|
||||||
paramsB.Target = livekit.SignalTarget_PUBLISHER
|
paramsB.IsOfferer = false
|
||||||
transportB, err := NewPCTransport(paramsB)
|
transportB, err := NewPCTransport(paramsB)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -215,8 +215,8 @@ func TestFirstAnswerMissedDuringICERestart(t *testing.T) {
|
|||||||
params := TransportParams{
|
params := TransportParams{
|
||||||
ParticipantID: "id",
|
ParticipantID: "id",
|
||||||
ParticipantIdentity: "identity",
|
ParticipantIdentity: "identity",
|
||||||
Target: livekit.SignalTarget_SUBSCRIBER,
|
|
||||||
Config: &WebRTCConfig{},
|
Config: &WebRTCConfig{},
|
||||||
|
IsOfferer: true,
|
||||||
}
|
}
|
||||||
transportA, err := NewPCTransport(params)
|
transportA, err := NewPCTransport(params)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -224,7 +224,7 @@ func TestFirstAnswerMissedDuringICERestart(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
paramsB := params
|
paramsB := params
|
||||||
paramsB.Target = livekit.SignalTarget_PUBLISHER
|
paramsB.IsOfferer = false
|
||||||
transportB, err := NewPCTransport(paramsB)
|
transportB, err := NewPCTransport(paramsB)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -288,8 +288,8 @@ func TestNegotiationFailed(t *testing.T) {
|
|||||||
params := TransportParams{
|
params := TransportParams{
|
||||||
ParticipantID: "id",
|
ParticipantID: "id",
|
||||||
ParticipantIdentity: "identity",
|
ParticipantIdentity: "identity",
|
||||||
Target: livekit.SignalTarget_SUBSCRIBER,
|
|
||||||
Config: &WebRTCConfig{},
|
Config: &WebRTCConfig{},
|
||||||
|
IsOfferer: true,
|
||||||
}
|
}
|
||||||
transportA, err := NewPCTransport(params)
|
transportA, err := NewPCTransport(params)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -319,7 +319,6 @@ func TestFilteringCandidates(t *testing.T) {
|
|||||||
params := TransportParams{
|
params := TransportParams{
|
||||||
ParticipantID: "id",
|
ParticipantID: "id",
|
||||||
ParticipantIdentity: "identity",
|
ParticipantIdentity: "identity",
|
||||||
Target: livekit.SignalTarget_PUBLISHER,
|
|
||||||
Config: &WebRTCConfig{},
|
Config: &WebRTCConfig{},
|
||||||
EnabledCodecs: []*livekit.Codec{
|
EnabledCodecs: []*livekit.Codec{
|
||||||
{Mime: webrtc.MimeTypeOpus},
|
{Mime: webrtc.MimeTypeOpus},
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ func NewTransportManager(params TransportManagerParams) (*TransportManager, erro
|
|||||||
ParticipantID: params.SID,
|
ParticipantID: params.SID,
|
||||||
ParticipantIdentity: params.Identity,
|
ParticipantIdentity: params.Identity,
|
||||||
ProtocolVersion: params.ProtocolVersion,
|
ProtocolVersion: params.ProtocolVersion,
|
||||||
Target: livekit.SignalTarget_PUBLISHER,
|
|
||||||
Config: params.Config,
|
Config: params.Config,
|
||||||
|
DirectionConfig: params.Config.Publisher,
|
||||||
CongestionControlConfig: params.CongestionControlConfig,
|
CongestionControlConfig: params.CongestionControlConfig,
|
||||||
Telemetry: params.Telemetry,
|
Telemetry: params.Telemetry,
|
||||||
EnabledCodecs: enabledCodecs,
|
EnabledCodecs: enabledCodecs,
|
||||||
@@ -111,13 +111,15 @@ func NewTransportManager(params TransportManagerParams) (*TransportManager, erro
|
|||||||
ParticipantID: params.SID,
|
ParticipantID: params.SID,
|
||||||
ParticipantIdentity: params.Identity,
|
ParticipantIdentity: params.Identity,
|
||||||
ProtocolVersion: params.ProtocolVersion,
|
ProtocolVersion: params.ProtocolVersion,
|
||||||
Target: livekit.SignalTarget_SUBSCRIBER,
|
|
||||||
Config: params.Config,
|
Config: params.Config,
|
||||||
|
DirectionConfig: params.Config.Subscriber,
|
||||||
CongestionControlConfig: params.CongestionControlConfig,
|
CongestionControlConfig: params.CongestionControlConfig,
|
||||||
Telemetry: params.Telemetry,
|
Telemetry: params.Telemetry,
|
||||||
EnabledCodecs: enabledCodecs,
|
EnabledCodecs: enabledCodecs,
|
||||||
Logger: LoggerWithPCTarget(params.Logger, livekit.SignalTarget_SUBSCRIBER),
|
Logger: LoggerWithPCTarget(params.Logger, livekit.SignalTarget_SUBSCRIBER),
|
||||||
ClientInfo: params.ClientInfo,
|
ClientInfo: params.ClientInfo,
|
||||||
|
IsOfferer: true,
|
||||||
|
IsSendSide: true,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -141,17 +141,19 @@ func NewRTCClient(conn *websocket.Conn) (*RTCClient, error) {
|
|||||||
// Same applies for subscriber transport also
|
// Same applies for subscriber transport also
|
||||||
//
|
//
|
||||||
c.publisher, err = rtc.NewPCTransport(rtc.TransportParams{
|
c.publisher, err = rtc.NewPCTransport(rtc.TransportParams{
|
||||||
Target: livekit.SignalTarget_SUBSCRIBER,
|
Config: &conf,
|
||||||
Config: &conf,
|
DirectionConfig: conf.Subscriber,
|
||||||
EnabledCodecs: codecs,
|
EnabledCodecs: codecs,
|
||||||
|
IsOfferer: true,
|
||||||
|
IsSendSide: true,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
c.subscriber, err = rtc.NewPCTransport(rtc.TransportParams{
|
c.subscriber, err = rtc.NewPCTransport(rtc.TransportParams{
|
||||||
Target: livekit.SignalTarget_PUBLISHER,
|
Config: &conf,
|
||||||
Config: &conf,
|
DirectionConfig: conf.Publisher,
|
||||||
EnabledCodecs: codecs,
|
EnabledCodecs: codecs,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in New Issue
Block a user