Documentation
¶
Overview ¶
Package moq implements the wire-protocol codec for MoQ Transport (draft-ietf-moq-transport-15), including control message parsing and serialization, media format conversion (Annex B → AVC1, ADTS stripping, decoder configuration records), and typed error definitions.
This package contains no session or relay logic; those higher-level concerns live in github.com/zsiec/prism/distribution.
Index ¶
- Constants
- Variables
- func AnnexBToAVC1(nalus [][]byte) []byte
- func AppendNamespaceTuple(buf []byte, parts []string) []byte
- func BuildAVCDecoderConfig(sps, pps []byte) []byte
- func BuildHEVCDecoderConfig(vps, sps, pps []byte) []byte
- func ReadControlMsg(r io.Reader) (uint64, []byte, error)
- func SerializeGoAway(ga GoAway) []byte
- func SerializeMaxRequestID(reqID uint64) []byte
- func SerializeServerSetup(ss ServerSetup) []byte
- func SerializeSubscribeError(se SubscribeError) []byte
- func SerializeSubscribeOK(sok SubscribeOK) []byte
- func StripADTS(data []byte) []byte
- func WriteControlMsg(w io.Writer, msgType uint64, payload []byte) error
- type ClientSetup
- type GoAway
- type MaxRequestIDMsg
- type ParseError
- type ServerSetup
- type Subscribe
- type SubscribeError
- type SubscribeOK
- type Unsubscribe
Constants ¶
const ( MsgSubscribe uint64 = 0x03 MsgSubscribeOK uint64 = 0x04 MsgSubscribeError uint64 = 0x05 MsgUnsubscribe uint64 = 0x0a MsgGoAway uint64 = 0x10 MsgMaxRequestID uint64 = 0x15 MsgClientSetup uint64 = 0x20 MsgServerSetup uint64 = 0x21 )
MoQ Transport draft-15 message type IDs.
const ( ParamPath uint64 = 0x01 // odd → length-prefixed byte string ParamMaxRequestID uint64 = 0x02 // even → varint value )
Setup parameter keys (draft-15 §6.2).
const ( FilterNextGroupStart uint64 = 0x01 FilterLatestObject uint64 = 0x02 FilterAbsoluteStart uint64 = 0x03 FilterAbsoluteRange uint64 = 0x04 )
Subscribe filter types (draft-15 §6.6).
const ( GroupOrderDefault byte = 0x00 GroupOrderAscending byte = 0x01 GroupOrderDescending byte = 0x02 )
Group order values (draft-15 §6.6).
const Version uint64 = 0xff00000f
Version is the MoQ Transport version: draft-15 uses 0xff000000 + draft number.
Variables ¶
var ( ErrVersionMismatch = errors.New("moq: no compatible version") ErrUnknownTrack = errors.New("moq: unknown track") ErrUnsupportedFilter = errors.New("moq: unsupported filter type") ErrUnknownNamespace = errors.New("moq: unknown namespace") )
Sentinel errors for MoQ session handling. These enable callers to programmatically distinguish failure modes using errors.Is.
Functions ¶
func AnnexBToAVC1 ¶
AnnexBToAVC1 converts Annex B NALUs (4-byte start code prefixed) to AVC1 format (4-byte big-endian length prefixed). Each NALU in the input slice is expected to start with a 4-byte start code (0x00 0x00 0x00 0x01).
func AppendNamespaceTuple ¶
AppendNamespaceTuple appends a namespace tuple to buf.
func BuildAVCDecoderConfig ¶
BuildAVCDecoderConfig builds an AVCDecoderConfigurationRecord (ISO 14496-15 §5.2.4.1.1) from raw SPS and PPS NAL data (without start codes). The SPS must include the NAL header byte (0x67).
func BuildHEVCDecoderConfig ¶
BuildHEVCDecoderConfig builds an HEVCDecoderConfigurationRecord (ISO 14496-15 §8.3.3.1.2) from raw VPS, SPS, and PPS NAL data (without start codes). The SPS must include the 2-byte NAL header.
func ReadControlMsg ¶
ReadControlMsg reads a MoQ control message from the control stream. Wire format: [message_type (varint)] [message_length (uint16 big-endian)] [payload].
func SerializeGoAway ¶
SerializeGoAway serializes a GOAWAY payload.
func SerializeMaxRequestID ¶
SerializeMaxRequestID serializes a MAX_REQUEST_ID payload.
func SerializeServerSetup ¶
func SerializeServerSetup(ss ServerSetup) []byte
SerializeServerSetup serializes a SERVER_SETUP payload.
func SerializeSubscribeError ¶
func SerializeSubscribeError(se SubscribeError) []byte
SerializeSubscribeError serializes a SUBSCRIBE_ERROR payload.
func SerializeSubscribeOK ¶
func SerializeSubscribeOK(sok SubscribeOK) []byte
SerializeSubscribeOK serializes a SUBSCRIBE_OK payload.
Types ¶
type ClientSetup ¶
ClientSetup is the first message sent by a MoQ client.
func ParseClientSetup ¶
func ParseClientSetup(data []byte) (ClientSetup, error)
ParseClientSetup parses a CLIENT_SETUP payload.
type GoAway ¶
type GoAway struct {
NewSessionURI string
}
GoAway signals a graceful session shutdown.
type MaxRequestIDMsg ¶
type MaxRequestIDMsg struct {
RequestID uint64
}
MaxRequestIDMsg updates the peer's request ID quota.
type ParseError ¶
ParseError indicates a failure to parse a MoQ control message field. It wraps the underlying I/O or format error and records which field was being parsed when the error occurred.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
type ServerSetup ¶
ServerSetup is the response to a ClientSetup.
type Subscribe ¶
type Subscribe struct {
RequestID uint64
Namespace []string
TrackName string
Priority byte
GroupOrder byte
Forward byte
FilterType uint64
StartGroup uint64 // only for AbsoluteStart / AbsoluteRange
StartObj uint64 // only for AbsoluteStart / AbsoluteRange
EndGroup uint64 // only for AbsoluteRange
}
Subscribe requests delivery of a track.
func ParseSubscribe ¶
ParseSubscribe parses a SUBSCRIBE payload.
type SubscribeError ¶
SubscribeError rejects a subscription.
type SubscribeOK ¶
type SubscribeOK struct {
RequestID uint64
TrackAlias uint64
Expires uint64
GroupOrder byte
ContentExists bool
LargestGroup uint64 // only when ContentExists
LargestObj uint64 // only when ContentExists
}
SubscribeOK confirms a subscription.
type Unsubscribe ¶
type Unsubscribe struct {
RequestID uint64
}
Unsubscribe cancels a subscription.
func ParseUnsubscribe ¶
func ParseUnsubscribe(data []byte) (Unsubscribe, error)
ParseUnsubscribe parses an UNSUBSCRIBE payload.