Created go RTMP_READ struct

This commit is contained in:
saxon 2018-07-19 00:54:36 +09:30
parent 3b33d1f050
commit 10cd22d02a
1 changed files with 51 additions and 24 deletions

View File

@ -61,18 +61,6 @@ import (
"unsafe"
)
const (
minDataSize = 11
debugMode = false
nullChar = "golang\000"
)
const (
byteSize = 1
int32Size = 4
int64Size = 8
)
const (
RTMPT_OPEN = iota
RTMPT_SEND
@ -87,21 +75,33 @@ const (
RTMP_PACKET_TYPE_INFO = 0x12
RTMP_PACKET_TYPE_AUDIO = 0x08
RTMP_PACKET_TYPE_VIDEO = 0x09
RTMP_READ_HEADER = 0x01
RTMP_READ_RESUME = 0x02
RTMP_READ_NO_IGNORE = 0x04
RTMP_READ_GOTKF = 0x08
RTMP_READ_GOTFLVK = 0x10
RTMP_READ_SEEKING = 0x20
RTMP_READ_COMPLETE = -3
RTMP_READ_ERROR = -2
RTMP_READ_EOF = -1
RTMP_READ_IGNORE = 0
)
const (
minDataSize = 11
debugMode = false
)
const (
byteSize = 1
int32Size = 4
int64Size = 8
)
// memmove copies n bytes from "from" to "to".
//go:linkname memmove runtime.memmove
//func memmove(to, from unsafe.Pointer, n uintptr)
// C.AVal is in amf.h
// See #define AVC(str) {str, sizeof(str)-1} in amf.h
func AVC(str string) C.AVal {
var aval C.AVal
aval.av_val = C.CString(str)
aval.av_len = C.int(len(str))
return aval
}
// av_setDataFrame is a static const global in rtmp.c
var setDataFrame = AVC("@setDataFrame")
@ -141,7 +141,7 @@ type RTMP struct {
m_bSendCounter uint8
m_numInvokes int
m_numCalls int
m_methodCalls *C.RTMP_METHOD
m_methodCalls *RTMP_METHOD
m_channelsAllocatedIn int
m_channelsAllocatedOut int
m_vecChannelsIn **RTMPPacket
@ -155,7 +155,7 @@ type RTMP struct {
m_polling int
m_resplen int
m_unackd int
m_clientID C.AVal
m_clientID AVal
m_read C.RTMP_READ
m_write C.RTMPPacket
m_sb C.RTMPSockBuf
@ -176,7 +176,7 @@ type RTMPPacket struct {
}
type RTMP_METHOD struct {
name C.AVal
name AVal
num int
}
@ -185,6 +185,24 @@ type AVal struct {
av_len int
}
type RTMP_READ struct {
buf *byte
bufpos *byte
buflen uint
timestamp uint32
dataType uint8
flags uint8
status int8
initialFrameType uint8
nResumeTS uint32
metaHeader *byte
initialFrame *byte
nMetaHeaderSize uint32
nInitialFrameSize uint32
nIgnoredFrameCounter uint32
nIgnoredFlvFrameCounter uint32
}
var _ Session = (*session)(nil)
// NewSession returns a new session.
@ -814,6 +832,15 @@ 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
aval.av_val = C.CString(str)
aval.av_len = C.int(len(str))
return aval
}
var rtmpErrs = [...]string{
1: "rtmp: not connected",
2: "rtmp: write error",