mirror of https://bitbucket.org/ausocean/av.git
Ported amfEncode - need to test
This commit is contained in:
parent
558c27ffbc
commit
51fc5b49af
34
rtmp/rtmp.go
34
rtmp/rtmp.go
|
@ -314,8 +314,6 @@ type RTMPChunk struct {
|
||||||
c_header [RTMP_MAX_HEADER_SIZE]byte
|
c_header [RTMP_MAX_HEADER_SIZE]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
type ushort [2]byte
|
|
||||||
|
|
||||||
type RTMP_LNK struct {
|
type RTMP_LNK struct {
|
||||||
hostname AVal
|
hostname AVal
|
||||||
sockshost AVal
|
sockshost AVal
|
||||||
|
@ -341,8 +339,8 @@ type RTMP_LNK struct {
|
||||||
protocol int
|
protocol int
|
||||||
timeout int
|
timeout int
|
||||||
pFlags int
|
pFlags int
|
||||||
socksport ushort
|
socksport uint16
|
||||||
port ushort
|
port uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
type AMFObject struct {
|
type AMFObject struct {
|
||||||
|
@ -1167,6 +1165,34 @@ func amfPropEncode(p *C.AMFObjectProperty, pBuffer *byte, pBufEnd *byte) *byte {
|
||||||
return pBuffer
|
return pBuffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func amfEncode(obj *AMFObject, pBuffer *byte, pBufEnd *byte) *byte {
|
||||||
|
if uintptr(unsafe.Pointer(pBuffer))+uintptr(4) >= uintptr(unsafe.Pointer(pBufEnd)) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
*(*byte)(unsafe.Pointer(pBuffer)) = AMF_OBJECT
|
||||||
|
pBuffer = (*byte)(incBytePtr(unsafe.Pointer(pBuffer), 1))
|
||||||
|
|
||||||
|
for i := 0; i < int(obj.o_num); i++ {
|
||||||
|
res := amfPropEncode((*C.AMFObjectProperty)(incPtr(unsafe.Pointer(
|
||||||
|
obj.o_props), i, int(unsafe.Sizeof(*obj.o_props)))), pBuffer, pBufEnd)
|
||||||
|
if res == nil {
|
||||||
|
log.Println("amfEncode: failed to encode property in index")
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
pBuffer = res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if uintptr(incBytePtr(unsafe.Pointer(pBuffer), 3)) >= uintptr(unsafe.Pointer(pBufEnd)) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
pBuffer = amfEncodeInt24(pBuffer, pBufEnd, int32(AMF_OBJECT_END))
|
||||||
|
|
||||||
|
return pBuffer
|
||||||
|
}
|
||||||
|
|
||||||
func rtmpConnectStream(r *C.RTMP, seekTime int32) int {
|
func rtmpConnectStream(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)))
|
||||||
|
|
Loading…
Reference in New Issue