Stabiliteitsfixes en in theorie werkende H.264 en AAC, maar je weet maar nooit...
This commit is contained in:
parent
a34a9b69cc
commit
94f587563c
10 changed files with 144 additions and 54 deletions
|
@ -15,6 +15,7 @@
|
|||
#include "../sockets/SocketW.h"
|
||||
bool ready4data = false;//set to true when streaming starts
|
||||
bool inited = false;
|
||||
bool stopparsing = false;
|
||||
timeval lastrec;
|
||||
|
||||
#include "parsechunks.cpp" //chunkstream parsing
|
||||
|
@ -44,9 +45,10 @@ int main(){
|
|||
fprintf(stderr, "Starting processing...\n");
|
||||
#endif
|
||||
while (!feof(stdin)){
|
||||
select(1, &pollset, 0, 0, &timeout);
|
||||
//select(1, &pollset, 0, 0, &timeout);
|
||||
//only parse input from stdin if available or not yet init'ed
|
||||
if (FD_ISSET(0, &pollset) || !ready4data || (snd_cnt - snd_window_at >= snd_window_size)){parseChunk();fflush(stdout);}// || !ready4data?
|
||||
//FD_ISSET(0, &pollset) || //NOTE: Polling does not work? WHY?!? WHY DAMN IT?!?
|
||||
if ((!ready4data || (snd_cnt - snd_window_at >= snd_window_size)) && !stopparsing){parseChunk();fflush(stdout);}
|
||||
if (ready4data){
|
||||
if (!inited){
|
||||
//we are ready, connect the socket!
|
||||
|
@ -54,7 +56,7 @@ int main(){
|
|||
#ifdef DEBUG
|
||||
fprintf(stderr, "Could not connect to server!\n");
|
||||
#endif
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
FLV_Readheader(ss);//read the header, we don't want it
|
||||
#ifdef DEBUG
|
||||
|
@ -69,17 +71,29 @@ int main(){
|
|||
ts += FLVbuffer[4] * 256*256;
|
||||
ts += FLVbuffer[5] * 256;
|
||||
ts += FLVbuffer[6];
|
||||
if (fts == 0){fts = ts;ftst = getNowMS();}
|
||||
ts -= fts;
|
||||
FLVbuffer[7] = ts / (256*256*256);
|
||||
FLVbuffer[4] = ts / (256*256);
|
||||
FLVbuffer[5] = ts / 256;
|
||||
FLVbuffer[6] = ts % 256;
|
||||
ts += ftst;
|
||||
if (ts != 0){
|
||||
if (fts == 0){fts = ts;ftst = getNowMS();}
|
||||
ts -= fts;
|
||||
FLVbuffer[7] = ts / (256*256*256);
|
||||
FLVbuffer[4] = ts / (256*256);
|
||||
FLVbuffer[5] = ts / 256;
|
||||
FLVbuffer[6] = ts % 256;
|
||||
ts += ftst;
|
||||
}else{
|
||||
ftst = getNowMS();
|
||||
FLVbuffer[7] = ftst / (256*256*256);
|
||||
FLVbuffer[4] = ftst / (256*256);
|
||||
FLVbuffer[5] = ftst / 256;
|
||||
FLVbuffer[6] = ftst % 256;
|
||||
}
|
||||
SendMedia((unsigned char)FLVbuffer[0], (unsigned char *)FLVbuffer+11, FLV_len-15, ts);
|
||||
//if (FLVbuffer[0] == 9){
|
||||
// fprintf(stderr, "first 2 bytes: 0x%hhx 0x%hhx\n", FLVbuffer[11], FLVbuffer[12]);
|
||||
//}
|
||||
FLV_Dump();//dump packet and get ready for next
|
||||
}
|
||||
if ((SWBerr != SWBaseSocket::ok) && (SWBerr != SWBaseSocket::notReady)){
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "No more data! :-( (%s)\n", SWBerr.get_error().c_str());
|
||||
#endif
|
||||
return 0;//no more input possible! Fail immediately.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,5 +103,8 @@ int main(){
|
|||
SendCTL(3, rec_cnt);//send ack (msg 3)
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "User disconnected.\n");
|
||||
#endif
|
||||
return 0;
|
||||
}//main
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue