mirror of https://bitbucket.org/ausocean/av.git
rtmp: moved C_AVMATCH and C_AVC into amf_headers.go - consistent with C structure
This commit is contained in:
parent
36dfa31c48
commit
a08c29ce81
|
@ -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 {
|
||||
|
|
24
rtmp/rtmp.go
24
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",
|
||||
|
|
Loading…
Reference in New Issue