mirror of
https://github.com/mpv-player/mpv
synced 2025-02-17 13:17:13 +00:00
Fix redirection in real rtsp connections.
Patch by yepyep (sdpplin.c part not committed) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10200 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
39fe37918d
commit
7f47ef5532
@ -912,8 +912,15 @@ realrtsp_streaming_start( stream_t *stream ) {
|
|||||||
rtsp_session_t *rtsp;
|
rtsp_session_t *rtsp;
|
||||||
char *mrl;
|
char *mrl;
|
||||||
int port;
|
int port;
|
||||||
|
int redirected, temp;
|
||||||
char aport[10];
|
char aport[10];
|
||||||
if( stream==NULL ) return -1;
|
if( stream==NULL ) return -1;
|
||||||
|
|
||||||
|
temp = 5; // counter so we don't get caught in infinite redirections (you never know)
|
||||||
|
|
||||||
|
do {
|
||||||
|
|
||||||
|
redirected = 0;
|
||||||
|
|
||||||
fd = connect2Server( stream->streaming_ctrl->url->hostname,
|
fd = connect2Server( stream->streaming_ctrl->url->hostname,
|
||||||
port = (stream->streaming_ctrl->url->port ? stream->streaming_ctrl->url->port : 554) );
|
port = (stream->streaming_ctrl->url->port ? stream->streaming_ctrl->url->port : 554) );
|
||||||
@ -925,9 +932,20 @@ realrtsp_streaming_start( stream_t *stream ) {
|
|||||||
strcpy(mrl,stream->streaming_ctrl->url->url);
|
strcpy(mrl,stream->streaming_ctrl->url->url);
|
||||||
strcat(mrl,":");
|
strcat(mrl,":");
|
||||||
strcat(mrl,aport);
|
strcat(mrl,aport);
|
||||||
rtsp = rtsp_session_start(fd,mrl, stream->streaming_ctrl->url->file,
|
rtsp = rtsp_session_start(fd,&mrl, stream->streaming_ctrl->url->file,
|
||||||
stream->streaming_ctrl->url->hostname, port);
|
stream->streaming_ctrl->url->hostname, port, &redirected);
|
||||||
|
|
||||||
|
if ( redirected == 1 ) {
|
||||||
|
url_free(stream->streaming_ctrl->url);
|
||||||
|
stream->streaming_ctrl->url = url_new(mrl);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
free(mrl);
|
free(mrl);
|
||||||
|
temp--;
|
||||||
|
|
||||||
|
} while( (redirected != 0) && (temp > 0) );
|
||||||
|
|
||||||
if(!rtsp) return -1;
|
if(!rtsp) return -1;
|
||||||
|
|
||||||
stream->fd=fd;
|
stream->fd=fd;
|
||||||
|
@ -65,7 +65,7 @@ struct rtsp_session_s {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//rtsp_session_t *rtsp_session_start(char *mrl) {
|
//rtsp_session_t *rtsp_session_start(char *mrl) {
|
||||||
rtsp_session_t *rtsp_session_start(int fd, char *mrl, char *path, char *host, int port) {
|
rtsp_session_t *rtsp_session_start(int fd, char **mrl, char *path, char *host, int port, int *redir) {
|
||||||
|
|
||||||
rtsp_session_t *rtsp_session=malloc(sizeof(rtsp_session_t));
|
rtsp_session_t *rtsp_session=malloc(sizeof(rtsp_session_t));
|
||||||
char *server;
|
char *server;
|
||||||
@ -73,10 +73,11 @@ rtsp_session_t *rtsp_session_start(int fd, char *mrl, char *path, char *host, in
|
|||||||
rmff_header_t *h;
|
rmff_header_t *h;
|
||||||
uint32_t bandwidth=10485800;
|
uint32_t bandwidth=10485800;
|
||||||
|
|
||||||
connect:
|
//connect:
|
||||||
|
*redir = 0;
|
||||||
|
|
||||||
/* connect to server */
|
/* connect to server */
|
||||||
rtsp_session->s=rtsp_connect(fd,mrl,path,host,port,NULL);
|
rtsp_session->s=rtsp_connect(fd,*mrl,path,host,port,NULL);
|
||||||
if (!rtsp_session->s)
|
if (!rtsp_session->s)
|
||||||
{
|
{
|
||||||
printf("rtsp_session: failed to connect to server %s\n", path);
|
printf("rtsp_session: failed to connect to server %s\n", path);
|
||||||
@ -107,8 +108,13 @@ connect:
|
|||||||
printf("rtsp_session: redirected to %s\n", mrl_line);
|
printf("rtsp_session: redirected to %s\n", mrl_line);
|
||||||
rtsp_close(rtsp_session->s);
|
rtsp_close(rtsp_session->s);
|
||||||
free(server);
|
free(server);
|
||||||
/* FIXME: this won't work in MPlayer, connection opened by caller */
|
free(*mrl);
|
||||||
goto connect; /* *shudder* i made a design mistake somewhere */
|
free(rtsp_session);
|
||||||
|
/* tell the caller to redirect, return url to redirect to in mrl */
|
||||||
|
*mrl = mrl_line;
|
||||||
|
*redir = 1;
|
||||||
|
return NULL;
|
||||||
|
// goto connect; /* *shudder* i made a design mistake somewhere */
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
printf("rtsp_session: session can not be established.\n");
|
printf("rtsp_session: session can not be established.\n");
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
typedef struct rtsp_session_s rtsp_session_t;
|
typedef struct rtsp_session_s rtsp_session_t;
|
||||||
|
|
||||||
rtsp_session_t *rtsp_session_start(int fd, char *mrl, char *path, char *host, int port);
|
rtsp_session_t *rtsp_session_start(int fd, char **mrl, char *path, char *host, int port, int *redir);
|
||||||
|
|
||||||
int rtsp_session_read(rtsp_session_t *session, char *data, int len);
|
int rtsp_session_read(rtsp_session_t *session, char *data, int len);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user