Update MPEG-TS consumer compatibility
This commit is contained in:
@@ -12,6 +12,8 @@ const (
|
||||
TypeAACMain = 1
|
||||
TypeAACLC = 2
|
||||
TypeESCAPE = 31
|
||||
|
||||
AUTime = 1024
|
||||
)
|
||||
|
||||
// streamtype=5 - audio stream
|
||||
|
||||
@@ -70,6 +70,16 @@ func WriteADTSSize(b []byte, size uint16) {
|
||||
return
|
||||
}
|
||||
|
||||
func ADTSTimeSize(b []byte) uint32 {
|
||||
var units uint32
|
||||
for len(b) > ADTSHeaderSize {
|
||||
auSize := ReadADTSSize(b)
|
||||
b = b[auSize:]
|
||||
units++
|
||||
}
|
||||
return units * AUTime
|
||||
}
|
||||
|
||||
func CodecToADTS(codec *core.Codec) []byte {
|
||||
s := core.Between(codec.FmtpLine, "config=", ";")
|
||||
conf, err := hex.DecodeString(s)
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ func RTPDepay(handler core.HandlerFunc) core.HandlerFunc {
|
||||
headers = headers[2:]
|
||||
units = units[unitSize:]
|
||||
|
||||
timestamp += 1024
|
||||
timestamp += AUTime
|
||||
|
||||
clone := *packet
|
||||
clone.Version = RTPPacketVersionAAC
|
||||
@@ -92,7 +92,7 @@ func ADTStoRTP(src []byte) (dst []byte) {
|
||||
func RTPTimeSize(b []byte) uint32 {
|
||||
// convert RTP header size to units count
|
||||
units := binary.BigEndian.Uint16(b) >> 4
|
||||
return 1024 * uint32(units)
|
||||
return uint32(units) * AUTime
|
||||
}
|
||||
|
||||
func RTPToADTS(codec *core.Codec, handler core.HandlerFunc) core.HandlerFunc {
|
||||
|
||||
Reference in New Issue
Block a user