replace proto.Clone calls (#3024)

* replace proto.Clone calls

* deps

* tests
This commit is contained in:
Paul Wells
2024-09-18 22:47:33 -07:00
committed by GitHub
parent 978db00034
commit 4deaac2f3f
21 changed files with 62 additions and 62 deletions
+2 -3
View File
@@ -21,7 +21,6 @@ import (
"time"
"go.uber.org/zap/zapcore"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/livekit/mediatransportutil"
@@ -302,8 +301,8 @@ func (r *rtpStatsBase) seed(from *rtpStatsBase) bool {
r.rtt = from.rtt
r.maxRtt = from.maxRtt
r.srFirst = proto.Clone(from.srFirst).(*livekit.RTCPSenderReportState)
r.srNewest = proto.Clone(from.srNewest).(*livekit.RTCPSenderReportState)
r.srFirst = utils.CloneProto(from.srFirst)
r.srNewest = utils.CloneProto(from.srNewest)
r.nextSnapshotID = from.nextSnapshotID
r.snapshots = make([]snapshot, cap(from.snapshots))
+2 -3
View File
@@ -21,7 +21,6 @@ import (
"github.com/pion/rtcp"
"go.uber.org/zap/zapcore"
"google.golang.org/protobuf/proto"
"github.com/livekit/livekit-server/pkg/sfu/utils"
"github.com/livekit/mediatransportutil"
@@ -413,7 +412,7 @@ func (r *RTPStatsReceiver) getExtendedSenderReport(srData *livekit.RTCPSenderRep
}
}
srDataExt := proto.Clone(srData).(*livekit.RTCPSenderReportState)
srDataExt := protoutils.CloneProto(srData)
srDataExt.RtpTimestampExt = uint64(srDataExt.RtpTimestamp) + tsCycles
return srDataExt
}
@@ -567,7 +566,7 @@ func (r *RTPStatsReceiver) GetRtcpSenderReportData() *livekit.RTCPSenderReportSt
r.lock.RLock()
defer r.lock.RUnlock()
return proto.Clone(r.srNewest).(*livekit.RTCPSenderReportState)
return protoutils.CloneProto(r.srNewest)
}
func (r *RTPStatsReceiver) LastSenderReportTime() time.Time {
+3 -3
View File
@@ -26,11 +26,11 @@ import (
"github.com/pion/rtp"
"github.com/pion/webrtc/v3"
"go.uber.org/zap/zapcore"
"google.golang.org/protobuf/proto"
"github.com/livekit/mediatransportutil"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/livekit/livekit-server/pkg/sfu/buffer"
"github.com/livekit/livekit-server/pkg/sfu/codecmunger"
@@ -406,7 +406,7 @@ func (f *Forwarder) GetState() *livekit.RTPForwarderState {
state.SenderReportState = make([]*livekit.RTCPSenderReportState, len(f.refInfos))
for layer, refInfo := range f.refInfos {
state.SenderReportState[layer] = proto.Clone(refInfo.senderReport).(*livekit.RTCPSenderReportState)
state.SenderReportState[layer] = utils.CloneProto(refInfo.senderReport)
}
return state
}
@@ -421,7 +421,7 @@ func (f *Forwarder) SeedState(state *livekit.RTPForwarderState) {
for layer, rtcpSenderReportState := range state.SenderReportState {
f.refInfos[layer] = refInfo{}
if senderReport := proto.Clone(rtcpSenderReportState).(*livekit.RTCPSenderReportState); senderReport != nil && senderReport.NtpTimestamp != 0 {
if senderReport := utils.CloneProto(rtcpSenderReportState); senderReport != nil && senderReport.NtpTimestamp != 0 {
f.refInfos[layer].senderReport = senderReport
}
}
+3 -3
View File
@@ -24,11 +24,11 @@ import (
"github.com/pion/rtcp"
"github.com/pion/webrtc/v3"
"go.uber.org/atomic"
"google.golang.org/protobuf/proto"
"github.com/livekit/mediatransportutil/pkg/bucket"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/sfu/audio"
@@ -209,7 +209,7 @@ func NewWebRTCReceiver(
for _, opt := range opts {
w = opt(w)
}
w.trackInfo.Store(proto.Clone(trackInfo).(*livekit.TrackInfo))
w.trackInfo.Store(utils.CloneProto(trackInfo))
w.downTrackSpreader = NewDownTrackSpreader(DownTrackSpreaderParams{
Threshold: w.lbThreshold,
@@ -249,7 +249,7 @@ func (w *WebRTCReceiver) TrackInfo() *livekit.TrackInfo {
}
func (w *WebRTCReceiver) UpdateTrackInfo(ti *livekit.TrackInfo) {
w.trackInfo.Store(proto.Clone(ti).(*livekit.TrackInfo))
w.trackInfo.Store(utils.CloneProto(ti))
w.streamTrackerManager.UpdateTrackInfo(ti)
}
+3 -3
View File
@@ -21,10 +21,10 @@ import (
"github.com/frostbyte73/core"
"go.uber.org/atomic"
"google.golang.org/protobuf/proto"
"github.com/livekit/protocol/livekit"
"github.com/livekit/protocol/logger"
"github.com/livekit/protocol/utils"
"github.com/livekit/livekit-server/pkg/config"
"github.com/livekit/livekit-server/pkg/sfu/buffer"
@@ -82,7 +82,7 @@ func NewStreamTrackerManager(
maxTemporalLayerSeen: buffer.InvalidLayerTemporal,
clockRate: clockRate,
}
s.trackInfo.Store(proto.Clone(trackInfo).(*livekit.TrackInfo))
s.trackInfo.Store(utils.CloneProto(trackInfo))
switch trackInfo.Source {
case livekit.TrackSource_SCREEN_SHARE:
@@ -312,7 +312,7 @@ func (s *StreamTrackerManager) IsPaused() bool {
}
func (s *StreamTrackerManager) UpdateTrackInfo(ti *livekit.TrackInfo) {
s.trackInfo.Store(proto.Clone(ti).(*livekit.TrackInfo))
s.trackInfo.Store(utils.CloneProto(ti))
s.maxExpectedLayerFromTrackInfo()
}