Documentation
¶
Index ¶
- Variables
- func BatchConvert(sourcePattern, targetDir string, toNevrcap bool) error
- func ConvertEchoReplayToNevrcap(echoReplayPath, nevrcapPath string) error
- func ConvertNevrcapToEchoReplay(nevrcapPath, echoReplayPath string) error
- func ConvertUncompressedEchoReplayToNevrcap(echoReplayPath, nevrcapPath string) error
- type DiscState
- type EchoReplayCodec
- func (e *EchoReplayCodec) Close() error
- func (e *EchoReplayCodec) Finalize() error
- func (e *EchoReplayCodec) FlushBuffer() error
- func (e *EchoReplayCodec) GetBufferSize() int
- func (e *EchoReplayCodec) HasNext() bool
- func (e *EchoReplayCodec) ReadFrame() (*rtapi.LobbySessionStateFrame, error)
- func (e *EchoReplayCodec) ReadFrames() ([]*rtapi.LobbySessionStateFrame, error)
- func (e *EchoReplayCodec) WriteFrame(frame *rtapi.LobbySessionStateFrame) error
- func (e *EchoReplayCodec) WriteFrameBatch(frames []*rtapi.LobbySessionStateFrame) error
- func (e *EchoReplayCodec) WriteReplayFrame(dst *bytes.Buffer, frame *rtapi.LobbySessionStateFrame) int
- type EchoReplayFrame
- type EventDetector
- type FrameProcessor
- type ScoreboardState
- type ZstdCodec
- func (z *ZstdCodec) Close() error
- func (z *ZstdCodec) ReadFrame() (*rtapi.LobbySessionStateFrame, error)
- func (z *ZstdCodec) ReadHeader() (*rtapi.TelemetryHeader, error)
- func (z *ZstdCodec) WriteFrame(frame *rtapi.LobbySessionStateFrame) error
- func (z *ZstdCodec) WriteHeader(header *rtapi.TelemetryHeader) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrCodecNotConfiguredForWriting = fmt.Errorf("codec not configured for writing") EchoReplayTimeFormat = "2006/01/02 15:04:05.000" )
Functions ¶
func BatchConvert ¶
BatchConvert converts multiple files
func ConvertEchoReplayToNevrcap ¶
ConvertEchoReplayToNevrcap converts a .echoreplay file to a .nevrcap file
func ConvertNevrcapToEchoReplay ¶
ConvertNevrcapToEchoReplay converts a .nevrcap file to a .echoreplay file
func ConvertUncompressedEchoReplayToNevrcap ¶
ConvertUncompressedEchoReplayToNevrcap converts with optimizations for benchmarking
Types ¶
type EchoReplayCodec ¶
type EchoReplayCodec struct {
// contains filtered or unexported fields
}
EchoReplayCodec handles .echoreplay file format (zip format)
Example ¶
ExampleEchoReplayCodec demonstrates how to use the optimized codec
// Create a new codec for writing
codec, err := NewEchoReplayCodecWriter("example_optimized.echoreplay")
if err != nil {
fmt.Printf("Error creating codec: %v\n", err)
return
}
defer codec.Close()
// Write some frames
for i := 0; i < 1000; i++ {
frame := &rtapi.LobbySessionStateFrame{
Timestamp: timestamppb.New(time.Now().Add(time.Duration(i) * time.Millisecond)),
Session: &apigame.SessionResponse{
SessionId: uuid.Must(uuid.NewV4()).String(),
},
}
if err := codec.WriteFrame(frame); err != nil {
fmt.Printf("Error writing frame: %v\n", err)
return
}
// Check buffer size periodically
if i%100 == 0 {
fmt.Printf("Buffer size after %d frames: %d bytes\n", i+1, codec.GetBufferSize())
}
}
fmt.Printf("Final buffer size: %d bytes\n", codec.GetBufferSize())
// Cleanup
os.Remove("example_optimized.echoreplay")
fmt.Println("Optimized codec example completed successfully")
func NewEchoReplayCodecWriter ¶
func NewEchoReplayCodecWriter(filename string) (*EchoReplayCodec, error)
NewEchoReplayCodecWriter creates a new EchoReplay codec for writing
func NewEchoReplayFileReader ¶
func NewEchoReplayFileReader(filename string) (*EchoReplayCodec, error)
NewEchoReplayFileReader creates a new EchoReplay codec for reading
func (*EchoReplayCodec) Close ¶
func (e *EchoReplayCodec) Close() error
Close closes the codec and underlying files
func (*EchoReplayCodec) Finalize ¶
func (e *EchoReplayCodec) Finalize() error
Finalize writes the buffered data to the zip file and closes it
func (*EchoReplayCodec) FlushBuffer ¶
func (e *EchoReplayCodec) FlushBuffer() error
FlushBuffer forces a flush of the internal buffer (useful for periodic flushing)
func (*EchoReplayCodec) GetBufferSize ¶
func (e *EchoReplayCodec) GetBufferSize() int
GetBufferSize returns the current size of the internal buffer
func (*EchoReplayCodec) HasNext ¶
func (e *EchoReplayCodec) HasNext() bool
HasNext checks if there are more frames to read
func (*EchoReplayCodec) ReadFrame ¶
func (e *EchoReplayCodec) ReadFrame() (*rtapi.LobbySessionStateFrame, error)
ReadFrame reads the next frame from the .echoreplay file
func (*EchoReplayCodec) ReadFrames ¶
func (e *EchoReplayCodec) ReadFrames() ([]*rtapi.LobbySessionStateFrame, error)
ReadFrames reads all frames from the .echoreplay file
func (*EchoReplayCodec) WriteFrame ¶
func (e *EchoReplayCodec) WriteFrame(frame *rtapi.LobbySessionStateFrame) error
WriteFrame writes a frame to the .echoreplay file using optimized buffer operations
func (*EchoReplayCodec) WriteFrameBatch ¶
func (e *EchoReplayCodec) WriteFrameBatch(frames []*rtapi.LobbySessionStateFrame) error
WriteFrameBatch writes multiple frames efficiently in a single operation
func (*EchoReplayCodec) WriteReplayFrame ¶
func (e *EchoReplayCodec) WriteReplayFrame(dst *bytes.Buffer, frame *rtapi.LobbySessionStateFrame) int
WriteReplayFrame writes a frame using optimized buffer operations (same approach as writer_replay_file.go)
type EchoReplayFrame ¶
type EchoReplayFrame struct {
Timestamp string `json:"timestamp"`
Session *apigame.SessionResponse `json:"session"`
PlayerBones *apigame.PlayerBonesResponse `json:"user_bones,omitempty"`
}
EchoReplayFrame represents a frame in the .echoreplay format
type EventDetector ¶
type EventDetector struct {
// contains filtered or unexported fields
}
EventDetector efficiently detects events between consecutive frames
func NewEventDetector ¶
func NewEventDetector() *EventDetector
NewEventDetector creates a new event detector
func (*EventDetector) DetectEvents ¶
func (ed *EventDetector) DetectEvents(prevFrame, currentFrame *rtapi.LobbySessionStateFrame) []*rtapi.LobbySessionEvent
DetectEvents analyzes two consecutive frames and returns detected events
func (*EventDetector) Reset ¶
func (ed *EventDetector) Reset()
Reset clears the event detector state
type FrameProcessor ¶
type FrameProcessor struct {
// contains filtered or unexported fields
}
FrameProcessor handles high-performance processing of game frames optimized for up to 600 Hz operation
func NewFrameProcessor ¶
func NewFrameProcessor() *FrameProcessor
NewFrameProcessor creates a new optimized frame processor
func (*FrameProcessor) ProcessFrame ¶
func (fp *FrameProcessor) ProcessFrame(sessionResponseData, userBonesData []byte, timestamp time.Time) (*rtapi.LobbySessionStateFrame, error)
ProcessFrame takes raw session and user bones data and processes it into a rtapi.LobbySessionStateFrame This is optimized for high-frequency invocation (up to 600 Hz)
type ScoreboardState ¶
type ScoreboardState struct {
BluePoints int32
OrangePoints int32
BlueRoundScore int32
OrangeRoundScore int32
GameClock string
}
ScoreboardState represents the scoring state
type ZstdCodec ¶
type ZstdCodec struct {
// contains filtered or unexported fields
}
ZstdCodec handles streaming to/from Zstd-compressed .nevrcap files
func NewZstdCodecReader ¶
NewZstdCodecReader creates a new Zstd codec for reading .nevrcap files
func NewZstdCodecWriter ¶
NewZstdCodecWriter creates a new Zstd codec for writing .nevrcap files
func (*ZstdCodec) ReadFrame ¶
func (z *ZstdCodec) ReadFrame() (*rtapi.LobbySessionStateFrame, error)
ReadFrame reads a frame from the file
func (*ZstdCodec) ReadHeader ¶
func (z *ZstdCodec) ReadHeader() (*rtapi.TelemetryHeader, error)
ReadHeader reads the nevrcap header from the file
func (*ZstdCodec) WriteFrame ¶
func (z *ZstdCodec) WriteFrame(frame *rtapi.LobbySessionStateFrame) error
WriteFrame writes a frame to the file
func (*ZstdCodec) WriteHeader ¶
func (z *ZstdCodec) WriteHeader(header *rtapi.TelemetryHeader) error
WriteHeader writes the nevrcap header to the file