diff --git a/rtmp/amf.go b/rtmp/amf.go index 6a190521..1d72d7ce 100644 --- a/rtmp/amf.go +++ b/rtmp/amf.go @@ -125,11 +125,8 @@ func C_AMF_DecodeNumber(data *byte) float64 { // int AMF_DecodeBoolean(const char *data); // amf.c +132 -func C_AMF_DecodeBoolean(data *byte) int32 { - if *data != 0 { - return 1 - } - return 0 +func C_AMF_DecodeBoolean(data *byte) bool { + return *data != 0 } // char* AMF_EncodeInt16(char* output, char* outend, short nVal); @@ -240,15 +237,15 @@ func C_AMF_EncodeNumber(output *byte, outend *byte, dVal float64) *byte { // char* AMF_EncodeBoolean(char* output, char* outend, int bVal); // amf.c +260 -func C_AMF_EncodeBoolean(output *byte, outend *byte, bVal int) *byte { +func C_AMF_EncodeBoolean(output *byte, outend *byte, bVal bool) *byte { if int(uintptr(unsafe.Pointer(output)))+2 > int(uintptr(unsafe.Pointer(outend))) { return nil } *(*byte)(unsafe.Pointer(output)) = AMF_BOOLEAN output = (*byte)(incBytePtr(unsafe.Pointer(output), 1)) - val := byte(0x01) - if bVal == 0 { - val = byte(0x00) + var val byte + if bVal { + val = 1 } *(*byte)(unsafe.Pointer(output)) = val output = (*byte)(incBytePtr(unsafe.Pointer(output), 1)) @@ -285,7 +282,7 @@ func C_AMF_EncodeNamedNumber(output *byte, outend *byte, key string, val float64 // char* AMF_EncodeNamedBoolean(char* output, char* outend, const C_AVal* strname, int bVal); // amf.c +299 -func C_AMF_EncodeNamedBoolean(output *byte, outend *byte, key string, val int) *byte { +func C_AMF_EncodeNamedBoolean(output *byte, outend *byte, key string, val bool) *byte { buflen := int(uintptr(unsafe.Pointer(outend)) - uintptr(unsafe.Pointer(output))) if 2+len(key) > buflen { return nil @@ -356,11 +353,7 @@ func C_AMF_PropEncode(p *C_AMFObjectProperty, pBuffer *byte, pBufEnd *byte) *byt case AMF_NUMBER: pBuffer = C_AMF_EncodeNumber(pBuffer, pBufEnd, float64(p.p_vu.p_number)) case AMF_BOOLEAN: - val := 0 - if p.p_vu.p_number != 0 { - val = 1 - } - pBuffer = C_AMF_EncodeBoolean(pBuffer, pBufEnd, val) + pBuffer = C_AMF_EncodeBoolean(pBuffer, pBufEnd, p.p_vu.p_number != 0) case AMF_STRING: pBuffer = C_AMF_EncodeString(pBuffer, pBufEnd, CAV(&p.p_vu.p_aval)) case AMF_NULL: diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index 8b77090d..deb3d1e5 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -778,7 +778,7 @@ func C_SendConnectPacket(r *C_RTMP, cp *C_RTMPPacket) (ok bool) { } if r.Link.protocol&RTMP_FEATURE_WRITE == 0 { - enc = C_AMF_EncodeNamedBoolean(enc, pend, CAV(&av_fpad), 0) + enc = C_AMF_EncodeNamedBoolean(enc, pend, CAV(&av_fpad), false) if enc == nil { return false } @@ -827,7 +827,7 @@ func C_SendConnectPacket(r *C_RTMP, cp *C_RTMPPacket) (ok bool) { /* add auth string */ if r.Link.auth.av_len != 0 { - enc = C_AMF_EncodeBoolean(enc, pend, int(r.Link.lFlags&RTMP_LF_AUTH)) + enc = C_AMF_EncodeBoolean(enc, pend, r.Link.lFlags&RTMP_LF_AUTH != 0) if enc == nil { return false }