[MPlayer-dev-eng] Code to download an ASF Playlist and AMD 64 Compile fix

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Dec 21 14:01:37 CET 2007


Hello,
On Fri, Dec 21, 2007 at 01:44:08AM +0000, iorrus mcdonnagh wrote:
> Thats much cleaner mine was a mess, although there seems to be a bug using just your patch as the file you gave works but  mms://ir2-c100.narrowstep.tv/mcp?psid=23504744&ref=0&chid=5&pid=494&vid=16988099&br=800&tid=1&void=25684
> doesn't (it works using my patch with rc1) it could be someting to do with changes since rc1 however as asf_streaming.c seems to be quite different!

Works for me with attached patch. For playback of the second part "-sb 2026732" is needed.

Greetings,
Reimar Döffinger
-------------- next part --------------
diff --git a/stream/asf_streaming.c b/stream/asf_streaming.c
index 856cc1c..24e027d 100644
--- a/stream/asf_streaming.c
+++ b/stream/asf_streaming.c
@@ -174,7 +174,8 @@ static int max_idx(int s_count, int *s_rates, int bound) {
   return best;
 }
 
-static int asf_streaming_parse_header(int fd, streaming_ctrl_t* streaming_ctrl) {
+static int asf_streaming_parse_header(int fd, streaming_ctrl_t* streaming_ctrl,
+             void **ret_buffer, int *ret_bufsize) {
   ASF_stream_chunck_t chunk;
   asf_http_streaming_ctrl_t* asf_ctrl = streaming_ctrl->data;
   char* buffer=NULL, *chunk_buffer=NULL;
@@ -335,6 +336,10 @@ static int asf_streaming_parse_header(int fd, streaming_ctrl_t* streaming_ctrl)
 			}
 		}
   }
+  if (ret_buffer) {
+    *ret_buffer = buffer;
+    *ret_bufsize = size;
+  } else
   free(buffer);
 
   // automatic stream selection based on bandwidth
@@ -414,6 +419,19 @@ static int asf_http_streaming_read( int fd, char *buffer, int size, streaming_ct
       if (asf_read_wrapper(fd, &chunk, sizeof(ASF_stream_chunck_t), streaming_ctrl) <= 0)
         return -1;
       
+      // "playlist" handling
+      if (AV_RL16(&chunk.type) == ASF_STREAMING_CLEAR) {
+        void *buf;
+        int buflen;
+        // reinserts end of chunk that contains header information into the stream
+        streaming_bufferize(streaming_ctrl, (char*)(&chunk)+sizeof(ASF_stream_chunck_t)-4, 4);
+        asf_streaming_parse_header(fd, streaming_ctrl, &buf, &buflen);
+        // reinsert the preprocessed file header
+        streaming_bufferize(streaming_ctrl, buf, buflen);
+        rest = waiting = buflen;
+        continue;
+      }
+
       // Endian handling of the stream chunk
       le2me_ASF_stream_chunck_t(&chunk);
       chunk_size = asf_streaming( &chunk, &drop_chunk );
@@ -761,7 +779,7 @@ static int asf_http_streaming_start( stream_t *stream, int *demuxer_type ) {
 				if( asf_http_ctrl->request==1 ) {
 					if( asf_http_ctrl->streaming_type!=ASF_PlainText_e ) {
 						// First request, we only got the ASF header.
-						ret = asf_streaming_parse_header(fd,stream->streaming_ctrl);
+						ret = asf_streaming_parse_header(fd,stream->streaming_ctrl,NULL,NULL);
 						if(ret < 0) goto err_out;
 						if(asf_http_ctrl->n_audio == 0 && asf_http_ctrl->n_video == 0) {
 							mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_NoStreamFound);


More information about the MPlayer-dev-eng mailing list