mirror of https://bitbucket.org/ausocean/av.git
rtmp: use []byte for RTMP message sends
This commit is contained in:
parent
eccc9377ab
commit
9cfe8c430b
279
rtmp/rtmp.go
279
rtmp/rtmp.go
|
@ -778,29 +778,25 @@ func C_SendConnectPacket(r *C_RTMP, cp *C_RTMPPacket) (ok bool) {
|
||||||
// int RTMP_SendCreateStream(RTMP* r);
|
// int RTMP_SendCreateStream(RTMP* r);
|
||||||
// rtmp.c +1725
|
// rtmp.c +1725
|
||||||
func C_RTMP_SendCreateStream(r *C_RTMP) (ok bool) {
|
func C_RTMP_SendCreateStream(r *C_RTMP) (ok bool) {
|
||||||
var packet C_RTMPPacket
|
|
||||||
var pbuf [256]byte
|
var pbuf [256]byte
|
||||||
var pend *byte = (*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&pbuf[0])) +
|
packet := C_RTMPPacket{
|
||||||
unsafe.Sizeof(pbuf)))
|
m_nChannel: 0x03, /* control channel (invoke) */
|
||||||
var enc *byte
|
m_headerType: RTMP_PACKET_SIZE_MEDIUM,
|
||||||
|
m_packetType: RTMP_PACKET_TYPE_INVOKE,
|
||||||
|
m_nTimeStamp: 0,
|
||||||
|
m_nInfoField2: 0,
|
||||||
|
m_hasAbsTimestamp: false,
|
||||||
|
m_body: &pbuf[RTMP_MAX_HEADER_SIZE],
|
||||||
|
}
|
||||||
|
enc := pbuf[RTMP_MAX_HEADER_SIZE:]
|
||||||
|
|
||||||
packet.m_nChannel = 0x03 /* control channel (invoke) */
|
enc = C_AMF_EncodeString(enc, av_createStream)
|
||||||
packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM
|
|
||||||
packet.m_packetType = RTMP_PACKET_TYPE_INVOKE
|
|
||||||
packet.m_nTimeStamp = 0
|
|
||||||
packet.m_nInfoField2 = 0
|
|
||||||
packet.m_hasAbsTimestamp = false
|
|
||||||
packet.m_body = &pbuf[RTMP_MAX_HEADER_SIZE]
|
|
||||||
|
|
||||||
enc = (*byte)(unsafe.Pointer(packet.m_body))
|
|
||||||
enc = bAddr(C_AMF_EncodeString(pp2b(enc, pend), av_createStream))
|
|
||||||
r.m_numInvokes++
|
r.m_numInvokes++
|
||||||
enc = bAddr(C_AMF_EncodeNumber(pp2b(enc, pend), float64(r.m_numInvokes)))
|
enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes))
|
||||||
*enc = AMF_NULL
|
enc[0] = AMF_NULL
|
||||||
enc = (*byte)(incBytePtr(unsafe.Pointer(enc), 1))
|
enc = enc[1:]
|
||||||
|
|
||||||
packet.m_nBodySize = uint32(uintptr(unsafe.Pointer(enc)) - uintptr(
|
packet.m_nBodySize = uint32((len(pbuf) - RTMP_MAX_HEADER_SIZE) - len(enc))
|
||||||
unsafe.Pointer(packet.m_body)))
|
|
||||||
|
|
||||||
return C_RTMP_SendPacket(r, &packet, 1)
|
return C_RTMP_SendPacket(r, &packet, 1)
|
||||||
}
|
}
|
||||||
|
@ -808,32 +804,29 @@ func C_RTMP_SendCreateStream(r *C_RTMP) (ok bool) {
|
||||||
// int SendReleaseStream(RTMP* r);
|
// int SendReleaseStream(RTMP* r);
|
||||||
// rtmp.c +1816
|
// rtmp.c +1816
|
||||||
func C_SendReleaseStream(r *C_RTMP) (ok bool) {
|
func C_SendReleaseStream(r *C_RTMP) (ok bool) {
|
||||||
var packet C_RTMPPacket
|
|
||||||
var pbuf [1024]byte
|
var pbuf [1024]byte
|
||||||
var pend *byte = (*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&pbuf[0])) +
|
packet := C_RTMPPacket{
|
||||||
unsafe.Sizeof(pbuf)))
|
m_nChannel: 0x03, /* control channel (invoke) */
|
||||||
var enc *byte
|
m_headerType: RTMP_PACKET_SIZE_MEDIUM,
|
||||||
|
m_packetType: RTMP_PACKET_TYPE_INVOKE,
|
||||||
|
m_nTimeStamp: 0,
|
||||||
|
m_nInfoField2: 0,
|
||||||
|
m_hasAbsTimestamp: false,
|
||||||
|
m_body: &pbuf[RTMP_MAX_HEADER_SIZE],
|
||||||
|
}
|
||||||
|
enc := pbuf[RTMP_MAX_HEADER_SIZE:]
|
||||||
|
|
||||||
packet.m_nChannel = 0x03 /* control channel (invoke) */
|
enc = C_AMF_EncodeString(enc, av_releaseStream)
|
||||||
packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM
|
|
||||||
packet.m_packetType = RTMP_PACKET_TYPE_INVOKE
|
|
||||||
packet.m_nTimeStamp = 0
|
|
||||||
packet.m_nInfoField2 = 0
|
|
||||||
packet.m_hasAbsTimestamp = false
|
|
||||||
packet.m_body = &pbuf[RTMP_MAX_HEADER_SIZE]
|
|
||||||
|
|
||||||
enc = (*byte)(unsafe.Pointer(packet.m_body))
|
|
||||||
enc = bAddr(C_AMF_EncodeString(pp2b(enc, pend), av_releaseStream))
|
|
||||||
r.m_numInvokes++
|
r.m_numInvokes++
|
||||||
enc = bAddr(C_AMF_EncodeNumber(pp2b(enc, pend), float64(r.m_numInvokes)))
|
enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes))
|
||||||
*enc = AMF_NULL
|
enc[0] = AMF_NULL
|
||||||
enc = (*byte)(incBytePtr(unsafe.Pointer(enc), 1))
|
enc = enc[1:]
|
||||||
enc = bAddr(C_AMF_EncodeString(pp2b(enc, pend), r.Link.playpath))
|
enc = C_AMF_EncodeString(enc, r.Link.playpath)
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
packet.m_nBodySize = uint32(uintptr(unsafe.Pointer(enc)) - uintptr(
|
|
||||||
unsafe.Pointer(packet.m_body)))
|
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)
|
||||||
}
|
}
|
||||||
|
@ -841,32 +834,29 @@ func C_SendReleaseStream(r *C_RTMP) (ok bool) {
|
||||||
// int SendFCPublish(RTMP* r);
|
// int SendFCPublish(RTMP* r);
|
||||||
// rtmp.c +1846
|
// rtmp.c +1846
|
||||||
func C_SendFCPublish(r *C_RTMP) (ok bool) {
|
func C_SendFCPublish(r *C_RTMP) (ok bool) {
|
||||||
var packet C_RTMPPacket
|
|
||||||
var pbuf [1024]byte
|
var pbuf [1024]byte
|
||||||
var pend *byte = (*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&pbuf[0])) +
|
packet := C_RTMPPacket{
|
||||||
unsafe.Sizeof(pbuf)))
|
m_nChannel: 0x03, /* control channel (invoke) */
|
||||||
var enc *byte
|
m_headerType: RTMP_PACKET_SIZE_MEDIUM,
|
||||||
|
m_packetType: RTMP_PACKET_TYPE_INVOKE,
|
||||||
|
m_nTimeStamp: 0,
|
||||||
|
m_nInfoField2: 0,
|
||||||
|
m_hasAbsTimestamp: false,
|
||||||
|
m_body: &pbuf[RTMP_MAX_HEADER_SIZE],
|
||||||
|
}
|
||||||
|
enc := pbuf[RTMP_MAX_HEADER_SIZE:]
|
||||||
|
|
||||||
packet.m_nChannel = 0x03 /* control channel (invoke) */
|
enc = C_AMF_EncodeString(enc, av_FCPublish)
|
||||||
packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM
|
|
||||||
packet.m_packetType = RTMP_PACKET_TYPE_INVOKE
|
|
||||||
packet.m_nTimeStamp = 0
|
|
||||||
packet.m_nInfoField2 = 0
|
|
||||||
packet.m_hasAbsTimestamp = false
|
|
||||||
packet.m_body = &pbuf[RTMP_MAX_HEADER_SIZE]
|
|
||||||
|
|
||||||
enc = (*byte)(unsafe.Pointer(packet.m_body))
|
|
||||||
enc = bAddr(C_AMF_EncodeString(pp2b(enc, pend), av_FCPublish))
|
|
||||||
r.m_numInvokes++
|
r.m_numInvokes++
|
||||||
enc = bAddr(C_AMF_EncodeNumber(pp2b(enc, pend), float64(r.m_numInvokes)))
|
enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes))
|
||||||
*enc = AMF_NULL
|
enc[0] = AMF_NULL
|
||||||
enc = (*byte)(incBytePtr(unsafe.Pointer(enc), 1))
|
enc = enc[1:]
|
||||||
enc = bAddr(C_AMF_EncodeString(pp2b(enc, pend), r.Link.playpath))
|
enc = C_AMF_EncodeString(enc, r.Link.playpath)
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
packet.m_nBodySize = uint32(uintptr(unsafe.Pointer(enc)) - uintptr(
|
|
||||||
unsafe.Pointer(packet.m_body)))
|
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)
|
||||||
}
|
}
|
||||||
|
@ -874,34 +864,30 @@ func C_SendFCPublish(r *C_RTMP) (ok bool) {
|
||||||
// int SendFCUnpublish(RTMP *r);
|
// int SendFCUnpublish(RTMP *r);
|
||||||
// rtmp.c +1875
|
// rtmp.c +1875
|
||||||
func C_SendFCUnpublish(r *C_RTMP) (ok bool) {
|
func C_SendFCUnpublish(r *C_RTMP) (ok bool) {
|
||||||
var packet C_RTMPPacket
|
|
||||||
var pbuf [1024]byte
|
var pbuf [1024]byte
|
||||||
var pend *byte = (*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&pbuf[0])) +
|
packet := C_RTMPPacket{
|
||||||
unsafe.Sizeof(pbuf)))
|
m_nChannel: 0x03, /* control channel (invoke) */
|
||||||
var enc *byte
|
m_headerType: RTMP_PACKET_SIZE_MEDIUM,
|
||||||
|
m_packetType: RTMP_PACKET_TYPE_INVOKE,
|
||||||
|
m_nTimeStamp: 0,
|
||||||
|
m_nInfoField2: 0,
|
||||||
|
m_hasAbsTimestamp: false,
|
||||||
|
m_body: &pbuf[RTMP_MAX_HEADER_SIZE],
|
||||||
|
}
|
||||||
|
enc := pbuf[RTMP_MAX_HEADER_SIZE:]
|
||||||
|
|
||||||
packet.m_nChannel = 0x03 /* control channel (invoke) */
|
enc = C_AMF_EncodeString(enc, av_FCUnpublish)
|
||||||
packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM
|
|
||||||
packet.m_packetType = RTMP_PACKET_TYPE_INVOKE
|
|
||||||
packet.m_nTimeStamp = 0
|
|
||||||
packet.m_nInfoField2 = 0
|
|
||||||
packet.m_hasAbsTimestamp = false
|
|
||||||
packet.m_body = &pbuf[RTMP_MAX_HEADER_SIZE]
|
|
||||||
|
|
||||||
enc = (*byte)(unsafe.Pointer(packet.m_body))
|
|
||||||
enc = bAddr(C_AMF_EncodeString(pp2b(enc, pend), av_FCUnpublish))
|
|
||||||
r.m_numInvokes++
|
r.m_numInvokes++
|
||||||
enc = bAddr(C_AMF_EncodeNumber(pp2b(enc, pend), float64(r.m_numInvokes)))
|
enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes))
|
||||||
*enc = AMF_NULL
|
enc[0] = AMF_NULL
|
||||||
enc = (*byte)(incBytePtr(unsafe.Pointer(enc), 1))
|
enc = enc[1:]
|
||||||
enc = bAddr(C_AMF_EncodeString(pp2b(enc, pend), r.Link.playpath))
|
enc = C_AMF_EncodeString(enc, r.Link.playpath)
|
||||||
|
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.m_nBodySize = uint32(uintptr(unsafe.Pointer(enc)) - uintptr(
|
packet.m_nBodySize = uint32((len(pbuf) - RTMP_MAX_HEADER_SIZE) - len(enc))
|
||||||
unsafe.Pointer(packet.m_body)))
|
|
||||||
|
|
||||||
return C_RTMP_SendPacket(r, &packet, 0)
|
return C_RTMP_SendPacket(r, &packet, 0)
|
||||||
}
|
}
|
||||||
|
@ -909,39 +895,35 @@ func C_SendFCUnpublish(r *C_RTMP) (ok bool) {
|
||||||
// int SendPublish(RTMP* r);
|
// int SendPublish(RTMP* r);
|
||||||
// rtmp.c +1908
|
// rtmp.c +1908
|
||||||
func C_SendPublish(r *C_RTMP) (ok bool) {
|
func C_SendPublish(r *C_RTMP) (ok bool) {
|
||||||
var packet C_RTMPPacket
|
|
||||||
var pbuf [1024]byte
|
var pbuf [1024]byte
|
||||||
var pend *byte = (*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&pbuf[0])) +
|
packet := C_RTMPPacket{
|
||||||
unsafe.Sizeof(pbuf)))
|
m_nChannel: 0x04, /* source channel (invoke) */
|
||||||
var enc *byte
|
m_headerType: RTMP_PACKET_SIZE_LARGE,
|
||||||
|
m_packetType: RTMP_PACKET_TYPE_INVOKE,
|
||||||
|
m_nTimeStamp: 0,
|
||||||
|
m_nInfoField2: r.m_stream_id,
|
||||||
|
m_hasAbsTimestamp: false,
|
||||||
|
m_body: &pbuf[RTMP_MAX_HEADER_SIZE],
|
||||||
|
}
|
||||||
|
enc := pbuf[RTMP_MAX_HEADER_SIZE:]
|
||||||
|
|
||||||
packet.m_nChannel = 0x04 /* source channel (invoke) */
|
enc = C_AMF_EncodeString(enc, av_publish)
|
||||||
packet.m_headerType = RTMP_PACKET_SIZE_LARGE
|
|
||||||
packet.m_packetType = RTMP_PACKET_TYPE_INVOKE
|
|
||||||
packet.m_nTimeStamp = 0
|
|
||||||
packet.m_nInfoField2 = r.m_stream_id
|
|
||||||
packet.m_hasAbsTimestamp = false
|
|
||||||
packet.m_body = &pbuf[RTMP_MAX_HEADER_SIZE]
|
|
||||||
|
|
||||||
enc = (*byte)(unsafe.Pointer(packet.m_body))
|
|
||||||
enc = bAddr(C_AMF_EncodeString(pp2b(enc, pend), av_publish))
|
|
||||||
r.m_numInvokes++
|
r.m_numInvokes++
|
||||||
enc = bAddr(C_AMF_EncodeNumber(pp2b(enc, pend), float64(r.m_numInvokes)))
|
enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes))
|
||||||
*enc = AMF_NULL
|
enc[0] = AMF_NULL
|
||||||
enc = (*byte)(incBytePtr(unsafe.Pointer(enc), 1))
|
enc = enc[1:]
|
||||||
enc = bAddr(C_AMF_EncodeString(pp2b(enc, pend), r.Link.playpath))
|
enc = C_AMF_EncodeString(enc, r.Link.playpath)
|
||||||
|
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
enc = bAddr(C_AMF_EncodeString(pp2b(enc, pend), av_live))
|
enc = C_AMF_EncodeString(enc, av_live)
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.m_nBodySize = uint32(uintptr(unsafe.Pointer(enc)) - uintptr(
|
packet.m_nBodySize = uint32((len(pbuf) - RTMP_MAX_HEADER_SIZE) - len(enc))
|
||||||
unsafe.Pointer(packet.m_body)))
|
|
||||||
|
|
||||||
return C_RTMP_SendPacket(r, &packet, 1)
|
return C_RTMP_SendPacket(r, &packet, 1)
|
||||||
}
|
}
|
||||||
|
@ -950,29 +932,26 @@ func C_SendPublish(r *C_RTMP) (ok bool) {
|
||||||
// SendDeleteStream(RTMP *r, double dStreamId)
|
// SendDeleteStream(RTMP *r, double dStreamId)
|
||||||
// rtmp.c +1942
|
// rtmp.c +1942
|
||||||
func C_SendDeleteStream(r *C_RTMP, dStreamId float64) (ok bool) {
|
func C_SendDeleteStream(r *C_RTMP, dStreamId float64) (ok bool) {
|
||||||
var packet C_RTMPPacket
|
|
||||||
var pbuf [256]byte
|
var pbuf [256]byte
|
||||||
pend := (*byte)(incBytePtr(unsafe.Pointer(&pbuf[0]), 256))
|
packet := C_RTMPPacket{
|
||||||
var enc *byte
|
m_nChannel: 0x03, /* control channel (invoke) */
|
||||||
|
m_headerType: RTMP_PACKET_SIZE_MEDIUM,
|
||||||
|
m_packetType: RTMP_PACKET_TYPE_INVOKE,
|
||||||
|
m_nTimeStamp: 0,
|
||||||
|
m_nInfoField2: 0,
|
||||||
|
m_hasAbsTimestamp: false,
|
||||||
|
m_body: &pbuf[RTMP_MAX_HEADER_SIZE],
|
||||||
|
}
|
||||||
|
enc := pbuf[RTMP_MAX_HEADER_SIZE:]
|
||||||
|
|
||||||
packet.m_nChannel = 0x03 /* control channel (invoke) */
|
enc = C_AMF_EncodeString(enc, av_deleteStream)
|
||||||
packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM
|
|
||||||
packet.m_packetType = RTMP_PACKET_TYPE_INVOKE
|
|
||||||
packet.m_nTimeStamp = 0
|
|
||||||
packet.m_nInfoField2 = 0
|
|
||||||
packet.m_hasAbsTimestamp = false
|
|
||||||
packet.m_body = &pbuf[RTMP_MAX_HEADER_SIZE]
|
|
||||||
|
|
||||||
enc = (*byte)(unsafe.Pointer(packet.m_body))
|
|
||||||
enc = bAddr(C_AMF_EncodeString(pp2b(enc, pend), av_deleteStream))
|
|
||||||
r.m_numInvokes++
|
r.m_numInvokes++
|
||||||
enc = bAddr(C_AMF_EncodeNumber(pp2b(enc, pend), float64(r.m_numInvokes)))
|
enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes))
|
||||||
*enc = AMF_NULL
|
enc[0] = AMF_NULL
|
||||||
enc = (*byte)(incBytePtr(unsafe.Pointer(enc), 1))
|
enc = enc[1:]
|
||||||
enc = bAddr(C_AMF_EncodeNumber(pp2b(enc, pend), dStreamId))
|
enc = C_AMF_EncodeNumber(enc, dStreamId)
|
||||||
|
|
||||||
packet.m_nBodySize = uint32(uintptr(unsafe.Pointer(enc)) - uintptr(
|
packet.m_nBodySize = uint32((len(pbuf) - RTMP_MAX_HEADER_SIZE) - len(enc))
|
||||||
unsafe.Pointer(packet.m_body)))
|
|
||||||
|
|
||||||
/* no response expected */
|
/* no response expected */
|
||||||
return C_RTMP_SendPacket(r, &packet, 0)
|
return C_RTMP_SendPacket(r, &packet, 0)
|
||||||
|
@ -981,23 +960,22 @@ func C_SendDeleteStream(r *C_RTMP, dStreamId float64) (ok bool) {
|
||||||
// int SendBytesReceived(RTMP* r);
|
// int SendBytesReceived(RTMP* r);
|
||||||
// rtmp.c +2080
|
// rtmp.c +2080
|
||||||
func C_SendBytesReceived(r *C_RTMP) (ok bool) {
|
func C_SendBytesReceived(r *C_RTMP) (ok bool) {
|
||||||
var packet C_RTMPPacket
|
|
||||||
var pbuf [256]byte
|
var pbuf [256]byte
|
||||||
pend := (*byte)(incBytePtr(unsafe.Pointer(&pbuf[0]), 256))
|
packet := C_RTMPPacket{
|
||||||
|
m_nChannel: 0x02, /* control channel (invoke) */
|
||||||
packet.m_nChannel = 0x02 /* control channel (invoke) */
|
m_headerType: RTMP_PACKET_SIZE_MEDIUM,
|
||||||
packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM
|
m_packetType: RTMP_PACKET_TYPE_BYTES_READ_REPORT,
|
||||||
packet.m_packetType = RTMP_PACKET_TYPE_BYTES_READ_REPORT
|
m_nTimeStamp: 0,
|
||||||
packet.m_nTimeStamp = 0
|
m_nInfoField2: 0,
|
||||||
packet.m_nInfoField2 = 0
|
m_hasAbsTimestamp: false,
|
||||||
packet.m_hasAbsTimestamp = false
|
m_body: &pbuf[RTMP_MAX_HEADER_SIZE],
|
||||||
packet.m_body = &pbuf[RTMP_MAX_HEADER_SIZE]
|
}
|
||||||
|
enc := pbuf[RTMP_MAX_HEADER_SIZE:]
|
||||||
packet.m_nBodySize = 4
|
|
||||||
|
|
||||||
C_AMF_EncodeInt32(pp2b(packet.m_body, pend), r.m_nBytesIn)
|
|
||||||
|
|
||||||
r.m_nBytesInSent = r.m_nBytesIn
|
r.m_nBytesInSent = r.m_nBytesIn
|
||||||
|
C_AMF_EncodeInt32(enc, r.m_nBytesIn)
|
||||||
|
|
||||||
|
packet.m_nBodySize = 4
|
||||||
|
|
||||||
return C_RTMP_SendPacket(r, &packet, 0)
|
return C_RTMP_SendPacket(r, &packet, 0)
|
||||||
}
|
}
|
||||||
|
@ -1005,29 +983,25 @@ func C_SendBytesReceived(r *C_RTMP) (ok bool) {
|
||||||
// int SendCheckBW(RTMP* r);
|
// int SendCheckBW(RTMP* r);
|
||||||
// rtmp.c +2105
|
// rtmp.c +2105
|
||||||
func C_SendCheckBW(r *C_RTMP) (ok bool) {
|
func C_SendCheckBW(r *C_RTMP) (ok bool) {
|
||||||
var packet C_RTMPPacket
|
|
||||||
var pbuf [256]byte
|
var pbuf [256]byte
|
||||||
var pend *byte = (*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&pbuf[0])) +
|
packet := C_RTMPPacket{
|
||||||
unsafe.Sizeof(pbuf)))
|
m_nChannel: 0x03, /* control channel (invoke) */
|
||||||
var enc *byte
|
m_headerType: RTMP_PACKET_SIZE_LARGE,
|
||||||
|
m_packetType: RTMP_PACKET_TYPE_INVOKE,
|
||||||
|
m_nTimeStamp: 0,
|
||||||
|
m_nInfoField2: 0,
|
||||||
|
m_hasAbsTimestamp: false,
|
||||||
|
m_body: &pbuf[RTMP_MAX_HEADER_SIZE],
|
||||||
|
}
|
||||||
|
enc := pbuf[RTMP_MAX_HEADER_SIZE:]
|
||||||
|
|
||||||
packet.m_nChannel = 0x03 /* control channel (invoke) */
|
enc = C_AMF_EncodeString(enc, av__checkbw)
|
||||||
packet.m_headerType = RTMP_PACKET_SIZE_LARGE
|
|
||||||
packet.m_packetType = RTMP_PACKET_TYPE_INVOKE
|
|
||||||
packet.m_nTimeStamp = 0
|
|
||||||
packet.m_nInfoField2 = 0
|
|
||||||
packet.m_hasAbsTimestamp = false
|
|
||||||
packet.m_body = &pbuf[RTMP_MAX_HEADER_SIZE]
|
|
||||||
|
|
||||||
enc = (*byte)(unsafe.Pointer(packet.m_body))
|
|
||||||
enc = bAddr(C_AMF_EncodeString(pp2b(enc, pend), av__checkbw))
|
|
||||||
r.m_numInvokes++
|
r.m_numInvokes++
|
||||||
enc = bAddr(C_AMF_EncodeNumber(pp2b(enc, pend), float64(r.m_numInvokes)))
|
enc = C_AMF_EncodeNumber(enc, float64(r.m_numInvokes))
|
||||||
*enc = AMF_NULL
|
enc[0] = AMF_NULL
|
||||||
enc = (*byte)(incBytePtr(unsafe.Pointer(enc), 1))
|
enc = enc[1:]
|
||||||
|
|
||||||
packet.m_nBodySize = uint32(uintptr(unsafe.Pointer(enc)) - uintptr(
|
packet.m_nBodySize = uint32((len(pbuf) - RTMP_MAX_HEADER_SIZE) - len(enc))
|
||||||
unsafe.Pointer(packet.m_body)))
|
|
||||||
|
|
||||||
return C_RTMP_SendPacket(r, &packet, 0)
|
return C_RTMP_SendPacket(r, &packet, 0)
|
||||||
}
|
}
|
||||||
|
@ -1043,7 +1017,6 @@ func C_AV_erase(m []C_RTMP_METHOD, i int) []C_RTMP_METHOD {
|
||||||
// int HandleInvoke(RTMP* r, const char* body, unsigned int nBodySize);
|
// int HandleInvoke(RTMP* r, const char* body, unsigned int nBodySize);
|
||||||
// rtmp.c +2912
|
// rtmp.c +2912
|
||||||
func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) (ok bool) {
|
func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) (ok bool) {
|
||||||
|
|
||||||
if *body != 0x02 {
|
if *body != 0x02 {
|
||||||
// TODO use new logger here
|
// TODO use new logger here
|
||||||
//RTMP_Log(RTMP_LOGWARNING, "%s, Sanity failed. no string method in invoke packet",
|
//RTMP_Log(RTMP_LOGWARNING, "%s, Sanity failed. no string method in invoke packet",
|
||||||
|
|
Loading…
Reference in New Issue