mirror of https://bitbucket.org/ausocean/av.git
Commented all functions with name and location of C versions
This commit is contained in:
parent
e4cd61b663
commit
8ca1aac3db
176
rtmp/rtmp.go
176
rtmp/rtmp.go
|
@ -974,7 +974,7 @@ func C_SendBytesReceived(r *C.RTMP) int {
|
||||||
|
|
||||||
packet.m_nBodySize = 4
|
packet.m_nBodySize = 4
|
||||||
|
|
||||||
C_AMFEncodeInt32((*byte)(unsafe.Pointer(packet.m_body)), pend, int32(r.m_nBytesIn))
|
C_AMF_EncodeInt32((*byte)(unsafe.Pointer(packet.m_body)), pend, int32(r.m_nBytesIn))
|
||||||
// C.AMF_EncodeInt32(packet.m_body, (*C.char)(unsafe.Pointer(pend)), r.m_nBytesIn)
|
// C.AMF_EncodeInt32(packet.m_body, (*C.char)(unsafe.Pointer(pend)), r.m_nBytesIn)
|
||||||
|
|
||||||
r.m_nBytesInSent = r.m_nBytesIn
|
r.m_nBytesInSent = r.m_nBytesIn
|
||||||
|
@ -983,6 +983,8 @@ func C_SendBytesReceived(r *C.RTMP) int {
|
||||||
return C_RTMP_SendPacket(r, &packet, 0)
|
return C_RTMP_SendPacket(r, &packet, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// int SendConnectPacket(RTMP* r, RTMPPacket* cp);
|
||||||
|
// rtmp.c +1579
|
||||||
func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
var packet C.RTMPPacket
|
var packet C.RTMPPacket
|
||||||
var pbuf [4096]byte
|
var pbuf [4096]byte
|
||||||
|
@ -1008,11 +1010,11 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
|
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeString((*C.char)(unsafe.Pointer(enc)),
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeString((*C.char)(unsafe.Pointer(enc)),
|
||||||
//(*C.char)(unsafe.Pointer(pend)), &av_connect)))
|
//(*C.char)(unsafe.Pointer(pend)), &av_connect)))
|
||||||
enc = C_AMFEncodeString(enc, pend, &av_connect)
|
enc = C_AMF_EncodeString(enc, pend, &av_connect)
|
||||||
r.m_numInvokes += 1
|
r.m_numInvokes += 1
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNumber((*C.char)(unsafe.Pointer(enc)),
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNumber((*C.char)(unsafe.Pointer(enc)),
|
||||||
//(*C.char)(unsafe.Pointer(pend)), C.double(r.m_numInvokes))))
|
//(*C.char)(unsafe.Pointer(pend)), C.double(r.m_numInvokes))))
|
||||||
enc = C_AMFEncodeNumber(enc, pend, float64(r.m_numInvokes))
|
enc = C_AMF_EncodeNumber(enc, pend, float64(r.m_numInvokes))
|
||||||
|
|
||||||
*indxBytePtr(unsafe.Pointer(enc), 0) = AMF_OBJECT
|
*indxBytePtr(unsafe.Pointer(enc), 0) = AMF_OBJECT
|
||||||
|
|
||||||
|
@ -1020,14 +1022,14 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
|
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)(
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)(
|
||||||
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_app, &r.Link.app)))
|
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_app, &r.Link.app)))
|
||||||
enc = C_AMFEncodeNamedString(enc, pend, &av_app, &r.Link.app)
|
enc = C_AMF_EncodeNamedString(enc, pend, &av_app, &r.Link.app)
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if r.Link.protocol&RTMP_FEATURE_WRITE != 0 {
|
if r.Link.protocol&RTMP_FEATURE_WRITE != 0 {
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)(
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)(
|
||||||
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_type, &av_nonprivate)))
|
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_type, &av_nonprivate)))
|
||||||
enc = C_AMFEncodeNamedString(enc, pend, &av_type, &av_nonprivate)
|
enc = C_AMF_EncodeNamedString(enc, pend, &av_type, &av_nonprivate)
|
||||||
|
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return 0
|
return 0
|
||||||
|
@ -1037,7 +1039,7 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
if r.Link.flashVer.av_len != 0 {
|
if r.Link.flashVer.av_len != 0 {
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)(
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)(
|
||||||
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_flashVer, &r.Link.flashVer)))
|
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_flashVer, &r.Link.flashVer)))
|
||||||
enc = C_AMFEncodeNamedString(enc, pend, &av_flashVer, &r.Link.flashVer)
|
enc = C_AMF_EncodeNamedString(enc, pend, &av_flashVer, &r.Link.flashVer)
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -1045,7 +1047,7 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
if r.Link.swfUrl.av_len != 0 {
|
if r.Link.swfUrl.av_len != 0 {
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)(
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)(
|
||||||
// unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_swfUrl, &r.Link.swfUrl)))
|
// unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_swfUrl, &r.Link.swfUrl)))
|
||||||
enc = C_AMFEncodeNamedString(enc, pend, &av_swfUrl, &r.Link.swfUrl)
|
enc = C_AMF_EncodeNamedString(enc, pend, &av_swfUrl, &r.Link.swfUrl)
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -1054,7 +1056,7 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
if r.Link.tcUrl.av_len != 0 {
|
if r.Link.tcUrl.av_len != 0 {
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)(
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)(
|
||||||
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_tcUrl, &r.Link.tcUrl)))
|
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_tcUrl, &r.Link.tcUrl)))
|
||||||
enc = C_AMFEncodeNamedString(enc, pend, &av_tcUrl, &r.Link.tcUrl)
|
enc = C_AMF_EncodeNamedString(enc, pend, &av_tcUrl, &r.Link.tcUrl)
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -1063,38 +1065,38 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
if r.Link.protocol&RTMP_FEATURE_WRITE == 0 {
|
if r.Link.protocol&RTMP_FEATURE_WRITE == 0 {
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedBoolean((*C.char)(
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedBoolean((*C.char)(
|
||||||
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_fpad, 0)))
|
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_fpad, 0)))
|
||||||
enc = C_AMFEncodeNamedBoolean(enc, pend, &av_fpad, 0)
|
enc = C_AMF_EncodeNamedBoolean(enc, pend, &av_fpad, 0)
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)(
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)(
|
||||||
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_capabilities, 15.0)))
|
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_capabilities, 15.0)))
|
||||||
enc = C_AMFEncodeNamedNumber(enc, pend, &av_capabilities, 15.0)
|
enc = C_AMF_EncodeNamedNumber(enc, pend, &av_capabilities, 15.0)
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)(
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)(
|
||||||
// unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_audioCodecs, r.m_fAudioCodecs)))
|
// unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_audioCodecs, r.m_fAudioCodecs)))
|
||||||
enc = C_AMFEncodeNamedNumber(enc, pend, &av_audioCodecs, float64(r.m_fAudioCodecs))
|
enc = C_AMF_EncodeNamedNumber(enc, pend, &av_audioCodecs, float64(r.m_fAudioCodecs))
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)(
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)(
|
||||||
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_videoCodecs, r.m_fVideoCodecs)))
|
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_videoCodecs, r.m_fVideoCodecs)))
|
||||||
enc = C_AMFEncodeNamedNumber(enc, pend, &av_videoCodecs, float64(r.m_fVideoCodecs))
|
enc = C_AMF_EncodeNamedNumber(enc, pend, &av_videoCodecs, float64(r.m_fVideoCodecs))
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)(
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)(
|
||||||
// unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_videoFunction, 1.0)))
|
// unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_videoFunction, 1.0)))
|
||||||
enc = C_AMFEncodeNamedNumber(enc, pend, &av_videoFunction, 1.0)
|
enc = C_AMF_EncodeNamedNumber(enc, pend, &av_videoFunction, 1.0)
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if r.Link.pageUrl.av_len != 0 {
|
if r.Link.pageUrl.av_len != 0 {
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)(
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedString((*C.char)(
|
||||||
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_pageUrl, &r.Link.pageUrl)))
|
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_pageUrl, &r.Link.pageUrl)))
|
||||||
enc = C_AMFEncodeNamedString(enc, pend, &av_pageUrl, &r.Link.pageUrl)
|
enc = C_AMF_EncodeNamedString(enc, pend, &av_pageUrl, &r.Link.pageUrl)
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -1104,7 +1106,7 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
if r.m_fEncoding != 0.0 || r.m_bSendEncoding != 0 {
|
if r.m_fEncoding != 0.0 || r.m_bSendEncoding != 0 {
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)(
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeNamedNumber((*C.char)(
|
||||||
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_objectEncoding, r.m_fEncoding)))
|
//unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), &av_objectEncoding, r.m_fEncoding)))
|
||||||
enc = C_AMFEncodeNamedNumber(enc, pend, &av_objectEncoding, float64(r.m_fEncoding))
|
enc = C_AMF_EncodeNamedNumber(enc, pend, &av_objectEncoding, float64(r.m_fEncoding))
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -1126,13 +1128,13 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
if r.Link.auth.av_len != 0 {
|
if r.Link.auth.av_len != 0 {
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeBoolean((*C.char)(
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeBoolean((*C.char)(
|
||||||
// unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), r.Link.lFlags&RTMP_LF_AUTH)))
|
// unsafe.Pointer(enc)), (*C.char)(unsafe.Pointer(pend)), r.Link.lFlags&RTMP_LF_AUTH)))
|
||||||
enc = C_AMFEncodeBoolean(enc, pend, int(r.Link.lFlags&RTMP_LF_AUTH))
|
enc = C_AMF_EncodeBoolean(enc, pend, int(r.Link.lFlags&RTMP_LF_AUTH))
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeString((*C.char)(unsafe.Pointer(enc)),
|
//enc = (*byte)(unsafe.Pointer(C.AMF_EncodeString((*C.char)(unsafe.Pointer(enc)),
|
||||||
//(*C.char)(unsafe.Pointer(pend)), &r.Link.auth)))
|
//(*C.char)(unsafe.Pointer(pend)), &r.Link.auth)))
|
||||||
enc = C_AMFEncodeString(enc, (*byte)(pend), &r.Link.auth)
|
enc = C_AMF_EncodeString(enc, (*byte)(pend), &r.Link.auth)
|
||||||
if enc == nil {
|
if enc == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -1161,6 +1163,8 @@ func C_SendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
return C_RTMP_SendPacket(r, &packet, 1)
|
return C_RTMP_SendPacket(r, &packet, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// char* AMFPropEncode(AMFOBjectProperty* prop, char* pBufer, char* pBufEnd);
|
||||||
|
// amf.c +366
|
||||||
func C_AMFPropEncode(p *C.AMFObjectProperty, pBuffer *byte, pBufEnd *byte) *byte {
|
func C_AMFPropEncode(p *C.AMFObjectProperty, pBuffer *byte, pBufEnd *byte) *byte {
|
||||||
if p.p_type == AMF_INVALID {
|
if p.p_type == AMF_INVALID {
|
||||||
return nil
|
return nil
|
||||||
|
@ -1184,15 +1188,15 @@ func C_AMFPropEncode(p *C.AMFObjectProperty, pBuffer *byte, pBufEnd *byte) *byte
|
||||||
|
|
||||||
switch p.p_type {
|
switch p.p_type {
|
||||||
case AMF_NUMBER:
|
case AMF_NUMBER:
|
||||||
pBuffer = C_AMFEncodeNumber(pBuffer, pBufEnd, float64(p.p_vu.p_number))
|
pBuffer = C_AMF_EncodeNumber(pBuffer, pBufEnd, float64(p.p_vu.p_number))
|
||||||
case AMF_BOOLEAN:
|
case AMF_BOOLEAN:
|
||||||
val := 0
|
val := 0
|
||||||
if p.p_vu.p_number != 0 {
|
if p.p_vu.p_number != 0 {
|
||||||
val = 1
|
val = 1
|
||||||
}
|
}
|
||||||
pBuffer = C_AMFEncodeBoolean(pBuffer, pBufEnd, val)
|
pBuffer = C_AMF_EncodeBoolean(pBuffer, pBufEnd, val)
|
||||||
case AMF_STRING:
|
case AMF_STRING:
|
||||||
pBuffer = C_AMFEncodeString(pBuffer, pBufEnd, &p.p_vu.p_aval)
|
pBuffer = C_AMF_EncodeString(pBuffer, pBufEnd, &p.p_vu.p_aval)
|
||||||
case AMF_NULL:
|
case AMF_NULL:
|
||||||
if uintptr(incBytePtr(unsafe.Pointer(pBuffer), 1)) >= uintptr(unsafe.Pointer(
|
if uintptr(incBytePtr(unsafe.Pointer(pBuffer), 1)) >= uintptr(unsafe.Pointer(
|
||||||
pBufEnd)) {
|
pBufEnd)) {
|
||||||
|
@ -1217,6 +1221,8 @@ func C_AMFPropEncode(p *C.AMFObjectProperty, pBuffer *byte, pBufEnd *byte) *byte
|
||||||
return pBuffer
|
return pBuffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// char* AMF_ENCODE(AMFObject* obj, char* pBuffer, char* pBufEnd);
|
||||||
|
// amf.c +891
|
||||||
func C_AMFEncode(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte {
|
func C_AMFEncode(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte {
|
||||||
if uintptr(unsafe.Pointer(pBuffer))+uintptr(4) >= uintptr(unsafe.Pointer(pBufEnd)) {
|
if uintptr(unsafe.Pointer(pBuffer))+uintptr(4) >= uintptr(unsafe.Pointer(pBufEnd)) {
|
||||||
return nil
|
return nil
|
||||||
|
@ -1245,6 +1251,8 @@ func C_AMFEncode(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte {
|
||||||
return pBuffer
|
return pBuffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// char* AMF_EncodeEcmaArray(AMFObject* obj, char* pBuffer, char* pBufEnd);
|
||||||
|
// amf.c +924
|
||||||
func C_AMFEncodeEcmaArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte {
|
func C_AMFEncodeEcmaArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte {
|
||||||
if int(uintptr(unsafe.Pointer(pBuffer)))+4 >= int(uintptr(unsafe.Pointer(pBufEnd))) {
|
if int(uintptr(unsafe.Pointer(pBuffer)))+4 >= int(uintptr(unsafe.Pointer(pBufEnd))) {
|
||||||
return nil
|
return nil
|
||||||
|
@ -1253,7 +1261,7 @@ func C_AMFEncodeEcmaArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte
|
||||||
*pBuffer = AMF_ECMA_ARRAY
|
*pBuffer = AMF_ECMA_ARRAY
|
||||||
pBuffer = (*byte)(incBytePtr(unsafe.Pointer(pBuffer), 1))
|
pBuffer = (*byte)(incBytePtr(unsafe.Pointer(pBuffer), 1))
|
||||||
|
|
||||||
pBuffer = C_AMFEncodeInt32(pBuffer, pBufEnd, int32(obj.o_num))
|
pBuffer = C_AMF_EncodeInt32(pBuffer, pBufEnd, int32(obj.o_num))
|
||||||
|
|
||||||
for i := 0; i < int(obj.o_num); i++ {
|
for i := 0; i < int(obj.o_num); i++ {
|
||||||
res := C_AMFPropEncode((*C.AMFObjectProperty)(incPtr(unsafe.Pointer(
|
res := C_AMFPropEncode((*C.AMFObjectProperty)(incPtr(unsafe.Pointer(
|
||||||
|
@ -1275,6 +1283,8 @@ func C_AMFEncodeEcmaArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte
|
||||||
return pBuffer
|
return pBuffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// char* AMF_EncodeArray(AMFObject* obj, char* pBuffer, char* pBufEnd);
|
||||||
|
// amf.c +959
|
||||||
func C_AMFEncodeArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte {
|
func C_AMFEncodeArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte {
|
||||||
if int(uintptr(unsafe.Pointer(pBuffer)))+4 >= int(uintptr(unsafe.Pointer(pBufEnd))) {
|
if int(uintptr(unsafe.Pointer(pBuffer)))+4 >= int(uintptr(unsafe.Pointer(pBufEnd))) {
|
||||||
return nil
|
return nil
|
||||||
|
@ -1283,7 +1293,7 @@ func C_AMFEncodeArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte {
|
||||||
*pBuffer = AMF_STRICT_ARRAY
|
*pBuffer = AMF_STRICT_ARRAY
|
||||||
pBuffer = (*byte)(incBytePtr(unsafe.Pointer(pBuffer), 1))
|
pBuffer = (*byte)(incBytePtr(unsafe.Pointer(pBuffer), 1))
|
||||||
|
|
||||||
pBuffer = C_AMFEncodeInt32(pBuffer, pBufEnd, int32(obj.o_num))
|
pBuffer = C_AMF_EncodeInt32(pBuffer, pBufEnd, int32(obj.o_num))
|
||||||
|
|
||||||
for i := 0; i < int(obj.o_num); i++ {
|
for i := 0; i < int(obj.o_num); i++ {
|
||||||
res := C_AMFPropEncode((*C.AMFObjectProperty)(incPtr(unsafe.Pointer(
|
res := C_AMFPropEncode((*C.AMFObjectProperty)(incPtr(unsafe.Pointer(
|
||||||
|
@ -1299,6 +1309,8 @@ func C_AMFEncodeArray(obj *C.AMFObject, pBuffer *byte, pBufEnd *byte) *byte {
|
||||||
return pBuffer
|
return pBuffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// int RTMP_ConnectStream(RTMP* r, int seekTime);
|
||||||
|
// rtmp.c +1099
|
||||||
func C_RTMP_ConnectStream(r *C.RTMP, seekTime int32) int {
|
func C_RTMP_ConnectStream(r *C.RTMP, seekTime int32) int {
|
||||||
var packet C.RTMPPacket
|
var packet C.RTMPPacket
|
||||||
memset((*byte)(unsafe.Pointer(&packet)), 0, int(unsafe.Sizeof(packet)))
|
memset((*byte)(unsafe.Pointer(&packet)), 0, int(unsafe.Sizeof(packet)))
|
||||||
|
@ -1314,7 +1326,7 @@ func C_RTMP_ConnectStream(r *C.RTMP, seekTime int32) int {
|
||||||
C.RTMP_ReadPacket(r, &packet) != 0 {
|
C.RTMP_ReadPacket(r, &packet) != 0 {
|
||||||
|
|
||||||
// TODO: port is ready
|
// TODO: port is ready
|
||||||
if C_RTMP_PacketIsReady(&packet) != 0 {
|
if C_RTMPPacketIsReady(&packet) != 0 {
|
||||||
if packet.m_nBodySize == 0 {
|
if packet.m_nBodySize == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -1335,6 +1347,8 @@ func C_RTMP_ConnectStream(r *C.RTMP, seekTime int32) int {
|
||||||
return int(r.m_bPlaying)
|
return int(r.m_bPlaying)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// int RTMP_ReadPacket(RTMP* r, RTMPPacket* packet);
|
||||||
|
// rtmp.c +3550
|
||||||
func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
|
func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
|
||||||
var hbuf [RTMP_MAX_HEADER_SIZE]uint8
|
var hbuf [RTMP_MAX_HEADER_SIZE]uint8
|
||||||
memset((*byte)(&hbuf[0]), 0, RTMP_MAX_HEADER_SIZE)
|
memset((*byte)(&hbuf[0]), 0, RTMP_MAX_HEADER_SIZE)
|
||||||
|
@ -1436,10 +1450,10 @@ func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
|
||||||
unsafe.Pointer(&hbuf[0])))), int(nSize))))
|
unsafe.Pointer(&hbuf[0])))), int(nSize))))
|
||||||
|
|
||||||
if nSize >= 3 {
|
if nSize >= 3 {
|
||||||
packet.m_nTimeStamp = C.uint32_t(C_AMFDecodeInt24(header))
|
packet.m_nTimeStamp = C.uint32_t(C_AMF_DecodeInt24(header))
|
||||||
|
|
||||||
if nSize >= 6 {
|
if nSize >= 6 {
|
||||||
packet.m_nBodySize = C.uint32_t(C_AMFDecodeInt24((*byte)(incBytePtr(
|
packet.m_nBodySize = C.uint32_t(C_AMF_DecodeInt24((*byte)(incBytePtr(
|
||||||
unsafe.Pointer(header), 3))))
|
unsafe.Pointer(header), 3))))
|
||||||
packet.m_nBytesRead = 0
|
packet.m_nBytesRead = 0
|
||||||
|
|
||||||
|
@ -1544,7 +1558,9 @@ func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
|
||||||
return TRUE
|
return TRUE
|
||||||
}
|
}
|
||||||
|
|
||||||
func C_RTMP_PacketIsReady(p *C.RTMPPacket) int {
|
// #define RTMPPacket_IsReady(a)
|
||||||
|
// rtmp.h +142
|
||||||
|
func C_RTMPPacketIsReady(p *C.RTMPPacket) int {
|
||||||
if p.m_nBytesRead == p.m_nBodySize {
|
if p.m_nBytesRead == p.m_nBodySize {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
@ -1561,7 +1577,8 @@ func endSession(rtmp *C.RTMP) uint32 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// C_RTMP_Write writes data to the current rtmp connection encapsulated by r
|
// int RTMP_Write(RTMP* r, const char* buf, int size);
|
||||||
|
// rtmp.c +5095
|
||||||
func C_RTMP_Write(r *C.RTMP, data []byte) int {
|
func C_RTMP_Write(r *C.RTMP, data []byte) int {
|
||||||
buf := sliceToPtr(data)
|
buf := sliceToPtr(data)
|
||||||
// TODO: port RTMPPacket
|
// TODO: port RTMPPacket
|
||||||
|
@ -1588,9 +1605,9 @@ func C_RTMP_Write(r *C.RTMP, data []byte) int {
|
||||||
|
|
||||||
pkt.m_packetType = C.uint8_t(*indxBytePtr(buf, 0))
|
pkt.m_packetType = C.uint8_t(*indxBytePtr(buf, 0))
|
||||||
buf = incBytePtr(buf, 1)
|
buf = incBytePtr(buf, 1)
|
||||||
pkt.m_nBodySize = C.uint32_t(C_AMFDecodeInt24((*byte)(buf)))
|
pkt.m_nBodySize = C.uint32_t(C_AMF_DecodeInt24((*byte)(buf)))
|
||||||
buf = incBytePtr(buf, 3)
|
buf = incBytePtr(buf, 3)
|
||||||
pkt.m_nTimeStamp = C.uint32_t(C_AMFDecodeInt24((*byte)(buf)))
|
pkt.m_nTimeStamp = C.uint32_t(C_AMF_DecodeInt24((*byte)(buf)))
|
||||||
buf = incBytePtr(buf, 3)
|
buf = incBytePtr(buf, 3)
|
||||||
pkt.m_nTimeStamp |= C.uint32_t(*indxBytePtr(buf, 0)) << 24
|
pkt.m_nTimeStamp |= C.uint32_t(*indxBytePtr(buf, 0)) << 24
|
||||||
buf = incBytePtr(buf, 4)
|
buf = incBytePtr(buf, 4)
|
||||||
|
@ -1618,7 +1635,7 @@ func C_RTMP_Write(r *C.RTMP, data []byte) int {
|
||||||
pend = incBytePtr(enc, int(pkt.m_nBodySize))
|
pend = incBytePtr(enc, int(pkt.m_nBodySize))
|
||||||
|
|
||||||
if pkt.m_packetType == RTMP_PACKET_TYPE_INFO {
|
if pkt.m_packetType == RTMP_PACKET_TYPE_INFO {
|
||||||
enc = unsafe.Pointer(C_AMFEncodeString((*byte)(enc), (*byte)(pend), &setDataFrame))
|
enc = unsafe.Pointer(C_AMF_EncodeString((*byte)(enc), (*byte)(pend), &setDataFrame))
|
||||||
pkt.m_nBytesRead = C.uint32_t(math.Abs(float64(uintptr(enc) -
|
pkt.m_nBytesRead = C.uint32_t(math.Abs(float64(uintptr(enc) -
|
||||||
uintptr(unsafe.Pointer(pkt.m_body)))))
|
uintptr(unsafe.Pointer(pkt.m_body)))))
|
||||||
}
|
}
|
||||||
|
@ -1654,7 +1671,8 @@ func C_RTMP_Write(r *C.RTMP, data []byte) int {
|
||||||
return size + s2
|
return size + s2
|
||||||
}
|
}
|
||||||
|
|
||||||
// send packet version 1 - less C stuff
|
// int RTMP_SendPacket(RTMP* r, RTMPPacket* packet, int queue);
|
||||||
|
// rtmp.c +3896
|
||||||
func C_RTMP_SendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
|
func C_RTMP_SendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
|
||||||
var prevPacket *C.RTMPPacket
|
var prevPacket *C.RTMPPacket
|
||||||
last := 0
|
last := 0
|
||||||
|
@ -1794,7 +1812,7 @@ func C_RTMP_SendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
if t >= 0xffffff {
|
if t >= 0xffffff {
|
||||||
hptr = unsafe.Pointer(C_AMFEncodeInt32((*byte)(hptr), (*byte)(hend), (int32)(t)))
|
hptr = unsafe.Pointer(C_AMF_EncodeInt32((*byte)(hptr), (*byte)(hend), (int32)(t)))
|
||||||
}
|
}
|
||||||
|
|
||||||
nSize = int(packet.m_nBodySize)
|
nSize = int(packet.m_nBodySize)
|
||||||
|
@ -1856,7 +1874,7 @@ func C_RTMP_SendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
|
||||||
}
|
}
|
||||||
if t >= 0xffffff {
|
if t >= 0xffffff {
|
||||||
extendedTimestamp := incBytePtr(header, 1+cSize)
|
extendedTimestamp := incBytePtr(header, 1+cSize)
|
||||||
C_AMFEncodeInt32((*byte)(extendedTimestamp),
|
C_AMF_EncodeInt32((*byte)(extendedTimestamp),
|
||||||
(*byte)(incBytePtr(extendedTimestamp, 4)), (int32)(t))
|
(*byte)(incBytePtr(extendedTimestamp, 4)), (int32)(t))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1881,7 +1899,7 @@ func C_RTMP_SendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
|
||||||
var ptr unsafe.Pointer
|
var ptr unsafe.Pointer
|
||||||
ptr = incBytePtr(unsafe.Pointer(packet.m_body), 1)
|
ptr = incBytePtr(unsafe.Pointer(packet.m_body), 1)
|
||||||
//C.AMF_DecodeString((*C.char)(ptr), &method)
|
//C.AMF_DecodeString((*C.char)(ptr), &method)
|
||||||
C_AMFDecodeString((*byte)(ptr), &method)
|
C_AMF_DecodeString((*byte)(ptr), &method)
|
||||||
|
|
||||||
if debugMode {
|
if debugMode {
|
||||||
log.Printf("Invoking %v", method.av_val)
|
log.Printf("Invoking %v", method.av_val)
|
||||||
|
@ -1891,8 +1909,8 @@ func C_RTMP_SendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
|
||||||
var txn int
|
var txn int
|
||||||
ptr = incBytePtr(ptr, 3+int(method.av_len))
|
ptr = incBytePtr(ptr, 3+int(method.av_len))
|
||||||
//txn = int(C.AMF_DecodeNumber((*C.char)(ptr)))
|
//txn = int(C.AMF_DecodeNumber((*C.char)(ptr)))
|
||||||
txn = int(C_AMFDecodeNumber((*byte)(ptr)))
|
txn = int(C_AMF_DecodeNumber((*byte)(ptr)))
|
||||||
C_AvQueue(&r.m_methodCalls, (*int32)(unsafe.Pointer(&r.m_numCalls)),
|
C_AV_queue(&r.m_methodCalls, (*int32)(unsafe.Pointer(&r.m_numCalls)),
|
||||||
&method, int32(txn))
|
&method, int32(txn))
|
||||||
//C.AV_queue(&r.m_methodCalls, (*C.int)(unsafe.Pointer(&r.m_numCalls)), &method,
|
//C.AV_queue(&r.m_methodCalls, (*C.int)(unsafe.Pointer(&r.m_numCalls)), &method,
|
||||||
//C.int(txn))
|
//C.int(txn))
|
||||||
|
@ -1913,13 +1931,15 @@ func C_RTMP_SendPacket(r *C.RTMP, packet *C.RTMPPacket, queue int) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// int WriteN(RTMP* r, const char* buffer, int n);
|
||||||
|
// rtmp.c +1502
|
||||||
func C_WriteN(r *C.RTMP, buffer unsafe.Pointer, n int) int {
|
func C_WriteN(r *C.RTMP, buffer unsafe.Pointer, n int) int {
|
||||||
ptr := buffer
|
ptr := buffer
|
||||||
for n > 0 {
|
for n > 0 {
|
||||||
var nBytes int
|
var nBytes int
|
||||||
|
|
||||||
// TODO: port this if necessary
|
// TODO: port this if necessary
|
||||||
nBytes = int(C_SockBufSend(&r.m_sb, (*byte)(ptr), int32(n)))
|
nBytes = int(C_RTMPSockBuf_Send(&r.m_sb, (*byte)(ptr), int32(n)))
|
||||||
|
|
||||||
if nBytes < 0 {
|
if nBytes < 0 {
|
||||||
if debugMode {
|
if debugMode {
|
||||||
|
@ -1955,11 +1975,15 @@ var RTMPT_cmds = []string{
|
||||||
"close",
|
"close",
|
||||||
}
|
}
|
||||||
|
|
||||||
func C_SockBufSend(sb *C.RTMPSockBuf, buf *byte, l int32) int32 {
|
// int RTMPSockBuf_Send(RTMPSockBuf* sb, const char* buf, int len);
|
||||||
|
// rtmp.c +4297
|
||||||
|
func C_RTMPSockBuf_Send(sb *C.RTMPSockBuf, buf *byte, l int32) int32 {
|
||||||
return int32(C.send(sb.sb_socket, unsafe.Pointer(buf), C.size_t(l), 0))
|
return int32(C.send(sb.sb_socket, unsafe.Pointer(buf), C.size_t(l), 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
func C_AvQueue(vals **C.RTMP_METHOD, num *int32, av *C.AVal, txn int32) {
|
// void AV_queue(RTMP_METHOD** vals, int* num, AVal* av, int txn);
|
||||||
|
// rtmp.c +2414
|
||||||
|
func C_AV_queue(vals **C.RTMP_METHOD, num *int32, av *C.AVal, txn int32) {
|
||||||
if (*num & 0x0f) == 0 {
|
if (*num & 0x0f) == 0 {
|
||||||
// TODO: work out what to do with the realloc
|
// TODO: work out what to do with the realloc
|
||||||
//*vals = (*C.RTMP_METHOD)(realloc(unsafe.Pointer(*vals), int((*num+16)*
|
//*vals = (*C.RTMP_METHOD)(realloc(unsafe.Pointer(*vals), int((*num+16)*
|
||||||
|
@ -1981,27 +2005,33 @@ func C_AvQueue(vals **C.RTMP_METHOD, num *int32, av *C.AVal, txn int32) {
|
||||||
(*num)++
|
(*num)++
|
||||||
}
|
}
|
||||||
|
|
||||||
func C_AMFEncodeNamedNumber(output *byte, outend *byte, strName *C.AVal, dVal float64) *byte {
|
// char* AMF_EncodeNamedNumber(char* output, char* outend, const AVal* strName, double dVal);
|
||||||
|
// amf.c +286
|
||||||
|
func C_AMF_EncodeNamedNumber(output *byte, outend *byte, strName *C.AVal, dVal float64) *byte {
|
||||||
if int(uintptr(unsafe.Pointer(output)))+2+int(strName.av_len) > int(uintptr(unsafe.Pointer(outend))) {
|
if int(uintptr(unsafe.Pointer(output)))+2+int(strName.av_len) > int(uintptr(unsafe.Pointer(outend))) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
output = C_AMFEncodeInt16(output, outend, int16(strName.av_len))
|
output = C_AMF_EncodeInt16(output, outend, int16(strName.av_len))
|
||||||
memmove(unsafe.Pointer(output), unsafe.Pointer(strName.av_val), uintptr(strName.av_len))
|
memmove(unsafe.Pointer(output), unsafe.Pointer(strName.av_val), uintptr(strName.av_len))
|
||||||
output = (*byte)(incBytePtr(unsafe.Pointer(output), int(strName.av_len)))
|
output = (*byte)(incBytePtr(unsafe.Pointer(output), int(strName.av_len)))
|
||||||
return C_AMFEncodeNumber(output, outend, dVal)
|
return C_AMF_EncodeNumber(output, outend, dVal)
|
||||||
}
|
}
|
||||||
|
|
||||||
func C_AMFEncodeNamedBoolean(output *byte, outend *byte, strName *C.AVal, bVal int) *byte {
|
// char* AMF_EncodeNamedBoolean(char* output, char* outend, const AVal* strname, int bVal);
|
||||||
|
// amf.c +299
|
||||||
|
func C_AMF_EncodeNamedBoolean(output *byte, outend *byte, strName *C.AVal, bVal int) *byte {
|
||||||
if int(uintptr(unsafe.Pointer(output)))+2+int(strName.av_len) > int(uintptr(unsafe.Pointer(outend))) {
|
if int(uintptr(unsafe.Pointer(output)))+2+int(strName.av_len) > int(uintptr(unsafe.Pointer(outend))) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
output = C_AMFEncodeInt16(output, outend, int16(strName.av_len))
|
output = C_AMF_EncodeInt16(output, outend, int16(strName.av_len))
|
||||||
memmove(unsafe.Pointer(output), unsafe.Pointer(strName.av_val), uintptr(strName.av_len))
|
memmove(unsafe.Pointer(output), unsafe.Pointer(strName.av_val), uintptr(strName.av_len))
|
||||||
output = (*byte)(incBytePtr(unsafe.Pointer(output), int(strName.av_len)))
|
output = (*byte)(incBytePtr(unsafe.Pointer(output), int(strName.av_len)))
|
||||||
return C_AMFEncodeBoolean(output, outend, bVal)
|
return C_AMF_EncodeBoolean(output, outend, bVal)
|
||||||
}
|
}
|
||||||
|
|
||||||
func C_AMFEncodeBoolean(output *byte, outend *byte, bVal int) *byte {
|
// char* AMF_EncodeBoolean(char* output, char* outend, int bVal);
|
||||||
|
// amf.c +260
|
||||||
|
func C_AMF_EncodeBoolean(output *byte, outend *byte, bVal int) *byte {
|
||||||
if int(uintptr(unsafe.Pointer(output)))+2 > int(uintptr(unsafe.Pointer(outend))) {
|
if int(uintptr(unsafe.Pointer(output)))+2 > int(uintptr(unsafe.Pointer(outend))) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -2016,7 +2046,9 @@ func C_AMFEncodeBoolean(output *byte, outend *byte, bVal int) *byte {
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
func C_AMFEncodeNumber(output *byte, outend *byte, dVal float64) *byte {
|
// char* AMF_EncodeNumber(char* output, char* outend, double dVal);
|
||||||
|
// amf.c +199
|
||||||
|
func C_AMF_EncodeNumber(output *byte, outend *byte, dVal float64) *byte {
|
||||||
if int(uintptr(unsafe.Pointer(output)))+1+8 > int(uintptr(unsafe.Pointer(outend))) {
|
if int(uintptr(unsafe.Pointer(output)))+1+8 > int(uintptr(unsafe.Pointer(outend))) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -2034,7 +2066,9 @@ func C_AMFEncodeNumber(output *byte, outend *byte, dVal float64) *byte {
|
||||||
return (*byte)(incBytePtr(unsafe.Pointer(output), 8))
|
return (*byte)(incBytePtr(unsafe.Pointer(output), 8))
|
||||||
}
|
}
|
||||||
|
|
||||||
func C_AMFDecodeNumber(data *byte) float64 {
|
// double AMF_DecodeNumber(const char* data);
|
||||||
|
// amf.c +82
|
||||||
|
func C_AMF_DecodeNumber(data *byte) float64 {
|
||||||
var dVal float64
|
var dVal float64
|
||||||
var ci, co *uint8
|
var ci, co *uint8
|
||||||
ci = (*uint8)(unsafe.Pointer(data))
|
ci = (*uint8)(unsafe.Pointer(data))
|
||||||
|
@ -2045,21 +2079,24 @@ func C_AMFDecodeNumber(data *byte) float64 {
|
||||||
return dVal
|
return dVal
|
||||||
}
|
}
|
||||||
|
|
||||||
func C_AMFEncodeNamedString(output *byte, outend *byte, strName *C.AVal, strValue *C.AVal) *byte {
|
// char* AMF_EncodeNamedString(char* output, char* outend, const AVal* strName, const AVal* strValue);
|
||||||
|
// amf.c +273
|
||||||
|
func C_AMF_EncodeNamedString(output *byte, outend *byte, strName *C.AVal, strValue *C.AVal) *byte {
|
||||||
if int(uintptr(unsafe.Pointer(output)))+2+int(strName.av_len) > int(uintptr(unsafe.Pointer(outend))) {
|
if int(uintptr(unsafe.Pointer(output)))+2+int(strName.av_len) > int(uintptr(unsafe.Pointer(outend))) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
output = C_AMFEncodeInt16(output, outend, int16(strName.av_len))
|
output = C_AMF_EncodeInt16(output, outend, int16(strName.av_len))
|
||||||
memmove(unsafe.Pointer(output), unsafe.Pointer(strName.av_val), uintptr(strName.av_len))
|
memmove(unsafe.Pointer(output), unsafe.Pointer(strName.av_val), uintptr(strName.av_len))
|
||||||
output = (*byte)(incBytePtr(unsafe.Pointer(output), int(strName.av_len)))
|
output = (*byte)(incBytePtr(unsafe.Pointer(output), int(strName.av_len)))
|
||||||
return C_AMFEncodeString(output, outend, strValue)
|
return C_AMF_EncodeString(output, outend, strValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
// C_AMFDecodeString decodes data into a string inside a AVal
|
// void AMF_DecodeString(const char* data, AVal* bv);
|
||||||
func C_AMFDecodeString(data *byte, bv *C.AVal) {
|
// amf.c +68
|
||||||
|
func C_AMF_DecodeString(data *byte, bv *C.AVal) {
|
||||||
dataPtr := unsafe.Pointer(data)
|
dataPtr := unsafe.Pointer(data)
|
||||||
//bv.av_len = C.int(C.AMF_DecodeInt16((*C.char)(dataPtr)))
|
//bv.av_len = C.int(C.AMF_DecodeInt16((*C.char)(dataPtr)))
|
||||||
bv.av_len = C.int(C_AMFDecodeInt16((*byte)(dataPtr)))
|
bv.av_len = C.int(C_AMF_DecodeInt16((*byte)(dataPtr)))
|
||||||
if bv.av_len > 0 {
|
if bv.av_len > 0 {
|
||||||
bv.av_val = (*C.char)(incBytePtr(dataPtr, 2))
|
bv.av_val = (*C.char)(incBytePtr(dataPtr, 2))
|
||||||
} else {
|
} else {
|
||||||
|
@ -2067,13 +2104,15 @@ func C_AMFDecodeString(data *byte, bv *C.AVal) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// C_AMFDecodeInt16 decodes data into a 16 bit number
|
// unsigned short AMF_DecodeInt16(const char* data);
|
||||||
func C_AMFDecodeInt16(data *byte) uint16 {
|
// amf.c +41
|
||||||
|
func C_AMF_DecodeInt16(data *byte) uint16 {
|
||||||
c := unsafe.Pointer(data)
|
c := unsafe.Pointer(data)
|
||||||
return uint16(*(*uint8)(c)<<8 | *(*byte)(incBytePtr(c, 1)))
|
return uint16(*(*uint8)(c)<<8 | *(*byte)(incBytePtr(c, 1)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// C_AMFEncodeInt24 encodes a int24 into data
|
// char* AMF_EncodeInt24(char* output, char* outend, int nVal);
|
||||||
|
// amf.c +149
|
||||||
func C_AMFEncodeInt24(output *byte, outend *byte, nVal int32) *byte {
|
func C_AMFEncodeInt24(output *byte, outend *byte, nVal int32) *byte {
|
||||||
outputPtr := unsafe.Pointer(output)
|
outputPtr := unsafe.Pointer(output)
|
||||||
outendPtr := unsafe.Pointer(outend)
|
outendPtr := unsafe.Pointer(outend)
|
||||||
|
@ -2092,8 +2131,9 @@ func C_AMFEncodeInt24(output *byte, outend *byte, nVal int32) *byte {
|
||||||
return (*byte)(incBytePtr(outputPtr, 3))
|
return (*byte)(incBytePtr(outputPtr, 3))
|
||||||
}
|
}
|
||||||
|
|
||||||
// C_AMFDecodeInt24 decodes data into an unsigned int
|
// unsigned int AMF_DecodeInt24(const char* data);
|
||||||
func C_AMFDecodeInt24(data *byte) uint32 {
|
// amf.c +50
|
||||||
|
func C_AMF_DecodeInt24(data *byte) uint32 {
|
||||||
// TODO Understand logic and simplify
|
// TODO Understand logic and simplify
|
||||||
c := (*uint8)(unsafe.Pointer(data))
|
c := (*uint8)(unsafe.Pointer(data))
|
||||||
dst := uint32(int32(*c) << 16)
|
dst := uint32(int32(*c) << 16)
|
||||||
|
@ -2104,7 +2144,9 @@ func C_AMFDecodeInt24(data *byte) uint32 {
|
||||||
return dst
|
return dst
|
||||||
}
|
}
|
||||||
|
|
||||||
func C_AMFEncodeString(output *byte, outend *byte, bv *C.AVal) *byte {
|
// char* AMF_EncodeString(char* output, char* outend, const AVal* bv);
|
||||||
|
// amf.c +174
|
||||||
|
func C_AMF_EncodeString(output *byte, outend *byte, bv *C.AVal) *byte {
|
||||||
outputPtr := unsafe.Pointer(output)
|
outputPtr := unsafe.Pointer(output)
|
||||||
outendPtr := unsafe.Pointer(outend)
|
outendPtr := unsafe.Pointer(outend)
|
||||||
if (bv.av_len < 65536 && uintptr(incBytePtr(outputPtr, 1+2+int(bv.av_len))) >
|
if (bv.av_len < 65536 && uintptr(incBytePtr(outputPtr, 1+2+int(bv.av_len))) >
|
||||||
|
@ -2117,14 +2159,14 @@ func C_AMFEncodeString(output *byte, outend *byte, bv *C.AVal) *byte {
|
||||||
outputPtr = incBytePtr(outputPtr, 1)
|
outputPtr = incBytePtr(outputPtr, 1)
|
||||||
outputPtr = unsafe.Pointer(C.AMF_EncodeInt16((*C.char)(outputPtr), (*C.char)(
|
outputPtr = unsafe.Pointer(C.AMF_EncodeInt16((*C.char)(outputPtr), (*C.char)(
|
||||||
outendPtr), C.short(bv.av_len)))
|
outendPtr), C.short(bv.av_len)))
|
||||||
//outputPtr = unsafe.Pointer(C_AMFEncodeInt16((*byte)(outputPtr),
|
//outputPtr = unsafe.Pointer(C_AMF_EncodeInt16((*byte)(outputPtr),
|
||||||
//(*byte)(outendPtr), (int16)(bv.av_len)))
|
//(*byte)(outendPtr), (int16)(bv.av_len)))
|
||||||
} else {
|
} else {
|
||||||
*(*byte)(outputPtr) = AMF_LONG_STRING
|
*(*byte)(outputPtr) = AMF_LONG_STRING
|
||||||
outputPtr = incBytePtr(outputPtr, 1)
|
outputPtr = incBytePtr(outputPtr, 1)
|
||||||
outputPtr = unsafe.Pointer(C.AMF_EncodeInt32((*C.char)(outputPtr), (*C.char)(
|
outputPtr = unsafe.Pointer(C.AMF_EncodeInt32((*C.char)(outputPtr), (*C.char)(
|
||||||
outendPtr), C.int(bv.av_len)))
|
outendPtr), C.int(bv.av_len)))
|
||||||
//outputPtr = unsafe.Pointer(C_AMFEncodeInt32((*byte)(outputPtr),
|
//outputPtr = unsafe.Pointer(C_AMF_EncodeInt32((*byte)(outputPtr),
|
||||||
//(*byte)(outendPtr), (int32)(bv.av_len)))
|
//(*byte)(outendPtr), (int32)(bv.av_len)))
|
||||||
}
|
}
|
||||||
memmove(unsafe.Pointer(outputPtr), unsafe.Pointer(bv.av_val), uintptr(bv.av_len))
|
memmove(unsafe.Pointer(outputPtr), unsafe.Pointer(bv.av_val), uintptr(bv.av_len))
|
||||||
|
@ -2133,8 +2175,9 @@ func C_AMFEncodeString(output *byte, outend *byte, bv *C.AVal) *byte {
|
||||||
return (*byte)(outputPtr)
|
return (*byte)(outputPtr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// C_AMFEncodeInt16 encodes a int16 into data
|
// char* AMF_EncodeInt16(char* output, char* outend, short nVal);
|
||||||
func C_AMFEncodeInt16(output *byte, outend *byte, nVal int16) *byte {
|
// amf.c +138
|
||||||
|
func C_AMF_EncodeInt16(output *byte, outend *byte, nVal int16) *byte {
|
||||||
outputPtr := unsafe.Pointer(output)
|
outputPtr := unsafe.Pointer(output)
|
||||||
outendPtr := unsafe.Pointer(outend)
|
outendPtr := unsafe.Pointer(outend)
|
||||||
if uintptr(outputPtr)+2 > uintptr(outendPtr) {
|
if uintptr(outputPtr)+2 > uintptr(outendPtr) {
|
||||||
|
@ -2149,8 +2192,9 @@ func C_AMFEncodeInt16(output *byte, outend *byte, nVal int16) *byte {
|
||||||
return (*byte)(incBytePtr(outputPtr, 2))
|
return (*byte)(incBytePtr(outputPtr, 2))
|
||||||
}
|
}
|
||||||
|
|
||||||
// C_AMFEncodeInt32 encodes a int32 into data
|
// char* AMF_EncodeInt32(char* output, char* outend, int nVal);
|
||||||
func C_AMFEncodeInt32(output *byte, outend *byte, nVal int32) *byte {
|
// amf.c +161
|
||||||
|
func C_AMF_EncodeInt32(output *byte, outend *byte, nVal int32) *byte {
|
||||||
outputPtr := unsafe.Pointer(output)
|
outputPtr := unsafe.Pointer(output)
|
||||||
outendPtr := unsafe.Pointer(outend)
|
outendPtr := unsafe.Pointer(outend)
|
||||||
if uintptr(outputPtr)+4 > uintptr(outendPtr) {
|
if uintptr(outputPtr)+4 > uintptr(outendPtr) {
|
||||||
|
|
Loading…
Reference in New Issue