In the middle of porting HandleInvoke

This commit is contained in:
saxon 2018-08-13 12:15:43 +09:30
parent 4328f1853b
commit 5f1879c58b
1 changed files with 86 additions and 3 deletions

View File

@ -1908,7 +1908,6 @@ func C_HandleClientBW(r *C.RTMP, packet *C.RTMPPacket) {
// int HandleInvoke(RTMP* r, const char* body, unsigned int nBodySize); // int HandleInvoke(RTMP* r, const char* body, unsigned int nBodySize);
// rtmp.c +2912 // rtmp.c +2912
/*
func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 { func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
var obj C.AMFObject var obj C.AMFObject
var method C.AVal 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); // RTMP_Log(RTMP_LOGDEBUG, "%s, server invoking <%s>", __FUNCTION__, method.av_val);
// TODO port this // 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); // void RTMPPacket_Free(RTMPPacket* p);
// rtmp.c +203 // rtmp.c +203