Double tag buffer

This commit is contained in:
Thulinma 2010-11-08 21:10:30 +01:00
parent 0a4afb2d81
commit bcd4ce2ad6

View file

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