Connection: close
5.2 Seek过程:需要关闭socket重新建立连接。
1. 发送GET请求,需要包含Range域信息,如Range: bytes=(int64_t)pos \,表示数据从pos开始。 2. 得到响应信息并解析
http_seek( stream_t *stream, off_t pos ) { HTTP_header_t *http_hdr = NULL; int fd; if( stream==NULL ) return 0; if( stream->fd>0 ) closesocket(stream->fd); // need to reconnect to seek in http-stream fd = http_send_request( stream->streaming_ctrl->url, pos ); if( fd<0 ) return 0; http_hdr = http_read_response( fd ); if( http_hdr==NULL ) return 0; if( mp_msg_test(MSGT_NETWORK,MSGL_V) ) http_debug_hdr( http_hdr ); switch( http_hdr->status_code ) { case 200: case 206: // OK mp_msg(MSGT_NETWORK,MSGL_V,\[%s]\\n\http_get_field(http_hdr, \ mp_msg(MSGT_NETWORK,MSGL_V,\[%s]\\n\http_get_field(http_hdr, \ if( http_hdr->body_size>0 ) { if( streaming_bufferize( stream->streaming_ctrl, http_hdr->body, http_hdr->body_size )<0 ) { http_free( http_hdr ); return -1; } } break;
default: mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_ErrServerReturned, http_hdr->status_code, http_hdr->reason_phrase ); closesocket( fd ); fd = -1; } stream->fd = fd; if( http_hdr ) { http_free( http_hdr ); stream->streaming_ctrl->data = NULL; } stream->pos=pos; return 1; }
HTTP seek交互过程: C ? S GET请求 GET
http://wbads-89.vo.llnwd.net/e1/wbol/us/whv/med/matrix/collection/ultimate_matrix_collection_sizzle_tlr_100.rm HTTP/1.0 Host: wbads-89.vo.llnwd.net
User-Agent: MPlayer/SVN-r31525-4.4.3 Icy-MetaData: 1
Range: bytes=3704832- Connection: close S -> C 响应过程
HTTP/1.0 206 Partial Content Server: Apache
Accept-Ranges: bytes
Cache-Control: max-age=300
Content-Type: application/vnd.rn-realmedia
Content-Range: bytes 3704832-6798222/6798223 Content-Length: 3093391 Age: 188
Date: Fri, 03 Sep 2010 07:21:54 GMT
Last-Modified: Sat, 02 Jul 2005 03:01:55 GMT Expires: Fri, 03 Sep 2010 07:23:46 GMT Connection: close