mirror of
https://github.com/bluenviron/mediamtx.git
synced 2026-01-25 21:09:15 -08:00
rtmp: add message reader / writer
This commit is contained in:
parent
76e47686b2
commit
ba83ef65d2
32 changed files with 1015 additions and 497 deletions
39
internal/rtmp/message/msg_dataamf0.go
Normal file
39
internal/rtmp/message/msg_dataamf0.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package message
|
||||
|
||||
import (
|
||||
"github.com/notedit/rtmp/format/flv/flvio"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtmp/chunk"
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtmp/rawmessage"
|
||||
)
|
||||
|
||||
// MsgDataAMF0 is a AMF0 data message.
|
||||
type MsgDataAMF0 struct {
|
||||
ChunkStreamID byte
|
||||
MessageStreamID uint32
|
||||
Payload []interface{}
|
||||
}
|
||||
|
||||
// Unmarshal implements Message.
|
||||
func (m *MsgDataAMF0) Unmarshal(raw *rawmessage.Message) error {
|
||||
m.ChunkStreamID = raw.ChunkStreamID
|
||||
m.MessageStreamID = raw.MessageStreamID
|
||||
|
||||
payload, err := flvio.ParseAMFVals(raw.Body, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m.Payload = payload
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Marshal implements Message.
|
||||
func (m MsgDataAMF0) Marshal() (*rawmessage.Message, error) {
|
||||
return &rawmessage.Message{
|
||||
ChunkStreamID: m.ChunkStreamID,
|
||||
Type: chunk.MessageTypeDataAMF0,
|
||||
MessageStreamID: m.MessageStreamID,
|
||||
Body: flvio.FillAMF0ValsMalloc(m.Payload),
|
||||
}, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue