Sophie

Sophie

distrib > Arklinux > devel > i586 > media > main-src > by-pkgid > 3e429247145990e1b6b9a4ae41857550 > files > 4

dvbstream-0.4-0.cvs20030207.16ark.src.rpm

--- dvbstream/mpegtools/transform.c.ark	2002-05-15 18:40:30.000000000 +0200
+++ dvbstream/mpegtools/transform.c	2004-01-24 18:33:54.000000000 +0100
@@ -1599,7 +1599,7 @@
 
 }
 
-
+/*
 static void write_ipack(ipack *p, uint8_t *data, int count)
 {
 
@@ -1618,8 +1618,60 @@
 	     diff < 3*p->size/2){
 		
 			p->size = diff/2;
+	}
+	if (p->count + count < p->size){
+		memcpy(p->buf+p->count, data, count); 
+		p->count += count;
+	} else {
+		int rest = p->size - p->count;
+		if (rest < 0) rest = 0;
+		memcpy(p->buf+p->count, data, rest);
+		p->count += rest;
+		send_ipack(p);
+		if (count - rest > 0)
+			write_ipack(p, data+rest, count-rest);
+	}
+}
+*/
+static void write_ipack(ipack *p, uint8_t *data, int count)
+{
+	AudioInfo ai;
+	uint8_t headr[3] = { 0x00, 0x00, 0x01} ;
+	int diff =0;
+
+	if (p->count < 6){
+		if (trans_pts_dts(p->pts) > trans_pts_dts(p->last_pts))
+			memcpy(p->last_pts, p->pts, 5);
+		p->count = 0;
+		memcpy(p->buf+p->count, headr, 3);
+		p->count += 6;
+	}
+	if ( p->size == p->size_orig && p->plength &&
+	     (diff = 6+p->plength - p->found + p->count +count) > p->size &&
+	     diff < 3*p->size/2){
+		
+			p->size = diff/2;
 //			fprintf(stderr,"size: %d \n",p->size);
 	}
+
+	if (p->cid == PRIVATE_STREAM1 && p->count == p->hlength+9){
+		if ((data[0] & 0xF8) != 0x80){
+			int ac3_off;
+
+			ac3_off = get_ac3info(data, count, &ai,0);
+			if (ac3_off>=0 && ai.framesize){
+				p->buf[p->count] = 0x80;
+				p->buf[p->count+1] = (p->size - p->count
+						      - 4 - ac3_off)/ 
+					ai.framesize + 1;
+				p->buf[p->count+2] = (ac3_off >> 8)& 0xFF;
+				p->buf[p->count+3] = (ac3_off)& 0xFF;
+				p->count+=4;
+				
+			}
+		}
+	}
+
 	if (p->count + count < p->size){
 		memcpy(p->buf+p->count, data, count); 
 		p->count += count;
@@ -1635,6 +1687,7 @@
 	}
 }
 
+
 void instant_repack (uint8_t *buf, int count, ipack *p)
 {