Track/Group/Frame
Media streams are organized into a hierarchy of tracks, groups, and frames.
- Track: A continuous media stream, such as video or audio, within a broadcast path.
- Group: A self-contained segment of a track, often corresponding to a time-based unit like a video GOP or an audio packet group.
- Frame: The smallest unit of media data, such as a single video image or audio sample.
Each track has a name that distinguishes it within the broadcast path, often corresponding to a specific media layer (e.g., SVC).
moqt.TrackWriter
Section titled “moqt.TrackWriter”The moqt.TrackWriter handles all aspects of writing data to a track, including managing the lifecycle of the track, opening and closing groups, transmitting media data, and dealing with errors.
type TrackWriter struct { BroadcastPath BroadcastPath TrackName TrackName // contains filtered or unexported fields}
func (*TrackWriter) Close() errorfunc (*TrackWriter) CloseWithError(SubscribeErrorCode)func (*TrackWriter) OpenGroup(context.Context) (*GroupWriter, error)func (*TrackWriter) OpenGroupAt(context.Context, GroupSequence) (*GroupWriter, error)func (*TrackWriter) SkipGroups(n uint64)func (*TrackWriter) DropGroups(SubscribeDrop) errorfunc (*TrackWriter) DropNextGroups(n uint64, code SubscribeErrorCode) errorfunc (*TrackWriter) TrackConfig() *SubscribeConfigfunc (*TrackWriter) ReadUpdate() (*SubscribeConfig, error)func (*TrackWriter) Context() context.Contextmoqt.TrackReader
Section titled “moqt.TrackReader”The moqt.TrackReader is responsible for reading data from a track, receiving groups and frames in order, and managing any errors that occur during the process.
type TrackReader struct { BroadcastPath BroadcastPath TrackName TrackName // contains filtered or unexported fields}
func (*TrackReader) AcceptGroup(context.Context) (*GroupReader, error)func (*TrackReader) Close() errorfunc (*TrackReader) CloseWithError(SubscribeErrorCode)func (*TrackReader) Update(*SubscribeConfig) errorfunc (*TrackReader) TrackConfig() *SubscribeConfigfunc (*TrackReader) SubscribeID() SubscribeIDfunc (*TrackReader) Drops(context.Context) iter.Seq[SubscribeDrop]func (*TrackReader) Context() context.ContextGroups are processed and transmitted independently, and may contain frames that are either standalone or interdependent (for example, I/P/B frames in video).
moqt.GroupWriter
Section titled “moqt.GroupWriter”The GroupWriter writes frames, can set deadlines, cancel or close groups, and exposes the group’s sequence.
type GroupWriter struct { // contains filtered or unexported fields}
func (*GroupWriter) GroupSequence() GroupSequencefunc (*GroupWriter) WriteFrame(*Frame) errorfunc (*GroupWriter) SetWriteDeadline(time.Time) errorfunc (*GroupWriter) CancelWrite(GroupErrorCode)func (*GroupWriter) Close() errorfunc (*GroupWriter) Context() context.Contextmoqt.GroupReader
Section titled “moqt.GroupReader”The GroupReader reads frames sequentially, can cancel reads, and provides group sequencing and deadline control.
type GroupReader struct { // contains filtered or unexported fields}
func (*GroupReader) GroupSequence() GroupSequencefunc (*GroupReader) ReadFrame(*Frame) errorfunc (*GroupReader) CancelRead(GroupErrorCode)func (*GroupReader) SetReadDeadline(time.Time) errorfunc (*GroupReader) Frames(*Frame) iter.Seq[*Frame]Frames can be independent (like keyframes) or rely on other frames (like delta frames in video), and together they form the building blocks of a track.
moqt.Frame
Section titled “moqt.Frame”The Frame struct represents the smallest unit of media data. It ensures that data is stored immutably.
type Frame struct { Timestamp uint64 // contains filtered or unexported fields}
func NewFrame(int) *Framefunc (*Frame) Body() []bytefunc (*Frame) Cap() intfunc (*Frame) Len() intfunc (*Frame) Reset()func (*Frame) Clone() *Framefunc (*Frame) Write([]byte) (int, error)func (*Frame) WriteTo(w io.Writer) (int64, error)