changeset 2706:3066369adb32

audio packet writting added
author arpi
date Mon, 05 Nov 2001 02:55:00 +0000
parents 013e84f44cf5
children 97efb75dceb8
files libvo/vo_mpegpes.c
diffstat 1 files changed, 67 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_mpegpes.c	Mon Nov 05 02:53:53 2001 +0000
+++ b/libvo/vo_mpegpes.c	Mon Nov 05 02:55:00 2001 +0000
@@ -1,4 +1,4 @@
-#undef HAVE_DVB
+#define HAVE_DVB
 #define PES_MAX_SIZE 2048
 /* 
  * Based on:
@@ -291,7 +291,7 @@
 
 static unsigned char pes_header[PES_MAX_SIZE];
 
-static void send_pes_packet(unsigned char* data,int len,int id,int timestamp){
+void send_pes_packet(unsigned char* data,int len,int id,int timestamp){
     int x;
 
 	      pes_header[0]=pes_header[1]=0;
@@ -327,6 +327,69 @@
 
 }
 
+void send_lpcm_packet(unsigned char* data,int len,int id,int timestamp){
+    int x;
+
+	      pes_header[0]=pes_header[1]=0;
+	      pes_header[2]=1; pes_header[3]=0xBD;
+    
+    while(len>=4){
+	    int payload_size;
+	    
+	    payload_size=PES_MAX_SIZE-6-20; // max possible data len
+	    if(payload_size>len) payload_size=len;
+	    payload_size&=(~3); // align!
+
+	    payload_size+=20;  //  PTS+headers
+	    
+	    //if(6+payload_size>PES_MAX_SIZE) payload_size=PES_MAX_SIZE-6;
+	    
+    // construct PES header:  (code from ffmpeg's libav)
+	      // startcode:
+	      // packetsize:
+	      pes_header[4]=(payload_size)>>8;
+	      pes_header[5]=(payload_size)&255;
+	      // stuffing:
+	      pes_header[6]=0x81;
+	      pes_header[7]=0x80;
+	      pes_header[8]=10; // hdrlen
+	      // presentation time stamp:
+	      x=(0x02 << 4) | (((timestamp >> 30) & 0x07) << 1) | 1;
+	      pes_header[9]=x;
+	      x=((((timestamp >> 15) & 0x7fff) << 1) | 1);
+	      pes_header[10]=x>>8; pes_header[11]=x&255;
+	      x=((((timestamp) & 0x7fff) << 1) | 1);
+	      pes_header[12]=x>>8; pes_header[13]=x&255;
+	      
+	      pes_header[14]=
+	      pes_header[15]=
+	      pes_header[16]=
+	      pes_header[17]=
+	      pes_header[18]=0xFF; // stuffing
+	      
+	      pes_header[19]=id;
+	      
+	      pes_header[20]=0x07; // dunnowhat
+	      pes_header[21]=0x00;
+	      pes_header[22]=0x04;
+	      pes_header[23]=0x0C;
+	      
+	      pes_header[24]=0x01; // LPCM id
+	      pes_header[25]=0x80;
+	      
+	payload_size-=20;
+	memcpy(&pes_header[6+20],data,payload_size);
+	my_write(pes_header,6+20+payload_size);
+
+	len-=payload_size; data+=payload_size;
+	if(len<=0) break;
+    }
+
+//    printf("PES: draw frame!  pts=%d   size=%d  \n",timestamp,len);
+
+}
+
+
 static uint32_t draw_frame(uint8_t * src[])
 {
     vo_mpegpes_t *p=(vo_mpegpes_t *)src[0];
@@ -400,9 +463,9 @@
 static uint32_t
 query_format(uint32_t format)
 {
-    if(format==IMGFMT_MPEGPES) return 1;
+    if(format==IMGFMT_MPEGPES) return 1|256;
 #ifdef USE_LIBAVCODEC
-    if(format==IMGFMT_YV12) return 1;
+    if(format==IMGFMT_YV12) return 1|256;
 #endif
     return 0;
 }