mirror of https://bitbucket.org/ausocean/av.git
Only set ts in C_RTMP_SendPacket() when prevPacket != nil.
This commit is contained in:
parent
3dccec4f35
commit
647f10f212
26
rtmp/rtmp.go
26
rtmp/rtmp.go
|
@ -444,6 +444,7 @@ func C_ReadN(r *C_RTMP, buf []byte) error {
|
||||||
// int WriteN(RTMP* r, const char* buffer, int n);
|
// int WriteN(RTMP* r, const char* buffer, int n);
|
||||||
// rtmp.c +1502
|
// rtmp.c +1502
|
||||||
func C_WriteN(r *C_RTMP, buf []byte) error {
|
func C_WriteN(r *C_RTMP, buf []byte) error {
|
||||||
|
//ToDo: consider using a different timeout for writes than for reads
|
||||||
err := r.Link.conn.SetWriteDeadline(time.Now().Add(time.Second * time.Duration(r.Link.timeout)))
|
err := r.Link.conn.SetWriteDeadline(time.Now().Add(time.Second * time.Duration(r.Link.timeout)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -1366,11 +1367,14 @@ func C_RTMP_SendPacket(r *C_RTMP, packet *C_RTMPPacket, queue int) error {
|
||||||
hSize += cSize
|
hSize += cSize
|
||||||
}
|
}
|
||||||
|
|
||||||
t := uint32(int(packet.m_nTimeStamp) - last)
|
var ts uint32
|
||||||
if t >= 0xffffff {
|
if prevPacket != nil {
|
||||||
|
ts = uint32(int(packet.m_nTimeStamp) - last)
|
||||||
|
}
|
||||||
|
if ts >= 0xffffff {
|
||||||
origIdx -= 4
|
origIdx -= 4
|
||||||
hSize += 4
|
hSize += 4
|
||||||
log.Printf("Larger timestamp than 24-bit: 0x%v", t)
|
log.Printf("Larger timestamp than 24-bit: 0x%v", ts)
|
||||||
}
|
}
|
||||||
|
|
||||||
headerIdx := origIdx
|
headerIdx := origIdx
|
||||||
|
@ -1399,8 +1403,8 @@ func C_RTMP_SendPacket(r *C_RTMP, packet *C_RTMPPacket, queue int) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if packetSize[packet.m_headerType] > 1 {
|
if packetSize[packet.m_headerType] > 1 {
|
||||||
res := t
|
res := ts
|
||||||
if t > 0xffffff {
|
if ts > 0xffffff {
|
||||||
res = 0xffffff
|
res = 0xffffff
|
||||||
}
|
}
|
||||||
C_AMF_EncodeInt24(headBytes[headerIdx:], int32(res))
|
C_AMF_EncodeInt24(headBytes[headerIdx:], int32(res))
|
||||||
|
@ -1419,8 +1423,8 @@ func C_RTMP_SendPacket(r *C_RTMP, packet *C_RTMPPacket, queue int) error {
|
||||||
headerIdx += n
|
headerIdx += n
|
||||||
}
|
}
|
||||||
|
|
||||||
if t >= 0xffffff {
|
if ts >= 0xffffff {
|
||||||
C_AMF_EncodeInt32(headBytes[headerIdx:], int32(t))
|
C_AMF_EncodeInt32(headBytes[headerIdx:], int32(ts))
|
||||||
headerIdx += 4 // 32bits
|
headerIdx += 4 // 32bits
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1429,7 +1433,7 @@ func C_RTMP_SendPacket(r *C_RTMP, packet *C_RTMPPacket, queue int) error {
|
||||||
|
|
||||||
if debugMode {
|
if debugMode {
|
||||||
if r.Link.conn != nil {
|
if r.Link.conn != nil {
|
||||||
log.Printf("C_RTMP_SendPacket: %v=>%v, size=%v", r.Link.conn.LocalAddr(), r.Link.conn.RemoteAddr(), nSize)
|
log.Printf("C_RTMP_SendPacket: %v->%v, size=%v", r.Link.conn.LocalAddr(), r.Link.conn.RemoteAddr(), nSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1453,7 +1457,7 @@ func C_RTMP_SendPacket(r *C_RTMP, packet *C_RTMPPacket, queue int) error {
|
||||||
origIdx -= 1 + cSize
|
origIdx -= 1 + cSize
|
||||||
hSize = 1 + cSize
|
hSize = 1 + cSize
|
||||||
|
|
||||||
if t >= 0xffffff {
|
if ts >= 0xffffff {
|
||||||
origIdx -= 4
|
origIdx -= 4
|
||||||
hSize += 4
|
hSize += 4
|
||||||
}
|
}
|
||||||
|
@ -1468,9 +1472,9 @@ func C_RTMP_SendPacket(r *C_RTMP, packet *C_RTMPPacket, queue int) error {
|
||||||
headBytes[origIdx+2] = byte(tmp >> 8)
|
headBytes[origIdx+2] = byte(tmp >> 8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if t >= 0xffffff {
|
if ts >= 0xffffff {
|
||||||
extendedTimestamp := headBytes[origIdx+1+cSize:]
|
extendedTimestamp := headBytes[origIdx+1+cSize:]
|
||||||
C_AMF_EncodeInt32(extendedTimestamp[:4], int32(t))
|
C_AMF_EncodeInt32(extendedTimestamp[:4], int32(ts))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue