This commit is contained in:
Thulinma 2010-11-08 21:23:20 +01:00
parent 0a04e77458
commit a72dc83304
2 changed files with 17 additions and 21 deletions

View file

@ -66,9 +66,7 @@ int main(int argc, char ** argv){
unsigned int fts = 0;
unsigned int ftst;
int ss;
FLV_Pack * tag[2];
tag[0] = 0;
tag[1] = 0;
FLV_Pack * tag = 0;
//first timestamp set
firsttime = getNowMS();
@ -133,30 +131,27 @@ int main(int argc, char ** argv){
retval = epoll_wait(poller, events, 1, 50);
if (DDV_ready(ss)){
if (FLV_GetPacket(tag[0], ss)){//able to read a full packet?
FLV_Pack * tmptag = tag[0];
tag[0] = tag[1];
tag[1] = tmptag;
ts = tag[1]->data[7] * 256*256*256;
ts += tag[1]->data[4] * 256*256;
ts += tag[1]->data[5] * 256;
ts += tag[1]->data[6];
if (FLV_GetPacket(tag, ss)){//able to read a full packet?
ts = tag->data[7] * 256*256*256;
ts += tag->data[4] * 256*256;
ts += tag->data[5] * 256;
ts += tag->data[6];
if (ts != 0){
if (fts == 0){fts = ts;ftst = getNowMS();}
ts -= fts;
tag[1]->data[7] = ts / (256*256*256);
tag[1]->data[4] = ts / (256*256);
tag[1]->data[5] = ts / 256;
tag[1]->data[6] = ts % 256;
tag->data[7] = ts / (256*256*256);
tag->data[4] = ts / (256*256);
tag->data[5] = ts / 256;
tag->data[6] = ts % 256;
ts += ftst;
}else{
ftst = getNowMS();
tag[1]->data[7] = ftst / (256*256*256);
tag[1]->data[4] = ftst / (256*256);
tag[1]->data[5] = ftst / 256;
tag[1]->data[6] = ftst % 256;
tag->data[7] = ftst / (256*256*256);
tag->data[4] = ftst / (256*256);
tag->data[5] = ftst / 256;
tag->data[6] = ftst % 256;
}
SendMedia((unsigned char)tag[1]->data[0], (unsigned char *)tag[1]->data+11, tag[1]->len-15, ts);
SendMedia((unsigned char)tag->data[0], (unsigned char *)tag->data+11, tag->len-15, ts);
#ifdef DEBUG
fprintf(stderr, "Sent a tag to %i\n", CONN_fd);
#endif

View file

@ -35,6 +35,7 @@ bool ReadUntil(char * buffer, unsigned int count, unsigned int & sofar, int sock
if (sofar >= count){return true;}
int r = 0;
r = DDV_iread(buffer + sofar,count-sofar,sock);
fprintf(stderr, "Reading %i/%i, read %i, at %i\n", count, sofar, r, buffer+sofar);
if (r < 0){
if (errno != EWOULDBLOCK){
All_Hell_Broke_Loose = true;