From 286d773e0adfa54382fc4491c8581f087eb45eae Mon Sep 17 00:00:00 2001 From: Oliver Lazoroski Date: Thu, 17 Apr 2025 12:19:59 +0200 Subject: [PATCH 1/4] fix: switch to float for averaged values --- protobuf/video/sfu/models/models.pb.go | 18 ++-- protobuf/video/sfu/models/models.proto | 6 +- .../video/sfu/models/models_vtproto.pb.go | 87 +++++++------------ 3 files changed, 45 insertions(+), 66 deletions(-) diff --git a/protobuf/video/sfu/models/models.pb.go b/protobuf/video/sfu/models/models.pb.go index 0bf8a7d0b..cb15deefa 100644 --- a/protobuf/video/sfu/models/models.pb.go +++ b/protobuf/video/sfu/models/models.pb.go @@ -2562,7 +2562,7 @@ type EncodeStats struct { TrackType TrackType `protobuf:"varint,1,opt,name=track_type,json=trackType,proto3,enum=stream.video.sfu.models.TrackType" json:"track_type,omitempty"` Codec *Codec `protobuf:"bytes,2,opt,name=codec,proto3" json:"codec,omitempty"` - AvgFrameEncodeTimeMs int64 `protobuf:"varint,3,opt,name=avg_frame_encode_time_ms,json=avgFrameEncodeTimeMs,proto3" json:"avg_frame_encode_time_ms,omitempty"` + AvgFrameEncodeTimeMs float32 `protobuf:"fixed32,3,opt,name=avg_frame_encode_time_ms,json=avgFrameEncodeTimeMs,proto3" json:"avg_frame_encode_time_ms,omitempty"` AvgFps int64 `protobuf:"varint,4,opt,name=avg_fps,json=avgFps,proto3" json:"avg_fps,omitempty"` } @@ -2612,7 +2612,7 @@ func (x *EncodeStats) GetCodec() *Codec { return nil } -func (x *EncodeStats) GetAvgFrameEncodeTimeMs() int64 { +func (x *EncodeStats) GetAvgFrameEncodeTimeMs() float32 { if x != nil { return x.AvgFrameEncodeTimeMs } @@ -2634,8 +2634,8 @@ type DecodeStats struct { TrackType TrackType `protobuf:"varint,1,opt,name=track_type,json=trackType,proto3,enum=stream.video.sfu.models.TrackType" json:"track_type,omitempty"` Codec *Codec `protobuf:"bytes,2,opt,name=codec,proto3" json:"codec,omitempty"` - AvgFrameDecodeTimeMs int64 `protobuf:"varint,3,opt,name=avg_frame_decode_time_ms,json=avgFrameDecodeTimeMs,proto3" json:"avg_frame_decode_time_ms,omitempty"` - AvgFps int64 `protobuf:"varint,4,opt,name=avg_fps,json=avgFps,proto3" json:"avg_fps,omitempty"` + AvgFrameDecodeTimeMs float32 `protobuf:"fixed32,3,opt,name=avg_frame_decode_time_ms,json=avgFrameDecodeTimeMs,proto3" json:"avg_frame_decode_time_ms,omitempty"` + AvgFps float32 `protobuf:"fixed32,4,opt,name=avg_fps,json=avgFps,proto3" json:"avg_fps,omitempty"` VideoDimension *VideoDimension `protobuf:"bytes,5,opt,name=video_dimension,json=videoDimension,proto3" json:"video_dimension,omitempty"` } @@ -2685,14 +2685,14 @@ func (x *DecodeStats) GetCodec() *Codec { return nil } -func (x *DecodeStats) GetAvgFrameDecodeTimeMs() int64 { +func (x *DecodeStats) GetAvgFrameDecodeTimeMs() float32 { if x != nil { return x.AvgFrameDecodeTimeMs } return 0 } -func (x *DecodeStats) GetAvgFps() int64 { +func (x *DecodeStats) GetAvgFps() float32 { if x != nil { return x.AvgFps } @@ -2999,7 +2999,7 @@ var file_video_sfu_models_models_proto_rawDesc = []byte{ 0x75, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x63, 0x52, 0x05, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x12, 0x36, 0x0a, 0x18, 0x61, 0x76, 0x67, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x5f, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, - 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x14, 0x61, 0x76, 0x67, 0x46, 0x72, 0x61, 0x6d, + 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x14, 0x61, 0x76, 0x67, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x12, 0x17, 0x0a, 0x07, 0x61, 0x76, 0x67, 0x5f, 0x66, 0x70, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x61, 0x76, 0x67, 0x46, 0x70, 0x73, 0x22, 0xa9, 0x02, 0x0a, 0x0b, 0x44, 0x65, 0x63, 0x6f, 0x64, @@ -3013,9 +3013,9 @@ var file_video_sfu_models_models_proto_rawDesc = []byte{ 0x6c, 0x73, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x63, 0x52, 0x05, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x12, 0x36, 0x0a, 0x18, 0x61, 0x76, 0x67, 0x5f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x5f, 0x64, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x14, 0x61, 0x76, 0x67, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x44, 0x65, 0x63, 0x6f, 0x64, + 0x02, 0x52, 0x14, 0x61, 0x76, 0x67, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x44, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x12, 0x17, 0x0a, 0x07, 0x61, 0x76, 0x67, 0x5f, 0x66, - 0x70, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x61, 0x76, 0x67, 0x46, 0x70, 0x73, + 0x70, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x02, 0x52, 0x06, 0x61, 0x76, 0x67, 0x46, 0x70, 0x73, 0x12, 0x50, 0x0a, 0x0f, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x64, 0x69, 0x6d, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x2e, 0x73, 0x66, 0x75, 0x2e, 0x6d, 0x6f, 0x64, diff --git a/protobuf/video/sfu/models/models.proto b/protobuf/video/sfu/models/models.proto index 5391a4be2..62a09c2b2 100644 --- a/protobuf/video/sfu/models/models.proto +++ b/protobuf/video/sfu/models/models.proto @@ -405,7 +405,7 @@ enum AppleThermalState { message EncodeStats { TrackType track_type = 1; Codec codec = 2; - int64 avg_frame_encode_time_ms = 3; + float avg_frame_encode_time_ms = 3; int64 avg_fps = 4; } @@ -413,7 +413,7 @@ message EncodeStats { message DecodeStats { TrackType track_type = 1; Codec codec = 2; - int64 avg_frame_decode_time_ms = 3; - int64 avg_fps = 4; + float avg_frame_decode_time_ms = 3; + float avg_fps = 4; VideoDimension video_dimension = 5; } diff --git a/protobuf/video/sfu/models/models_vtproto.pb.go b/protobuf/video/sfu/models/models_vtproto.pb.go index 4399ec863..097227239 100644 --- a/protobuf/video/sfu/models/models_vtproto.pb.go +++ b/protobuf/video/sfu/models/models_vtproto.pb.go @@ -1691,9 +1691,10 @@ func (m *EncodeStats) MarshalToSizedBufferVT(dAtA []byte) (int, error) { dAtA[i] = 0x20 } if m.AvgFrameEncodeTimeMs != 0 { - i = encodeVarint(dAtA, i, uint64(m.AvgFrameEncodeTimeMs)) + i -= 4 + binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.AvgFrameEncodeTimeMs)))) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x1d } if m.Codec != nil { size, err := m.Codec.MarshalToSizedBufferVT(dAtA[:i]) @@ -1754,14 +1755,16 @@ func (m *DecodeStats) MarshalToSizedBufferVT(dAtA []byte) (int, error) { dAtA[i] = 0x2a } if m.AvgFps != 0 { - i = encodeVarint(dAtA, i, uint64(m.AvgFps)) + i -= 4 + binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.AvgFps)))) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x25 } if m.AvgFrameDecodeTimeMs != 0 { - i = encodeVarint(dAtA, i, uint64(m.AvgFrameDecodeTimeMs)) + i -= 4 + binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.AvgFrameDecodeTimeMs)))) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x1d } if m.Codec != nil { size, err := m.Codec.MarshalToSizedBufferVT(dAtA[:i]) @@ -2503,7 +2506,7 @@ func (m *EncodeStats) SizeVT() (n int) { n += 1 + l + sov(uint64(l)) } if m.AvgFrameEncodeTimeMs != 0 { - n += 1 + sov(uint64(m.AvgFrameEncodeTimeMs)) + n += 5 } if m.AvgFps != 0 { n += 1 + sov(uint64(m.AvgFps)) @@ -2528,10 +2531,10 @@ func (m *DecodeStats) SizeVT() (n int) { n += 1 + l + sov(uint64(l)) } if m.AvgFrameDecodeTimeMs != 0 { - n += 1 + sov(uint64(m.AvgFrameDecodeTimeMs)) + n += 5 } if m.AvgFps != 0 { - n += 1 + sov(uint64(m.AvgFps)) + n += 5 } if m.VideoDimension != nil { l = m.VideoDimension.SizeVT() @@ -6662,24 +6665,16 @@ func (m *EncodeStats) UnmarshalVT(dAtA []byte) error { } iNdEx = postIndex case 3: - if wireType != 0 { + if wireType != 5 { return fmt.Errorf("proto: wrong wireType = %d for field AvgFrameEncodeTimeMs", wireType) } - m.AvgFrameEncodeTimeMs = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AvgFrameEncodeTimeMs |= int64(b&0x7F) << shift - if b < 0x80 { - break - } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF } + v = uint32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.AvgFrameEncodeTimeMs = float32(math.Float32frombits(v)) case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field AvgFps", wireType) @@ -6806,43 +6801,27 @@ func (m *DecodeStats) UnmarshalVT(dAtA []byte) error { } iNdEx = postIndex case 3: - if wireType != 0 { + if wireType != 5 { return fmt.Errorf("proto: wrong wireType = %d for field AvgFrameDecodeTimeMs", wireType) } - m.AvgFrameDecodeTimeMs = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AvgFrameDecodeTimeMs |= int64(b&0x7F) << shift - if b < 0x80 { - break - } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF } + v = uint32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.AvgFrameDecodeTimeMs = float32(math.Float32frombits(v)) case 4: - if wireType != 0 { + if wireType != 5 { return fmt.Errorf("proto: wrong wireType = %d for field AvgFps", wireType) } - m.AvgFps = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AvgFps |= int64(b&0x7F) << shift - if b < 0x80 { - break - } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF } + v = uint32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.AvgFps = float32(math.Float32frombits(v)) case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field VideoDimension", wireType) From 163a9459ba9a7a74bcac425efb0d9410784c9bf2 Mon Sep 17 00:00:00 2001 From: Oliver Lazoroski Date: Thu, 17 Apr 2025 12:25:05 +0200 Subject: [PATCH 2/4] fix: switch to float for averaged values --- protobuf/video/sfu/models/models.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobuf/video/sfu/models/models.proto b/protobuf/video/sfu/models/models.proto index 62a09c2b2..46aa57135 100644 --- a/protobuf/video/sfu/models/models.proto +++ b/protobuf/video/sfu/models/models.proto @@ -406,7 +406,7 @@ message EncodeStats { TrackType track_type = 1; Codec codec = 2; float avg_frame_encode_time_ms = 3; - int64 avg_fps = 4; + float avg_fps = 4; } // DecodeStats represents the decoding statistics for a track. From 3a5b1844cf7f6f7704c5b81c1fff0eb1545caead Mon Sep 17 00:00:00 2001 From: Oliver Lazoroski Date: Thu, 17 Apr 2025 12:25:35 +0200 Subject: [PATCH 3/4] fix: switch to float for averaged values --- protobuf/video/sfu/models/models.pb.go | 6 ++-- .../video/sfu/models/models_vtproto.pb.go | 29 +++++++------------ 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/protobuf/video/sfu/models/models.pb.go b/protobuf/video/sfu/models/models.pb.go index cb15deefa..a4caf3d2e 100644 --- a/protobuf/video/sfu/models/models.pb.go +++ b/protobuf/video/sfu/models/models.pb.go @@ -2563,7 +2563,7 @@ type EncodeStats struct { TrackType TrackType `protobuf:"varint,1,opt,name=track_type,json=trackType,proto3,enum=stream.video.sfu.models.TrackType" json:"track_type,omitempty"` Codec *Codec `protobuf:"bytes,2,opt,name=codec,proto3" json:"codec,omitempty"` AvgFrameEncodeTimeMs float32 `protobuf:"fixed32,3,opt,name=avg_frame_encode_time_ms,json=avgFrameEncodeTimeMs,proto3" json:"avg_frame_encode_time_ms,omitempty"` - AvgFps int64 `protobuf:"varint,4,opt,name=avg_fps,json=avgFps,proto3" json:"avg_fps,omitempty"` + AvgFps float32 `protobuf:"fixed32,4,opt,name=avg_fps,json=avgFps,proto3" json:"avg_fps,omitempty"` } func (x *EncodeStats) Reset() { @@ -2619,7 +2619,7 @@ func (x *EncodeStats) GetAvgFrameEncodeTimeMs() float32 { return 0 } -func (x *EncodeStats) GetAvgFps() int64 { +func (x *EncodeStats) GetAvgFps() float32 { if x != nil { return x.AvgFps } @@ -3001,7 +3001,7 @@ var file_video_sfu_models_models_proto_rawDesc = []byte{ 0x6d, 0x65, 0x5f, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x14, 0x61, 0x76, 0x67, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x12, 0x17, 0x0a, - 0x07, 0x61, 0x76, 0x67, 0x5f, 0x66, 0x70, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, + 0x07, 0x61, 0x76, 0x67, 0x5f, 0x66, 0x70, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x02, 0x52, 0x06, 0x61, 0x76, 0x67, 0x46, 0x70, 0x73, 0x22, 0xa9, 0x02, 0x0a, 0x0b, 0x44, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x41, 0x0a, 0x0a, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x22, 0x2e, 0x73, 0x74, 0x72, diff --git a/protobuf/video/sfu/models/models_vtproto.pb.go b/protobuf/video/sfu/models/models_vtproto.pb.go index 097227239..3bb3ea45d 100644 --- a/protobuf/video/sfu/models/models_vtproto.pb.go +++ b/protobuf/video/sfu/models/models_vtproto.pb.go @@ -1686,9 +1686,10 @@ func (m *EncodeStats) MarshalToSizedBufferVT(dAtA []byte) (int, error) { copy(dAtA[i:], m.unknownFields) } if m.AvgFps != 0 { - i = encodeVarint(dAtA, i, uint64(m.AvgFps)) + i -= 4 + binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.AvgFps)))) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x25 } if m.AvgFrameEncodeTimeMs != 0 { i -= 4 @@ -2509,7 +2510,7 @@ func (m *EncodeStats) SizeVT() (n int) { n += 5 } if m.AvgFps != 0 { - n += 1 + sov(uint64(m.AvgFps)) + n += 5 } if m.unknownFields != nil { n += len(m.unknownFields) @@ -6676,24 +6677,16 @@ func (m *EncodeStats) UnmarshalVT(dAtA []byte) error { iNdEx += 4 m.AvgFrameEncodeTimeMs = float32(math.Float32frombits(v)) case 4: - if wireType != 0 { + if wireType != 5 { return fmt.Errorf("proto: wrong wireType = %d for field AvgFps", wireType) } - m.AvgFps = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AvgFps |= int64(b&0x7F) << shift - if b < 0x80 { - break - } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF } + v = uint32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.AvgFps = float32(math.Float32frombits(v)) default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) From 162b0c8ee6f4d3e4a422f3de9c18ea815557b1a7 Mon Sep 17 00:00:00 2001 From: Oliver Lazoroski Date: Thu, 17 Apr 2025 12:27:45 +0200 Subject: [PATCH 4/4] fix: switch to float for averaged values --- protobuf/video/sfu/models/models.pb.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protobuf/video/sfu/models/models.pb.go b/protobuf/video/sfu/models/models.pb.go index fffce45fd..a4caf3d2e 100644 --- a/protobuf/video/sfu/models/models.pb.go +++ b/protobuf/video/sfu/models/models.pb.go @@ -2634,8 +2634,8 @@ type DecodeStats struct { TrackType TrackType `protobuf:"varint,1,opt,name=track_type,json=trackType,proto3,enum=stream.video.sfu.models.TrackType" json:"track_type,omitempty"` Codec *Codec `protobuf:"bytes,2,opt,name=codec,proto3" json:"codec,omitempty"` - AvgFrameDecodeTimeMs int64 `protobuf:"varint,3,opt,name=avg_frame_decode_time_ms,json=avgFrameDecodeTimeMs,proto3" json:"avg_frame_decode_time_ms,omitempty"` - AvgFps int64 `protobuf:"varint,4,opt,name=avg_fps,json=avgFps,proto3" json:"avg_fps,omitempty"` + AvgFrameDecodeTimeMs float32 `protobuf:"fixed32,3,opt,name=avg_frame_decode_time_ms,json=avgFrameDecodeTimeMs,proto3" json:"avg_frame_decode_time_ms,omitempty"` + AvgFps float32 `protobuf:"fixed32,4,opt,name=avg_fps,json=avgFps,proto3" json:"avg_fps,omitempty"` VideoDimension *VideoDimension `protobuf:"bytes,5,opt,name=video_dimension,json=videoDimension,proto3" json:"video_dimension,omitempty"` }