mirror of https://bitbucket.org/ausocean/av.git
Created allocate func
This commit is contained in:
parent
283fb1e3ab
commit
b8c54118c9
13
rtmp/rtmp.go
13
rtmp/rtmp.go
|
@ -321,7 +321,7 @@ func (s *session) Open() error {
|
||||||
func startSession(rtmp *C.RTMP, u string, timeout uint32) (*C.RTMP, error) {
|
func startSession(rtmp *C.RTMP, u string, timeout uint32) (*C.RTMP, error) {
|
||||||
url := C.CString(u)
|
url := C.CString(u)
|
||||||
connect_timeout := C.int(timeout)
|
connect_timeout := C.int(timeout)
|
||||||
rtmp = C.RTMP_Alloc()
|
rtmp = rtmpAlloc()
|
||||||
C.RTMP_Init(rtmp)
|
C.RTMP_Init(rtmp)
|
||||||
rtmp.Link.timeout = connect_timeout
|
rtmp.Link.timeout = connect_timeout
|
||||||
if C.RTMP_SetupURL(rtmp, url) == 0 {
|
if C.RTMP_SetupURL(rtmp, url) == 0 {
|
||||||
|
@ -347,11 +347,11 @@ func startSession(rtmp *C.RTMP, u string, timeout uint32) (*C.RTMP, error) {
|
||||||
return rtmp, nil
|
return rtmp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func rtmpAlloc() *C.RTMP {
|
func rtmpAlloc() *C.RTMP {
|
||||||
return C.calloc
|
var r C.RTMP
|
||||||
|
return (*C.RTMP)(allocate(unsafe.Sizeof(r)))
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
// Close terminates the rtmp connection
|
// Close terminates the rtmp connection
|
||||||
func (s *session) Close() error {
|
func (s *session) Close() error {
|
||||||
if s.rtmp == nil {
|
if s.rtmp == nil {
|
||||||
|
@ -911,6 +911,11 @@ func avQueue(vals **C.RTMP_METHOD, num *int, av *C.AVal, txn int) {
|
||||||
int(unsafe.Sizeof(rtmpMethodPtr))))).name.av_val = (*C.char)(tmp)
|
int(unsafe.Sizeof(rtmpMethodPtr))))).name.av_val = (*C.char)(tmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func allocate(nOfBytes uintptr) unsafe.Pointer {
|
||||||
|
mem := make([]byte, int(nOfBytes))
|
||||||
|
return unsafe.Pointer(&mem[0])
|
||||||
|
}
|
||||||
|
|
||||||
// indxBytePtr returns a byte at the indx inc give a ptr
|
// indxBytePtr returns a byte at the indx inc give a ptr
|
||||||
func indxBytePtr(ptr unsafe.Pointer, inc int) *byte {
|
func indxBytePtr(ptr unsafe.Pointer, inc int) *byte {
|
||||||
return (*byte)(incPtr(ptr, inc, byteSize))
|
return (*byte)(incPtr(ptr, inc, byteSize))
|
||||||
|
|
Loading…
Reference in New Issue