Testing oplossing

This commit is contained in:
Thulinma 2011-01-17 14:30:11 +01:00
parent 1413e40dd3
commit 71efc65684
3 changed files with 13 additions and 7 deletions

View file

@ -38,12 +38,14 @@ class user{
int MyBuffer_len; int MyBuffer_len;
int MyNum; int MyNum;
int currsend; int currsend;
bool gotproperaudio;
void * lastpointer; void * lastpointer;
static int UserCount; static int UserCount;
int s; int s;
user(int fd){ user(int fd){
s = fd; s = fd;
MyNum = UserCount++; MyNum = UserCount++;
gotproperaudio = false;
std::cout << "User " << MyNum << " connected" << std::endl; std::cout << "User " << MyNum << " connected" << std::endl;
}//constructor }//constructor
void Disconnect(std::string reason) { void Disconnect(std::string reason) {
@ -64,6 +66,7 @@ class user{
return (currsend == todo); return (currsend == todo);
} }
void Send(buffer ** ringbuf, int buffers){ void Send(buffer ** ringbuf, int buffers){
//TODO: Bij MP3: gotproperaudio - if false, stuur alleen als eerste byte is 0xFF en set op true
//not connected? cancel //not connected? cancel
if (s < 0){return;} if (s < 0){return;}
//still waiting for next buffer? check it //still waiting for next buffer? check it

View file

@ -3,6 +3,7 @@
//debugging level 2 = errors //debugging level 2 = errors
//debugging level 3 = status information //debugging level 3 = status information
//debugging level 4 = extremely verbose status information //debugging level 4 = extremely verbose status information
//debugging level 5 = save all streams to FLV files
#define DEBUG 3 #define DEBUG 3
#include <iostream> #include <iostream>
@ -60,10 +61,11 @@ int mainHandler(int connection){
ev.data.fd = CONN_fd; ev.data.fd = CONN_fd;
epoll_ctl(poller, EPOLL_CTL_ADD, CONN_fd, &ev); epoll_ctl(poller, EPOLL_CTL_ADD, CONN_fd, &ev);
struct epoll_event events[1]; struct epoll_event events[1];
#if DEBUG >= 5
//for writing whole stream to a file
FILE * tmpfile = 0; FILE * tmpfile = 0;
char tmpstr[200]; char tmpstr[200];
#endif
while (!socketError && !All_Hell_Broke_Loose){ while (!socketError && !All_Hell_Broke_Loose){
//only parse input if available or not yet init'ed //only parse input if available or not yet init'ed
@ -135,15 +137,15 @@ int mainHandler(int connection){
tag->data[6] = ftst % 256; tag->data[6] = ftst % 256;
} }
SendMedia((unsigned char)tag->data[0], (unsigned char *)tag->data+11, tag->len-15, ts); SendMedia((unsigned char)tag->data[0], (unsigned char *)tag->data+11, tag->len-15, ts);
#if DEBUG >= 5
//write whole stream to a file
if (tmpfile == 0){ if (tmpfile == 0){
sprintf(tmpstr, "./tmpfile_socket_%i.flv", CONN_fd); sprintf(tmpstr, "./tmpfile_socket_%i.flv", CONN_fd);
tmpfile = fopen(tmpstr, "w"); tmpfile = fopen(tmpstr, "w");
fwrite(FLVHeader, 13, 1, tmpfile); fwrite(FLVHeader, 13, 1, tmpfile);
} }
fwrite(tag->data, tag->len, 1, tmpfile); fwrite(tag->data, tag->len, 1, tmpfile);
#endif
lastcheck = getNowMS(); lastcheck = getNowMS();
#if DEBUG >= 4 #if DEBUG >= 4
fprintf(stderr, "Sent a tag to %i\n", CONN_fd); fprintf(stderr, "Sent a tag to %i\n", CONN_fd);

View file

@ -45,6 +45,7 @@ void parseChunk(){
//6 = pingrequest, 4 bytes data //6 = pingrequest, 4 bytes data
//7 = pingresponse, 4 bytes data //7 = pingresponse, 4 bytes data
//we don't need to process this //we don't need to process this
SendCTL(3, rec_cnt);//send ack (msg 3)
} break; } break;
case 5://window size of other end case 5://window size of other end
#if DEBUG >= 4 #if DEBUG >= 4