mirror of https://bitbucket.org/ausocean/av.git
Got rid of build errors, just need to test
This commit is contained in:
parent
736e96142c
commit
0d7d445804
40
rtmp/rtmp.go
40
rtmp/rtmp.go
|
@ -863,23 +863,23 @@ func sendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
|||
|
||||
if r.Link.protocol&RTMP_FEATURE_WRITE == 0 {
|
||||
// TODO: port this
|
||||
enc = C.AMF_EncodeNamedBoolean(enc, pend, &av_fpad, 0)
|
||||
enc = amfEncodeNamedBoolean(enc, pend, &av_fpad, 0)
|
||||
if enc == nil {
|
||||
return 0
|
||||
}
|
||||
enc = C.AMF_EncodeNamedNumber(enc, pend, &av_capabilities, 15.0)
|
||||
enc = amfEncodeNamedNumber(enc, pend, &av_capabilities, 15.0)
|
||||
if enc == nil {
|
||||
return 0
|
||||
}
|
||||
enc = C.AMF_EncodeNamedNumber(enc, pend, &av_audioCodecs, r.m_fAudioCodecs)
|
||||
enc = amfEncodeNamedNumber(enc, pend, &av_audioCodecs, float64(r.m_fAudioCodecs))
|
||||
if enc == nil {
|
||||
return 0
|
||||
}
|
||||
enc = C.AMF_EncodeNamedNumber(enc, pend, &av_videoCodecs, r.m_fVideoCodecs)
|
||||
enc = amfEncodeNamedNumber(enc, pend, &av_videoCodecs, float64(r.m_fVideoCodecs))
|
||||
if enc == nil {
|
||||
return 0
|
||||
}
|
||||
enc = C.AMF_EncodeNamedNumber(enc, pend, &av_videoFunction, 1.0)
|
||||
enc = amfEncodeNamedNumber(enc, pend, &av_videoFunction, 1.0)
|
||||
if enc == nil {
|
||||
return 0
|
||||
}
|
||||
|
@ -892,7 +892,7 @@ func sendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
|||
}
|
||||
|
||||
if r.m_fEncoding != 0.0 || r.m_bSendEncoding != 0 {
|
||||
enc = C.AMF_EncodeNamedNumber(enc, pend, &av_objectEncoding, r.m_fEncoding)
|
||||
enc = amfEncodeNamedNumber(enc, pend, &av_objectEncoding, float64(r.m_fEncoding))
|
||||
if enc == nil {
|
||||
return 0
|
||||
}
|
||||
|
@ -913,8 +913,7 @@ func sendConnectPacket(r *C.RTMP, cp *C.RTMPPacket) int {
|
|||
/* add auth string */
|
||||
if r.Link.auth.av_len != 0 {
|
||||
// TODO: port this
|
||||
enc = (*byte)(unsafe.Pointer(C.AMF_EncodeBoolean((*C.char)(unsafe.Pointer(enc)), (*C.char)(
|
||||
unsafe.Pointer(pend)), r.Link.lFlags&RTMP_LF_AUTH)))
|
||||
enc = amfEncodeBoolean(enc, pend, int(r.Link.lFlags&RTMP_LF_AUTH))
|
||||
if enc == nil {
|
||||
return 0
|
||||
}
|
||||
|
@ -1430,37 +1429,46 @@ func amfEncodeNamedNumber(output *byte, outend *byte, strName *C.AVal, dVal floa
|
|||
return amfEncodeNumber(output, outend, dVal)
|
||||
}
|
||||
|
||||
func amfEncodeNamedBoolean(output *byte, outend *byte, strName *AVal, bVal int) *byte {
|
||||
func amfEncodeNamedBoolean(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))) {
|
||||
return nil
|
||||
}
|
||||
output = amfEncodeInt16(output, outend, int16(strName.av_len))
|
||||
memmove(unsafe.Pointer(output), unsafe.Pointer(outend), uintptr(strName.av_len))
|
||||
output = (*byte)(incBytePtr(unsafe.Pointer(output), int(strName.av_len)))
|
||||
return amfEncodeBoolean(output, outend, bVal)
|
||||
}
|
||||
|
||||
return amfEncodeBoolean(output, outend, dVal)
|
||||
func amfEncodeBoolean(output *byte, outend *byte, bVal int) *byte {
|
||||
if int(uintptr(unsafe.Pointer(output)))+2 > int(uintptr(unsafe.Pointer(outend))) {
|
||||
return nil
|
||||
}
|
||||
*(*byte)(unsafe.Pointer(output)) = C.AMF_BOOLEAN
|
||||
output = (*byte)(incBytePtr(unsafe.Pointer(output), 1))
|
||||
val := byte(0x01)
|
||||
if bVal == 0 {
|
||||
val = byte(0x00)
|
||||
}
|
||||
*(*byte)(unsafe.Pointer(output)) = val
|
||||
return output
|
||||
}
|
||||
|
||||
func amfEncodeNumber(output *byte, outend *byte, dVal float64) *byte {
|
||||
if int(uintptr(unsafe.Pointer(output)))+1+8 > int(uintptr(unsafe.Pointer(outend))) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO: port this
|
||||
*(*byte)(unsafe.Pointer(enc)) = C.AMF_NUMBER
|
||||
*(*byte)(unsafe.Pointer(output)) = C.AMF_NUMBER
|
||||
output = (*byte)(incBytePtr(unsafe.Pointer(output), 1))
|
||||
|
||||
// NOTE: here we are assuming little endian for both byte order and float
|
||||
// word order
|
||||
var ci, co *uint8
|
||||
ci = (*uint8)(unsafe.Pointer(&dVal))
|
||||
co = (*uint8)(unsafe.Pointer(output))
|
||||
|
||||
for i := 0; i < 8; i++ {
|
||||
*indxBytePtr(unsafe.Pointer(co), i) = *indxBytePtr(unsafe.Pointer(ci), 7-i)
|
||||
}
|
||||
|
||||
return (*Byte)(incBytePtr(unsafe.Pointer(output), 8))
|
||||
return (*byte)(incBytePtr(unsafe.Pointer(output), 8))
|
||||
}
|
||||
|
||||
func amfEncodeNamedString(output *byte, outend *byte, strName *C.AVal, strValue *C.AVal) *byte {
|
||||
|
|
Loading…
Reference in New Issue