rtmp: fix error when publishing AAC audio tracks (#3414)
* fix single aac file rtmp publish error. * add tests --------- Co-authored-by: aler9 <46489434+aler9@users.noreply.github.com>
This commit is contained in:
parent
e996ae5a21
commit
3a2594d610
|
@ -327,6 +327,9 @@ func tracksFromMetadata(conn *Conn, payload []interface{}) (format.Format, forma
|
|||
}
|
||||
|
||||
if audioTrack == nil {
|
||||
if len(msg.Payload) == 0 {
|
||||
continue
|
||||
}
|
||||
switch {
|
||||
case msg.Codec == message.CodecMPEG4Audio &&
|
||||
msg.AACType == message.AudioAACTypeConfig:
|
||||
|
|
|
@ -332,6 +332,77 @@ func TestReadTracks(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"aac, issue mediamtx/3414 (empty audio payload)",
|
||||
nil,
|
||||
&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: "videodatarate",
|
||||
Value: float64(0),
|
||||
},
|
||||
{
|
||||
Key: "videocodecid",
|
||||
Value: float64(0),
|
||||
},
|
||||
{
|
||||
Key: "audiodatarate",
|
||||
Value: float64(0),
|
||||
},
|
||||
{
|
||||
Key: "audiocodecid",
|
||||
Value: float64(message.CodecMPEG4Audio),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
&message.Audio{
|
||||
ChunkStreamID: message.AudioChunkStreamID,
|
||||
MessageStreamID: 0x1000000,
|
||||
Codec: message.CodecMPEG4Audio,
|
||||
Rate: message.Rate44100,
|
||||
Depth: message.Depth16,
|
||||
IsStereo: true,
|
||||
AACType: message.AudioAACTypeConfig,
|
||||
Payload: nil,
|
||||
},
|
||||
&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
|
||||
}(),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"h265 + aac, obs studio pre 29.1 h265",
|
||||
&format.H265{
|
||||
|
|
Loading…
Reference in New Issue