Ported AMF_DecodeInt32 to C_AMF_DecodeInt32 - tested and working

This commit is contained in:
saxon 2018-08-12 20:45:46 +09:30
parent 1fcb91dcef
commit 74735feb63
3 changed files with 33 additions and 17 deletions

View File

@ -125,14 +125,14 @@ static int SendUsherToken(RTMP *r, AVal *usherToken);
static int SendBGHasStream(RTMP *r, double dId, AVal *playpath);
#endif
static int HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize);
static int HandleMetadata(RTMP *r, char *body, unsigned int len);
static void HandleChangeChunkSize(RTMP *r, const RTMPPacket *packet);
static void HandleAudio(RTMP *r, const RTMPPacket *packet);
static void HandleVideo(RTMP *r, const RTMPPacket *packet);
static void HandleCtrl(RTMP *r, const RTMPPacket *packet);
static void HandleServerBW(RTMP *r, const RTMPPacket *packet);
static void HandleClientBW(RTMP *r, const RTMPPacket *packet);
int HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize);
int HandleMetadata(RTMP *r, char *body, unsigned int len);
void HandleChangeChunkSize(RTMP *r, const RTMPPacket *packet);
void HandleAudio(RTMP *r, const RTMPPacket *packet);
void HandleVideo(RTMP *r, const RTMPPacket *packet);
void HandleCtrl(RTMP *r, const RTMPPacket *packet);
void HandleServerBW(RTMP *r, const RTMPPacket *packet);
void HandleClientBW(RTMP *r, const RTMPPacket *packet);
int ReadN(RTMP *r, char *buffer, int n);
int WriteN(RTMP *r, const char *buffer, int n);
@ -2908,7 +2908,7 @@ static const AVal av_NetConnection_Connect_Rejected =
AVC("NetConnection.Connect.Rejected");
/* Returns 0 for OK/Failed/error, 1 for 'Stop or Complete' */
static int
int
HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
{
AMFObject obj;
@ -3299,7 +3299,7 @@ SAVC(duration);
SAVC(video);
SAVC(audio);
static int
int
HandleMetadata(RTMP *r, char *body, unsigned int len)
{
/* allright we get some info here, so parse it and print it */
@ -3341,7 +3341,7 @@ HandleMetadata(RTMP *r, char *body, unsigned int len)
return ret;
}
static void
void
HandleChangeChunkSize(RTMP *r, const RTMPPacket *packet)
{
if (packet->m_nBodySize >= 4)
@ -3352,17 +3352,17 @@ HandleChangeChunkSize(RTMP *r, const RTMPPacket *packet)
}
}
static void
void
HandleAudio(RTMP *r, const RTMPPacket *packet)
{
}
static void
void
HandleVideo(RTMP *r, const RTMPPacket *packet)
{
}
static void
void
HandleCtrl(RTMP *r, const RTMPPacket *packet)
{
short nType = -1;
@ -3504,14 +3504,14 @@ HandleCtrl(RTMP *r, const RTMPPacket *packet)
}
}
static void
void
HandleServerBW(RTMP *r, const RTMPPacket *packet)
{
r->m_nServerBW = AMF_DecodeInt32(packet->m_body);
RTMP_Log(RTMP_LOGDEBUG, "%s: server BW = %d", __FUNCTION__, r->m_nServerBW);
}
static void
void
HandleClientBW(RTMP *r, const RTMPPacket *packet)
{
r->m_nClientBW = AMF_DecodeInt32(packet->m_body);

View File

@ -309,6 +309,16 @@ extern "C"
int ReadN(RTMP *r, char *buffer, int n);
int HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize);
int HandleMetadata(RTMP *r, char *body, unsigned int len);
void HandleChangeChunkSize(RTMP *r, const RTMPPacket *packet);
void HandleAudio(RTMP *r, const RTMPPacket *packet);
void HandleVideo(RTMP *r, const RTMPPacket *packet);
void HandleCtrl(RTMP *r, const RTMPPacket *packet);
void HandleServerBW(RTMP *r, const RTMPPacket *packet);
void HandleClientBW(RTMP *r, const RTMPPacket *packet);
int RTMP_SetOpt(RTMP *r, const AVal *opt, AVal *arg);
int RTMP_SetupURL(RTMP *r, char *url);
void RTMP_SetupStream(RTMP *r, int protocol,

View File

@ -40,6 +40,12 @@ const (
dec = 3
)
const (
byteSize = 1
int32Size = 4
int64Size = 8
)
var (
byteArr = [arrSize]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}
int32Arr = [arrSize]int32{1, 2, 3, 4, 5, 6}
@ -70,7 +76,7 @@ func TestMemset(t *testing.T) {
setNum := 5
testVal := byte('A')
mem := allocate(uintptr(size))
memset((*byte)(mem), testVal, setNum)
memset((*byte)(mem), int(testVal), setNum)
for i := 0; i < size; i++ {
if i > setNum-1 {
testVal = byte(0)