mirror of
https://github.com/aler9/gortsplib
synced 2025-10-30 10:06:28 +08:00
rtpaac: fix decoding timestamp of aggregated units
This commit is contained in:
@@ -65,6 +65,7 @@ func (d *Decoder) Decode(byts []byte) ([]*AUAndTimestamp, error) {
|
|||||||
pkt.Payload = pkt.Payload[headerCount*2:]
|
pkt.Payload = pkt.Payload[headerCount*2:]
|
||||||
|
|
||||||
var rets []*AUAndTimestamp
|
var rets []*AUAndTimestamp
|
||||||
|
ts := d.decodeTimestamp(pkt.Timestamp)
|
||||||
|
|
||||||
for _, ds := range dataSizes {
|
for _, ds := range dataSizes {
|
||||||
if len(pkt.Payload) < int(ds) {
|
if len(pkt.Payload) < int(ds) {
|
||||||
@@ -73,8 +74,12 @@ func (d *Decoder) Decode(byts []byte) ([]*AUAndTimestamp, error) {
|
|||||||
|
|
||||||
rets = append(rets, &AUAndTimestamp{
|
rets = append(rets, &AUAndTimestamp{
|
||||||
AU: pkt.Payload[:ds],
|
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:]
|
pkt.Payload = pkt.Payload[ds:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ func TestDecode(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDecodeMultiple(t *testing.T) {
|
func TestDecodeAggregated(t *testing.T) {
|
||||||
enc := []byte{
|
enc := []byte{
|
||||||
0x80, 0xe1, 0x0e, 0xaf, 0xd1, 0xec, 0xbd, 0x7e,
|
0x80, 0xe1, 0x0e, 0xaf, 0xd1, 0xec, 0xbd, 0x7e,
|
||||||
0x2d, 0x47, 0x97, 0x58, 0x00, 0x40, 0x09, 0x38,
|
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{
|
AU: []byte{
|
||||||
0x21, 0x1a, 0xd5, 0x05,
|
0x21, 0x1a, 0xd5, 0x05,
|
||||||
0x9d, 0x93, 0x01, 0x63, 0xa0, 0xc4, 0xc0,
|
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{
|
AU: []byte{
|
||||||
0x21, 0x1a, 0xd4, 0xf5, 0x9d, 0x93,
|
0x21, 0x1a, 0xd4, 0xf5, 0x9d, 0x93,
|
||||||
0x45, 0x61, 0xa0, 0xc8, 0xa2, 0x40, 0x38, 0x00,
|
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{
|
AU: []byte{
|
||||||
0x21, 0x1a, 0xd5, 0x05,
|
0x21, 0x1a, 0xd5, 0x05,
|
||||||
0xa5, 0x93, 0x06, 0x42, 0x09, 0x00, 0xa4, 0x10,
|
0xa5, 0x93, 0x06, 0x42, 0x09, 0x00, 0xa4, 0x10,
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ func TestDecode(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDecodeStapA(t *testing.T) {
|
func TestDecodeAggregated(t *testing.T) {
|
||||||
sent := false
|
sent := false
|
||||||
r := readerFunc(func(p []byte) (int, error) {
|
r := readerFunc(func(p []byte) (int, error) {
|
||||||
if sent {
|
if sent {
|
||||||
|
|||||||
Reference in New Issue
Block a user