[MPlayer-dev-eng] [PATCH] Fw: rtsp fixes (buffer size, redirections)
Sascha Sommer
saschasommer at freenet.de
Wed May 28 13:19:43 CEST 2003
Got a new message from yepyep.
Can someone please look at thes rtsp fixes. Maybe also inform xine people to
make further syncing easier.
Sascha
----- Original Message -----
From: "flo/yepyep" <flodt8 at yahoo.de>
To: <saschasommer at freenet.de>
Sent: Wednesday, May 28, 2003 12:38 PM
Subject: rtsp fixes (buffer size, redirections)
> hi,
>
> i figured out how to make that viva stream work yesterday, attached
> is a patch. rtsp://rd01.t-bn.de/live/viva/viva1tv_live_adsl.rm
> returns a redirection, which could not be handled before. it said
> "FIXME" in the source actually :)
>
> anyhow, i made this quick fix that tells the caller in network.c to
> connect to the other server when a redirection is found. i hope it's
> okay that way. this patch also fixes the problem with the buffers
> being too small in sdpplin.c and the resulting crashes and
> non-working streams. i think 255 should be a decent size for them.
>
> there is still one thing that's not very beautiful: when it outputs
> "Connected to server: blah ..." (from open.c) it still prints the
> hostname part of the first server. but i concider that to be just a
> cosmetic thing.
>
> if you apply this patch and plan to use it on windows, also change
> the close(fd); in realrtsp_streaming_start (somewhere in network.c)
> to closesocket(fd);, or more correct to "#ifndef HAVE_WINSOCK2 /
> close(fd) / #else / closesocket(fd) / #endif" (/ = line breaks) - i
> will put this fix into the mingwnetwork patch later, didn't make much
> sense to me putting that ifdef in before the rest is there too.
>
> demux_real.c still prints that "!!!! BUG !! len=-1397 !!!!" message
> (with changing values for len) for this stream, but that's obviously
> a completely different bug. maybe the maintainer of this file knows
> why it might happen?
>
> feel free to forward this to the mailing list :)
>
> flo/yepyep
>
> __________________________________________________________________
>
> Gesendet von Yahoo! Mail - http://mail.yahoo.de
> Logos und Klingeltöne fürs Handy bei http://sms.yahoo.de
----------------------------------------------------------------------------
----
> diff -Naur main/libmpdemux/network.c main.new/libmpdemux/network.c
> --- main/libmpdemux/network.c Tue May 27 15:08:06 2003
> +++ main.new/libmpdemux/network.c Wed May 28 09:43:35 2003
> @@ -963,8 +963,15 @@
> rtsp_session_t *rtsp;
> char *mrl;
> int port;
> + int redirected, temp;
> char aport[10];
> 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,
> port = (stream->streaming_ctrl->url->port ?
stream->streaming_ctrl->url->port : 554) );
> @@ -976,9 +983,20 @@
> strcpy(mrl,stream->streaming_ctrl->url->url);
> strcat(mrl,":");
> strcat(mrl,aport);
> - rtsp = rtsp_session_start(fd,mrl, stream->streaming_ctrl->url->file,
> - stream->streaming_ctrl->url->hostname, port);
> + rtsp = rtsp_session_start(fd,&mrl, stream->streaming_ctrl->url->file,
> + 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);
> + temp--;
> +
> + } while( (redirected != 0) && (temp > 0) );
> +
> if(!rtsp) return -1;
>
> stream->fd=fd;
> diff -Naur main/libmpdemux/realrtsp/rtsp_session.c
main.new/libmpdemux/realrtsp/rtsp_session.c
> --- main/libmpdemux/realrtsp/rtsp_session.c Tue May 27 15:08:06 2003
> +++ main.new/libmpdemux/realrtsp/rtsp_session.c Wed May 28 10:32:06 2003
> @@ -71,7 +71,7 @@
> };
>
> //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));
> char *server;
> @@ -79,10 +79,11 @@
> rmff_header_t *h;
> uint32_t bandwidth=10485800;
>
> -connect:
> +//connect:
> + *redir = 0;
>
> /* 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)
> {
> printf("rtsp_session: failed to connect to server %s\n", path);
> @@ -113,8 +114,13 @@
> printf("rtsp_session: redirected to %s\n", mrl_line);
> rtsp_close(rtsp_session->s);
> free(server);
> - /* FIXME: this won't work in MPlayer, connection opened by caller */
> - goto connect; /* *shudder* i made a design mistake somewhere */
> + free(*mrl);
> + 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
> {
> printf("rtsp_session: session can not be established.\n");
> diff -Naur main/libmpdemux/realrtsp/rtsp_session.h
main.new/libmpdemux/realrtsp/rtsp_session.h
> --- main/libmpdemux/realrtsp/rtsp_session.h Thu Apr 17 20:38:57 2003
> +++ main.new/libmpdemux/realrtsp/rtsp_session.h Wed May 28 08:37:00 2003
> @@ -30,7 +30,7 @@
>
> 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);
>
> diff -Naur main/libmpdemux/realrtsp/sdpplin.c
main.new/libmpdemux/realrtsp/sdpplin.c
> --- main/libmpdemux/realrtsp/sdpplin.c Thu Apr 17 20:38:57 2003
> +++ main.new/libmpdemux/realrtsp/sdpplin.c Wed May 28 08:49:31 2003
> @@ -31,6 +31,8 @@
> #include "sdpplin.h"
> #include "xbuffer.h"
>
> +#define BUF_SIZE 255
> +
> /*
> #define LOG
> */
> @@ -120,8 +122,8 @@
> static sdpplin_stream_t *sdpplin_parse_stream(char **data) {
>
> sdpplin_stream_t *desc=calloc(1,sizeof(sdpplin_stream_t));
> - char *buf=xbuffer_init(32);
> - char *decoded=xbuffer_init(32);
> + char *buf=xbuffer_init(BUF_SIZE);
> + char *decoded=xbuffer_init(BUF_SIZE);
> int handled;
>
> if (filter(*data, "m=", &buf)) {
> @@ -231,8 +233,8 @@
>
> sdpplin_t *desc=calloc(1,sizeof(sdpplin_t));
> sdpplin_stream_t *stream;
> - char *buf=xbuffer_init(32);
> - char *decoded=xbuffer_init(32);
> + char *buf=xbuffer_init(BUF_SIZE);
> + char *decoded=xbuffer_init(BUF_SIZE);
> int handled;
> int len;
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rtsp_bufsize_and_redir.diff
Type: application/octet-stream
Size: 4423 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20030528/5a6edeed/attachment.obj>
More information about the MPlayer-dev-eng
mailing list