mirror of https://bitbucket.org/ausocean/av.git
Identified functions that need porting using todo comments above HandleInvoke in rtmp.go at +1911 onwards
This commit is contained in:
parent
96290d295d
commit
73e2c9977a
137
rtmp/rtmp.go
137
rtmp/rtmp.go
|
@ -1908,6 +1908,28 @@ 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
|
||||||
|
// TODO port AMF_Dump
|
||||||
|
// TODO port AMFPRop_GetString
|
||||||
|
// TODO port AMF_GetProp
|
||||||
|
// TODO port AMFProp_GetNumber
|
||||||
|
// TODO port RTMP_FindFirstMatchingProperty
|
||||||
|
// TODO port DecodeTEA
|
||||||
|
// TODO port SendSecureTokenResponse
|
||||||
|
// TODO port SendRealseStream
|
||||||
|
// TODO port SendFCPublish
|
||||||
|
// TODO port RTMP_SendServerBW
|
||||||
|
// TODO port RTMP_SendCtrl
|
||||||
|
// TODO port RTMP_SendCreateStream
|
||||||
|
// TODO port SendUsherToken
|
||||||
|
// TODO port SendFCSubscribe
|
||||||
|
// TODO port SendPublish
|
||||||
|
// TODO port SendPlaylist
|
||||||
|
// TODO port SendPlay
|
||||||
|
// TODO port SendCheckBw
|
||||||
|
// TODO port SendPong
|
||||||
|
// TODO port SendCheckBWResult
|
||||||
|
// TODO port AMFProp_GetObject
|
||||||
|
// TODO port AV_erase
|
||||||
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
|
||||||
|
@ -1929,12 +1951,9 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
|
||||||
//RTMP_Log(RTMP_LOGERROR, "%s, error decoding invoke packet", __FUNCTION__);
|
//RTMP_Log(RTMP_LOGERROR, "%s, error decoding invoke packet", __FUNCTION__);
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
// TODO port AMF_Dump
|
|
||||||
C.AMF_Dump(&obj);
|
C.AMF_Dump(&obj);
|
||||||
// TODO port AMFPRop_GetString
|
|
||||||
// TODO port AMF_GetProp
|
|
||||||
C.AMFProp_GetString(C.AMF_GetProp(&obj, NULL, 0), &method);
|
C.AMFProp_GetString(C.AMF_GetProp(&obj, NULL, 0), &method);
|
||||||
// TODO port AMFProp_GetNumber
|
|
||||||
txn = C.AMFProp_GetNumber(AMF_GetProp(&obj, NULL, 1));
|
txn = C.AMFProp_GetNumber(AMF_GetProp(&obj, NULL, 1));
|
||||||
// TODO use new logger here
|
// TODO use new logger here
|
||||||
// RTMP_Log(RTMP_LOGDEBUG, "%s, server invoking <%s>", __FUNCTION__, method.av_val);
|
// RTMP_Log(RTMP_LOGDEBUG, "%s, server invoking <%s>", __FUNCTION__, method.av_val);
|
||||||
|
@ -1946,7 +1965,6 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
|
||||||
for i=0; i < r.m_numCalls; i++ {
|
for i=0; i < r.m_numCalls; i++ {
|
||||||
if r.m_methodCalls[i].num == (int)txn {
|
if r.m_methodCalls[i].num == (int)txn {
|
||||||
methodInvoked = r.m_methodCalls[i].name;
|
methodInvoked = r.m_methodCalls[i].name;
|
||||||
// TODO port AV_erase
|
|
||||||
C.AV_erase(r.m_methodCalls, &r.m_numCalls, i, FALSE);
|
C.AV_erase(r.m_methodCalls, &r.m_numCalls, i, FALSE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1964,147 +1982,140 @@ func C_HandleInvoke(r *C.RTMP, body *byte, nBodySize uint32) int32 {
|
||||||
case C_AVMATCH(&methodInvoked, &av_connect):
|
case C_AVMATCH(&methodInvoked, &av_connect):
|
||||||
if r.Link.token.av_len != 0 {
|
if r.Link.token.av_len != 0 {
|
||||||
var p C.AMFObjectProperty
|
var p C.AMFObjectProperty
|
||||||
|
|
||||||
// TODO port this func
|
|
||||||
if C.RTMP_FindFirstMatchingProperty(&obj, &av_secureToken, &p){
|
if C.RTMP_FindFirstMatchingProperty(&obj, &av_secureToken, &p){
|
||||||
// TODO port this func
|
|
||||||
C.DecodeTEA(&r.Link.token, &p.p_vu.p_aval);
|
C.DecodeTEA(&r.Link.token, &p.p_vu.p_aval);
|
||||||
// TODO port this func
|
|
||||||
C.SendSecureTokenResponse(r, &p.p_vu.p_aval);
|
C.SendSecureTokenResponse(r, &p.p_vu.p_aval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (r.Link.protocol & RTMP_FEATURE_WRITE){
|
if (r.Link.protocol & RTMP_FEATURE_WRITE){
|
||||||
// TODO port this func
|
|
||||||
C.SendReleaseStream(r);
|
C.SendReleaseStream(r);
|
||||||
// TODO port this func
|
|
||||||
C.SendFCPublish(r);
|
C.SendFCPublish(r);
|
||||||
}else{
|
}else{
|
||||||
// TODO port this func
|
|
||||||
C.RTMP_SendServerBW(r);
|
C.RTMP_SendServerBW(r);
|
||||||
// TODO port this func
|
|
||||||
C.RTMP_SendCtrl(r, 3, 0, 300);
|
C.RTMP_SendCtrl(r, 3, 0, 300);
|
||||||
}
|
}
|
||||||
// TODO port this func
|
|
||||||
C.RTMP_SendCreateStream(r);
|
C.RTMP_SendCreateStream(r);
|
||||||
|
|
||||||
if (r.Link.protocol & RTMP_FEATURE_WRITE) == 0 {
|
if (r.Link.protocol & RTMP_FEATURE_WRITE) == 0 {
|
||||||
/* Authenticate on Justin.tv legacy servers before sending FCSubscribe */
|
/* Authenticate on Justin.tv legacy servers before sending FCSubscribe */
|
||||||
if r.Link.usherToken.av_len != 0 {
|
if r.Link.usherToken.av_len != 0 {
|
||||||
// TODO port this func
|
|
||||||
C.SendUsherToken(r, &r.Link.usherToken);
|
C.SendUsherToken(r, &r.Link.usherToken);
|
||||||
}
|
}
|
||||||
/* Send the FCSubscribe if live stream or if subscribepath is set */
|
/* Send the FCSubscribe if live stream or if subscribepath is set */
|
||||||
switch{
|
switch{
|
||||||
case r.Link.subscribepath.av_len:
|
case r.Link.subscribepath.av_len:
|
||||||
// TODO port
|
|
||||||
C.SendFCSubscribe(r, &r.Link.subscribepath);
|
C.SendFCSubscribe(r, &r.Link.subscribepath);
|
||||||
case r.Link.lFlags & RTMP_LF_LIV:
|
case r.Link.lFlags & RTMP_LF_LIV:
|
||||||
SendFCSubscribe(r, &r.Link.playpath);
|
C.SendFCSubscribe(r, &r.Link.playpath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case AVMATCH(&methodInvoked, &av_createStream):
|
case C_AVMATCH(&methodInvoked, &av_createStream):
|
||||||
r.m_stream_id = (int)AMFProp_GetNumber(AMF_GetProp(&obj, NULL, 3));
|
r.m_stream_id = (int)AMFProp_GetNumber(AMF_GetProp(&obj, NULL, 3));
|
||||||
|
|
||||||
if (r.Link.protocol & RTMP_FEATURE_WRITE){
|
if (r.Link.protocol & RTMP_FEATURE_WRITE){
|
||||||
SendPublish(r);
|
C.SendPublish(r);
|
||||||
} else {
|
} else {
|
||||||
if (r.Link.lFlags & RTMP_LF_PLST){
|
if (r.Link.lFlags & RTMP_LF_PLST){
|
||||||
SendPlaylist(r);
|
C.SendPlaylist(r);
|
||||||
}
|
}
|
||||||
SendPlay(r);
|
C.SendPlay(r);
|
||||||
RTMP_SendCtrl(r, 3, r.m_stream_id, r.m_nBufferMS);
|
C.RTMP_SendCtrl(r, 3, r.m_stream_id, r.m_nBufferMS);
|
||||||
}
|
}
|
||||||
case AVMATCH(&methodInvoked, &av_play) ||
|
case C_AVMATCH(&methodInvoked, &av_play) ||
|
||||||
AVMATCH(&methodInvoked, &av_publish):
|
C_AVMATCH(&methodInvoked, &av_publish):
|
||||||
r.m_bPlaying = TRUE;
|
r.m_bPlaying = TRUE;
|
||||||
}
|
}
|
||||||
free(methodInvoked.av_val);
|
free(methodInvoked.av_val);
|
||||||
case (AVMATCH(&method, &av_onBWDone)):
|
case (C_AVMATCH(&method, &av_onBWDone)):
|
||||||
if (!r.m_nBWCheckCounter){
|
if (!r.m_nBWCheckCounter){
|
||||||
SendCheckBW(r);
|
C.SendCheckBW(r);
|
||||||
}
|
}
|
||||||
case AVMATCH(&method, &av_onFCSubscribe):
|
case C_AVMATCH(&method, &av_onFCSubscribe):
|
||||||
/* SendOnFCSubscribe(); */
|
/* SendOnFCSubscribe(); */
|
||||||
case AVMATCH(&method, &av_onFCUnsubscribe):
|
case C_AVMATCH(&method, &av_onFCUnsubscribe):
|
||||||
RTMP_Close(r);
|
RTMP_Close(r);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
case AVMATCH(&method, &av_ping):
|
case C_AVMATCH(&method, &av_ping):
|
||||||
SendPong(r, txn);
|
C.SendPong(r, txn);
|
||||||
case AVMATCH(&method, &av__onbwcheck):
|
case C_AVMATCH(&method, &av__onbwcheck):
|
||||||
SendCheckBWResult(r, txn);
|
C.SendCheckBWResult(r, txn);
|
||||||
case AVMATCH(&method, &av__onbwdone):
|
case C_AVMATCH(&method, &av__onbwdone):
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < r.m_numCalls; i++){
|
for (i = 0; i < r.m_numCalls; i++){
|
||||||
if (AVMATCH(&r.m_methodCalls[i].name, &av__checkbw)){
|
if (C_AVMATCH(&r.m_methodCalls[i].name, &av__checkbw)){
|
||||||
AV_erase(r.m_methodCalls, &r.m_numCalls, i, TRUE);
|
C.AV_erase(r.m_methodCalls, &r.m_numCalls, i, TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case AVMATCH(&method, &av_close):
|
case C_AVMATCH(&method, &av_close):
|
||||||
RTMP_Log(RTMP_LOGERROR, "rtmp server requested close");
|
// TODO use new logger
|
||||||
|
//RTMP_Log(RTMP_LOGERROR, "rtmp server requested close");
|
||||||
RTMP_Close(r);
|
RTMP_Close(r);
|
||||||
case AVMATCH(&method, &av_onStatus):
|
case C_AVMATCH(&method, &av_onStatus):
|
||||||
AMFObject obj2;
|
var obj2 C.AMFObject
|
||||||
AVal code, level;
|
var code, level C.AVal
|
||||||
AMFProp_GetObject(AMF_GetProp(&obj, NULL, 3), &obj2);
|
C.AMFProp_GetObject(AMF_GetProp(&obj, NULL, 3), &obj2);
|
||||||
AMFProp_GetString(AMF_GetProp(&obj2, &av_code, -1), &code);
|
AMFProp_GetString(AMF_GetProp(&obj2, &av_code, -1), &code);
|
||||||
AMFProp_GetString(AMF_GetProp(&obj2, &av_level, -1), &level);
|
AMFProp_GetString(AMF_GetProp(&obj2, &av_level, -1), &level);
|
||||||
|
|
||||||
RTMP_Log(RTMP_LOGDEBUG, "%s, onStatus: %s", __FUNCTION__, code.av_val);
|
// TODO use new logger
|
||||||
|
// RTMP_Log(RTMP_LOGDEBUG, "%s, onStatus: %s", __FUNCTION__, code.av_val);
|
||||||
switch {
|
switch {
|
||||||
case AVMATCH(&code, &av_NetStream_Failed)
|
case C_AVMATCH(&code, &av_NetStream_Failed)
|
||||||
|| AVMATCH(&code, &av_NetStream_Play_Failed)
|
|| C_AVMATCH(&code, &av_NetStream_Play_Failed)
|
||||||
|| AVMATCH(&code, &av_NetStream_Play_StreamNotFound)
|
|| C_AVMATCH(&code, &av_NetStream_Play_StreamNotFound)
|
||||||
|| AVMATCH(&code, &av_NetConnection_Connect_InvalidApp):
|
|| C_AVMATCH(&code, &av_NetConnection_Connect_InvalidApp):
|
||||||
r.m_stream_id = -1;
|
r.m_stream_id = -1;
|
||||||
RTMP_Close(r);
|
RTMP_Close(r);
|
||||||
RTMP_Log(RTMP_LOGERROR, "Closing connection: %s", code.av_val);
|
// TODO use new logger
|
||||||
case AVMATCH(&code, &av_NetStream_Play_Start)
|
// RTMP_Log(RTMP_LOGERROR, "Closing connection: %s", code.av_val);
|
||||||
|| AVMATCH(&code, &av_NetStream_Play_PublishNotify):
|
case C_AVMATCH(&code, &av_NetStream_Play_Start)
|
||||||
|
|| C_AVMATCH(&code, &av_NetStream_Play_PublishNotify):
|
||||||
int i;
|
int i;
|
||||||
r.m_bPlaying = TRUE;
|
r.m_bPlaying = TRUE;
|
||||||
for (i = 0; i < r.m_numCalls; i++){
|
for (i = 0; i < r.m_numCalls; i++){
|
||||||
if (AVMATCH(&r.m_methodCalls[i].name, &av_play)){
|
if (C_AVMATCH(&r.m_methodCalls[i].name, &av_play)){
|
||||||
AV_erase(r.m_methodCalls, &r.m_numCalls, i, TRUE);
|
C.AV_erase(r.m_methodCalls, &r.m_numCalls, i, TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case AVMATCH(&code, &av_NetStream_Publish_Start):
|
case C_AVMATCH(&code, &av_NetStream_Publish_Start):
|
||||||
int i;
|
int i;
|
||||||
r.m_bPlaying = TRUE;
|
r.m_bPlaying = TRUE;
|
||||||
for (i = 0; i < r.m_numCalls; i++){
|
for (i = 0; i < r.m_numCalls; i++){
|
||||||
if (AVMATCH(&r.m_methodCalls[i].name, &av_publish)){
|
if (C_AVMATCH(&r.m_methodCalls[i].name, &av_publish)){
|
||||||
AV_erase(r.m_methodCalls, &r.m_numCalls, i, TRUE);
|
C.AV_erase(r.m_methodCalls, &r.m_numCalls, i, TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case AVMATCH(&code, &av_NetStream_Play_Complete)
|
case C_AVMATCH(&code, &av_NetStream_Play_Complete)
|
||||||
|| AVMATCH(&code, &av_NetStream_Play_Stop)
|
|| C_AVMATCH(&code, &av_NetStream_Play_Stop)
|
||||||
|| AVMATCH(&code, &av_NetStream_Play_UnpublishNotify):
|
|| C_AVMATCH(&code, &av_NetStream_Play_UnpublishNotify):
|
||||||
RTMP_Close(r);
|
RTMP_Close(r);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
case AVMATCH(&code, &av_NetStream_Seek_Notify):
|
case C_AVMATCH(&code, &av_NetStream_Seek_Notify):
|
||||||
r.m_read.flags &= ~RTMP_READ_SEEKING;
|
r.m_read.flags &= ~RTMP_READ_SEEKING;
|
||||||
case AVMATCH(&code, &av_NetStream_Pause_Notify):
|
case C_AVMATCH(&code, &av_NetStream_Pause_Notify):
|
||||||
if (r.m_pausing == 1 || r.m_pausing == 2){
|
if (r.m_pausing == 1 || r.m_pausing == 2){
|
||||||
RTMP_SendPause(r, FALSE, r.m_pauseStamp);
|
RTMP_SendPause(r, FALSE, r.m_pauseStamp);
|
||||||
r.m_pausing = 3;
|
r.m_pausing = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case AVMATCH(&method, &av_playlist_ready):
|
case C_AVMATCH(&method, &av_playlist_ready):
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < r.m_numCalls; i++){
|
for (i = 0; i < r.m_numCalls; i++){
|
||||||
if (AVMATCH(&r.m_methodCalls[i].name, &av_set_playlist)){
|
if (C_AVMATCH(&r.m_methodCalls[i].name, &av_set_playlist)){
|
||||||
AV_erase(r.m_methodCalls, &r.m_numCalls, i, TRUE);
|
C.AV_erase(r.m_methodCalls, &r.m_numCalls, i, TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
leave:
|
leave:
|
||||||
AMF_Reset(&obj);
|
C.AMF_Reset(&obj);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #define AVMATCH(a1,a2)
|
// #define AVMATCH(a1,a2)
|
||||||
// amf.h +63
|
// amf.h +63
|
||||||
func C_AVMATCH(a1, a2 C.AVal) int32 {
|
func C_AVMATCH(a1, a2 C.AVal) int32 {
|
||||||
|
|
Loading…
Reference in New Issue