# HG changeset patch # User rtognimp # Date 1136558350 0 # Node ID 88adbc28f60b793fa4292eba7b290d11684a3d0c # Parent 7a718d3fd1fdaddd8bc2a286c2f762a43e2b2a75 This patch makes real rtsp tell the server to deliver data at specified bandwidth, if bandwidth cmdline option is given. Also, if that's given, it uses it for sdp stream selection. If not given, the behavior is the same as before. It's used to implement something like turboplay in realplayer. Patch by Tomas Janousek >>> tomi (At) nomi (.) cz <<< diff -r 7a718d3fd1fd -r 88adbc28f60b DOCS/man/en/mplayer.1 --- a/DOCS/man/en/mplayer.1 Fri Jan 06 14:03:51 2006 +0000 +++ b/DOCS/man/en/mplayer.1 Fri Jan 06 14:39:10 2006 +0000 @@ -946,6 +946,8 @@ Specify the maximum bandwidth for network streaming (for servers that are able to send content in different bitrates). Useful if you want to watch live streamed media behind a slow connection. +With Real RTSP streaming, it's also used to set maximum delivery bandwidth +allowing faster cache filling and stream dumping. . .TP .B \-cache diff -r 7a718d3fd1fd -r 88adbc28f60b libmpdemux/realrtsp/real.c --- a/libmpdemux/realrtsp/real.c Fri Jan 06 14:03:51 2006 +0000 +++ b/libmpdemux/realrtsp/real.c Fri Jan 06 14:39:10 2006 +0000 @@ -706,12 +706,17 @@ char *mrl=rtsp_get_mrl(rtsp_session); unsigned int size; int status; + uint32_t maxbandwidth = bandwidth; /* get challenge */ challenge1=strdup(rtsp_search_answers(rtsp_session,"RealChallenge1")); #ifdef LOG printf("real: Challenge1: %s\n", challenge1); #endif + + /* set a reasonable default to get the best stream, unless bandwidth given */ + if (!bandwidth) + bandwidth = 10485800; /* request stream description */ rtsp_schedule_field(rtsp_session, "Accept: application/sdp"); @@ -811,6 +816,13 @@ rtsp_schedule_field(rtsp_session, subscribe); rtsp_request_setparameter(rtsp_session,NULL); + /* set delivery bandwidth */ + if (maxbandwidth) { + sprintf(buf, "SetDeliveryBandwidth: Bandwidth=%u;BackOff=0", maxbandwidth); + rtsp_schedule_field(rtsp_session, buf); + rtsp_request_setparameter(rtsp_session,NULL); + } + { int s_ss = 0, s_ms = 0, e_ss = 0, e_ms = 0; char *str; diff -r 7a718d3fd1fd -r 88adbc28f60b libmpdemux/realrtsp/rtsp.c --- a/libmpdemux/realrtsp/rtsp.c Fri Jan 06 14:03:51 2006 +0000 +++ b/libmpdemux/realrtsp/rtsp.c Fri Jan 06 14:39:10 2006 +0000 @@ -877,7 +877,7 @@ file++; mrl = malloc(sizeof(char)*(strlen(stream->streaming_ctrl->url->hostname)+strlen(file)+16)); sprintf(mrl,"rtsp://%s:%i/%s",stream->streaming_ctrl->url->hostname,port,file); - rtsp = rtsp_session_start(fd,&mrl, file, stream->streaming_ctrl->url->hostname, port, &redirected); + rtsp = rtsp_session_start(fd,&mrl, file, stream->streaming_ctrl->url->hostname, port, &redirected, stream->streaming_ctrl->bandwidth); if( redirected == 1) { url_free(stream->streaming_ctrl->url); diff -r 7a718d3fd1fd -r 88adbc28f60b libmpdemux/realrtsp/rtsp_session.c --- a/libmpdemux/realrtsp/rtsp_session.c Fri Jan 06 14:03:51 2006 +0000 +++ b/libmpdemux/realrtsp/rtsp_session.c Fri Jan 06 14:39:10 2006 +0000 @@ -71,13 +71,12 @@ }; //rtsp_session_t *rtsp_session_start(char *mrl) { -rtsp_session_t *rtsp_session_start(int fd, char **mrl, char *path, char *host, int port, int *redir) { +rtsp_session_t *rtsp_session_start(int fd, char **mrl, char *path, char *host, int port, int *redir, uint32_t bandwidth) { rtsp_session_t *rtsp_session=malloc(sizeof(rtsp_session_t)); char *server; char *mrl_line = NULL; rmff_header_t *h; - uint32_t bandwidth=10485800; rtsp_session->recv = xbuffer_init(BUF_SIZE); diff -r 7a718d3fd1fd -r 88adbc28f60b libmpdemux/realrtsp/rtsp_session.h --- a/libmpdemux/realrtsp/rtsp_session.h Fri Jan 06 14:03:51 2006 +0000 +++ b/libmpdemux/realrtsp/rtsp_session.h Fri Jan 06 14:39:10 2006 +0000 @@ -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, int *redir); +rtsp_session_t *rtsp_session_start(int fd, char **mrl, char *path, char *host, int port, int *redir, uint32_t bandwidth); int rtsp_session_read(rtsp_session_t *session, char *data, int len);