mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-16 20:50:58 +08:00
rtmp: rewrite implementation of rtmp connection (#1047)
* rtmp: improve MsgCommandAMF0 * rtmp: fix MsgSetPeerBandwidth * rtmp: add message tests * rtmp: replace implementation with new one * rtmp: rename handshake functions * rtmp: avoid calling useless function * rtmp: use time.Duration for PTSDelta * rtmp: fix decoding chunks with relevant size * rtmp: rewrite implementation of rtmp connection * rtmp: fix tests * rtmp: improve error message * rtmp: replace h264 config implementation * link against github.com/notedit/rtmp * normalize MessageStreamID * rtmp: make acknowledge optional * rtmp: fix decoding of chunk2 + chunk3 * avoid using encoding/binary
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package message
|
||||
package message //nolint:dupl
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/rtmp/chunk"
|
||||
@@ -24,20 +23,25 @@ func (m *MsgSetPeerBandwidth) Unmarshal(raw *rawmessage.Message) error {
|
||||
return fmt.Errorf("unexpected body size")
|
||||
}
|
||||
|
||||
m.Value = binary.BigEndian.Uint32(raw.Body)
|
||||
m.Value = uint32(raw.Body[0])<<24 | uint32(raw.Body[1])<<16 | uint32(raw.Body[2])<<8 | uint32(raw.Body[3])
|
||||
m.Type = raw.Body[4]
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Marshal implements Message.
|
||||
func (m *MsgSetPeerBandwidth) Marshal() (*rawmessage.Message, error) {
|
||||
body := make([]byte, 5)
|
||||
binary.BigEndian.PutUint32(body, m.Value)
|
||||
body[4] = m.Type
|
||||
buf := make([]byte, 5)
|
||||
|
||||
buf[0] = byte(m.Value >> 24)
|
||||
buf[1] = byte(m.Value >> 16)
|
||||
buf[2] = byte(m.Value >> 8)
|
||||
buf[3] = byte(m.Value)
|
||||
buf[4] = m.Type
|
||||
|
||||
return &rawmessage.Message{
|
||||
ChunkStreamID: ControlChunkStreamID,
|
||||
Type: chunk.MessageTypeSetChunkSize,
|
||||
Body: body,
|
||||
Type: chunk.MessageTypeSetPeerBandwidth,
|
||||
Body: buf,
|
||||
}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user