mirror of
https://github.com/mpv-player/mpv
synced 2025-01-18 21:31:13 +00:00
Support stream redirection from http to mms, fix bug #927.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25163 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
88f37769f2
commit
0bb30d41b3
@ -721,7 +721,7 @@ static int http_streaming_start(stream_t *stream, int* file_format) {
|
||||
HTTP_header_t *http_hdr = NULL;
|
||||
unsigned int i;
|
||||
int fd = stream->fd;
|
||||
int res = 0;
|
||||
int res = STREAM_UNSUPPORTED;
|
||||
int redirect = 0;
|
||||
int auth_retry=0;
|
||||
int seekable=0;
|
||||
@ -783,6 +783,7 @@ static int http_streaming_start(stream_t *stream, int* file_format) {
|
||||
*file_format = DEMUXER_TYPE_AAC;
|
||||
else
|
||||
*file_format = DEMUXER_TYPE_AUDIO;
|
||||
res = STREAM_ERROR;
|
||||
goto out;
|
||||
}
|
||||
case 400: // Server Full
|
||||
@ -836,6 +837,14 @@ static int http_streaming_start(stream_t *stream, int* file_format) {
|
||||
next_url = http_get_field( http_hdr, "Location" );
|
||||
if( next_url!=NULL ) {
|
||||
stream->streaming_ctrl->url = url_redirect( &url, next_url );
|
||||
if (!strcasecmp(url->protocol, "mms")) {
|
||||
res = STREAM_REDIRECTED;
|
||||
goto err_out;
|
||||
}
|
||||
if (strcasecmp(url->protocol, "http")) {
|
||||
mp_msg(MSGT_NETWORK,MSGL_ERR,"Unsupported http %d redirect to %s protocol\n", http_hdr->status_code, url->protocol);
|
||||
goto err_out;
|
||||
}
|
||||
redirect = 1;
|
||||
}
|
||||
break;
|
||||
@ -853,7 +862,6 @@ static int http_streaming_start(stream_t *stream, int* file_format) {
|
||||
err_out:
|
||||
if (fd > 0) closesocket( fd );
|
||||
fd = -1;
|
||||
res = STREAM_UNSUPPORTED;
|
||||
http_free( http_hdr );
|
||||
http_hdr = NULL;
|
||||
out:
|
||||
@ -908,6 +916,8 @@ static int open_s1(stream_t *stream,int mode, void* opts, int* file_format) {
|
||||
if (stream->fd >= 0)
|
||||
closesocket(stream->fd);
|
||||
stream->fd = -1;
|
||||
if (seekable == STREAM_REDIRECTED)
|
||||
return seekable;
|
||||
streaming_ctrl_free(stream->streaming_ctrl);
|
||||
stream->streaming_ctrl = NULL;
|
||||
return STREAM_UNSUPPORTED;
|
||||
|
@ -145,7 +145,8 @@ stream_info_t* auto_open_streams[] = {
|
||||
};
|
||||
|
||||
stream_t* open_stream_plugin(stream_info_t* sinfo,char* filename,int mode,
|
||||
char** options, int* file_format, int* ret) {
|
||||
char** options, int* file_format, int* ret,
|
||||
char** redirected_url) {
|
||||
void* arg = NULL;
|
||||
stream_t* s;
|
||||
m_struct_t* desc = (m_struct_t*)sinfo->opts;
|
||||
@ -178,6 +179,16 @@ stream_t* open_stream_plugin(stream_info_t* sinfo,char* filename,int mode,
|
||||
s->flags |= mode;
|
||||
*ret = sinfo->open(s,mode,arg,file_format);
|
||||
if((*ret) != STREAM_OK) {
|
||||
#ifdef MPLAYER_NETWORK
|
||||
if (*ret == STREAM_REDIRECTED && redirected_url) {
|
||||
if (s->streaming_ctrl && s->streaming_ctrl->url
|
||||
&& s->streaming_ctrl->url->url)
|
||||
*redirected_url = strdup(s->streaming_ctrl->url->url);
|
||||
else
|
||||
*redirected_url = NULL;
|
||||
}
|
||||
streaming_ctrl_free(s->streaming_ctrl);
|
||||
#endif
|
||||
free(s->url);
|
||||
free(s);
|
||||
return NULL;
|
||||
@ -204,6 +215,7 @@ stream_t* open_stream_full(char* filename,int mode, char** options, int* file_fo
|
||||
int i,j,l,r;
|
||||
stream_info_t* sinfo;
|
||||
stream_t* s;
|
||||
char *redirected_url = NULL;
|
||||
|
||||
for(i = 0 ; auto_open_streams[i] ; i++) {
|
||||
sinfo = auto_open_streams[i];
|
||||
@ -218,9 +230,17 @@ stream_t* open_stream_full(char* filename,int mode, char** options, int* file_fo
|
||||
((strncmp(sinfo->protocols[j],filename,l) == 0) &&
|
||||
(strncmp("://",filename+l,3) == 0))) {
|
||||
*file_format = DEMUXER_TYPE_UNKNOWN;
|
||||
s = open_stream_plugin(sinfo,filename,mode,options,file_format,&r);
|
||||
s = open_stream_plugin(sinfo,filename,mode,options,file_format,&r,
|
||||
&redirected_url);
|
||||
if(s) return s;
|
||||
if(r != STREAM_UNSUPPORTED) {
|
||||
if(r == STREAM_REDIRECTED && redirected_url) {
|
||||
mp_msg(MSGT_OPEN,MSGL_V, "[%s] open %s redirected to %s\n",
|
||||
sinfo->info, filename, redirected_url);
|
||||
s = open_stream_full(redirected_url, mode, options, file_format);
|
||||
free(redirected_url);
|
||||
return s;
|
||||
}
|
||||
else if(r != STREAM_UNSUPPORTED) {
|
||||
mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_FailedToOpen,filename);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
#define STREAM_SEEK (STREAM_SEEK_BW|STREAM_SEEK_FW)
|
||||
|
||||
//////////// Open return code
|
||||
#define STREAM_REDIRECTED -2
|
||||
/// This can't open the requested protocol (used by stream wich have a
|
||||
/// * protocol when they don't know the requested protocol)
|
||||
#define STREAM_UNSUPPORTED -1
|
||||
|
Loading…
Reference in New Issue
Block a user