diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index eeda665b..7ebe337f 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -1908,7 +1908,6 @@ func C_HandleClientBW(r *C.RTMP, packet *C.RTMPPacket) { // int HandleInvoke(RTMP* r, const char* body, unsigned int nBodySize); // rtmp.c +2912 -/* func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 { var obj C.AMFObject var method C.AVal @@ -1941,9 +1940,93 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 { // RTMP_Log(RTMP_LOGDEBUG, "%s, server invoking <%s>", __FUNCTION__, method.av_val); // TODO port this - if C.AVMATCH(&method, &av__result) + switch { + case C.AVMATCH(&method, &av__result): + var methodInvoked C.AVal + + for i := 0; i < r.m_numCalls; i++ { + if r.m_methodCalls[i].num == int32(txn) { + methodInvoked = r.m_methodCalls[i].name + // TODO port this + C.AV_erase(r.m_methodCalls, &r.m_numCalls, i, 0) + break + } + } + if methodInvoked.av_val == 0 { + // TODO use new logger here + // RTMP_Log(RTMP_LOGDEBUG, "%s, received result id %f without matching request", + //__FUNCTION__, txn); + goto leave + } + // TODO use new logger here + // RTMP_Log(RTMP_LOGDEBUG, "%s, received result for method call <%s>", __FUNCTION__, + //methodInvoked.av_val); + // TODO port AVMATCH + switch { + case AVMATCH(&methodInvoked, &av_connect) != 0: + if r.Link.token.av_len != 0 { + var p C.AMFOBjectProperty + // TODO port this + if C.RTMP_FindFirstMatchingProperty(&obj, &av_secureToken, &p) { + // TODO port This + C.DecodeTEA(&r.Link.token, &p.p_vu.p_aval) + // TODO port this + C.SendSecureTokenResponse(r, &p.p_vu.p_aval) + } + } + if r.Link.protocol & RTMP_FEATURE_WRITE { + // TODO port this + C.SendReleaseStream(r) + // TODO port this + C.SendFCPublish(r) + } else { + // TODO port this + C.RTMP_SendServerBW(r) + // TODO port this + C.RTMP_SendCtrl(r, 3, 0, 300) + } + // TODO port this + C.RTMP_SendCreateStream(r) + + if (r.Link.protocol & RTMP_FEATURE_WRITE) == 0 { + if r.Link.usherToken.av_len != 0 { + // TODO port this + C.SendUsherToken(r, &r.Link.usherToken) + } + switch { + case r.Link.subscribepath.av_len != 0: + // TODO port this + C.SendFCSubscribe(r, &r.Link.subscribepath) + case r.Link.lFlags & RTMP_LF_LIVE: + C.SendFCSubscribe(r, &r.Link.playpath) + } + } + case AVMATCH(&methodInvoked, &av_createStream) != 0: + r->m_stream_id = (int)AMFProp_GetNumber(AMF_GetProp(&obj, NULL, 3)); + + if (r->Link.protocol & RTMP_FEATURE_WRITE) + { + SendPublish(r); + } + else + { + if (r->Link.lFlags & RTMP_LF_PLST) + SendPlaylist(r); + SendPlay(r); + RTMP_SendCtrl(r, 3, r->m_stream_id, r->m_nBufferMS); + } + case + } + case AVMATCH(&method, &av_onBWDone): + case AVMATCH(&method, &av_onFCSubscribe): + case AVMATCH(&method, &av_onFCUnsubscribe): + case AVMATCH(&method, &av_ping): + case AVMATCH(&method, &av__onbwcheck): + case AVMATCH(&method, &av__onbwdone): + case AVMATCH(&method, &av__error): + } } -*/ + // void RTMPPacket_Free(RTMPPacket* p); // rtmp.c +203