golanggohlsrtmpwebrtcmedia-serverobs-studiortcprtmp-proxyrtmp-serverrtprtsprtsp-proxyrtsp-relayrtsp-serversrtstreamingwebrtc-proxy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
package message //nolint:dupl |
|
|
|
import ( |
|
"fmt" |
|
|
|
"github.com/bluenviron/mediamtx/internal/rtmp/rawmessage" |
|
) |
|
|
|
// UserControlSetBufferLength is a user control message. |
|
type UserControlSetBufferLength struct { |
|
StreamID uint32 |
|
BufferLength uint32 |
|
} |
|
|
|
// Unmarshal implements Message. |
|
func (m *UserControlSetBufferLength) Unmarshal(raw *rawmessage.Message) error { |
|
if raw.ChunkStreamID != ControlChunkStreamID { |
|
return fmt.Errorf("unexpected chunk stream ID") |
|
} |
|
|
|
if len(raw.Body) != 10 { |
|
return fmt.Errorf("invalid body size") |
|
} |
|
|
|
m.StreamID = uint32(raw.Body[2])<<24 | uint32(raw.Body[3])<<16 | uint32(raw.Body[4])<<8 | uint32(raw.Body[5]) |
|
m.BufferLength = uint32(raw.Body[6])<<24 | uint32(raw.Body[7])<<16 | uint32(raw.Body[8])<<8 | uint32(raw.Body[9]) |
|
|
|
return nil |
|
} |
|
|
|
// Marshal implements Message. |
|
func (m UserControlSetBufferLength) Marshal() (*rawmessage.Message, error) { |
|
buf := make([]byte, 10) |
|
|
|
buf[0] = byte(UserControlTypeSetBufferLength >> 8) |
|
buf[1] = byte(UserControlTypeSetBufferLength) |
|
buf[2] = byte(m.StreamID >> 24) |
|
buf[3] = byte(m.StreamID >> 16) |
|
buf[4] = byte(m.StreamID >> 8) |
|
buf[5] = byte(m.StreamID) |
|
buf[6] = byte(m.BufferLength >> 24) |
|
buf[7] = byte(m.BufferLength >> 16) |
|
buf[8] = byte(m.BufferLength >> 8) |
|
buf[9] = byte(m.BufferLength) |
|
|
|
return &rawmessage.Message{ |
|
ChunkStreamID: ControlChunkStreamID, |
|
Type: uint8(TypeUserControl), |
|
Body: buf, |
|
}, nil |
|
}
|
|
|