mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2026-04-22 23:57:20 +08:00
22 lines
596 B
Go
22 lines
596 B
Go
package flv
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestTimeToRTP(t *testing.T) {
|
|
// Reolink camera has 20 FPS
|
|
// Video timestamp increases by 50ms, SampleRate 90000, RTP timestamp increases by 4500
|
|
// Audio timestamp increases by 64ms, SampleRate 16000, RTP timestamp increases by 1024
|
|
frameN := 1
|
|
for i := 0; i < 32; i++ {
|
|
// 1000ms/(90000/4500) = 50ms
|
|
require.Equal(t, uint32(frameN*4500), TimeToRTP(uint32(frameN*50), 90000))
|
|
// 1000ms/(16000/1024) = 64ms
|
|
require.Equal(t, uint32(frameN*1024), TimeToRTP(uint32(frameN*64), 16000))
|
|
frameN *= 2
|
|
}
|
|
}
|