mirror of https://bitbucket.org/ausocean/av.git
Fixed alot of errors in code, now runnable
This commit is contained in:
parent
28ae89ac29
commit
358e32d2ac
141
rtmp/rtmp.go
141
rtmp/rtmp.go
|
@ -244,11 +244,11 @@ type C_RTMP struct {
|
||||||
m_bSendCounter uint8
|
m_bSendCounter uint8
|
||||||
m_numInvokes int
|
m_numInvokes int
|
||||||
m_numCalls int
|
m_numCalls int
|
||||||
m_methodCalls *RTMP_METHOD
|
m_methodCalls *C.RTMP_METHOD
|
||||||
m_channelsAllocatedIn int
|
m_channelsAllocatedIn int
|
||||||
m_channelsAllocatedOut int
|
m_channelsAllocatedOut int
|
||||||
m_vecChannelsIn **RTMPPacket
|
m_vecChannelsIn **C.RTMPPacket
|
||||||
m_vecChannelsOut **RTMPPacket
|
m_vecChannelsOut **C.RTMPPacket
|
||||||
m_channelTimestamp *int
|
m_channelTimestamp *int
|
||||||
m_fAudioCodecs float64
|
m_fAudioCodecs float64
|
||||||
m_fVideoCodecs float64
|
m_fVideoCodecs float64
|
||||||
|
@ -258,11 +258,11 @@ type C_RTMP struct {
|
||||||
m_polling int
|
m_polling int
|
||||||
m_resplen int
|
m_resplen int
|
||||||
m_unackd int
|
m_unackd int
|
||||||
m_clientID AVal
|
m_clientID C.AVal
|
||||||
m_read RTMP_READ
|
m_read C.RTMP_READ
|
||||||
m_write RTMPPacket
|
m_write C.RTMPPacket
|
||||||
m_sb RTMPSockBuf
|
m_sb C.RTMPSockBuf
|
||||||
Link RTMP_LNK
|
Link C.RTMP_LNK
|
||||||
}
|
}
|
||||||
|
|
||||||
// typedef struct RTMPPacket
|
// typedef struct RTMPPacket
|
||||||
|
@ -276,18 +276,18 @@ type C_RTMPPacket struct {
|
||||||
m_nInfoField2 int32
|
m_nInfoField2 int32
|
||||||
m_nBodySize uint32
|
m_nBodySize uint32
|
||||||
m_nBytesRead uint32
|
m_nBytesRead uint32
|
||||||
m_chunk *RTMPChunk
|
m_chunk *C.RTMPChunk
|
||||||
m_body *byte
|
m_body *byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// typedef struct RTMPMethod
|
// typedef struct RTMPMethod
|
||||||
// rtmp.h +231
|
// rtmp.h +231
|
||||||
type C_RTMP_METHOD struct {
|
type C_RTMP_METHOD struct {
|
||||||
name AVal
|
name C.AVal
|
||||||
num int
|
num int
|
||||||
}
|
}
|
||||||
|
|
||||||
// typedef struct AVal
|
// typedef struct C.AVal
|
||||||
// amf.h +57
|
// amf.h +57
|
||||||
type C_AVal struct {
|
type C_AVal struct {
|
||||||
av_val *byte
|
av_val *byte
|
||||||
|
@ -337,22 +337,22 @@ type C_RTMPChunk struct {
|
||||||
// typedef struct RTMP_LNK
|
// typedef struct RTMP_LNK
|
||||||
// rtmp.h +144
|
// rtmp.h +144
|
||||||
type C_RTMP_LNK struct {
|
type C_RTMP_LNK struct {
|
||||||
hostname AVal
|
hostname C.AVal
|
||||||
sockshost AVal
|
sockshost C.AVal
|
||||||
playpath0 AVal
|
playpath0 C.AVal
|
||||||
playpath AVal
|
playpath C.AVal
|
||||||
tcUrl AVal
|
tcUrl C.AVal
|
||||||
swfUrl AVal
|
swfUrl C.AVal
|
||||||
pageUrl AVal
|
pageUrl C.AVal
|
||||||
app AVal
|
app C.AVal
|
||||||
auth AVal
|
auth C.AVal
|
||||||
flashVer AVal
|
flashVer C.AVal
|
||||||
subscribepath AVal
|
subscribepath C.AVal
|
||||||
usherToken AVal
|
usherToken C.AVal
|
||||||
token AVal
|
token C.AVal
|
||||||
pubUser AVal
|
pubUser C.AVal
|
||||||
pubPasswd AVal
|
pubPasswd C.AVal
|
||||||
extras AMFObject
|
extras C.AMFObject
|
||||||
edepth int
|
edepth int
|
||||||
seekTime int
|
seekTime int
|
||||||
stopTime int
|
stopTime int
|
||||||
|
@ -374,7 +374,7 @@ type C_AMFObject struct {
|
||||||
|
|
||||||
// NewSession returns a new session.
|
// NewSession returns a new session.
|
||||||
func NewSession(url string, connectTimeout uint) Session {
|
func NewSession(url string, connectTimeout uint) Session {
|
||||||
return &session{
|
return Session{
|
||||||
url: url,
|
url: url,
|
||||||
timeout: connectTimeout,
|
timeout: connectTimeout,
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ func NewSession(url string, connectTimeout uint) Session {
|
||||||
|
|
||||||
// Open establishes an rtmp connection with the url passed into the
|
// Open establishes an rtmp connection with the url passed into the
|
||||||
// constructor
|
// constructor
|
||||||
func (s *session) Open() error {
|
func (s *Session) Open() error {
|
||||||
if s.rtmp != nil {
|
if s.rtmp != nil {
|
||||||
return errors.New("rtmp: attempt to start already running session")
|
return errors.New("rtmp: attempt to start already running session")
|
||||||
}
|
}
|
||||||
|
@ -395,7 +395,7 @@ func (s *session) Open() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close terminates the rtmp connection
|
// Close terminates the rtmp connection
|
||||||
func (s *session) Close() error {
|
func (s *Session) Close() error {
|
||||||
if s.rtmp == nil {
|
if s.rtmp == nil {
|
||||||
return Err(3)
|
return Err(3)
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ func (s *session) Close() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write writes a frame (flv tag) to the rtmp connection
|
// Write writes a frame (flv tag) to the rtmp connection
|
||||||
func (s *session) Write(data []byte) (int, error) {
|
func (s *Session) Write(data []byte) (int, error) {
|
||||||
if s.rtmp == nil {
|
if s.rtmp == nil {
|
||||||
return 0, Err(3)
|
return 0, Err(3)
|
||||||
}
|
}
|
||||||
|
@ -566,14 +566,14 @@ func C_RTMP_SetupURL(r *C.RTMP, u string) int32 {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// void SocksSetup(RTMP *r, AVal* sockshost);
|
// void SocksSetup(RTMP *r, C.AVal* sockshost);
|
||||||
// rtmp.c +410
|
// rtmp.c +410
|
||||||
func C_SocksSetup(r *C.RTMP, sockshost *C.AVal) {
|
func C_SocksSetup(r *C.RTMP, sockshost *C.AVal) {
|
||||||
if sockshost.av_len != 0 {
|
if sockshost.av_len != 0 {
|
||||||
socksport := strchr((*byte)(unsafe.Pointer(sockshost.av_val)), ':')
|
socksport := strchr((*byte)(unsafe.Pointer(sockshost.av_val)), ':')
|
||||||
hostname := strdup((*byte)(unsafe.Pointer(sockshost.av_val)))
|
hostname := strdup((*byte)(unsafe.Pointer(sockshost.av_val)))
|
||||||
|
|
||||||
if uintptr(unsafe.Pointer(socksport)) != nil {
|
if unsafe.Pointer(socksport) != nil {
|
||||||
*indxBytePtr(unsafe.Pointer(hostname),
|
*indxBytePtr(unsafe.Pointer(hostname),
|
||||||
int(uintptr(decBytePtr(unsafe.Pointer(socksport),
|
int(uintptr(decBytePtr(unsafe.Pointer(socksport),
|
||||||
int(uintptr(unsafe.Pointer(sockshost.av_val))))))) = '\000'
|
int(uintptr(unsafe.Pointer(sockshost.av_val))))))) = '\000'
|
||||||
|
@ -762,7 +762,9 @@ func C_RTMP_Connect0(r *C.RTMP, service *C.sockaddr) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
tv := C.int(r.Link.timeout * 1000)
|
var tv int32
|
||||||
|
SET_RCVTIMEO(&tv, int32(r.Link.timeout))
|
||||||
|
// tv := C.int(r.Link.timeout * 1000)
|
||||||
|
|
||||||
if C.setsockopt(r.m_sb.sb_socket, C.SOL_SOCKET, C.SO_RCVTIMEO,
|
if C.setsockopt(r.m_sb.sb_socket, C.SOL_SOCKET, C.SO_RCVTIMEO,
|
||||||
unsafe.Pointer(&tv), C.socklen_t(unsafe.Sizeof(tv))) != 0 {
|
unsafe.Pointer(&tv), C.socklen_t(unsafe.Sizeof(tv))) != 0 {
|
||||||
|
@ -776,6 +778,10 @@ func C_RTMP_Connect0(r *C.RTMP, service *C.sockaddr) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SET_RCVTIMEO(tv *int32, s int32) {
|
||||||
|
*tv = s * 1000
|
||||||
|
}
|
||||||
|
|
||||||
// int RTMP_Connect1(RTMP* r, RTMPPacket* cp);
|
// int RTMP_Connect1(RTMP* r, RTMPPacket* cp);
|
||||||
// rtmp.c +978
|
// rtmp.c +978
|
||||||
func C_RTMP_Connect1(r *C.RTMP, cp *C.RTMPPacket) int {
|
func C_RTMP_Connect1(r *C.RTMP, cp *C.RTMPPacket) int {
|
||||||
|
@ -1332,7 +1338,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_RTMPPacketIsReady(&packet) != 0 {
|
if C_RTMPPacket_IsReady(&packet) != 0 {
|
||||||
if packet.m_nBodySize == 0 {
|
if packet.m_nBodySize == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -1361,7 +1367,6 @@ func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
|
||||||
var header *byte
|
var header *byte
|
||||||
header = (*byte)(unsafe.Pointer(&hbuf[0]))
|
header = (*byte)(unsafe.Pointer(&hbuf[0]))
|
||||||
var nSize, hSize, nToRead, nChunk int32
|
var nSize, hSize, nToRead, nChunk int32
|
||||||
var didAlloc int32 = 0
|
|
||||||
var extendedTimestamp int32
|
var extendedTimestamp int32
|
||||||
|
|
||||||
if C_ReadN(r, (*byte)(&hbuf[0]), 1) == 0 {
|
if C_ReadN(r, (*byte)(&hbuf[0]), 1) == 0 {
|
||||||
|
@ -1423,7 +1428,7 @@ func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
|
||||||
|
|
||||||
memset((*byte)(incPtr(unsafe.Pointer(r.m_channelTimestamp),
|
memset((*byte)(incPtr(unsafe.Pointer(r.m_channelTimestamp),
|
||||||
int(r.m_channelsAllocatedIn), int(unsafe.Sizeof(*r.m_channelTimestamp)))),
|
int(r.m_channelsAllocatedIn), int(unsafe.Sizeof(*r.m_channelTimestamp)))),
|
||||||
0, int(int32Size*int32((n-int32(r.m_channelsAllocatedIn)))))
|
0, int(4*int32((n-int32(r.m_channelsAllocatedIn)))))
|
||||||
memset((*byte)(incPtr(unsafe.Pointer(r.m_vecChannelsIn), int(
|
memset((*byte)(incPtr(unsafe.Pointer(r.m_vecChannelsIn), int(
|
||||||
r.m_channelsAllocatedIn), int(unsafe.Sizeof(*r.m_vecChannelsIn)))), 0,
|
r.m_channelsAllocatedIn), int(unsafe.Sizeof(*r.m_vecChannelsIn)))), 0,
|
||||||
int(int32(unsafe.Sizeof(*packets))*(n-int32(r.m_channelsAllocatedIn))))
|
int(int32(unsafe.Sizeof(*packets))*(n-int32(r.m_channelsAllocatedIn))))
|
||||||
|
@ -1496,7 +1501,6 @@ func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
|
||||||
log.Println("RTMPRead_Packet: failed to allocate packet")
|
log.Println("RTMPRead_Packet: failed to allocate packet")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
didAlloc = TRUE
|
|
||||||
packet.m_headerType = C.uint8_t((hbuf[0] & 0xc0) >> 6)
|
packet.m_headerType = C.uint8_t((hbuf[0] & 0xc0) >> 6)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1519,7 +1523,7 @@ func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
|
||||||
if C_ReadN(r, (*byte)(incBytePtr(unsafe.Pointer(packet.m_body), int(packet.m_nBytesRead))),
|
if C_ReadN(r, (*byte)(incBytePtr(unsafe.Pointer(packet.m_body), int(packet.m_nBytesRead))),
|
||||||
int(nChunk)) != int(nChunk) {
|
int(nChunk)) != int(nChunk) {
|
||||||
log.Println("C_RTMP_ReadPacket: failed to read RTMP packet body")
|
log.Println("C_RTMP_ReadPacket: failed to read RTMP packet body")
|
||||||
return FALSE
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.m_nBytesRead += C.uint32_t(nChunk)
|
packet.m_nBytesRead += C.uint32_t(nChunk)
|
||||||
|
@ -1534,7 +1538,7 @@ func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
|
||||||
}
|
}
|
||||||
memmove(unsafe.Pointer(*(**C.RTMPPacket)(incPtr(unsafe.Pointer(
|
memmove(unsafe.Pointer(*(**C.RTMPPacket)(incPtr(unsafe.Pointer(
|
||||||
r.m_vecChannelsIn), int(packet.m_nChannel), int(unsafe.Sizeof(tmpPktPtr))))),
|
r.m_vecChannelsIn), int(packet.m_nChannel), int(unsafe.Sizeof(tmpPktPtr))))),
|
||||||
unsafe.Pointer(packet), unsafe.Sizeof(tmpPkt))
|
unsafe.Pointer(packet), unsafe.Sizeof(tmpPktPtr))
|
||||||
|
|
||||||
if extendedTimestamp != 0 {
|
if extendedTimestamp != 0 {
|
||||||
(*(**C.RTMPPacket)(incPtr(unsafe.Pointer(
|
(*(**C.RTMPPacket)(incPtr(unsafe.Pointer(
|
||||||
|
@ -1543,30 +1547,31 @@ func C_RTMP_ReadPacket(r *C.RTMP, packet *C.RTMPPacket) int32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: port this
|
// TODO: port this
|
||||||
if C.RTMPPacket_IsRead(packet) != 0 {
|
if C_RTMPPacket_IsReady(packet) != 0 {
|
||||||
if !packet.m_hasAbsTimestamp {
|
if packet.m_hasAbsTimestamp == 0 {
|
||||||
// timestamps seem to always be relative
|
// timestamps seem to always be relative
|
||||||
packet.m_nTimeStamp += r.m_channelTimestamp[packet.m_nChannel]
|
packet.m_nTimeStamp += *(*C.uint32_t)(incPtr(unsafe.Pointer(r.m_channelTimestamp),
|
||||||
|
int(packet.m_nChannel), 4))
|
||||||
}
|
}
|
||||||
r.m_channelTimestamp[packet.m_nChannel] = packet.m_nTimeStamp
|
*(*C.uint32_t)(incPtr(unsafe.Pointer(r.m_channelTimestamp), int(packet.m_nChannel),
|
||||||
|
4)) = packet.m_nTimeStamp
|
||||||
|
|
||||||
/* reset the data from the stored packet. we keep the header since we may
|
(*(**C.RTMPPacket)(incPtr(unsafe.Pointer(r.m_vecChannelsIn), int(packet.m_nChannel),
|
||||||
use it later if a new packet for this channel
|
int(unsafe.Sizeof(*r.m_vecChannelsIn))))).m_body = nil
|
||||||
arrives and requests to re-use some info (small packet header) */
|
(*(**C.RTMPPacket)(incPtr(unsafe.Pointer(r.m_vecChannelsIn), int(packet.m_nChannel),
|
||||||
r.m_vecChannelsIn[packet.m_nChannel].m_body = NULL
|
int(unsafe.Sizeof(*r.m_vecChannelsIn))))).m_nBytesRead = 0
|
||||||
r.m_vecChannelsIn[packet.m_nChannel].m_nBytesRead = 0
|
(*(**C.RTMPPacket)(incPtr(unsafe.Pointer(r.m_vecChannelsIn), int(packet.m_nChannel),
|
||||||
/* can only be false if we reuse header */
|
int(unsafe.Sizeof(*r.m_vecChannelsIn))))).m_hasAbsTimestamp = 0
|
||||||
r.m_vecChannelsIn[packet.m_nChannel].m_hasAbsTimestamp = FALSE
|
|
||||||
} else {
|
} else {
|
||||||
packet.m_body = nil /* so it won't be erased on free */
|
packet.m_body = nil /* so it won't be erased on free */
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// #define RTMPPacket_IsReady(a)
|
// #define RTMPPacket_IsReady(a)
|
||||||
// rtmp.h +142
|
// rtmp.h +142
|
||||||
func C_RTMPPacketIsReady(p *C.RTMPPacket) int {
|
func C_RTMPPacket_IsReady(p *C.RTMPPacket) int {
|
||||||
if p.m_nBytesRead == p.m_nBodySize {
|
if p.m_nBytesRead == p.m_nBodySize {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
@ -1987,7 +1992,7 @@ 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))
|
||||||
}
|
}
|
||||||
|
|
||||||
// void AV_queue(RTMP_METHOD** vals, int* num, AVal* av, int txn);
|
// void AV_queue(RTMP_METHOD** vals, int* num, C.AVal* av, int txn);
|
||||||
// rtmp.c +2414
|
// rtmp.c +2414
|
||||||
func C_AV_queue(vals **C.RTMP_METHOD, num *int32, av *C.AVal, txn int32) {
|
func C_AV_queue(vals **C.RTMP_METHOD, num *int32, av *C.AVal, txn int32) {
|
||||||
if (*num & 0x0f) == 0 {
|
if (*num & 0x0f) == 0 {
|
||||||
|
@ -2011,7 +2016,7 @@ func C_AV_queue(vals **C.RTMP_METHOD, num *int32, av *C.AVal, txn int32) {
|
||||||
(*num)++
|
(*num)++
|
||||||
}
|
}
|
||||||
|
|
||||||
// char* AMF_EncodeNamedNumber(char* output, char* outend, const AVal* strName, double dVal);
|
// char* AMF_EncodeNamedNumber(char* output, char* outend, const C.AVal* strName, double dVal);
|
||||||
// amf.c +286
|
// amf.c +286
|
||||||
func C_AMF_EncodeNamedNumber(output *byte, outend *byte, strName *C.AVal, dVal float64) *byte {
|
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))) {
|
||||||
|
@ -2023,7 +2028,7 @@ func C_AMF_EncodeNamedNumber(output *byte, outend *byte, strName *C.AVal, dVal f
|
||||||
return C_AMF_EncodeNumber(output, outend, dVal)
|
return C_AMF_EncodeNumber(output, outend, dVal)
|
||||||
}
|
}
|
||||||
|
|
||||||
// char* AMF_EncodeNamedBoolean(char* output, char* outend, const AVal* strname, int bVal);
|
// char* AMF_EncodeNamedBoolean(char* output, char* outend, const C.AVal* strname, int bVal);
|
||||||
// amf.c +299
|
// amf.c +299
|
||||||
func C_AMF_EncodeNamedBoolean(output *byte, outend *byte, strName *C.AVal, bVal int) *byte {
|
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))) {
|
||||||
|
@ -2085,7 +2090,7 @@ func C_AMF_DecodeNumber(data *byte) float64 {
|
||||||
return dVal
|
return dVal
|
||||||
}
|
}
|
||||||
|
|
||||||
// char* AMF_EncodeNamedString(char* output, char* outend, const AVal* strName, const AVal* strValue);
|
// char* AMF_EncodeNamedString(char* output, char* outend, const C.AVal* strName, const C.AVal* strValue);
|
||||||
// amf.c +273
|
// amf.c +273
|
||||||
func C_AMF_EncodeNamedString(output *byte, outend *byte, strName *C.AVal, strValue *C.AVal) *byte {
|
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))) {
|
||||||
|
@ -2097,7 +2102,7 @@ func C_AMF_EncodeNamedString(output *byte, outend *byte, strName *C.AVal, strVal
|
||||||
return C_AMF_EncodeString(output, outend, strValue)
|
return C_AMF_EncodeString(output, outend, strValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
// void AMF_DecodeString(const char* data, AVal* bv);
|
// void AMF_DecodeString(const char* data, C.AVal* bv);
|
||||||
// amf.c +68
|
// amf.c +68
|
||||||
func C_AMF_DecodeString(data *byte, bv *C.AVal) {
|
func C_AMF_DecodeString(data *byte, bv *C.AVal) {
|
||||||
dataPtr := unsafe.Pointer(data)
|
dataPtr := unsafe.Pointer(data)
|
||||||
|
@ -2150,7 +2155,7 @@ func C_AMF_DecodeInt24(data *byte) uint32 {
|
||||||
return dst
|
return dst
|
||||||
}
|
}
|
||||||
|
|
||||||
// char* AMF_EncodeString(char* output, char* outend, const AVal* bv);
|
// char* AMF_EncodeString(char* output, char* outend, const C.AVal* bv);
|
||||||
// amf.c +174
|
// amf.c +174
|
||||||
func C_AMF_EncodeString(output *byte, outend *byte, bv *C.AVal) *byte {
|
func C_AMF_EncodeString(output *byte, outend *byte, bv *C.AVal) *byte {
|
||||||
outputPtr := unsafe.Pointer(output)
|
outputPtr := unsafe.Pointer(output)
|
||||||
|
@ -2329,35 +2334,35 @@ func allocate(nOfBytes uintptr) unsafe.Pointer {
|
||||||
|
|
||||||
// indxBytePtr returns a byte at the indx inc give a ptr
|
// indxBytePtr returns a byte at the indx inc give a ptr
|
||||||
func indxBytePtr(ptr unsafe.Pointer, inc int) *byte {
|
func indxBytePtr(ptr unsafe.Pointer, inc int) *byte {
|
||||||
return (*byte)(incPtr(ptr, inc, byteSize))
|
return (*byte)(incPtr(ptr, inc, 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
// indxInt32Ptr returns an int32 at the indx inc given a ptr
|
// indxInt32Ptr returns an int32 at the indx inc given a ptr
|
||||||
func indxInt32Ptr(ptr unsafe.Pointer, inc int) *int32 {
|
func indxInt32Ptr(ptr unsafe.Pointer, inc int) *int32 {
|
||||||
return (*int32)(incPtr(ptr, inc, int32Size))
|
return (*int32)(incPtr(ptr, inc, 4))
|
||||||
}
|
}
|
||||||
|
|
||||||
// indxInt64Ptr returns an int64 at the indx inc given a ptr
|
// indxInt64Ptr returns an int64 at the indx inc given a ptr
|
||||||
func indxInt64Ptr(ptr unsafe.Pointer, inc int) *int64 {
|
func indxInt64Ptr(ptr unsafe.Pointer, inc int) *int64 {
|
||||||
return (*int64)(incPtr(ptr, inc, int64Size))
|
return (*int64)(incPtr(ptr, inc, 8))
|
||||||
}
|
}
|
||||||
|
|
||||||
// incBytePtr returns an unsafe.Pointer to a byte that is inc positive positions
|
// incBytePtr returns an unsafe.Pointer to a byte that is inc positive positions
|
||||||
// from the passed ptr
|
// from the passed ptr
|
||||||
func incBytePtr(ptr unsafe.Pointer, inc int) unsafe.Pointer {
|
func incBytePtr(ptr unsafe.Pointer, inc int) unsafe.Pointer {
|
||||||
return incPtr(ptr, inc, byteSize)
|
return incPtr(ptr, inc, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// incInt32Ptr returns an unsafe.Pointer to an int32 that is inc positive
|
// incInt32Ptr returns an unsafe.Pointer to an int32 that is inc positive
|
||||||
// positions from the passed ptr
|
// positions from the passed ptr
|
||||||
func incInt32Ptr(ptr unsafe.Pointer, inc int) unsafe.Pointer {
|
func incInt32Ptr(ptr unsafe.Pointer, inc int) unsafe.Pointer {
|
||||||
return incPtr(ptr, inc, int32Size)
|
return incPtr(ptr, inc, 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
// incInt64Ptr returns an unsafe.Pointer to an int64 that is inc positive
|
// incInt64Ptr returns an unsafe.Pointer to an int64 that is inc positive
|
||||||
// positions from the passed ptr
|
// positions from the passed ptr
|
||||||
func incInt64Ptr(ptr unsafe.Pointer, inc int) unsafe.Pointer {
|
func incInt64Ptr(ptr unsafe.Pointer, inc int) unsafe.Pointer {
|
||||||
return incPtr(ptr, inc, int64Size)
|
return incPtr(ptr, inc, 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
// incPtr attempts to replicate C like pointer arithmatic functionality
|
// incPtr attempts to replicate C like pointer arithmatic functionality
|
||||||
|
@ -2373,19 +2378,19 @@ func decPtr(ptr unsafe.Pointer, dec, typeSize int) unsafe.Pointer {
|
||||||
// decBytePtr returns an unsafe.Pointer to a byte that is dec negative positions
|
// decBytePtr returns an unsafe.Pointer to a byte that is dec negative positions
|
||||||
// from ptr
|
// from ptr
|
||||||
func decBytePtr(ptr unsafe.Pointer, dec int) unsafe.Pointer {
|
func decBytePtr(ptr unsafe.Pointer, dec int) unsafe.Pointer {
|
||||||
return decPtr(ptr, dec, byteSize)
|
return decPtr(ptr, dec, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// decBytePtr returns an unsafe.Pointer to a int32 that is dec negative positions
|
// decBytePtr returns an unsafe.Pointer to a int32 that is dec negative positions
|
||||||
// from ptr
|
// from ptr
|
||||||
func decInt32Ptr(ptr unsafe.Pointer, dec int) unsafe.Pointer {
|
func decInt32Ptr(ptr unsafe.Pointer, dec int) unsafe.Pointer {
|
||||||
return decPtr(ptr, dec, int32Size)
|
return decPtr(ptr, dec, 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
// decBytePtr returns an unsafe.Pointer to a int64 that is dec negative positions
|
// decBytePtr returns an unsafe.Pointer to a int64 that is dec negative positions
|
||||||
// from ptr
|
// from ptr
|
||||||
func decInt64Ptr(ptr unsafe.Pointer, dec int) unsafe.Pointer {
|
func decInt64Ptr(ptr unsafe.Pointer, dec int) unsafe.Pointer {
|
||||||
return decPtr(ptr, dec, int64Size)
|
return decPtr(ptr, dec, 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
// sliceToPtr get's the address of the first data element and returns as unsafe
|
// sliceToPtr get's the address of the first data element and returns as unsafe
|
||||||
|
|
Loading…
Reference in New Issue