Documentation
¶
Index ¶
- Constants
- func ConnectByUID(stage byte, uid string, sid8 []byte) []byte
- func FindHL(data []byte, offset int) []byte
- func GenSessionID() []byte
- func GetSampleRateIndex(sampleRate uint32) uint8
- func GetSamplesPerFrame(codecID byte) uint32
- func HL(cmdID uint16, payload []byte) []byte
- func ICAM(cmd uint32, args ...byte) []byte
- func IsAudioCodec(id byte) bool
- func IsContinuationFrame(frameType uint8) bool
- func IsEndFrame(frameType uint8) bool
- func IsStartFrame(frameType uint8) bool
- func IsVideoCodec(id byte) bool
- func ParseHL(data []byte) (cmdID uint16, payload []byte, ok bool)
- func ReverseTransCodeBlob(src []byte) []byte
- func ReverseTransCodePartial(dst, src []byte) []byte
- func TransCodeBlob(src []byte) []byte
- func TransCodePartial(dst, src []byte) []byte
- func XXTEADecrypt(dst, src, key []byte)
- func XXTEADecryptVar(data, key []byte) []byte
- type Conn
- func (c *Conn) Error() error
- func (c *Conn) Protocol() string
- func (c *Conn) Read(buf []byte) (n int, err error)
- func (c *Conn) ReadCommand() (ctrlType uint32, ctrlData []byte, err error)
- func (c *Conn) ReadPacket() (hdr, payload []byte, err error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) Version() string
- func (c *Conn) Write(b []byte) (n int, err error)
- func (c *Conn) WriteCommand(ctrlType uint32, ctrlData []byte) error
- func (c *Conn) WritePacket(hdr, payload []byte) error
- type FrameHandler
- type FrameInfo
- type Packet
- type PacketHeader
- type ReorderBuffer
- type Session
- type Session16
- func (s *Session16) ClientStart(i byte, username, password string) []byte
- func (s *Session16) Close() error
- func (s *Session16) Msg(size uint16) []byte
- func (s *Session16) RecvFrameData() (frameInfo, frameData []byte, err error)
- func (s *Session16) RecvIOCtrl() (ctrlType uint32, ctrlData []byte, err error)
- func (s *Session16) SendFrameData(frameInfo, frameData []byte) []byte
- func (s *Session16) SendIOCtrl(ctrlType uint32, ctrlData []byte) []byte
- func (s *Session16) SessionRead(chID byte, cmd []byte) int
- func (s *Session16) SessionWrite(chID byte, buf []byte) error
- type Session25
Constants ¶
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
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 )
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) )
const ( ChannelIVideo uint8 = 0x05 ChannelAudio uint8 = 0x03 ChannelPVideo uint8 = 0x07 )
Variables ¶
This section is empty.
Functions ¶
func GenSessionID ¶
func GenSessionID() []byte
func GetSampleRateIndex ¶
func GetSamplesPerFrame ¶
func IsAudioCodec ¶
func IsContinuationFrame ¶
func IsEndFrame ¶
func IsStartFrame ¶
func IsVideoCodec ¶
func ReverseTransCodeBlob ¶
func ReverseTransCodePartial ¶
func TransCodeBlob ¶
func TransCodePartial ¶
func XXTEADecrypt ¶
func XXTEADecrypt(dst, src, key []byte)
func XXTEADecryptVar ¶
Types ¶
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 (*FrameInfo) IsKeyframe ¶
func (*FrameInfo) SampleRate ¶
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 (*Session16) ClientStart ¶
func (*Session16) RecvFrameData ¶
func (*Session16) RecvIOCtrl ¶
func (*Session16) SendFrameData ¶
func (*Session16) SendIOCtrl ¶
type Session25 ¶
type Session25 struct {
*Session16
// contains filtered or unexported fields
}