rtmp: moved C_AVMATCH and C_AVC into amf_headers.go - consistent with C structure

This commit is contained in:
saxon 2018-08-25 22:27:20 +09:30
parent 36dfa31c48
commit a08c29ce81
2 changed files with 28 additions and 24 deletions

View File

@ -31,6 +31,10 @@ LICENSE
*/ */
package rtmp package rtmp
import (
"unsafe"
)
const ( const (
AMF_NUMBER = iota AMF_NUMBER = iota
AMF_BOOLEAN AMF_BOOLEAN
@ -64,6 +68,30 @@ type C_AVal struct {
av_len int32 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 // typedef struct AMF_Object
// amf.h +67 // amf.h +67
type C_AMFObject struct { type C_AMFObject struct {

View File

@ -200,17 +200,6 @@ func endSession(rtmp *C_RTMP) uint32 {
return 0 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) // #define RTMPPacket_IsReady(a)
// rtmp.h +142 // rtmp.h +142
func C_RTMPPacket_IsReady(p *C_RTMPPacket) int { func C_RTMPPacket_IsReady(p *C_RTMPPacket) int {
@ -2589,19 +2578,6 @@ func ptrToSlice(data unsafe.Pointer, size int) []byte {
return ret 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{ var rtmpErrs = [...]string{
1: "rtmp: not connected", 1: "rtmp: not connected",
2: "rtmp: write error", 2: "rtmp: write error",