mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-10 17:12:48 +00:00
wip
This commit is contained in:
40
server/rtp/stream.go
Normal file
40
server/rtp/stream.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package rtp
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
// Stream -
|
||||
type Stream struct {
|
||||
StartTime time.Time
|
||||
StartingTimestamp uint32
|
||||
LatestTimestamp uint32
|
||||
Packets []*discordgo.Packet
|
||||
}
|
||||
|
||||
// GetTimeDiff -
|
||||
func (s *Stream) GetTimeDiff() uint32 {
|
||||
return s.LatestTimestamp - s.StartingTimestamp
|
||||
}
|
||||
|
||||
func (s *Stream) GetTimeOffset(startTime int64) int64 {
|
||||
return s.StartTime.Unix() - startTime
|
||||
}
|
||||
|
||||
// PushPacket -
|
||||
func (s *Stream) PushPacket(packet *discordgo.Packet) {
|
||||
|
||||
if s.StartTime.Unix() == 0 {
|
||||
s.StartTime = time.Now()
|
||||
}
|
||||
|
||||
if s.StartingTimestamp == 0 && packet.Timestamp != 0 {
|
||||
s.StartingTimestamp = packet.Timestamp
|
||||
}
|
||||
|
||||
s.LatestTimestamp = packet.Timestamp
|
||||
|
||||
s.Packets = append(s.Packets, packet)
|
||||
}
|
||||
Reference in New Issue
Block a user