forked from External/mediamtx
This commit is contained in:
parent
225220ddd5
commit
e8124e2f56
57 changed files with 1971 additions and 1716 deletions
45
internal/rtmp/message/user_control_stream_begin.go
Normal file
45
internal/rtmp/message/user_control_stream_begin.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package message //nolint:dupl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/aler9/mediamtx/internal/rtmp/rawmessage"
|
||||
)
|
||||
|
||||
// UserControlStreamBegin is a user control message.
|
||||
type UserControlStreamBegin struct {
|
||||
StreamID uint32
|
||||
}
|
||||
|
||||
// Unmarshal implements Message.
|
||||
func (m *UserControlStreamBegin) Unmarshal(raw *rawmessage.Message) error {
|
||||
if raw.ChunkStreamID != ControlChunkStreamID {
|
||||
return fmt.Errorf("unexpected chunk stream ID")
|
||||
}
|
||||
|
||||
if len(raw.Body) != 6 {
|
||||
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])
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Marshal implements Message.
|
||||
func (m UserControlStreamBegin) Marshal() (*rawmessage.Message, error) {
|
||||
buf := make([]byte, 6)
|
||||
|
||||
buf[0] = byte(UserControlTypeStreamBegin >> 8)
|
||||
buf[1] = byte(UserControlTypeStreamBegin)
|
||||
buf[2] = byte(m.StreamID >> 24)
|
||||
buf[3] = byte(m.StreamID >> 16)
|
||||
buf[4] = byte(m.StreamID >> 8)
|
||||
buf[5] = byte(m.StreamID)
|
||||
|
||||
return &rawmessage.Message{
|
||||
ChunkStreamID: ControlChunkStreamID,
|
||||
Type: uint8(TypeUserControl),
|
||||
Body: buf,
|
||||
}, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue