diff options
author | Claudio Ciccani <klan@users.sourceforge.net> | 2006-12-18 21:31:47 +0000 |
---|---|---|
committer | Claudio Ciccani <klan@users.sourceforge.net> | 2006-12-18 21:31:47 +0000 |
commit | 25665d389818fca81eefaf83b217c0061b482551 (patch) | |
tree | 6e1fa36708ddb24af215de304c4aac628b0db518 /src/input/librtsp | |
parent | 8eae85edce64a5454036be7ffa5c526dc7e1f92e (diff) | |
download | xine-lib-25665d389818fca81eefaf83b217c0061b482551.tar.gz xine-lib-25665d389818fca81eefaf83b217c0061b482551.tar.bz2 |
Partially implemented RTSP seekability:
support starting the playback at an optional time by delaying the PLAY
request upon the first call to rtsp_session_read() and setting the playback
start time via input_plugin->seek_time().
CVS patchset: 8422
CVS date: 2006/12/18 21:31:47
Diffstat (limited to 'src/input/librtsp')
-rw-r--r-- | src/input/librtsp/rtsp_session.c | 30 | ||||
-rw-r--r-- | src/input/librtsp/rtsp_session.h | 4 |
2 files changed, 30 insertions, 4 deletions
diff --git a/src/input/librtsp/rtsp_session.c b/src/input/librtsp/rtsp_session.c index 6f06693a9..8a5135ac3 100644 --- a/src/input/librtsp/rtsp_session.c +++ b/src/input/librtsp/rtsp_session.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: rtsp_session.c,v 1.16 2004/04/24 16:55:42 miguelfreitas Exp $ + * $Id: rtsp_session.c,v 1.17 2006/12/18 21:31:47 klan Exp $ * * high level interface to rtsp servers. */ @@ -53,7 +53,7 @@ struct rtsp_session_s { rtsp_t *s; /* receive buffer */ - uint8_t *recv; + uint8_t *recv; int recv_size; int recv_read; @@ -62,11 +62,13 @@ struct rtsp_session_s { int header_len; int header_read; + int playing; + int start_time; }; rtsp_session_t *rtsp_session_start(xine_stream_t *stream, char *mrl) { - rtsp_session_t *rtsp_session = malloc(sizeof(rtsp_session_t)); + rtsp_session_t *rtsp_session = xine_xmalloc(sizeof(rtsp_session_t)); char *server; char *mrl_line=strdup(mrl); rmff_header_t *h; @@ -144,6 +146,23 @@ connect: return rtsp_session; } +void rtsp_session_set_start_time (rtsp_session_t *this, int start_time) { + + if (start_time >= 0) + this->start_time = start_time; +} + +static void rtsp_session_play (rtsp_session_t *this) { + + char buf[256]; + + snprintf (buf, sizeof(buf), "Range: npt=%d.%03d-", + this->start_time/1000, this->start_time%1000); + + rtsp_schedule_field (this->s, buf); + rtsp_request_play (this->s,NULL); +} + int rtsp_session_read (rtsp_session_t *this, char *data, int len) { int to_copy=len; @@ -154,6 +173,11 @@ int rtsp_session_read (rtsp_session_t *this, char *data, int len) { if (len < 0) return 0; while (to_copy > fill) { + if (!this->playing) { + rtsp_session_play (this); + this->playing = 1; + } + memcpy(dest, source, fill); to_copy -= fill; dest += fill; diff --git a/src/input/librtsp/rtsp_session.h b/src/input/librtsp/rtsp_session.h index 140d09a0a..649842e7a 100644 --- a/src/input/librtsp/rtsp_session.h +++ b/src/input/librtsp/rtsp_session.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: rtsp_session.h,v 1.6 2003/12/09 00:02:31 f1rmb Exp $ + * $Id: rtsp_session.h,v 1.7 2006/12/18 21:31:47 klan Exp $ * * high level interface to rtsp servers. */ @@ -29,6 +29,8 @@ typedef struct rtsp_session_s rtsp_session_t; rtsp_session_t *rtsp_session_start(xine_stream_t *stream, char *mrl); +void rtsp_session_set_start_time(rtsp_session_t *this, int start_time); + int rtsp_session_read(rtsp_session_t *session, char *data, int len); int rtsp_session_peek_header(rtsp_session_t *this, char *buf, int maxsize); |