diff --git a/pkg/rtpaac/decoder.go b/pkg/rtpaac/decoder.go index abafe951..a3a3b20c 100644 --- a/pkg/rtpaac/decoder.go +++ b/pkg/rtpaac/decoder.go @@ -65,6 +65,7 @@ func (d *Decoder) Decode(byts []byte) ([]*AUAndTimestamp, error) { pkt.Payload = pkt.Payload[headerCount*2:] var rets []*AUAndTimestamp + ts := d.decodeTimestamp(pkt.Timestamp) for _, ds := range dataSizes { if len(pkt.Payload) < int(ds) { @@ -73,8 +74,12 @@ func (d *Decoder) Decode(byts []byte) ([]*AUAndTimestamp, error) { rets = append(rets, &AUAndTimestamp{ AU: pkt.Payload[:ds], - Timestamp: d.decodeTimestamp(pkt.Timestamp), + Timestamp: ts, }) + + // properly space samples in time + ts += 1000 * time.Second / d.clockRate + pkt.Payload = pkt.Payload[ds:] } diff --git a/pkg/rtpaac/rtpaac_test.go b/pkg/rtpaac/rtpaac_test.go index 1ea226d0..26a2efa1 100644 --- a/pkg/rtpaac/rtpaac_test.go +++ b/pkg/rtpaac/rtpaac_test.go @@ -148,7 +148,7 @@ func TestDecode(t *testing.T) { } } -func TestDecodeMultiple(t *testing.T) { +func TestDecodeAggregated(t *testing.T) { enc := []byte{ 0x80, 0xe1, 0x0e, 0xaf, 0xd1, 0xec, 0xbd, 0x7e, 0x2d, 0x47, 0x97, 0x58, 0x00, 0x40, 0x09, 0x38, @@ -355,7 +355,7 @@ func TestDecodeMultiple(t *testing.T) { }, }, { - Timestamp: 25675558187500, + Timestamp: 25675558187500 + (1000 * time.Second / 48000), AU: []byte{ 0x21, 0x1a, 0xd5, 0x05, 0x9d, 0x93, 0x01, 0x63, 0xa0, 0xc4, 0xc0, @@ -395,7 +395,7 @@ func TestDecodeMultiple(t *testing.T) { }, }, { - Timestamp: 25675558187500, + Timestamp: 25675558187500 + (2000 * time.Second / 48000), AU: []byte{ 0x21, 0x1a, 0xd4, 0xf5, 0x9d, 0x93, 0x45, 0x61, 0xa0, 0xc8, 0xa2, 0x40, 0x38, 0x00, @@ -437,7 +437,7 @@ func TestDecodeMultiple(t *testing.T) { }, }, { - Timestamp: 25675558187500, + Timestamp: 25675558187500 + (3000 * time.Second / 48000) - 1, AU: []byte{ 0x21, 0x1a, 0xd5, 0x05, 0xa5, 0x93, 0x06, 0x42, 0x09, 0x00, 0xa4, 0x10, diff --git a/pkg/rtph264/rtph264_test.go b/pkg/rtph264/rtph264_test.go index 820ecba9..b4c3ab38 100644 --- a/pkg/rtph264/rtph264_test.go +++ b/pkg/rtph264/rtph264_test.go @@ -152,7 +152,7 @@ func TestDecode(t *testing.T) { } } -func TestDecodeStapA(t *testing.T) { +func TestDecodeAggregated(t *testing.T) { sent := false r := readerFunc(func(p []byte) (int, error) { if sent {