Web lists-archives.org

[MPlayer-dev-eng] [PATCH] http streaming issues




Hi folks,

I've discovered a couple problems with http streaming in mplayer, and wrote two patches that fix them:

1) Some web servers don't provide a way to seek within a file (example:
Nokia N-series phones), because "Accept-range" http header is absent. MP3
playback code however tries to seek to the end of the file to read some
tags. This fails and all kinds of breakage follows. 730_mp3-streaming.diff
makes mplayer only do the seeking if the stream allows it.

2) ASF streaming code relies on having first few bytes of the stream body
available when it parses the http headers, however it only ensures that the
entire http header is available when reading from a socket, and doesn't
ensure that the beginning of the body is available as well. Some web
servers, such as Windows Media Player in Windows Vista, send the headers
and the body in separate TCP packets, so the body isn't read at all and
this breaks ASF playback. 740_asf-streaming.diff fixes that.

Let me know if you need further explanation.

Alex

diff -uNr MPlayer-r27054.orig/stream/asf_streaming.c MPlayer-r27054/stream/asf_streaming.c
--- MPlayer-r27054.orig/stream/asf_streaming.c	2008-04-09 03:32:35.000000000 +0300
+++ MPlayer-r27054/stream/asf_streaming.c	2008-06-24 17:46:42.000000000 +0300
@@ -731,6 +731,11 @@
 			}
 			http_response_append( http_hdr, buffer, i );
 		} while( !http_is_header_entire( http_hdr ) );
+		// Also receive first few bytes of the body 
+		// because asf_http_parse_response might need that
+		i = recv( fd, buffer, BUFFER_SIZE, 0 );
+		if ( i>0 )      
+			http_response_append( http_hdr, buffer, i );
 		if( mp_msg_test(MSGT_NETWORK,MSGL_V) ) {
 			http_hdr->buffer[http_hdr->buffer_size]='\0';
 			mp_msg(MSGT_NETWORK,MSGL_DBG2,"Response [%s]\n", http_hdr->buffer );

diff -uNr MPlayer-r27054.orig/libmpdemux/demux_audio.c MPlayer-r27054/libmpdemux/demux_audio.c
--- MPlayer-r27054.orig/libmpdemux/demux_audio.c	2008-05-21 19:07:37.000000000 +0300
+++ MPlayer-r27054/libmpdemux/demux_audio.c	2008-06-23 15:04:54.000000000 +0300
@@ -329,7 +329,7 @@
     sh_audio->i_bps = sh_audio->wf->nAvgBytesPerSec;
     free(mp3_found);
     mp3_found = NULL;
-    if(s->end_pos) {
+    if(s->end_pos && (s->flags & STREAM_SEEK)) {
       char tag[4];
       stream_seek(s,s->end_pos-128);
       stream_read(s,tag,3);

_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng