rtmp: removed case braces in C_HandlInvoke and replaced code not run with panics in case we do get those cases

This commit is contained in:
saxon 2018-08-28 18:40:10 +09:30
parent bd630fd893
commit 8318f34be4
1 changed files with 114 additions and 174 deletions

View File

@ -1315,10 +1315,9 @@ func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) int32 {
//methodInvoked.av_val);
switch {
case C_AVMATCH(&methodInvoked, &av_connect) != 0:
{
/* NOTE This code doesn't run in our use case
TODO port this eventually
if r.Link.token.av_len != 0 {
panic("No support for link token")
/*
log.Println("2.1")
var p C_AMFObjectProperty
if C.RTMP_FindFirstMatchingProperty(&obj, &av_secureToken, &p) != 0 {
@ -1326,21 +1325,24 @@ func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) int32 {
C.DecodeTEA(&r.Link.token, &p.p_vu.p_aval)
C.SendSecureTokenResponse(r, &p.p_vu.p_aval)
}
}
*/
}
if (r.Link.protocol & RTMP_FEATURE_WRITE) != 0 {
C_SendReleaseStream(r)
C_SendFCPublish(r)
} /* NOTE This code doesn't run in our use case
else {
} else {
panic("Link protocol has no RTMP_FEATURE_WRITE")
/*
log.Println("2.4")
C.RTMP_SendServerBW(r)
C.RTMP_SendCtrl(r, 3, 0, 300)
}
*/
}
C_RTMP_SendCreateStream(r)
/* NOTE This code doesn't run in our use case
if (r.Link.protocol & RTMP_FEATURE_WRITE) == 0 {
panic("Link protocol has no RTMP_FEATURE_WRITE")
/*
log.Println("2.5")
// Authenticate on Justin.tv legacy servers before sending FCSubscribe
if r.Link.usherToken.av_len != 0 {
@ -1360,17 +1362,17 @@ func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) int32 {
C.SendFCSubscribe(r, &r.Link.playpath)
}
}
}
*/
}
case C_AVMATCH(&methodInvoked, &av_createStream) != 0:
{
r.m_stream_id = int32(C_AMFProp_GetNumber(C_AMF_GetProp(&obj, nil, 3)))
if (r.Link.protocol & RTMP_FEATURE_WRITE) != 0 {
C_SendPublish(r)
} /* NOTE This code doesn't run in our use case
else {
} else {
panic("Link protocol has no RTMP_FEATURE_WRITE")
/*
log.Println("5.2")
if (r.Link.lFlags & RTMP_LF_PLST) != 0 {
log.Println("5.3")
@ -1378,66 +1380,41 @@ func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) int32 {
}
C.SendPlay(r)
C.RTMP_SendCtrl(r, 3, C.uint(r.m_stream_id), C.uint(r.m_nBufferMS))
}
*/
}
/*NOTE This code doesn't run in our use case
case C_AVMATCH(&methodInvoked, &av_play) != 0 ||
C_AVMATCH(&methodInvoked, &av_publish) != 0:
{
log.Println("6")
r.m_bPlaying = 1
}
*/
panic("Unsupported method av_play/av_publish")
}
//C.free(unsafe.Pointer(methodInvoked.av_val))
}
case C_AVMATCH(&method, &av_onBWDone) != 0:
{
if r.m_nBWCheckCounter == 0 {
C_SendCheckBW(r)
}
}
/*NOTE This code doesn't run in our use case
case C_AVMATCH(&method, &av_onFCSubscribe) != 0:
case C_AVMATCH(&method, &av_onFCUnsubscribe) != 0:
{
log.Println("8")
C.RTMP_Close(r)
ret = 1
}
case C_AVMATCH(&method, &av_onFCUnsubscribe) != 0 || C_AVMATCH(&method, &av_onFCSubscribe) != 0:
panic("Unsupported method av_onFCUnsubscribe/av_onFCSubscribe")
case C_AVMATCH(&method, &av_ping) != 0:
{
log.Println("9")
panic("Unsupported method av_ping")
/*
C.SendPong(r, float64(txn))
}
*/
case C_AVMATCH(&method, &av__onbwcheck) != 0:
{
panic("Unsupported method av_onbwcheck")
/*
log.Println("10")
C.SendCheckBWResult(r, float64(txn))
}
case C_AVMATCH(&method, &av__onbwdone) != 0:
{
log.Println("11")
var i int32
for i = 0; i < int32(r.m_numCalls); i++ {
if C_AVMATCH(&(*(*C_RTMP_METHOD)(incPtr(unsafe.Pointer(r.m_methodCalls), int(i),
int(unsafe.Sizeof(*r.m_methodCalls))))).name, &av__checkbw) != 0 {
C.AV_erase(r.m_methodCalls, &r.m_numCalls, int32(i), 1)
break
}
}
}
case C_AVMATCH(&method, &av_close) != 0:
{
log.Println("12")
// TODO use new logger
//RTMP_Log(RTMP_LOGERROR, "rtmp server requested close");
C.RTMP_Close(r)
}
*/
case C_AVMATCH(&method, &av__onbwdone) != 0:
panic("Unsupported method av_onbwdone")
case C_AVMATCH(&method, &av_close) != 0:
panic("Unsupported method av_close")
case C_AVMATCH(&method, &av_onStatus) != 0:
{
var obj2 C_AMFObject
var code, level C_AVal
C_AMFProp_GetObject(C_AMF_GetProp(&obj, nil, 3), &obj2)
@ -1447,36 +1424,18 @@ func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) int32 {
// TODO use new logger
// RTMP_Log(RTMP_LOGDEBUG, "%s, onStatus: %s", __FUNCTION__, code.av_val);
switch {
/*NOTE This code doesn't run in our use case
case C_AVMATCH(&code, &av_NetStream_Failed) != 0 ||
C_AVMATCH(&code, &av_NetStream_Play_Failed) != 0 ||
C_AVMATCH(&code, &av_NetStream_Play_StreamNotFound) != 0 ||
C_AVMATCH(&code, &av_NetConnection_Connect_InvalidApp) != 0:
{
log.Println("14")
r.m_stream_id = -1
C.RTMP_Close(r)
// TODO use new logger
// RTMP_Log(RTMP_LOGERROR, "Closing connection: %s", code.av_val);
}
panic("Unsupported method av_NetStream/av_NetStream_Play_Failed/av_netSTream_Play_StreamNotFound/av_netConnection_Connect_invalidApp")
case C_AVMATCH(&code, &av_NetStream_Play_Start) != 0 ||
C_AVMATCH(&code, &av_NetStream_Play_PublishNotify) != 0:
{
log.Println("15")
var i int32
r.m_bPlaying = 1
for i = 0; i < int32(r.m_numCalls); i++ {
if C_AVMATCH(&(*(*C_RTMP_METHOD)(incPtr(unsafe.Pointer(r.m_methodCalls), int(i),
int(unsafe.Sizeof(*r.m_methodCalls))))).name, &av_play) != 0 {
log.Println("15.1")
C.AV_erase(r.m_methodCalls, &r.m_numCalls, int32(i), 1)
break
}
}
}
*/
panic("Unsupported method av_NetStream_Play_Start/av_NetStream_Play_PublishNotify")
case C_AVMATCH(&code, &av_NetStream_Publish_Start) != 0:
{
var i int32
r.m_bPlaying = 1
for i = 0; i < int32(r.m_numCalls); i++ {
@ -1487,49 +1446,30 @@ func C_HandleInvoke(r *C_RTMP, body *byte, nBodySize uint32) int32 {
break
}
}
}
/*NOTE This code doesn't run in our use case
case C_AVMATCH(&code, &av_NetStream_Play_Complete) != 0 ||
C_AVMATCH(&code, &av_NetStream_Play_Stop) != 0 ||
C_AVMATCH(&code, &av_NetStream_Play_UnpublishNotify) != 0:
{
log.Println("17")
C.RTMP_Close(r)
ret = 1
}
panic("Unsupported method av_NetStream_Play_Complete/av_NetStream_Play_Stop/av_NetStream_Play_UnpublishNotify")
case C_AVMATCH(&code, &av_NetStream_Seek_Notify) != 0:
{
log.Println("18")
// NOTE ~ has been replace by ^ - is this correct ?
r.m_read.flags = uint8(int8(r.m_read.flags) & ^RTMP_READ_SEEKING)
}
panic("Unsupported method av_netStream_Seek_Notify")
case C_AVMATCH(&code, &av_NetStream_Pause_Notify) != 0:
{
panic("Unsupported method av_NetStream_Pause_Notify")
/*
log.Println("19")
if r.m_pausing == 1 || r.m_pausing == 2 {
C.RTMP_SendPause(r, 0, int32(r.m_pauseStamp))
r.m_pausing = 3
}
}
*/
}
}
/*NOTE This code doesn't run in our use case
case C_AVMATCH(&method, &av_playlist_ready) != 0:
{
log.Println("19")
var i int32
for i = 0; i < int32(r.m_numCalls); i++ {
if C_AVMATCH(&(*(*C_RTMP_METHOD)(incPtr(unsafe.Pointer(r.m_methodCalls), int(i),
int(unsafe.Sizeof(*r.m_methodCalls))))).name, &av_set_playlist) != 0 {
C.AV_erase(r.m_methodCalls, &r.m_numCalls, int32(i), 1)
break
}
}
}
panic("Unsupported method av_playlist_ready")
default:
log.Println("20")
*/
}
leave:
C_AMF_Reset(&obj)