tutk

package
v1.9.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodecMPEG4 byte = 0x4C
	CodecH263  byte = 0x4D
	CodecH264  byte = 0x4E
	CodecMJPEG byte = 0x4F
	CodecH265  byte = 0x50
)

https://github.com/seydx/tutk_wyze#11-codec-reference

View Source
const (
	CodecAACRaw  byte = 0x86
	CodecAACADTS byte = 0x87
	CodecAACLATM byte = 0x88
	CodecPCMU    byte = 0x89
	CodecPCMA    byte = 0x8A
	CodecADPCM   byte = 0x8B
	CodecPCML    byte = 0x8C
	CodecSPEEX   byte = 0x8D
	CodecMP3     byte = 0x8E
	CodecG726    byte = 0x8F
	CodecAACAlt  byte = 0x90
	CodecOpus    byte = 0x92
)
View Source
const (
	FrameTypeStart     uint8 = 0x08 // Extended start (36-byte header)
	FrameTypeStartAlt  uint8 = 0x09 // StartAlt (36-byte header)
	FrameTypeCont      uint8 = 0x00 // Continuation (28-byte header)
	FrameTypeContAlt   uint8 = 0x04 // Continuation alt
	FrameTypeEndSingle uint8 = 0x01 // Single-packet frame (28-byte)
	FrameTypeEndMulti  uint8 = 0x05 // Multi-packet end (28-byte)
	FrameTypeEndExt    uint8 = 0x0d // Extended end (36-byte)
)
View Source
const (
	ChannelIVideo uint8 = 0x05
	ChannelAudio  uint8 = 0x03
	ChannelPVideo uint8 = 0x07
)

Variables

This section is empty.

Functions

func ConnectByUID

func ConnectByUID(stage byte, uid string, sid8 []byte) []byte

func FindHL

func FindHL(data []byte, offset int) []byte

func GenSessionID

func GenSessionID() []byte

func GetSampleRateIndex

func GetSampleRateIndex(sampleRate uint32) uint8

func GetSamplesPerFrame

func GetSamplesPerFrame(codecID byte) uint32

func HL

func HL(cmdID uint16, payload []byte) []byte

func ICAM

func ICAM(cmd uint32, args ...byte) []byte

func IsAudioCodec

func IsAudioCodec(id byte) bool

func IsContinuationFrame

func IsContinuationFrame(frameType uint8) bool

func IsEndFrame

func IsEndFrame(frameType uint8) bool

func IsStartFrame

func IsStartFrame(frameType uint8) bool

func IsVideoCodec

func IsVideoCodec(id byte) bool

func ParseHL

func ParseHL(data []byte) (cmdID uint16, payload []byte, ok bool)

func ReverseTransCodeBlob

func ReverseTransCodeBlob(src []byte) []byte

func ReverseTransCodePartial

func ReverseTransCodePartial(dst, src []byte) []byte

func TransCodeBlob

func TransCodeBlob(src []byte) []byte

func TransCodePartial

func TransCodePartial(dst, src []byte) []byte

func XXTEADecrypt

func XXTEADecrypt(dst, src, key []byte)

func XXTEADecryptVar

func XXTEADecryptVar(data, key []byte) []byte

Types

type Conn

type Conn struct {
	*net.UDPConn
	// contains filtered or unexported fields
}

func Dial

func Dial(host, uid, username, password string) (*Conn, error)

func (*Conn) Error

func (c *Conn) Error() error

func (*Conn) Protocol

func (c *Conn) Protocol() string

func (*Conn) Read

func (c *Conn) Read(buf []byte) (n int, err error)

Read overwrite net.Conn

func (*Conn) ReadCommand

func (c *Conn) ReadCommand() (ctrlType uint32, ctrlData []byte, err error)

func (*Conn) ReadPacket

func (c *Conn) ReadPacket() (hdr, payload []byte, err error)

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr overwrite net.Conn

func (*Conn) Version

func (c *Conn) Version() string

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

Write overwrite net.Conn

func (*Conn) WriteCommand

func (c *Conn) WriteCommand(ctrlType uint32, ctrlData []byte) error

func (*Conn) WritePacket

func (c *Conn) WritePacket(hdr, payload []byte) error

type FrameHandler

type FrameHandler struct {
	// contains filtered or unexported fields
}

func NewFrameHandler

func NewFrameHandler(verbose bool) *FrameHandler

func (*FrameHandler) Close

func (h *FrameHandler) Close()

func (*FrameHandler) Handle

func (h *FrameHandler) Handle(data []byte)

func (*FrameHandler) Recv

func (h *FrameHandler) Recv() <-chan *Packet

type FrameInfo

type FrameInfo struct {
	CodecID     byte   // 0 (only low byte used)
	Flags       uint8  // 2
	CamIndex    uint8  // 3
	OnlineNum   uint8  // 4
	FPS         uint8  // 5: Framerate
	ResTier     uint8  // 6: Resolution tier (1=Low, 4=High)
	Bitrate     uint8  // 7: Bitrate index (30=360P, 100=HD, 200=2K)
	Timestamp   uint32 // 8-11: Timestamp
	SessionID   uint32 // 12-15: Session marker (constant)
	PayloadSize uint32 // 16-19: Payload size
	FrameNo     uint32 // 20-23: Frame number
}

FrameInfo - Wyze extended FRAMEINFO (40 bytes at end of packet) Video: 40 bytes, Audio: 16 bytes (uses same struct, fields 16+ are zero)

Offset Size Field 0-1 2 CodecID - 0x4E=H264, 0x7B=H265, 0x90=AAC_WYZE 2 1 Flags - Video: 1=Keyframe, 0=P-frame | Audio: sample rate/bits/channels 3 1 CamIndex - Camera index 4 1 OnlineNum - Online number 5 1 FPS - Framerate (e.g. 20) 6 1 ResTier - Video: 1=Low(360P), 4=High(HD/2K) | Audio: 0 7 1 Bitrate - Video: 30=360P, 100=HD, 200=2K | Audio: 1 8-11 4 Timestamp - Timestamp (increases ~50000/frame for 20fps video) 12-15 4 SessionID - Session marker (constant per stream) 16-19 4 PayloadSize - Frame payload size in bytes 20-23 4 FrameNo - Global frame number 24-35 12 DeviceID - MAC address (ASCII) - video only 36-39 4 Padding - Always 0 - video only

func ParseFrameInfo

func ParseFrameInfo(data []byte) *FrameInfo

func (*FrameInfo) Channels

func (fi *FrameInfo) Channels() uint8

func (*FrameInfo) IsKeyframe

func (fi *FrameInfo) IsKeyframe() bool

func (*FrameInfo) SampleRate

func (fi *FrameInfo) SampleRate() uint32

type Packet

type Packet struct {
	Channel    uint8
	Codec      byte
	Timestamp  uint32
	Payload    []byte
	IsKeyframe bool
	FrameNo    uint32
	SampleRate uint32
	Channels   uint8
}

type PacketHeader

type PacketHeader struct {
	Channel      byte
	FrameType    byte
	HeaderSize   int
	FrameNo      uint32
	PktIdx       uint16
	PktTotal     uint16
	PayloadSize  uint16
	HasFrameInfo bool
}

func ParsePacketHeader

func ParsePacketHeader(data []byte) *PacketHeader

type ReorderBuffer

type ReorderBuffer struct {
	// contains filtered or unexported fields
}

ReorderBuffer used for UDP incoming data. Because the order of the packets may be mixed up.

func NewReorderBuffer

func NewReorderBuffer(size int) *ReorderBuffer

func (*ReorderBuffer) Available

func (r *ReorderBuffer) Available() int

Available return how much free slots is in the buffer.

func (*ReorderBuffer) Check

func (r *ReorderBuffer) Check(seq uint16) (ok bool)

Check return OK if this is the seq we are waiting for.

func (*ReorderBuffer) Next

func (r *ReorderBuffer) Next()

func (*ReorderBuffer) Pop

func (r *ReorderBuffer) Pop() []byte

Pop latest item from buffer. OK - if items wasn't dropped.

func (*ReorderBuffer) Push

func (r *ReorderBuffer) Push(seq uint16, data []byte)

Push new item to buffer. Important! There is no buffer full check here.

type Session

type Session interface {
	Close() error

	ClientStart(i byte, username, password string) []byte

	SendIOCtrl(ctrlType uint32, ctrlData []byte) []byte
	SendFrameData(frameInfo, frameData []byte) []byte

	RecvIOCtrl() (ctrlType uint32, ctrlData []byte, err error)
	RecvFrameData() (frameInfo, frameData []byte, err error)

	SessionRead(chID byte, buf []byte) int
	SessionWrite(chID byte, buf []byte) error
}

type Session16

type Session16 struct {
	// contains filtered or unexported fields
}

func NewSession16

func NewSession16(conn net.Conn, sid8 []byte) *Session16

func (*Session16) ClientStart

func (s *Session16) ClientStart(i byte, username, password string) []byte

func (*Session16) Close

func (s *Session16) Close() error

func (*Session16) Msg

func (s *Session16) Msg(size uint16) []byte

func (*Session16) RecvFrameData

func (s *Session16) RecvFrameData() (frameInfo, frameData []byte, err error)

func (*Session16) RecvIOCtrl

func (s *Session16) RecvIOCtrl() (ctrlType uint32, ctrlData []byte, err error)

func (*Session16) SendFrameData

func (s *Session16) SendFrameData(frameInfo, frameData []byte) []byte

func (*Session16) SendIOCtrl

func (s *Session16) SendIOCtrl(ctrlType uint32, ctrlData []byte) []byte

func (*Session16) SessionRead

func (s *Session16) SessionRead(chID byte, cmd []byte) int

func (*Session16) SessionWrite

func (s *Session16) SessionWrite(chID byte, buf []byte) error

type Session25

type Session25 struct {
	*Session16
	// contains filtered or unexported fields
}

func NewSession25

func NewSession25(conn net.Conn, sid []byte) *Session25

func (*Session25) SendFrameData

func (s *Session25) SendFrameData(frameInfo, frameData []byte) []byte

func (*Session25) SendIOCtrl

func (s *Session25) SendIOCtrl(ctrlType uint32, ctrlData []byte) []byte

func (*Session25) SessionRead

func (s *Session25) SessionRead(chID byte, cmd []byte) (res int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL