impose a minimum value to clock rate of always-available tracks (#6086)
Clock rates below 10 caused the emission of empty samples. Fix the issue by imposing a minimum value of 8khz, that rises to 22khz in case of AAC.
This commit is contained in:
@@ -31,10 +31,24 @@ func (t *AlwaysAvailableTrack) UnmarshalJSON(b []byte) error {
|
||||
return fmt.Errorf("channelCount must not be specified for codec '%s'", t.Codec)
|
||||
}
|
||||
|
||||
case CodecMPEG4Audio, CodecG711, CodecLPCM:
|
||||
case CodecMPEG4Audio:
|
||||
if t.SampleRate == 0 {
|
||||
return fmt.Errorf("sampleRate is mandatory for codec '%s'", t.Codec)
|
||||
}
|
||||
if t.SampleRate < 22050 {
|
||||
return fmt.Errorf("sampleRate must be greater than or equal to 22050 for codec '%s'", t.Codec)
|
||||
}
|
||||
if t.ChannelCount == 0 {
|
||||
return fmt.Errorf("channelCount is mandatory for codec '%s'", t.Codec)
|
||||
}
|
||||
|
||||
case CodecG711, CodecLPCM:
|
||||
if t.SampleRate == 0 {
|
||||
return fmt.Errorf("sampleRate is mandatory for codec '%s'", t.Codec)
|
||||
}
|
||||
if t.SampleRate < 8000 {
|
||||
return fmt.Errorf("sampleRate must be greater than or equal to 8000 for codec '%s'", t.Codec)
|
||||
}
|
||||
if t.ChannelCount == 0 {
|
||||
return fmt.Errorf("channelCount is mandatory for codec '%s'", t.Codec)
|
||||
}
|
||||
|
||||
@@ -841,6 +841,28 @@ func TestConfErrors(t *testing.T) {
|
||||
" alwaysAvailableFile: /path/to/file.mp4\n",
|
||||
"'alwaysAvailableFile' and 'alwaysAvailableTracks' cannot be used together",
|
||||
},
|
||||
{
|
||||
"alwaysAvailableTracks g711 sampleRate too low",
|
||||
"paths:\n" +
|
||||
" mypath:\n" +
|
||||
" alwaysAvailable: yes\n" +
|
||||
" alwaysAvailableTracks:\n" +
|
||||
" - codec: G711\n" +
|
||||
" sampleRate: 7999\n" +
|
||||
" channelCount: 1\n",
|
||||
"sampleRate must be greater than or equal to 8000 for codec 'G711'",
|
||||
},
|
||||
{
|
||||
"alwaysAvailableTracks mpeg4audio sampleRate too low",
|
||||
"paths:\n" +
|
||||
" mypath:\n" +
|
||||
" alwaysAvailable: yes\n" +
|
||||
" alwaysAvailableTracks:\n" +
|
||||
" - codec: MPEG4Audio\n" +
|
||||
" sampleRate: 22049\n" +
|
||||
" channelCount: 1\n",
|
||||
"sampleRate must be greater than or equal to 22050 for codec 'MPEG4Audio'",
|
||||
},
|
||||
{
|
||||
"missing udp port",
|
||||
"paths:\n" +
|
||||
|
||||
Reference in New Issue
Block a user