changeset 4288:b84e9861461c

Changed the asf_file_header_t struct to read all the fields properly.
author bertrand
date Sun, 20 Jan 2002 21:38:11 +0000
parents 438345c64f3a
children 973c6912c586
files libmpdemux/asf.h libmpdemux/asf_streaming.c libmpdemux/asfheader.c
diffstat 3 files changed, 41 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/asf.h	Sun Jan 20 19:08:56 2002 +0000
+++ b/libmpdemux/asf.h	Sun Jan 20 21:38:11 2002 +0000
@@ -48,6 +48,7 @@
 /////////////////////
 // ASF File Header 
 /////////////////////
+/* Bertrand -- 2002/01/19 -- Start --
 typedef struct __attribute__((packed)) {
   uint8_t client[16]; // Client GUID
   uint64_t file_size;
@@ -62,6 +63,21 @@
   uint32_t packetsize2; //Size of packet ( confirm ) UINT32 4
   uint32_t frame_size; //Size of uncompressed video frame UINT32 4
 } ASF_file_header_t;
+*/
+typedef struct __attribute__((packed)) {
+  uint8_t stream_id[16]; // stream GUID
+  uint64_t file_size;
+  uint64_t creation_time; //File creation time FILETIME 8
+  uint64_t num_packets;    //Number of packets UINT64 8
+  uint64_t play_duration; //Timestamp of the end position UINT64 8
+  uint64_t send_duration;  //Duration of the playback UINT64 8
+  uint64_t preroll; //Time to bufferize before playing UINT32 4
+  uint32_t flags; //Unknown, maybe flags ( usually contains 2 ) UINT32 4
+  uint32_t min_packet_size; //Min size of the packet, in bytes UINT32 4
+  uint32_t max_packet_size; //Max size of the packet  UINT32 4
+  uint32_t max_bitrate; //Maximum bitrate of the media (sum of all the stream)
+} ASF_file_header_t;
+// Bertrand -- 2002/01/19 -- End --
 
 ///////////////////////
 // ASF Stream Header
@@ -138,6 +154,7 @@
     (h)->stream_no = le2me_16((h)->stream_no);				\
     (h)->unk2 = le2me_32((h)->unk2);					\
 }
+/* Bertrand -- 2002/01/19 -- Start --
 #define le2me_ASF_file_header_t(h) {					\
     (h)->file_size = le2me_64((h)->file_size);				\
     (h)->creat_time = le2me_64((h)->creat_time);			\
@@ -151,6 +168,20 @@
     (h)->packetsize2 = le2me_32((h)->packetsize2);			\
     (h)->frame_size = le2me_32((h)->frame_size);			\
 }
+*/
+#define le2me_ASF_file_header_t(h) {					\
+    (h)->file_size = le2me_64((h)->file_size);				\
+    (h)->creation_time = le2me_64((h)->creation_time);			\
+    (h)->num_packets = le2me_64((h)->num_packets);			\
+    (h)->play_duration = le2me_64((h)->play_duration);			\
+    (h)->send_duration = le2me_64((h)->send_duration);			\
+    (h)->preroll = le2me_64((h)->preroll);				\
+    (h)->flags = le2me_32((h)->flags);					\
+    (h)->min_packet_size = le2me_32((h)->min_packet_size);		\
+    (h)->max_packet_size = le2me_32((h)->max_packet_size);		\
+    (h)->max_bitrate = le2me_32((h)->max_bitrate);			\
+}
+// Bertrand -- 2002/01/19 -- End --
 #define le2me_ASF_content_description_t(h) {				\
     (h)->title_size = le2me_16((h)->title_size);			\
     (h)->author_size = le2me_16((h)->author_size);			\
--- a/libmpdemux/asf_streaming.c	Sun Jan 20 19:08:56 2002 +0000
+++ b/libmpdemux/asf_streaming.c	Sun Jan 20 21:38:11 2002 +0000
@@ -209,15 +209,16 @@
       pos += sizeof(objh);
       memcpy(&fileh,buffer + pos,sizeof(fileh));
       le2me_ASF_file_header_t(&fileh);
+/*
       if(fileh.packetsize != fileh.packetsize2) {
 	printf("Error packetsize check don't match\n");
 	return -1;
       }
-      asf_ctrl->packet_size = fileh.packetsize;
-      // FIXME: preroll contains the amount of time to bufferize
-      // before playing. To be able to do that we need to
-      // read the timestamp of the first data packet and bufferize.
-      streaming_ctrl->prebuffer_size = fileh.preroll;
+*/
+      asf_ctrl->packet_size = fileh.max_packet_size;
+      // before playing. 
+      // preroll: time in ms to bufferize before playing
+      streaming_ctrl->prebuffer_size = (unsigned int)((double)((double)fileh.preroll/1000)*((double)fileh.max_bitrate/8));
       pos += sizeof(fileh);
       break;
     case 0xB7DC0791 : // stream header
@@ -655,9 +656,8 @@
 	} else {
 		stream->streaming_ctrl->streaming_read = asf_http_streaming_read;
 		stream->streaming_ctrl->streaming_seek = asf_http_streaming_seek;
+		stream->streaming_ctrl->buffering = 1;
 	}
-	stream->streaming_ctrl->prebuffer_size = 20000;
-	stream->streaming_ctrl->buffering = 1;
 	stream->streaming_ctrl->status = streaming_playing_e;
 
 	http_free( http_hdr );
--- a/libmpdemux/asfheader.c	Sun Jan 20 19:08:56 2002 +0000
+++ b/libmpdemux/asfheader.c	Sun Jan 20 21:38:11 2002 +0000
@@ -200,8 +200,9 @@
     case ASF_GUID_PREFIX_file_header: // guid_file_header
       stream_read(demuxer->stream,(char*) &fileh,sizeof(fileh));
       le2me_ASF_file_header_t(&fileh);
-      mp_msg(MSGT_HEADER,MSGL_V,"ASF: packets: %d  flags: %d  pack_size: %d  frame_size: %d\n",(int)fileh.packets,(int)fileh.flags,(int)fileh.packetsize,(int)fileh.frame_size);
-      asf_packetsize=fileh.packetsize;
+      //mp_msg(MSGT_HEADER,MSGL_V,"ASF: packets: %d  flags: %d  pack_size: %d  frame_size: %d\n",(int)fileh.packets,(int)fileh.flags,(int)fileh.packetsize,(int)fileh.frame_size);
+      mp_msg(MSGT_HEADER,MSGL_V,"ASF: packets: %d  flags: %d  max_packet_size: %d  min_packet_size: %d  max_bitrate: %d  preroll: %d\n",(int)fileh.num_packets,(int)fileh.flags,(int)fileh.min_packet_size,(int)fileh.max_packet_size,(int)fileh.max_bitrate,(int)fileh.preroll);
+      asf_packetsize=fileh.max_packet_size;
       asf_packet=malloc(asf_packetsize); // !!!
       break;
     case ASF_GUID_PREFIX_data_chunk: // guid_data_chunk