#include <sys/types.h> #include <sys/socket.h> #include <stdio.h> #include "rtmp.h" int amfDoHandshake(int fd) { int recLen = 0x0; int i = 0x0; int cmd = 0x0; char data1[1536]; char data2[1536]; recLen = sReadSocket(fd,&cmd,1); if (cmd != 0x03) { return(-1); } recLen = sReadSocket(fd,&data1,1536); for (i = 0;i < 1536;i++) { data2[i] = 'a'; } if (send(fd,&cmd,1,MSG_NOSIGNAL) != 1) { printf("Error Sending Header\n"); return(-1); } if (send(fd,&data2,1536,MSG_NOSIGNAL) != 1536) { printf("Error Sending Hand2\n"); return(-1); } if (send(fd,&data1,1536,0) != 1536) { printf("Error Sending Hand1\n"); return(-1); } if (sReadSocket(fd,&data1,1536) != 1536) { printf("Error: getting handshake\n"); return(-1); } printf("Got all data!\n"); return(0x0); } int amfDoAccept(int fd) { char raw1[] = {0x02,0x00,0x00,0x00,0x00,0x00,0x04,0x05,0x00,0x00,0x00,0x00,0x07,0xeb,0x58,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x96,0x14,0x00,0x00,0x00,0x00,0x02,0x00,0x07,0x5f,0x72,0x65,0x73,0x75,0x6c,0x74,0x00,0x3f,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x03,0x00,0x04,0x63,0x6f,0x64,0x65,0x02,0x00,0x1d,0x4e,0x65,0x74,0x43,0x6f,0x6e,0x6e,0x65,0x63,0x74,0x69,0x6f,0x6e,0x2e,0x43,0x6f,0x6e,0x6e,0x65,0x63,0x74,0x2e,0x53,0x75,0x63,0x63,0x65,0x73,0x73,0x00,0x05,0x6c,0x65,0x76,0x65,0x6c,0x02,0x00,0x06,0x73,0x74,0x61,0x74,0x75,0x73,0x00,0x07,0x64,0x65,0x74,0x61,0x69,0x6c,0x73,0x05,0x00,0x0b,0x64,0x65,0x73,0x63,0x72,0x69,0x70,0x74,0x69,0x6f,0x6e,0x02,0x00,0x15,0x43,0x6f,0x6e,0x6e,0x65,0x63,0x74,0x69,0x6f,0x6e,0x20,0x73,0x75,0x63,0x63,0x65,0x65,0x64,0x65,0x64,0x2e,0x00,0x0e,0x6f,0x62,0x6a,0x65,0x02,0x00,0x00,0x00,0x00,0x00,0x05,0x06,0x00,0x00,0x00,0x00,0x00,0x03,0xd0,0x90,0x02,0xc3,0x63,0x74,0x45,0x6e,0x63,0x6f,0x64,0x69,0x6e,0x67,0x00,0x40,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09}; int recLen = 0x0; recLen = send(fd,&raw1,sizeof(raw1),0); if (recLen != sizeof(raw1)) return(-1); return(0x0); }