mirror of https://bitbucket.org/ausocean/av.git
Ported AMF_GetProp - tested and working
This commit is contained in:
parent
48042f6813
commit
137c5a0c14
47
rtmp/rtmp.go
47
rtmp/rtmp.go
|
@ -238,11 +238,11 @@ var (
|
|||
av_set_playlist = AVC("set_playlist")
|
||||
)
|
||||
|
||||
var packetSize = [...]int{12, 8, 4, 1}
|
||||
|
||||
var AMFObj_Invalid C.AMFObject
|
||||
|
||||
var RTMPProtocolStringsLower = [...]string{
|
||||
var (
|
||||
AMFObj_Invalid C.AMFObject
|
||||
AMFProp_Invalid = C.AMFObjectProperty{p_type: AMF_INVALID}
|
||||
packetSize = [...]int{12, 8, 4, 1}
|
||||
RTMPProtocolStringsLower = [...]string{
|
||||
"rtmp",
|
||||
"rtmpt",
|
||||
"rtmpe",
|
||||
|
@ -253,6 +253,7 @@ var RTMPProtocolStringsLower = [...]string{
|
|||
"",
|
||||
"rtmfp",
|
||||
}
|
||||
)
|
||||
|
||||
type Session interface {
|
||||
Open() error
|
||||
|
@ -1976,9 +1977,9 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
|
|||
|
||||
// NOTE we don't really need this ?? still functions without it
|
||||
//C.AMF_Dump(&obj)
|
||||
//C.AMFProp_GetString(C.AMF_GetProp(&obj, nil, 0), &method)
|
||||
C_AMFProp_GetString(C.AMF_GetProp(&obj, nil, 0), &method)
|
||||
txn = float64(C.AMFProp_GetNumber(C.AMF_GetProp(&obj, nil, 1)))
|
||||
//C.AMFProp_GetString(C_AMF_GetProp(&obj, nil, 0), &method)
|
||||
C_AMFProp_GetString(C_AMF_GetProp(&obj, nil, 0), &method)
|
||||
txn = float64(C.AMFProp_GetNumber(C_AMF_GetProp(&obj, nil, 1)))
|
||||
// TODO use new logger here
|
||||
// RTMP_Log(RTMP_LOGDEBUG, "%s, server invoking <%s>", __FUNCTION__, method.av_val);
|
||||
|
||||
|
@ -2063,7 +2064,7 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
|
|||
case C_AVMATCH(&methodInvoked, &av_createStream) != 0:
|
||||
{
|
||||
log.Println("5")
|
||||
r.m_stream_id = C.int(C.AMFProp_GetNumber(C.AMF_GetProp(&obj, nil, 3)))
|
||||
r.m_stream_id = C.int(C.AMFProp_GetNumber(C_AMF_GetProp(&obj, nil, 3)))
|
||||
|
||||
if (r.Link.protocol & RTMP_FEATURE_WRITE) != 0 {
|
||||
log.Println("5.1")
|
||||
|
@ -2142,9 +2143,9 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
|
|||
log.Println("13")
|
||||
var obj2 C.AMFObject
|
||||
var code, level C.AVal
|
||||
C_AMFProp_GetObject(C.AMF_GetProp(&obj, nil, 3), &obj2)
|
||||
C_AMFProp_GetString(C.AMF_GetProp(&obj2, &av_code, -1), &code)
|
||||
C_AMFProp_GetString(C.AMF_GetProp(&obj2, &av_level, -1), &level)
|
||||
C_AMFProp_GetObject(C_AMF_GetProp(&obj, nil, 3), &obj2)
|
||||
C_AMFProp_GetString(C_AMF_GetProp(&obj2, &av_code, -1), &code)
|
||||
C_AMFProp_GetString(C_AMF_GetProp(&obj2, &av_level, -1), &level)
|
||||
|
||||
// TODO use new logger
|
||||
// RTMP_Log(RTMP_LOGDEBUG, "%s, onStatus: %s", __FUNCTION__, code.av_val);
|
||||
|
@ -2270,6 +2271,28 @@ func C_AMFProp_GetObject(prop *C.AMFObjectProperty, obj *C.AMFObject) {
|
|||
}
|
||||
}
|
||||
|
||||
// AMFObjectProperty* AMF_GetProp(AMFObject *obj, const AVal* name, int nIndex);
|
||||
// amf.c + 1249
|
||||
func C_AMF_GetProp(obj *C.AMFObject, name *C.AVal, nIndex int32) *C.AMFObjectProperty {
|
||||
if nIndex >= 0 {
|
||||
if nIndex < int32(obj.o_num) {
|
||||
return &(*(*C.AMFObjectProperty)(incPtr(unsafe.Pointer(obj.o_props),
|
||||
int(nIndex), int(unsafe.Sizeof(*obj.o_props)))))
|
||||
//return &obj.o_props[nIndex]
|
||||
}
|
||||
} else {
|
||||
var n int32
|
||||
for n = 0; n < int32(obj.o_num); n++ {
|
||||
if C_AVMATCH(&(*(*C.AMFObjectProperty)(incPtr(unsafe.Pointer(obj.o_props),
|
||||
int(n), int(unsafe.Sizeof(*obj.o_props))))).p_name, name) != 0 {
|
||||
return &(*(*C.AMFObjectProperty)(incPtr(unsafe.Pointer(obj.o_props),
|
||||
int(n), int(unsafe.Sizeof(*obj.o_props)))))
|
||||
}
|
||||
}
|
||||
}
|
||||
return (*C.AMFObjectProperty)(&AMFProp_Invalid)
|
||||
}
|
||||
|
||||
// void RTMPPacket_Free(RTMPPacket* p);
|
||||
// rtmp.c +203
|
||||
func C_RTMPPacket_Free(p *C.RTMPPacket) {
|
||||
|
|
Loading…
Reference in New Issue