mirror of https://bitbucket.org/ausocean/av.git
Testing passed for inc ptr and dec ptr
This commit is contained in:
parent
fc6dfef893
commit
ccdcba91ea
45
rtmp/rtmp.go
45
rtmp/rtmp.go
|
@ -43,10 +43,10 @@ int end_session(RTMP* rtmp);
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
_"errors"
|
||||||
_ "fmt"
|
_ "fmt"
|
||||||
"log"
|
_"log"
|
||||||
"math"
|
_"math"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
@ -77,7 +77,7 @@ func AVC(str string) C.AVal {
|
||||||
|
|
||||||
// av_setDataFrame is a static const global in rtmp.c
|
// av_setDataFrame is a static const global in rtmp.c
|
||||||
var setDataFrame = AVC("@setDataFrame")
|
var setDataFrame = AVC("@setDataFrame")
|
||||||
|
/*
|
||||||
// Session provides an interface for sending flv tags over rtmp.
|
// Session provides an interface for sending flv tags over rtmp.
|
||||||
type Session interface {
|
type Session interface {
|
||||||
Open() error
|
Open() error
|
||||||
|
@ -116,6 +116,19 @@ func (s *session) Open() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close terminates the rtmp connection
|
||||||
|
func (s *session) Close() error {
|
||||||
|
if s.rtmp == nil {
|
||||||
|
return Err(3)
|
||||||
|
}
|
||||||
|
ret := C.end_session(s.rtmp)
|
||||||
|
s.rtmp = nil
|
||||||
|
if ret != 0 {
|
||||||
|
return Err(ret)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Write writes a frame (flv tag) to the rtmp connection
|
// Write writes a frame (flv tag) to the rtmp connection
|
||||||
func (s *session) Write(data []byte) (int, error) {
|
func (s *session) Write(data []byte) (int, error) {
|
||||||
if s.rtmp == nil {
|
if s.rtmp == nil {
|
||||||
|
@ -530,16 +543,15 @@ func AV_queue(vals **C.RTMP_METHOD, num *int, av *AVal, txn int ) {
|
||||||
memmove(tmp, unsafe.Pointer(av.av_val), int(av.av_len))
|
memmove(tmp, unsafe.Pointer(av.av_val), int(av.av_len))
|
||||||
indxPtr(tpm,av.av_len) = '\0'
|
indxPtr(tpm,av.av_len) = '\0'
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// memmove copies n bytes from "from" to "to".
|
// memmove copies n bytes from "from" to "to".
|
||||||
//go:linkname memmove runtime.memmove
|
//go:linkname memmove runtime.memmove
|
||||||
func memmove(to, from unsafe.Pointer, n uintptr)
|
func memmove(to, from unsafe.Pointer, n uintptr)
|
||||||
|
|
||||||
func indxPtr(ptr unsafe.Pointer, indx, typeSize int) unsafe.Pointer {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// sliceToPtr get's the address of the first data element and returns as unsafe
|
// sliceToPtr get's the address of the first data element and returns as unsafe
|
||||||
// pointer
|
// pointer
|
||||||
func sliceToPtr(data []byte) unsafe.Pointer {
|
func sliceToPtr(data []byte) unsafe.Pointer {
|
||||||
|
@ -559,25 +571,12 @@ func ptrToSlice(data unsafe.Pointer, size int) []byte {
|
||||||
|
|
||||||
// incPtr attempts to replicate C like pointer arithmatic functionality
|
// incPtr attempts to replicate C like pointer arithmatic functionality
|
||||||
func incPtr(ptr unsafe.Pointer, inc, typeSize int) unsafe.Pointer {
|
func incPtr(ptr unsafe.Pointer, inc, typeSize int) unsafe.Pointer {
|
||||||
return unsafe.Pointer(uintptr(ptr) + uintptr(inc))
|
return unsafe.Pointer(uintptr(ptr) + uintptr(inc*typeSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
// incPtr attempts to replicate C like pointer arithmatic functionality
|
// incPtr attempts to replicate C like pointer arithmatic functionality
|
||||||
func decPtr(ptr unsafe.Pointer, dec, typeSize int) unsafe.Pointer {
|
func decPtr(ptr unsafe.Pointer, dec, typeSize int) unsafe.Pointer {
|
||||||
return unsafe.Pointer(uintptr(ptr) - uintptr(inc))
|
return unsafe.Pointer(uintptr(ptr) - uintptr(dec*typeSize))
|
||||||
}
|
|
||||||
|
|
||||||
// Close terminates the rtmp connection
|
|
||||||
func (s *session) Close() error {
|
|
||||||
if s.rtmp == nil {
|
|
||||||
return Err(3)
|
|
||||||
}
|
|
||||||
ret := C.end_session(s.rtmp)
|
|
||||||
s.rtmp = nil
|
|
||||||
if ret != 0 {
|
|
||||||
return Err(ret)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var rtmpErrs = [...]string{
|
var rtmpErrs = [...]string{
|
||||||
|
|
Loading…
Reference in New Issue