mirror of https://bitbucket.org/ausocean/av.git
Added some commenting above functions
This commit is contained in:
parent
0898d50f0f
commit
a9b5c7a26f
11
rtmp/rtmp.go
11
rtmp/rtmp.go
|
@ -130,6 +130,7 @@ func (s *session) Write(data []byte) (int, error) {
|
|||
return len(data), nil
|
||||
}
|
||||
|
||||
// rtmpWrite writes data to the current rtmp connection encapsulated by r
|
||||
func rtmpWrite(r *C.RTMP, data []byte) int {
|
||||
buf := sliceToPtr(data)
|
||||
// TODO: port RTMPPacket
|
||||
|
@ -224,14 +225,19 @@ func rtmpWrite(r *C.RTMP, data []byte) int {
|
|||
return size + s2
|
||||
}
|
||||
|
||||
// indxPtr replicates C array indexing using an unsafe pointer
|
||||
func indxPtr(ptr unsafe.Pointer, inc int) byte {
|
||||
return *(*byte)(incPtr(ptr,inc))
|
||||
}
|
||||
|
||||
// sliceToPtr get's the address of the first data element and returns as unsafe
|
||||
// pointer
|
||||
func sliceToPtr(data []byte) unsafe.Pointer {
|
||||
return unsafe.Pointer(&data[0])
|
||||
}
|
||||
|
||||
// ptrToSlice returns a slice given unsafe pointer and size - no allocation and
|
||||
// copying is required - same data is used.
|
||||
func ptrToSlice(data unsafe.Pointer, size int) []byte {
|
||||
var ret []byte
|
||||
shDest := (*reflect.SliceHeader)(unsafe.Pointer(&ret))
|
||||
|
@ -241,6 +247,7 @@ func ptrToSlice(data unsafe.Pointer, size int) []byte {
|
|||
return ret
|
||||
}
|
||||
|
||||
// incPtr attempts to replicate C like pointer arithmatic functionality
|
||||
func incPtr(ptr unsafe.Pointer, inc int) unsafe.Pointer {
|
||||
return unsafe.Pointer(uintptr(ptr) + uintptr(inc))
|
||||
}
|
||||
|
@ -290,7 +297,3 @@ func (e Err) Error() string {
|
|||
}
|
||||
return "rtmp: " + strconv.Itoa(int(e))
|
||||
}
|
||||
|
||||
func byteSliceToCArr(buf []byte) *C.char {
|
||||
return (*C.char)(unsafe.Pointer(&buf[0]))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue