Use blank frames at frame rate (#710)
* Inject silence opus frames on mute. If not, under certain circumstances, residual noise seems to trigger comfort noise generation at the decoder which is not all that comfortable. * inject silence only when muting * Add comment * augment comment * Delete blank line * Adjust TS offset on blank frames * Remove debug * Do not modify `lastTS` as it affects timestamp on next switch. * Trying more stuff for DTX * - Use a go routine to send blank frames - Use duration instead of number of frames and calculate number of frames * augment comment * Remove debug * Return a chan from writeBlankFrameRTP * Use a long duration for mute * add comment * Incorporate suggestion from Jie
This commit is contained in:
@@ -1382,12 +1382,13 @@ func TestForwardGetSnTsForBlankFrames(t *testing.T) {
|
||||
_, _ = f.GetTranslationParams(extPkt, 0)
|
||||
|
||||
// should get back frame end needed as the last packet did not have RTP marker set
|
||||
snts, frameEndNeeded, err := f.GetSnTsForBlankFrames(30, 6)
|
||||
numBlankFrames := 6
|
||||
snts, frameEndNeeded, err := f.GetSnTsForBlankFrames(30, numBlankFrames)
|
||||
require.NoError(t, err)
|
||||
require.True(t, frameEndNeeded)
|
||||
|
||||
// there should be one more than RTPBlankFramesMax as one would have been allocated to end previous frame
|
||||
numPadding := 7
|
||||
numPadding := numBlankFrames + 1
|
||||
clockRate := testutils.TestVP8Codec.ClockRate
|
||||
frameRate := uint32(30)
|
||||
var sntsExpected = make([]SnTs, numPadding)
|
||||
@@ -1401,15 +1402,15 @@ func TestForwardGetSnTsForBlankFrames(t *testing.T) {
|
||||
|
||||
// now that there is a marker, timestamp should jump on first padding when asked again
|
||||
// also number of padding should be RTPBlankFramesMax
|
||||
numPadding = 6
|
||||
numPadding = numBlankFrames
|
||||
sntsExpected = sntsExpected[:numPadding]
|
||||
for i := 0; i < numPadding; i++ {
|
||||
sntsExpected[i] = SnTs{
|
||||
sequenceNumber: params.SequenceNumber + uint16(len(snts)) + uint16(i) + 1,
|
||||
timestamp: params.Timestamp + (uint32(i+1)*clockRate)/frameRate,
|
||||
timestamp: snts[len(snts)-1].timestamp + (uint32(i+1)*clockRate)/frameRate,
|
||||
}
|
||||
}
|
||||
snts, frameEndNeeded, err = f.GetSnTsForBlankFrames(30, 6)
|
||||
snts, frameEndNeeded, err = f.GetSnTsForBlankFrames(30, numBlankFrames)
|
||||
require.NoError(t, err)
|
||||
require.False(t, frameEndNeeded)
|
||||
require.Equal(t, sntsExpected, snts)
|
||||
|
||||
Reference in New Issue
Block a user