mirror of
https://github.com/livekit/livekit.git
synced 2026-07-28 18:39:41 +00:00
check using protocol version
This commit is contained in:
+8
-15
@@ -662,8 +662,7 @@ func (c *RTCClient) hasPrimaryEverConnected() bool {
|
||||
}
|
||||
|
||||
type AddTrackParams struct {
|
||||
NoWriter bool
|
||||
UseSubscriberPeerConnection bool
|
||||
NoWriter bool
|
||||
}
|
||||
|
||||
type AddTrackOption func(params *AddTrackParams)
|
||||
@@ -674,12 +673,6 @@ func AddTrackNoWriter() AddTrackOption {
|
||||
}
|
||||
}
|
||||
|
||||
func AddTrackUseSubscriberPeerConnectionr() AddTrackOption {
|
||||
return func(params *AddTrackParams) {
|
||||
params.UseSubscriberPeerConnection = true
|
||||
}
|
||||
}
|
||||
|
||||
func (c *RTCClient) AddTrack(track *webrtc.TrackLocalStaticSample, path string, opts ...AddTrackOption) (writer *TrackWriter, err error) {
|
||||
var params AddTrackParams
|
||||
for _, opt := range opts {
|
||||
@@ -691,10 +684,10 @@ func (c *RTCClient) AddTrack(track *webrtc.TrackLocalStaticSample, path string,
|
||||
}
|
||||
|
||||
var sender *webrtc.RTPSender
|
||||
if !params.UseSubscriberPeerConnection {
|
||||
sender, _, err = c.publisher.AddTrack(track, types.AddTrackParams{})
|
||||
} else {
|
||||
if types.ProtocolVersion(types.CurrentProtocol).SupportsSinglePeerConnection() {
|
||||
sender, _, err = c.subscriber.AddTrack(track, types.AddTrackParams{})
|
||||
} else {
|
||||
sender, _, err = c.publisher.AddTrack(track, types.AddTrackParams{})
|
||||
}
|
||||
if err != nil {
|
||||
logger.Errorw(
|
||||
@@ -743,10 +736,10 @@ func (c *RTCClient) AddTrack(track *webrtc.TrackLocalStaticSample, path string,
|
||||
|
||||
/* RAJA-TODO
|
||||
var sender *webrtc.RTPSender
|
||||
if !params.UseSubscriberPeerConnection {
|
||||
sender, _, err = c.publisher.AddTrack(track, types.AddTrackParams{})
|
||||
} else {
|
||||
if types.ProtocolVersion(types.CurrentProtocol).SupportsSinglePeerConnection() {
|
||||
sender, _, err = c.subscriber.AddTrack(track, types.AddTrackParams{})
|
||||
} else {
|
||||
sender, _, err = c.publisher.AddTrack(track, types.AddTrackParams{})
|
||||
}
|
||||
if err != nil {
|
||||
logger.Errorw(
|
||||
@@ -767,7 +760,7 @@ func (c *RTCClient) AddTrack(track *webrtc.TrackLocalStaticSample, path string,
|
||||
*/
|
||||
c.localTracks[ti.Sid] = track
|
||||
c.trackSenders[ti.Sid] = sender
|
||||
if !params.UseSubscriberPeerConnection {
|
||||
if !types.ProtocolVersion(types.CurrentProtocol).SupportsSinglePeerConnection() {
|
||||
c.publisher.Negotiate(false)
|
||||
}
|
||||
|
||||
|
||||
@@ -981,7 +981,7 @@ func TestSinglePeerConnection(t *testing.T) {
|
||||
{MimeType: mime.MimeTypeOpus.String()},
|
||||
}
|
||||
for _, codec := range codecs {
|
||||
_, err := c1.AddStaticTrackWithCodec(codec, codec.MimeType, codec.MimeType, testclient.AddTrackUseSubscriberPeerConnectionr())
|
||||
_, err := c1.AddStaticTrackWithCodec(codec, codec.MimeType, codec.MimeType)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user