mediamtx/internal/rtmp/base/chunk3.go

30 lines
686 B
Go
Raw Normal View History

2022-05-13 17:04:47 +00:00
package base
import (
"io"
)
// Chunk3 is a type 3 chunk.
// Type 3 chunks have no message header. The stream ID, message length
// and timestamp delta fields are not present; chunks of this type take
// values from the preceding chunk for the same Chunk Stream ID. When a
// single message is split into chunks, all chunks of a message except
// the first one SHOULD use this type.
type Chunk3 struct {
ChunkStreamID byte
Body []byte
}
// Write writes the chunk.
2022-05-13 18:53:52 +00:00
func (c Chunk3) Write(w io.Writer) error {
2022-05-13 17:04:47 +00:00
header := make([]byte, 1)
2022-05-13 18:53:52 +00:00
header[0] = 3<<6 | c.ChunkStreamID
2022-05-13 17:04:47 +00:00
_, err := w.Write(header)
if err != nil {
return err
}
2022-05-13 18:53:52 +00:00
_, err = w.Write(c.Body)
2022-05-13 17:04:47 +00:00
return err
}