Skip to content

Commit 371c795

Browse files
committed
entirely remove control chunk stream ID validation
1 parent 2e0950f commit 371c795

12 files changed

+0
-82
lines changed

internal/protocols/rtmp/message/message.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,6 @@ const (
1010
ControlChunkStreamID = 2
1111
)
1212

13-
// Common non-standard control chunk stream IDs used by various cameras
14-
var commonControlChunkStreamIDs = []byte{
15-
2, // Standard RTMP
16-
3, // Some cameras use this
17-
4, // PTZ cameras and others
18-
5, // Some IP cameras
19-
6, // Alternative implementation
20-
}
21-
22-
// isControlChunkStreamID checks if the given chunk stream ID is acceptable for control messages
23-
// This provides compatibility with various camera implementations that don't strictly follow RTMP spec
24-
func isControlChunkStreamID(chunkStreamID byte) bool {
25-
for _, id := range commonControlChunkStreamIDs {
26-
if chunkStreamID == id {
27-
return true
28-
}
29-
}
30-
return false
31-
}
32-
3313
// Type is a message type.
3414
type Type byte
3515

internal/protocols/rtmp/message/msg_acknowledge.go

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

1414
func (m *Acknowledge) unmarshal(raw *rawmessage.Message) error {
15-
// Use flexible chunk stream ID validation for better camera compatibility
16-
if !isControlChunkStreamID(raw.ChunkStreamID) {
17-
return fmt.Errorf("unexpected chunk stream ID: %d", raw.ChunkStreamID)
18-
}
19-
2015
if len(raw.Body) != 4 {
2116
return fmt.Errorf("unexpected body size")
2217
}

internal/protocols/rtmp/message/msg_set_chunk_size.go

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

1414
func (m *SetChunkSize) unmarshal(raw *rawmessage.Message) error {
15-
// Use flexible chunk stream ID validation for better camera compatibility
16-
if !isControlChunkStreamID(raw.ChunkStreamID) {
17-
return fmt.Errorf("unexpected chunk stream ID: %d", raw.ChunkStreamID)
18-
}
19-
2015
if len(raw.Body) != 4 {
2116
return fmt.Errorf("invalid body size")
2217
}

internal/protocols/rtmp/message/msg_set_peer_bandwidth.go

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

1515
func (m *SetPeerBandwidth) unmarshal(raw *rawmessage.Message) error {
16-
// Use flexible chunk stream ID validation for better camera compatibility
17-
if !isControlChunkStreamID(raw.ChunkStreamID) {
18-
return fmt.Errorf("unexpected chunk stream ID: %d", raw.ChunkStreamID)
19-
}
20-
2116
if len(raw.Body) != 5 {
2217
return fmt.Errorf("invalid body size")
2318
}

internal/protocols/rtmp/message/msg_set_window_ack_size.go

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

1414
func (m *SetWindowAckSize) unmarshal(raw *rawmessage.Message) error {
15-
// Use flexible chunk stream ID validation for better camera compatibility
16-
if !isControlChunkStreamID(raw.ChunkStreamID) {
17-
return fmt.Errorf("unexpected chunk stream ID: %d", raw.ChunkStreamID)
18-
}
19-
2015
if len(raw.Body) != 4 {
2116
return fmt.Errorf("invalid body size")
2217
}

internal/protocols/rtmp/message/msg_user_control_ping_request.go

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

1414
func (m *UserControlPingRequest) unmarshal(raw *rawmessage.Message) error {
15-
// Use flexible chunk stream ID validation for better camera compatibility
16-
// Standard RTMP uses ControlChunkStreamID (2), but some cameras use other IDs like 4
17-
if !isControlChunkStreamID(raw.ChunkStreamID) {
18-
return fmt.Errorf("unexpected chunk stream ID: %d", raw.ChunkStreamID)
19-
}
20-
2115
if len(raw.Body) != 6 {
2216
return fmt.Errorf("invalid body size")
2317
}

internal/protocols/rtmp/message/msg_user_control_ping_response.go

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

1414
func (m *UserControlPingResponse) unmarshal(raw *rawmessage.Message) error {
15-
// Use flexible chunk stream ID validation for better camera compatibility
16-
// Standard RTMP uses ControlChunkStreamID (2), but some cameras use other IDs like 4
17-
if !isControlChunkStreamID(raw.ChunkStreamID) {
18-
return fmt.Errorf("6666 unexpected chunk stream ID: %d", raw.ChunkStreamID)
19-
}
20-
2115
if len(raw.Body) != 6 {
2216
return fmt.Errorf("invalid body size")
2317
}

internal/protocols/rtmp/message/msg_user_control_set_buffer_length.go

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

1515
func (m *UserControlSetBufferLength) unmarshal(raw *rawmessage.Message) error {
16-
// Use flexible chunk stream ID validation for better camera compatibility
17-
// Standard RTMP uses ControlChunkStreamID (2), but some cameras use other IDs like 4
18-
if !isControlChunkStreamID(raw.ChunkStreamID) {
19-
return fmt.Errorf("7777 unexpected chunk stream ID: %d", raw.ChunkStreamID)
20-
}
21-
2216
if len(raw.Body) != 10 {
2317
return fmt.Errorf("invalid body size")
2418
}

internal/protocols/rtmp/message/msg_user_control_stream_begin.go

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

1414
func (m *UserControlStreamBegin) unmarshal(raw *rawmessage.Message) error {
15-
// Use flexible chunk stream ID validation for better camera compatibility
16-
// Standard RTMP uses ControlChunkStreamID (2), but some cameras use other IDs like 4
17-
if !isControlChunkStreamID(raw.ChunkStreamID) {
18-
return fmt.Errorf("unexpected chunk stream ID: %d", raw.ChunkStreamID)
19-
}
20-
2115
if len(raw.Body) != 6 {
2216
return fmt.Errorf("invalid body size")
2317
}

internal/protocols/rtmp/message/msg_user_control_stream_dry.go

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

1414
func (m *UserControlStreamDry) unmarshal(raw *rawmessage.Message) error {
15-
// Use flexible chunk stream ID validation for better camera compatibility
16-
// Standard RTMP uses ControlChunkStreamID (2), but some cameras use other IDs like 4
17-
if !isControlChunkStreamID(raw.ChunkStreamID) {
18-
return fmt.Errorf("9999 unexpected chunk stream ID: %d", raw.ChunkStreamID)
19-
}
20-
2115
if len(raw.Body) != 6 {
2216
return fmt.Errorf("invalid body size")
2317
}

0 commit comments

Comments
 (0)