Check for an propagate encoding errors.

This commit is contained in:
scruzin 2019-01-06 15:19:58 +10:30
parent e876491f24
commit c7b96f1c31
1 changed files with 49 additions and 6 deletions

View File

@ -490,10 +490,14 @@ func C_SendConnectPacket(r *C_RTMP, cp *C_RTMPPacket) error {
enc := packet.m_body enc := packet.m_body
enc = C_AMF_EncodeString(enc, av_connect) enc = C_AMF_EncodeString(enc, av_connect)
if enc == nil {
return errEncoding
}
r.m_numInvokes += 1 r.m_numInvokes += 1
enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes)) enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes))
if enc == nil {
return errEncoding
}
enc[0] = AMF_OBJECT enc[0] = AMF_OBJECT
enc = enc[1:] enc = enc[1:]
@ -610,8 +614,14 @@ func C_RTMP_SendCreateStream(r *C_RTMP) error {
enc := packet.m_body enc := packet.m_body
enc = C_AMF_EncodeString(enc, av_createStream) enc = C_AMF_EncodeString(enc, av_createStream)
if enc == nil {
return errEncoding
}
r.m_numInvokes++ r.m_numInvokes++
enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes)) enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes))
if enc == nil {
return errEncoding
}
enc[0] = AMF_NULL enc[0] = AMF_NULL
enc = enc[1:] enc = enc[1:]
@ -637,15 +647,20 @@ func C_SendReleaseStream(r *C_RTMP) error {
enc := packet.m_body enc := packet.m_body
enc = C_AMF_EncodeString(enc, av_releaseStream) enc = C_AMF_EncodeString(enc, av_releaseStream)
if enc == nil {
return errEncoding
}
r.m_numInvokes++ r.m_numInvokes++
enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes)) enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes))
if enc == nil {
return errEncoding
}
enc[0] = AMF_NULL enc[0] = AMF_NULL
enc = enc[1:] enc = enc[1:]
enc = C_AMF_EncodeString(enc, r.Link.playpath) enc = C_AMF_EncodeString(enc, r.Link.playpath)
if enc == nil { if enc == nil {
return errEncoding return errEncoding
} }
packet.m_nBodySize = uint32((len(pbuf) - RTMP_MAX_HEADER_SIZE) - len(enc)) packet.m_nBodySize = uint32((len(pbuf) - RTMP_MAX_HEADER_SIZE) - len(enc))
return C_RTMP_SendPacket(r, &packet, 0) return C_RTMP_SendPacket(r, &packet, 0)
@ -668,8 +683,14 @@ func C_SendFCPublish(r *C_RTMP) error {
enc := packet.m_body enc := packet.m_body
enc = C_AMF_EncodeString(enc, av_FCPublish) enc = C_AMF_EncodeString(enc, av_FCPublish)
if enc == nil {
return errEncoding
}
r.m_numInvokes++ r.m_numInvokes++
enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes)) enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes))
if enc == nil {
return errEncoding
}
enc[0] = AMF_NULL enc[0] = AMF_NULL
enc = enc[1:] enc = enc[1:]
enc = C_AMF_EncodeString(enc, r.Link.playpath) enc = C_AMF_EncodeString(enc, r.Link.playpath)
@ -699,12 +720,17 @@ func C_SendFCUnpublish(r *C_RTMP) error {
enc := packet.m_body enc := packet.m_body
enc = C_AMF_EncodeString(enc, av_FCUnpublish) enc = C_AMF_EncodeString(enc, av_FCUnpublish)
if enc == nil {
return errEncoding
}
r.m_numInvokes++ r.m_numInvokes++
enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes)) enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes))
if enc == nil {
return errEncoding
}
enc[0] = AMF_NULL enc[0] = AMF_NULL
enc = enc[1:] enc = enc[1:]
enc = C_AMF_EncodeString(enc, r.Link.playpath) enc = C_AMF_EncodeString(enc, r.Link.playpath)
if enc == nil { if enc == nil {
return errEncoding return errEncoding
} }
@ -731,8 +757,14 @@ func C_SendPublish(r *C_RTMP) error {
enc := packet.m_body enc := packet.m_body
enc = C_AMF_EncodeString(enc, av_publish) enc = C_AMF_EncodeString(enc, av_publish)
if enc == nil {
return errEncoding
}
r.m_numInvokes++ r.m_numInvokes++
enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes)) enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes))
if enc == nil {
return errEncoding
}
enc[0] = AMF_NULL enc[0] = AMF_NULL
enc = enc[1:] enc = enc[1:]
enc = C_AMF_EncodeString(enc, r.Link.playpath) enc = C_AMF_EncodeString(enc, r.Link.playpath)
@ -804,8 +836,10 @@ func C_SendBytesReceived(r *C_RTMP) error {
enc := packet.m_body enc := packet.m_body
r.m_nBytesInSent = r.m_nBytesIn r.m_nBytesInSent = r.m_nBytesIn
C_AMF_EncodeInt32(enc, r.m_nBytesIn) enc = C_AMF_EncodeInt32(enc, r.m_nBytesIn)
if enc == nil {
return errEncoding
}
packet.m_nBodySize = 4 packet.m_nBodySize = 4
return C_RTMP_SendPacket(r, &packet, 0) return C_RTMP_SendPacket(r, &packet, 0)
@ -828,8 +862,14 @@ func C_SendCheckBW(r *C_RTMP) error {
enc := packet.m_body enc := packet.m_body
enc = C_AMF_EncodeString(enc, av__checkbw) enc = C_AMF_EncodeString(enc, av__checkbw)
if enc == nil {
return errEncoding
}
r.m_numInvokes++ r.m_numInvokes++
enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes)) enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes))
if enc == nil {
return errEncoding
}
enc[0] = AMF_NULL enc[0] = AMF_NULL
enc = enc[1:] enc = enc[1:]
@ -1588,6 +1628,9 @@ func C_RTMP_Write(r *C_RTMP, buf []byte) error {
enc = pkt.m_body[:pkt.m_nBodySize] enc = pkt.m_body[:pkt.m_nBodySize]
if pkt.m_packetType == RTMP_PACKET_TYPE_INFO { if pkt.m_packetType == RTMP_PACKET_TYPE_INFO {
enc = C_AMF_EncodeString(enc, setDataFrame) enc = C_AMF_EncodeString(enc, setDataFrame)
if enc == nil {
return errEncoding
}
pkt.m_nBytesRead = uint32(len(pkt.m_body) - len(enc)) pkt.m_nBytesRead = uint32(len(pkt.m_body) - len(enc))
} }