mplayer中http流媒体协议分析(3)

2018-12-29 18:57

video stream

// otherwise it should be mp3. if there are more types consider

adding mime type

// handling like later

if ( (field_data = http_get_field(http_hdr, \!=

NULL && (!strcmp(field_data, \

else

*file_format = DEMUXER_TYPE_NSV;

if

(

(field_data

=

http_get_field(http_hdr,

\\

}

case 400: // Server Full

mp_msg(MSGT_NETWORK,MSGL_ERR,\ICY-Server

*file_format = DEMUXER_TYPE_AAC;

else

*file_format = DEMUXER_TYPE_AUDIO;

res = STREAM_ERROR; goto out;

is full, skipping!\\n\

goto err_out;

case 401: // Service Unavailable

mp_msg(MSGT_NETWORK,MSGL_ERR,\ICY-Server

return service unavailable, skipping!\\n\

goto err_out;

case 403: // Service Forbidden

mp_msg(MSGT_NETWORK,MSGL_ERR,\ICY-Server

return 'Service Forbidden'\\n\

goto err_out;

case 404: // Resource Not Found

mp_msg(MSGT_NETWORK,MSGL_ERR,\ICY-Server

couldn't find requested stream, skipping!\\n\

goto err_out;

default:

mp_msg(MSGT_NETWORK,MSGL_ERR,%unhandled

ICY-Errorcode, contact MPlayer developers!\\n\

// Assume standard http if not ICY switch( http_hdr->status_code ) {

case 200: // OK

content_length = http_get_field(http_hdr, \if (content_length) {

mp_msg(MSGT_NETWORK,MSGL_V,\

}

}

goto err_out;

[%s]\\n\

}

// Look if we can use the Content-Type

content_type = http_get_field( http_hdr, \if( content_type!=NULL ) {

mp_msg(MSGT_NETWORK,MSGL_V,\stream->end_pos = atoll(content_length);

[%s]\\n\

// Check in the mime type table for a demuxer type i = 0;

while(mime_type_table[i].mime_type != NULL) {

if(

!strcasecmp(

content_type,

mime_type_table[i].mime_type ) ) {

*file_format = mime_type_table[i].demuxer_type; res = seekable;

}

}

}

goto out;

i++;

// Not found in the mime type table, don't fail, // we should try raw HTTP res = seekable; goto out;

// Redirect

case 301: // Permanently case 302: // Temporarily case 303: // See Other

// TODO: RFC 2616, recommand to detect infinite redirection loops next_url = http_get_field( http_hdr, \if( next_url!=NULL ) {

int

is_ultravox

=

strcasecmp(stream->streaming_ctrl->url->protocol, \

stream->streaming_ctrl->url = url_redirect( &url, next_url ); if (!strcasecmp(url->protocol, \ }

if (strcasecmp(url->protocol, \

mp_msg(MSGT_NETWORK,MSGL_ERR,\res = STREAM_REDIRECTED; goto err_out;

http %d redirect to %s protocol\\n\

}

if (is_ultravox) {

free(url->protocol); goto err_out;

}

}

url->protocol = strdup(\

redirect = 1;

break;

case 401: // Authentication required

if( http_authenticate(http_hdr, url, &auth_retry)<0 )

goto err_out;

redirect = 1; break;

default:

mp_msg(MSGT_NETWORK,MSGL_ERR,\

returned %d: %s\\n\ err_out:

if (fd > 0) closesocket( fd ); fd = -1;

http_free( http_hdr ); http_hdr = NULL;

}

goto err_out;

} while( redirect );

out: }

HTTP交互过程:

stream->streaming_ctrl->data = (void*)http_hdr; stream->fd = fd; return res;

C ? S GET请求 GET

http://pdl.warnerbros.com/wbol/us/whv/med/matrix/collection/ultimate_matrix_collection_sizzle_tlr_100.rm HTTP/1.0 Host: pdl.warnerbros.com

User-Agent: MPlayer/SVN-r31525-4.4.3 Icy-MetaData: 1 Connection: close S -> C 响应过程 HTTP/1.1 302 Found

Date: Thu, 02 Sep 2010 10:17:56 GMT Server: Apache Location:

http://wbads-89.vo.llnwd.net/e1/wbol/us/whv/med/matrix/collection/ultimate_matrix_collection_sizzle_tlr_100.rm Content-Length: 0 Connection: close

Content-Type: text/plain

根据响应消息报头 Location的域值

http://wbads-89.vo.llnwd.net/e1/wbol/us/whv/med/matrix/collection/ultimate_matrix_collection_sizzle_tlr_100.rm 重定位

重定位 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 Connection: close

S-> C响应

HTTP/1.0 200 OK Server: Apache

ETag: \Accept-Ranges: bytes Content-Length: 6798223 Cache-Control: max-age=300

Content-Type: application/vnd.rn-realmedia Date: Thu, 02 Sep 2010 10:18:01 GMT

Last-Modified: Sat, 02 Jul 2005 03:01:55 GMT Expires: Thu, 02 Sep 2010 10:23:01 GMT


mplayer中http流媒体协议分析(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2018-2019年初中历史鲁教版《九年级上》《第七单元 垄断资本主义

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: