diff --git a/Connector_RTMP/main.cpp b/Connector_RTMP/main.cpp index 48ed22f5..7526143f 100644 --- a/Connector_RTMP/main.cpp +++ b/Connector_RTMP/main.cpp @@ -91,6 +91,7 @@ int main(int argc, char ** argv){ int retval; int poller = epoll_create(1); + int sspoller = epoll_create(1); struct epoll_event ev; ev.events = EPOLLIN; ev.data.fd = CONN_fd; @@ -119,14 +120,17 @@ int main(int argc, char ** argv){ #endif return 0; } + ev.events = EPOLLIN; + ev.data.fd = ss; + epoll_ctl(sspoller, EPOLL_CTL_ADD, ss, &ev); #ifdef DEBUG fprintf(stderr, "Everything connected, starting to send video data...\n"); #endif inited = true; } - //only send data if previous data has been ACK'ed... - //if (snd_cnt - snd_window_at < snd_window_size){ - if (DDV_ready(ss)){ + + retval = epoll_wait(poller, events, 1, 50); + if ((retval > 0) && (DDV_ready(ss))){ if (FLV_GetPacket(tag, ss)){//able to read a full packet? ts = tag->data[7] * 256*256*256; ts += tag->data[4] * 256*256; @@ -153,7 +157,6 @@ int main(int argc, char ** argv){ #endif } } - //} } //send ACK if we received a whole window if (rec_cnt - rec_window_at > rec_window_size){ diff --git a/util/flv_sock.cpp b/util/flv_sock.cpp index 8de52131..d04e3283 100644 --- a/util/flv_sock.cpp +++ b/util/flv_sock.cpp @@ -32,6 +32,11 @@ bool FLV_Isheader(char * header){ }//FLV_Isheader bool ReadUntil(char * buffer, unsigned int count, unsigned int & sofar, int sock){ + if (count > 500000){ + All_Hell_Broke_Loose = true; + fprintf(stderr, "ReadUntil fail: > 500kb tag? All Hell Broke Loose!\n", strerror(errno)); + return false; + } if (sofar >= count){return true;} int r = 0; r = DDV_iread(buffer + sofar,count-sofar,sock);