check using protocol version

This commit is contained in:
boks1971
2025-08-14 10:12:36 +05:30
parent 1b03d382fa
commit d20d4ba0cb
2 changed files with 9 additions and 16 deletions
+8 -15
View File
@@ -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)
}
+1 -1
View File
@@ -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)
}