rtmp: fix publishing from DJI FlightHub Sync (#3301) (#3504)

This commit is contained in:
Alessandro Ros 2024-07-01 16:03:12 +02:00 committed by GitHub
parent a1dc9f45f5
commit afec0cd86c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 62 additions and 2 deletions

View File

@ -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
@ -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
}
}
}
}

View File

@ -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,