diff --git a/Connector_RTMP/main.cpp b/Connector_RTMP/main.cpp index 2ee622eb..e267f289 100644 --- a/Connector_RTMP/main.cpp +++ b/Connector_RTMP/main.cpp @@ -11,6 +11,9 @@ #include #include +//needed for poll +#include + //for connection to server #include "../sockets/SocketW.h" bool ready4data = false;//set to true when streaming starts @@ -27,12 +30,16 @@ int main(){ unsigned int fts = 0; unsigned int ftst; SWUnixSocket ss; - fd_set pollset; - struct timeval timeout; + //fd_set pollset; + //struct timeval timeout; //0 timeout - return immediately after select call - timeout.tv_sec = 1; timeout.tv_usec = 0; - FD_ZERO(&pollset);//clear the polling set - FD_SET(0, &pollset);//add stdin to polling set + //timeout.tv_sec = 1; timeout.tv_usec = 0; + //FD_ZERO(&pollset);//clear the polling set + //FD_SET(0, &pollset);//add stdin to polling set + + pollfd cinfd[1]; + cinfd[0].fd = fileno(stdin); + cinfd[0].events = POLLIN; //first timestamp set firsttime = getNowMS(); @@ -57,7 +64,8 @@ int main(){ //select(1, &pollset, 0, 0, &timeout); //only parse input from stdin if available or not yet init'ed //FD_ISSET(0, &pollset) || //NOTE: Polling does not work? WHY?!? WHY DAMN IT?!? - if ((!ready4data || (snd_cnt - snd_window_at >= snd_window_size)) && !stopparsing){fflush(stdout);parseChunk();fflush(stdout);} + //if ((!ready4data || (snd_cnt - snd_window_at >= snd_window_size)) && !stopparsing){fflush(stdout);parseChunk();fflush(stdout);} + if ((!ready4data || (snd_cnt - snd_window_at >= snd_window_size)) && poll(cinfd, 1, 100)){parseChunk();fflush(stdout);} if (ready4data){ if (!inited){ //we are ready, connect the socket!