Skip to content

Commit

Permalink
rtmp: fix publishing from DJI FlightHub Sync (#3301)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Jun 22, 2024
1 parent a1dc9f4 commit 0a7a44a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/protocols/rtmp/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func tracksFromMetadata(conn *Conn, payload []interface{}) (format.Format, forma
}

if !hasVideo && !hasAudio {
return nil, nil, fmt.Errorf("metadata doesn't contain any track")
return nil, nil, nil
}

firstReceived := false
Expand Down Expand Up @@ -523,7 +523,9 @@ func (r *Reader) readTracks() (format.Format, format.Format, error) {
return nil, nil, err
}

return videoTrack, audioTrack, nil
if videoTrack != nil || audioTrack != nil {
return videoTrack, audioTrack, nil
}
}
}
}
Expand Down
58 changes: 58 additions & 0 deletions internal/protocols/rtmp/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,64 @@ func TestReadTracks(t *testing.T) {
return buf
}(),
},
&message.Audio{
ChunkStreamID: message.AudioChunkStreamID,
MessageStreamID: 0x1000000,
Codec: message.CodecMPEG4Audio,
Rate: message.Rate44100,
Depth: message.Depth16,
IsStereo: true,
AACType: message.AudioAACTypeConfig,
Payload: func() []byte {
enc, err2 := mpeg4audio.Config{
Type: 2,
SampleRate: 44100,
ChannelCount: 2,
}.Marshal()
require.NoError(t, err2)
return enc
}(),
},
},
},
{
"h264 + aac, issue mediamtx/3301 (metadata without tracks)",
&format.H264{
PayloadTyp: 96,
SPS: test.FormatH264.SPS,
PPS: test.FormatH264.PPS,
PacketizationMode: 1,
},
&format.MPEG4Audio{
PayloadTyp: 96,
Config: &mpeg4audio.Config{
Type: 2,
SampleRate: 44100,
ChannelCount: 2,
},
SizeLength: 13,
IndexLength: 3,
IndexDeltaLength: 3,
},
[]message.Message{
&message.DataAMF0{
ChunkStreamID: 4,
MessageStreamID: 1,
Payload: []interface{}{
"@setDataFrame",
"onMetaData",
amf0.Object{
{
Key: "metadatacreator",
Value: "Agora.io SDK",
},
{
Key: "encoder",
Value: "Agora.io Encoder",
},
},
},
},
&message.Video{
ChunkStreamID: message.VideoChunkStreamID,
MessageStreamID: 0x1000000,
Expand Down

0 comments on commit 0a7a44a

Please sign in to comment.