mirror of
https://github.com/bluenviron/mediamtx.git
synced 2026-01-23 03:49: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>
39 lines
971 B
Go
39 lines
971 B
Go
package message //nolint:dupl
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/bluenviron/mediamtx/internal/protocols/rtmp/rawmessage"
|
|
)
|
|
|
|
// UserControlPingRequest is a user control message.
|
|
type UserControlPingRequest struct {
|
|
ServerTime uint32
|
|
}
|
|
|
|
func (m *UserControlPingRequest) unmarshal(raw *rawmessage.Message) error {
|
|
if len(raw.Body) != 6 {
|
|
return fmt.Errorf("invalid body size")
|
|
}
|
|
|
|
m.ServerTime = uint32(raw.Body[2])<<24 | uint32(raw.Body[3])<<16 | uint32(raw.Body[4])<<8 | uint32(raw.Body[5])
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m UserControlPingRequest) marshal() (*rawmessage.Message, error) {
|
|
buf := make([]byte, 6)
|
|
|
|
buf[0] = byte(UserControlTypePingRequest >> 8)
|
|
buf[1] = byte(UserControlTypePingRequest)
|
|
buf[2] = byte(m.ServerTime >> 24)
|
|
buf[3] = byte(m.ServerTime >> 16)
|
|
buf[4] = byte(m.ServerTime >> 8)
|
|
buf[5] = byte(m.ServerTime)
|
|
|
|
return &rawmessage.Message{
|
|
ChunkStreamID: ControlChunkStreamID,
|
|
Type: uint8(TypeUserControl),
|
|
Body: buf,
|
|
}, nil
|
|
}
|