mirror of
https://github.com/bluenviron/mediamtx.git
synced 2026-01-23 20:09:49 -08:00
* feat: improve RTMP control message compatibility with non-standard cameras - Add flexible chunk stream ID validation for control messages - Support common non-standard chunk stream IDs (2,3,4,5,6) used by various cameras - Maintain backward compatibility with standard RTMP clients - Fix connection issues with PTZ cameras using chunk stream ID 4 This resolves compatibility issues with IP cameras that don't strictly follow RTMP spec while maintaining full support for standard RTMP implementations. Previously, cameras using non-standard chunk stream IDs would fail with 'unexpected chunk stream ID' errors. Now MediaMTX provides nginx-rtmp level compatibility with real-world camera implementations." * add tests * entirely remove control chunk stream ID validation --------- Co-authored-by: Hyesung.Kim <hyesung.kim@xcath.com> Co-authored-by: aler9 <46489434+aler9@users.noreply.github.com>
40 lines
889 B
Go
40 lines
889 B
Go
package message //nolint:dupl
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/bluenviron/mediamtx/internal/protocols/rtmp/rawmessage"
|
|
)
|
|
|
|
// SetPeerBandwidth is a set peer bandwidth message.
|
|
type SetPeerBandwidth struct {
|
|
Value uint32
|
|
Type byte
|
|
}
|
|
|
|
func (m *SetPeerBandwidth) unmarshal(raw *rawmessage.Message) error {
|
|
if len(raw.Body) != 5 {
|
|
return fmt.Errorf("invalid body size")
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
func (m *SetPeerBandwidth) marshal() (*rawmessage.Message, error) {
|
|
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: uint8(TypeSetPeerBandwidth),
|
|
Body: buf,
|
|
}, nil
|
|
}
|