diff --git a/rtmp/amf_headers.go b/rtmp/amf_headers.go index 7ad0fc6b..02e5343b 100644 --- a/rtmp/amf_headers.go +++ b/rtmp/amf_headers.go @@ -31,6 +31,10 @@ LICENSE */ package rtmp +import ( + "unsafe" +) + const ( AMF_NUMBER = iota AMF_BOOLEAN @@ -64,6 +68,30 @@ type C_AVal struct { av_len int32 } +// C_AVal is in amf.h +// amf.h +62 +func AVC(str string) C_AVal { + var aval C_AVal + if len(str) != 0 { + aval.av_val = &([]byte(str)[0]) + } else { + aval.av_val = nil + } + aval.av_len = int32(len(str)) + return aval +} + +// #define AVMATCH(a1,a2) +// amf.h +63 +func C_AVMATCH(a1, a2 *C_AVal) int32 { + if a1.av_len == a2.av_len && memcmp(unsafe.Pointer(a1.av_val), + unsafe.Pointer(a2.av_val), int(a1.av_len)) == 0 { + return 1 + } else { + return 0 + } +} + // typedef struct AMF_Object // amf.h +67 type C_AMFObject struct { diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index 2cd12e22..6be90ce2 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -200,17 +200,6 @@ func endSession(rtmp *C_RTMP) uint32 { return 0 } -// #define AVMATCH(a1,a2) -// amf.h +63 -func C_AVMATCH(a1, a2 *C_AVal) int32 { - if a1.av_len == a2.av_len && memcmp(unsafe.Pointer(a1.av_val), - unsafe.Pointer(a2.av_val), int(a1.av_len)) == 0 { - return 1 - } else { - return 0 - } -} - // #define RTMPPacket_IsReady(a) // rtmp.h +142 func C_RTMPPacket_IsReady(p *C_RTMPPacket) int { @@ -2589,19 +2578,6 @@ func ptrToSlice(data unsafe.Pointer, size int) []byte { return ret } -// C_AVal is in amf.h -// See AVC(str) {str, sizeof(str)-1} in amf.h -func AVC(str string) C_AVal { - var aval C_AVal - if len(str) != 0 { - aval.av_val = &([]byte(str)[0]) - } else { - aval.av_val = nil - } - aval.av_len = int32(len(str)) - return aval -} - var rtmpErrs = [...]string{ 1: "rtmp: not connected", 2: "rtmp: write error",