Polling support voor RTMP connector
This commit is contained in:
parent
f16aa16a66
commit
86ebaa9b04
1 changed files with 14 additions and 6 deletions
|
@ -11,6 +11,9 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
//needed for poll
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
//for connection to server
|
//for connection to server
|
||||||
#include "../sockets/SocketW.h"
|
#include "../sockets/SocketW.h"
|
||||||
bool ready4data = false;//set to true when streaming starts
|
bool ready4data = false;//set to true when streaming starts
|
||||||
|
@ -27,12 +30,16 @@ int main(){
|
||||||
unsigned int fts = 0;
|
unsigned int fts = 0;
|
||||||
unsigned int ftst;
|
unsigned int ftst;
|
||||||
SWUnixSocket ss;
|
SWUnixSocket ss;
|
||||||
fd_set pollset;
|
//fd_set pollset;
|
||||||
struct timeval timeout;
|
//struct timeval timeout;
|
||||||
//0 timeout - return immediately after select call
|
//0 timeout - return immediately after select call
|
||||||
timeout.tv_sec = 1; timeout.tv_usec = 0;
|
//timeout.tv_sec = 1; timeout.tv_usec = 0;
|
||||||
FD_ZERO(&pollset);//clear the polling set
|
//FD_ZERO(&pollset);//clear the polling set
|
||||||
FD_SET(0, &pollset);//add stdin to 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
|
//first timestamp set
|
||||||
firsttime = getNowMS();
|
firsttime = getNowMS();
|
||||||
|
@ -57,7 +64,8 @@ int main(){
|
||||||
//select(1, &pollset, 0, 0, &timeout);
|
//select(1, &pollset, 0, 0, &timeout);
|
||||||
//only parse input from stdin if available or not yet init'ed
|
//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?!?
|
//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 (ready4data){
|
||||||
if (!inited){
|
if (!inited){
|
||||||
//we are ready, connect the socket!
|
//we are ready, connect the socket!
|
||||||
|
|
Loading…
Add table
Reference in a new issue