Skip to content

Commit cb16f68

Browse files
hyesung913HyesungKim510aler9
authored
rtmp: improve control message compatibility with non-standard cameras (#4909)
* 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 <[email protected]> Co-authored-by: aler9 <[email protected]>
1 parent 15e2713 commit cb16f68

12 files changed

+16
-44
lines changed

internal/protocols/rtmp/message/msg_acknowledge.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ type Acknowledge struct {
1212
}
1313

1414
func (m *Acknowledge) unmarshal(raw *rawmessage.Message) error {
15-
if raw.ChunkStreamID != ControlChunkStreamID {
16-
return fmt.Errorf("unexpected chunk stream ID")
17-
}
18-
1915
if len(raw.Body) != 4 {
2016
return fmt.Errorf("unexpected body size")
2117
}

internal/protocols/rtmp/message/msg_set_chunk_size.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ type SetChunkSize struct {
1212
}
1313

1414
func (m *SetChunkSize) unmarshal(raw *rawmessage.Message) error {
15-
if raw.ChunkStreamID != ControlChunkStreamID {
16-
return fmt.Errorf("unexpected chunk stream ID")
17-
}
18-
1915
if len(raw.Body) != 4 {
2016
return fmt.Errorf("invalid body size")
2117
}

internal/protocols/rtmp/message/msg_set_peer_bandwidth.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ type SetPeerBandwidth struct {
1313
}
1414

1515
func (m *SetPeerBandwidth) unmarshal(raw *rawmessage.Message) error {
16-
if raw.ChunkStreamID != ControlChunkStreamID {
17-
return fmt.Errorf("unexpected chunk stream ID")
18-
}
19-
2016
if len(raw.Body) != 5 {
2117
return fmt.Errorf("invalid body size")
2218
}

internal/protocols/rtmp/message/msg_set_window_ack_size.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ type SetWindowAckSize struct {
1212
}
1313

1414
func (m *SetWindowAckSize) unmarshal(raw *rawmessage.Message) error {
15-
if raw.ChunkStreamID != ControlChunkStreamID {
16-
return fmt.Errorf("unexpected chunk stream ID")
17-
}
18-
1915
if len(raw.Body) != 4 {
2016
return fmt.Errorf("invalid body size")
2117
}

internal/protocols/rtmp/message/msg_user_control_ping_request.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ type UserControlPingRequest struct {
1212
}
1313

1414
func (m *UserControlPingRequest) unmarshal(raw *rawmessage.Message) error {
15-
if raw.ChunkStreamID != ControlChunkStreamID {
16-
return fmt.Errorf("unexpected chunk stream ID")
17-
}
18-
1915
if len(raw.Body) != 6 {
2016
return fmt.Errorf("invalid body size")
2117
}

internal/protocols/rtmp/message/msg_user_control_ping_response.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ type UserControlPingResponse struct {
1212
}
1313

1414
func (m *UserControlPingResponse) unmarshal(raw *rawmessage.Message) error {
15-
if raw.ChunkStreamID != ControlChunkStreamID {
16-
return fmt.Errorf("unexpected chunk stream ID")
17-
}
18-
1915
if len(raw.Body) != 6 {
2016
return fmt.Errorf("invalid body size")
2117
}

internal/protocols/rtmp/message/msg_user_control_set_buffer_length.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ type UserControlSetBufferLength struct {
1313
}
1414

1515
func (m *UserControlSetBufferLength) unmarshal(raw *rawmessage.Message) error {
16-
if raw.ChunkStreamID != ControlChunkStreamID {
17-
return fmt.Errorf("unexpected chunk stream ID")
18-
}
19-
2016
if len(raw.Body) != 10 {
2117
return fmt.Errorf("invalid body size")
2218
}

internal/protocols/rtmp/message/msg_user_control_stream_begin.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ type UserControlStreamBegin struct {
1212
}
1313

1414
func (m *UserControlStreamBegin) unmarshal(raw *rawmessage.Message) error {
15-
if raw.ChunkStreamID != ControlChunkStreamID {
16-
return fmt.Errorf("unexpected chunk stream ID")
17-
}
18-
1915
if len(raw.Body) != 6 {
2016
return fmt.Errorf("invalid body size")
2117
}

internal/protocols/rtmp/message/msg_user_control_stream_dry.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ type UserControlStreamDry struct {
1212
}
1313

1414
func (m *UserControlStreamDry) unmarshal(raw *rawmessage.Message) error {
15-
if raw.ChunkStreamID != ControlChunkStreamID {
16-
return fmt.Errorf("unexpected chunk stream ID")
17-
}
18-
1915
if len(raw.Body) != 6 {
2016
return fmt.Errorf("invalid body size")
2117
}

internal/protocols/rtmp/message/msg_user_control_stream_eof.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ type UserControlStreamEOF struct {
1212
}
1313

1414
func (m *UserControlStreamEOF) unmarshal(raw *rawmessage.Message) error {
15-
if raw.ChunkStreamID != ControlChunkStreamID {
16-
return fmt.Errorf("unexpected chunk stream ID")
17-
}
18-
1915
if len(raw.Body) != 6 {
2016
return fmt.Errorf("invalid body size")
2117
}

0 commit comments

Comments
 (0)