File: received_stats.go

package info (click to toggle)
golang-github-pion-interceptor 0.1.12-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, forky, sid, trixie
  • size: 764 kB
  • sloc: makefile: 8
file content (68 lines) | stat: -rw-r--r-- 2,286 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package stats

import (
	"fmt"
	"time"
)

// ReceivedRTPStreamStats contains common receiver stats of RTP streams
type ReceivedRTPStreamStats struct {
	PacketsReceived uint64
	PacketsLost     int64
	Jitter          float64
}

// String returns a string representation of ReceivedRTPStreamStats
func (s ReceivedRTPStreamStats) String() string {
	out := fmt.Sprintf("\tPacketsReceived: %v\n", s.PacketsReceived)
	out += fmt.Sprintf("\tPacketsLost: %v\n", s.PacketsLost)
	out += fmt.Sprintf("\tJitter: %v\n", s.Jitter)
	return out
}

// InboundRTPStreamStats contains stats of inbound RTP streams
type InboundRTPStreamStats struct {
	ReceivedRTPStreamStats

	LastPacketReceivedTimestamp time.Time
	HeaderBytesReceived         uint64
	BytesReceived               uint64
	FIRCount                    uint32
	PLICount                    uint32
	NACKCount                   uint32
}

// String returns a string representation of InboundRTPStreamStats
func (s InboundRTPStreamStats) String() string {
	out := "InboundRTPStreamStats:\n"
	out += s.ReceivedRTPStreamStats.String()
	out += fmt.Sprintf("\tLastPacketReceivedTimestamp: %v\n", s.LastPacketReceivedTimestamp)
	out += fmt.Sprintf("\tHeaderBytesReceived: %v\n", s.HeaderBytesReceived)
	out += fmt.Sprintf("\tBytesReceived: %v\n", s.BytesReceived)
	out += fmt.Sprintf("\tFIRCount: %v\n", s.FIRCount)
	out += fmt.Sprintf("\tPLICount: %v\n", s.PLICount)
	out += fmt.Sprintf("\tNACKCount: %v\n", s.NACKCount)
	return out
}

// RemoteInboundRTPStreamStats contains stats of inbound RTP streams of the
// remote peer
type RemoteInboundRTPStreamStats struct {
	ReceivedRTPStreamStats

	RoundTripTime             time.Duration
	TotalRoundTripTime        time.Duration
	FractionLost              float64
	RoundTripTimeMeasurements uint64
}

// String returns a string representation of RemoteInboundRTPStreamStats
func (s RemoteInboundRTPStreamStats) String() string {
	out := "RemoteInboundRTPStreamStats:\n"
	out += s.ReceivedRTPStreamStats.String()
	out += fmt.Sprintf("\tRoundTripTime: %v\n", s.RoundTripTime)
	out += fmt.Sprintf("\tTotalRoundTripTime: %v\n", s.TotalRoundTripTime)
	out += fmt.Sprintf("\tFractionLost: %v\n", s.FractionLost)
	out += fmt.Sprintf("\tRoundTripTimeMeasurements: %v\n", s.RoundTripTimeMeasurements)
	return out
}