mirror of https://bitbucket.org/ausocean/av.git
Ported RTMP_ParsePlaypath to C_RTMP_ParsPlaypath - still need to test
This commit is contained in:
parent
e9a196306c
commit
fbaafa0f8d
107
rtmp/rtmp.go
107
rtmp/rtmp.go
|
@ -771,6 +771,7 @@ func C_RTMP_ParseURL(url *byte, protocol *int32, host *C.AVal, port *uint32,
|
|||
if *p == '/' {
|
||||
p = (*byte)(incBytePtr(unsafe.Pointer(p), 1))
|
||||
}
|
||||
// NOTE: don't think we currently need this section - see 787 for this func
|
||||
|
||||
if int(uintptr(unsafe.Pointer(end))-uintptr(unsafe.Pointer(p))) != 0 {
|
||||
var av C.AVal
|
||||
|
@ -783,6 +784,112 @@ func C_RTMP_ParseURL(url *byte, protocol *int32, host *C.AVal, port *uint32,
|
|||
return 1
|
||||
}
|
||||
|
||||
// void RTMP_ParsePlaypath(AVal *in, AVal *out);
|
||||
// parseurl.c +201
|
||||
func C_RTMP_ParsePlaypath(in, out *C.AVal) {
|
||||
var addMP4 int32 = 0
|
||||
var addMP3 int32 = 0
|
||||
var subExt int32 = 0
|
||||
playpath := in.av_val
|
||||
var temp, q *byte
|
||||
var ext *byte = nil
|
||||
ppstart := (*byte)(unsafe.Pointer(playpath))
|
||||
var streamname, destptr, p *byte
|
||||
|
||||
pplen := int32(in.av_len)
|
||||
|
||||
out.av_val = nil
|
||||
out.av_len = 0
|
||||
|
||||
temp = strstr((*byte)(unsafe.Pointer(ppstart)), goStrToCStr("slist="))
|
||||
if *ppstart == '?' && temp != nil {
|
||||
ppstart = (*byte)(incBytePtr(unsafe.Pointer(temp), 6))
|
||||
pplen = int32(strlen(ppstart))
|
||||
|
||||
temp = strchr(ppstart, '&')
|
||||
|
||||
if temp != nil {
|
||||
pplen = int32(uintptr(unsafe.Pointer(temp)) - uintptr(unsafe.Pointer(ppstart)))
|
||||
}
|
||||
}
|
||||
|
||||
q = strchr(ppstart, '?')
|
||||
|
||||
if pplen >= 4 {
|
||||
if q != nil {
|
||||
ext = (*byte)(decBytePtr(unsafe.Pointer(q), 4))
|
||||
} else {
|
||||
ext = (*byte)(indxBytePtr(unsafe.Pointer(ppstart), int(uintptr(pplen)-
|
||||
uintptr(4))))
|
||||
}
|
||||
switch {
|
||||
case strings.Compare(cStrToGoStr(ext)[:4], ".f4v") == 0 ||
|
||||
strings.Compare(cStrToGoStr(ext)[:4], ".mp4") == 0:
|
||||
addMP4 = 1
|
||||
subExt = 1
|
||||
case ppstart == (*byte)(unsafe.Pointer(playpath)) && strings.Compare(
|
||||
cStrToGoStr(ext)[:4], ".flv") == 0:
|
||||
subExt = 1
|
||||
case strings.Compare(cStrToGoStr(ext)[:4], ".mp3") == 0:
|
||||
addMP3 = 1
|
||||
subExt = 1
|
||||
}
|
||||
}
|
||||
|
||||
streamname = (*byte)(C.malloc(C.size_t(pplen + 4 + 1)))
|
||||
|
||||
if streamname == nil {
|
||||
return
|
||||
}
|
||||
|
||||
destptr = streamname
|
||||
switch {
|
||||
case addMP4 != 0:
|
||||
if strings.Compare(cStrToGoStr(ppstart)[:4], "mp4") != 0 {
|
||||
memmove(unsafe.Pointer(destptr), unsafe.Pointer(goStrToCStr("mp4:")),
|
||||
uintptr(len("mp4:")))
|
||||
destptr = (*byte)(incBytePtr(unsafe.Pointer(destptr), 4))
|
||||
} else {
|
||||
subExt = 0
|
||||
}
|
||||
case addMP3 != 0:
|
||||
if strings.Compare(cStrToGoStr(ppstart)[:4], "mp3") != 0 {
|
||||
memmove(unsafe.Pointer(destptr), unsafe.Pointer(goStrToCStr("mp3:")),
|
||||
uintptr(len("mp4:")))
|
||||
destptr = (*byte)(incBytePtr(unsafe.Pointer(destptr), 4))
|
||||
} else {
|
||||
subExt = 0
|
||||
}
|
||||
}
|
||||
|
||||
p = (*byte)(ppstart)
|
||||
for pplen > 0 {
|
||||
if subExt != 0 && p == ext {
|
||||
p = (*byte)(incBytePtr(unsafe.Pointer(p), 4))
|
||||
pplen -= 4
|
||||
continue
|
||||
}
|
||||
if *p == '%' {
|
||||
var c uint32
|
||||
fmt.Sscanf(cStrToGoStr((*byte)(incBytePtr(unsafe.Pointer(p), 1))), "%02x", &c)
|
||||
*indxBytePtr(unsafe.Pointer(destptr), 0) = byte(c)
|
||||
destptr = (*byte)(incBytePtr(unsafe.Pointer(destptr), 1))
|
||||
pplen -= 3
|
||||
p = (*byte)(incBytePtr(unsafe.Pointer(p), 3))
|
||||
} else {
|
||||
*indxBytePtr(unsafe.Pointer(destptr), 0) = *p
|
||||
destptr = (*byte)(incBytePtr(unsafe.Pointer(destptr), 1))
|
||||
p = (*byte)(incBytePtr(unsafe.Pointer(p), 1))
|
||||
pplen--
|
||||
}
|
||||
}
|
||||
*destptr = '\x00'
|
||||
|
||||
out.av_val = (*C.char)(unsafe.Pointer(streamname))
|
||||
out.av_len = C.int(uintptr(unsafe.Pointer(destptr)) - uintptr(unsafe.Pointer(
|
||||
streamname)))
|
||||
}
|
||||
|
||||
// void SocksSetup(RTMP *r, C.AVal* sockshost);
|
||||
// rtmp.c +410
|
||||
func C_SocksSetup(r *C.RTMP, sockshost *C.AVal) {
|
||||
|
|
Loading…
Reference in New Issue