mirror of https://bitbucket.org/ausocean/av.git
rtmp: remove deadcode and make tests pass
This commit is contained in:
parent
ddefd198d0
commit
6187df1c20
43
rtmp/rtmp.go
43
rtmp/rtmp.go
|
@ -1680,10 +1680,10 @@ func C_HandShake(r *C_RTMP, FP9HandShake int32) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
if debugMode {
|
if debugMode {
|
||||||
log.Println("C_HandShake: Type answer: %v", typ)
|
log.Printf("C_HandShake: Type answer: %v\n", typ)
|
||||||
}
|
}
|
||||||
if typ != clientbuf[0] {
|
if typ != clientbuf[0] {
|
||||||
log.Println("C_HandShake: type mismatch: client sent %v, server sent: %v",
|
log.Printf("C_HandShake: type mismatch: client sent %v, server sent: %v\n",
|
||||||
clientbuf[0], typ)
|
clientbuf[0], typ)
|
||||||
}
|
}
|
||||||
if C_ReadN(r, (*byte)(unsafe.Pointer(&serversig[0])), RTMP_SIG_SIZE) != RTMP_SIG_SIZE {
|
if C_ReadN(r, (*byte)(unsafe.Pointer(&serversig[0])), RTMP_SIG_SIZE) != RTMP_SIG_SIZE {
|
||||||
|
@ -2248,11 +2248,6 @@ func bToUP(b *byte) unsafe.Pointer {
|
||||||
return unsafe.Pointer(b)
|
return unsafe.Pointer(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
// wrapper for converting slice to unsafe.pointer
|
|
||||||
func sToUP(b []byte) unsafe.Pointer {
|
|
||||||
return unsafe.Pointer(&b[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creates a new C style string from a go string
|
// Creates a new C style string from a go string
|
||||||
func goStrToCStr(str string) *byte {
|
func goStrToCStr(str string) *byte {
|
||||||
l := len(str)
|
l := len(str)
|
||||||
|
@ -2364,34 +2359,12 @@ func indxBytePtr(ptr unsafe.Pointer, inc int) *byte {
|
||||||
return (*byte)(incPtr(ptr, inc, 1))
|
return (*byte)(incPtr(ptr, inc, 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
// indxInt32Ptr returns an int32 at the indx inc given a ptr
|
|
||||||
func indxInt32Ptr(ptr unsafe.Pointer, inc int) *int32 {
|
|
||||||
return (*int32)(incPtr(ptr, inc, 4))
|
|
||||||
}
|
|
||||||
|
|
||||||
// indxInt64Ptr returns an int64 at the indx inc given a ptr
|
|
||||||
func indxInt64Ptr(ptr unsafe.Pointer, inc int) *int64 {
|
|
||||||
return (*int64)(incPtr(ptr, inc, 8))
|
|
||||||
}
|
|
||||||
|
|
||||||
// incBytePtr returns an unsafe.Pointer to a byte that is inc positive positions
|
// incBytePtr returns an unsafe.Pointer to a byte that is inc positive positions
|
||||||
// from the passed ptr
|
// from the passed ptr
|
||||||
func incBytePtr(ptr unsafe.Pointer, inc int) unsafe.Pointer {
|
func incBytePtr(ptr unsafe.Pointer, inc int) unsafe.Pointer {
|
||||||
return incPtr(ptr, inc, 1)
|
return incPtr(ptr, inc, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// incInt32Ptr returns an unsafe.Pointer to an int32 that is inc positive
|
|
||||||
// positions from the passed ptr
|
|
||||||
func incInt32Ptr(ptr unsafe.Pointer, inc int) unsafe.Pointer {
|
|
||||||
return incPtr(ptr, inc, 4)
|
|
||||||
}
|
|
||||||
|
|
||||||
// incInt64Ptr returns an unsafe.Pointer to an int64 that is inc positive
|
|
||||||
// positions from the passed ptr
|
|
||||||
func incInt64Ptr(ptr unsafe.Pointer, inc int) unsafe.Pointer {
|
|
||||||
return incPtr(ptr, inc, 8)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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*typeSize))
|
return unsafe.Pointer(uintptr(ptr) + uintptr(inc*typeSize))
|
||||||
|
@ -2408,18 +2381,6 @@ func decBytePtr(ptr unsafe.Pointer, dec int) unsafe.Pointer {
|
||||||
return decPtr(ptr, dec, 1)
|
return decPtr(ptr, dec, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// decBytePtr returns an unsafe.Pointer to a int32 that is dec negative positions
|
|
||||||
// from ptr
|
|
||||||
func decInt32Ptr(ptr unsafe.Pointer, dec int) unsafe.Pointer {
|
|
||||||
return decPtr(ptr, dec, 4)
|
|
||||||
}
|
|
||||||
|
|
||||||
// decBytePtr returns an unsafe.Pointer to a int64 that is dec negative positions
|
|
||||||
// from ptr
|
|
||||||
func decInt64Ptr(ptr unsafe.Pointer, dec int) unsafe.Pointer {
|
|
||||||
return decPtr(ptr, dec, 8)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 {
|
||||||
|
|
|
@ -200,26 +200,3 @@ func TestIndxBytePtr(t *testing.T) {
|
||||||
t.Errorf(errMsg, valueByte, byteArr[inc])
|
t.Errorf(errMsg, valueByte, byteArr[inc])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIndxInt32Ptr(t *testing.T) {
|
|
||||||
// Test how it deals with int32s
|
|
||||||
int32Ptr := unsafe.Pointer(&int32Arr[arrStart])
|
|
||||||
valueInt32 := indxInt32Ptr(int32Ptr, inc)
|
|
||||||
if *valueInt32 != int32Arr[inc] {
|
|
||||||
t.Errorf(errMsg, valueInt32, int32Arr[inc])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestIndxInt64Ptr(t *testing.T) {
|
|
||||||
// Test how it deals with int64
|
|
||||||
int64Ptr := unsafe.Pointer(&int64Arr[arrStart])
|
|
||||||
valueInt64 := indxInt64Ptr(int64Ptr, inc)
|
|
||||||
if *valueInt64 != int64Arr[inc] {
|
|
||||||
t.Errorf(errMsg, valueInt64, int64Arr[inc])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
func TestPtrToSlice(t *testing.T){
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
Loading…
Reference in New Issue