From de701fc58ee7d8440f48a3514cb27181229bff75 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Sat, 6 Nov 2010 16:38:19 +0100 Subject: [PATCH] Buffer conn timeout fix --- Buffer/main.cpp | 4 +++- Makefile | 2 +- PLS | 20 +++++++++++++------- util/flv.cpp | 7 ++++--- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Buffer/main.cpp b/Buffer/main.cpp index fb078177..2812df88 100644 --- a/Buffer/main.cpp +++ b/Buffer/main.cpp @@ -55,7 +55,9 @@ int main( int argc, char * argv[] ) { //new FLV file, read the file header again. FLV_Readheader(); } else { - FLV_GetPacket(ringbuf[current_buffer]->FLV); + if (!FLV_GetPacket(ringbuf[current_buffer]->FLV)){ + break;//wrong packet? something bust be broken. End program! + } packtype = ringbuf[current_buffer]->FLV->data[0]; //store metadata, if available if (packtype == 0x12){ diff --git a/Makefile b/Makefile index cceed8f6..8d83b685 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ client-clean: #cd Connector_RTSP; $(MAKE) clean cd Buffer; $(MAKE) clean clean: client-clean -client-install: client +client-install: client-clean client cp -f ./Connector_HTTP/Connector_HTTP /usr/bin/ cp -f ./Connector_RTMP/Connector_RTMP /usr/bin/ cp -f ./Connector_RAW/Connector_RAW /usr/bin/ diff --git a/PLS b/PLS index c4546aa2..d041a879 100644 --- a/PLS +++ b/PLS @@ -8,6 +8,8 @@ service ddvtechhttp server = /usr/bin/Connector_HTTP port = 7337 wait = no + per_source = 10 + cps = 100 5 } service ddvtechrtmp @@ -20,17 +22,21 @@ service ddvtechrtmp server = /usr/bin/Connector_RTMP port = 1935 wait = no + per_source = 10 + cps = 100 5 } service ddvtechraw { - disable = no - type = UNLISTED + disable = no + type = UNLISTED protocol = tcp - socket_type = stream - user = root - server = /usr/bin/Connector_RAW - port = 3773 - wait = no + socket_type = stream + user = root + server = /usr/bin/Connector_RAW + port = 3773 + wait = no + per_source = 10 + cps = 100 5 } diff --git a/util/flv.cpp b/util/flv.cpp index 0e119a52..0c922506 100644 --- a/util/flv.cpp +++ b/util/flv.cpp @@ -35,15 +35,16 @@ bool FLV_Readheader(){ //will assign pointer if null //resizes FLV_Pack data field bigger if data doesn't fit // (does not auto-shrink for speed!) -void FLV_GetPacket(FLV_Pack *& p){ +bool FLV_GetPacket(FLV_Pack *& p){ if (!p){p = (FLV_Pack*)calloc(1, sizeof(FLV_Pack));} if (p->buf < 15){p->data = (char*)realloc(p->data, 15); p->buf = 15;} - fread(p->data,1,11,stdin); + if (fread(p->data,1,11,stdin) != 11){return false;} p->len = p->data[3] + 15; p->len += (p->data[2] << 8); p->len += (p->data[1] << 16); if (p->buf < p->len){p->data = (char*)realloc(p->data, p->len);p->buf = p->len;} - fread(p->data+11,1,p->len-11,stdin); + if (fread(p->data+11,1,p->len-11,stdin) != (unsigned int)(p->len-11)){return false;} p->isKeyframe = false; if ((p->data[0] == 0x09) && (((p->data[11] & 0xf0) >> 4) == 1)){p->isKeyframe = true;} + return true; }//FLV_GetPacket