1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
23 #include "curl_setup.h"
25 #ifndef CURL_DISABLE_RTSP
28 #include <curl/curl.h>
40 /* The last 3 #include files should be in this order */
41 #include "curl_printf.h"
42 #include "curl_memory.h"
47 * -incoming server requests
48 * -server CSeq counter
49 * -digest authentication
50 * -connect through proxy
55 #define RTP_PKT_CHANNEL(p) ((int)((unsigned char)((p)[1])))
57 #define RTP_PKT_LENGTH(p) ((((int)((unsigned char)((p)[2]))) << 8) | \
58 ((int)((unsigned char)((p)[3]))))
60 /* protocol-specific functions set up to be called by the main engine */
61 static CURLcode rtsp_do(struct connectdata *conn, bool *done);
62 static CURLcode rtsp_done(struct connectdata *conn, CURLcode, bool premature);
63 static CURLcode rtsp_connect(struct connectdata *conn, bool *done);
64 static CURLcode rtsp_disconnect(struct connectdata *conn, bool dead);
66 static int rtsp_getsock_do(struct connectdata *conn,
71 * Parse and write out any available RTP data.
73 * nread: amount of data left after k->str. will be modified if RTP
74 * data is parsed and k->str is moved up
75 * readmore: whether or not the RTP parser needs more data right away
77 static CURLcode rtsp_rtp_readwrite(struct Curl_easy *data,
78 struct connectdata *conn,
82 static CURLcode rtsp_setup_connection(struct connectdata *conn);
84 bool rtsp_connisdead(struct connectdata *check);
85 static unsigned int rtsp_conncheck(struct connectdata *check,
86 unsigned int checks_to_perform);
88 /* this returns the socket to wait for in the DO and DOING state for the multi
89 interface and then we're always _sending_ a request and thus we wait for
90 the single socket to become writable only */
91 static int rtsp_getsock_do(struct connectdata *conn,
96 (void)numsocks; /* unused, we trust it to be at least 1 */
97 socks[0] = conn->sock[FIRSTSOCKET];
98 return GETSOCK_WRITESOCK(0);
102 CURLcode rtp_client_write(struct connectdata *conn, char *ptr, size_t len);
106 * RTSP handler interface.
108 const struct Curl_handler Curl_handler_rtsp = {
110 rtsp_setup_connection, /* setup_connection */
112 rtsp_done, /* done */
113 ZERO_NULL, /* do_more */
114 rtsp_connect, /* connect_it */
115 ZERO_NULL, /* connecting */
116 ZERO_NULL, /* doing */
117 ZERO_NULL, /* proto_getsock */
118 rtsp_getsock_do, /* doing_getsock */
119 ZERO_NULL, /* domore_getsock */
120 ZERO_NULL, /* perform_getsock */
121 rtsp_disconnect, /* disconnect */
122 rtsp_rtp_readwrite, /* readwrite */
123 rtsp_conncheck, /* connection_check */
124 PORT_RTSP, /* defport */
125 CURLPROTO_RTSP, /* protocol */
126 PROTOPT_NONE /* flags */
130 static CURLcode rtsp_setup_connection(struct connectdata *conn)
134 conn->data->req.protop = rtsp = calloc(1, sizeof(struct RTSP));
136 return CURLE_OUT_OF_MEMORY;
143 * The server may send us RTP data at any point, and RTSPREQ_RECEIVE does not
144 * want to block the application forever while receiving a stream. Therefore,
145 * we cannot assume that an RTSP socket is dead just because it is readable.
147 * Instead, if it is readable, run Curl_connalive() to peek at the socket
148 * and distinguish between closed and data.
150 bool rtsp_connisdead(struct connectdata *check)
155 sval = SOCKET_READABLE(check->sock[FIRSTSOCKET], 0);
160 else if(sval & CURL_CSELECT_ERR) {
161 /* socket is in an error state */
164 else if(sval & CURL_CSELECT_IN) {
165 /* readable with no error. could still be closed */
166 ret_val = !Curl_connalive(check);
173 * Function to check on various aspects of a connection.
175 static unsigned int rtsp_conncheck(struct connectdata *check,
176 unsigned int checks_to_perform)
178 unsigned int ret_val = CONNRESULT_NONE;
180 if(checks_to_perform & CONNCHECK_ISDEAD) {
181 if(rtsp_connisdead(check))
182 ret_val |= CONNRESULT_DEAD;
189 static CURLcode rtsp_connect(struct connectdata *conn, bool *done)
192 struct Curl_easy *data = conn->data;
194 httpStatus = Curl_http_connect(conn, done);
196 /* Initialize the CSeq if not already done */
197 if(data->state.rtsp_next_client_CSeq == 0)
198 data->state.rtsp_next_client_CSeq = 1;
199 if(data->state.rtsp_next_server_CSeq == 0)
200 data->state.rtsp_next_server_CSeq = 1;
202 conn->proto.rtspc.rtp_channel = -1;
207 static CURLcode rtsp_disconnect(struct connectdata *conn, bool dead)
210 Curl_safefree(conn->proto.rtspc.rtp_buf);
215 static CURLcode rtsp_done(struct connectdata *conn,
216 CURLcode status, bool premature)
218 struct Curl_easy *data = conn->data;
219 struct RTSP *rtsp = data->req.protop;
224 /* Bypass HTTP empty-reply checks on receive */
225 if(data->set.rtspreq == RTSPREQ_RECEIVE)
228 httpStatus = Curl_http_done(conn, status, premature);
231 /* Check the sequence numbers */
232 CSeq_sent = rtsp->CSeq_sent;
233 CSeq_recv = rtsp->CSeq_recv;
234 if((data->set.rtspreq != RTSPREQ_RECEIVE) && (CSeq_sent != CSeq_recv)) {
236 "The CSeq of this request %ld did not match the response %ld",
237 CSeq_sent, CSeq_recv);
238 return CURLE_RTSP_CSEQ_ERROR;
240 if(data->set.rtspreq == RTSPREQ_RECEIVE &&
241 (conn->proto.rtspc.rtp_channel == -1)) {
242 infof(data, "Got an RTP Receive with a CSeq of %ld\n", CSeq_recv);
243 /* TODO CPC: Server -> Client logic here */
250 static CURLcode rtsp_do(struct connectdata *conn, bool *done)
252 struct Curl_easy *data = conn->data;
253 CURLcode result = CURLE_OK;
254 Curl_RtspReq rtspreq = data->set.rtspreq;
255 struct RTSP *rtsp = data->req.protop;
257 Curl_send_buffer *req_buffer;
258 curl_off_t postsize = 0; /* for ANNOUNCE and SET_PARAMETER */
259 curl_off_t putsize = 0; /* for ANNOUNCE and SET_PARAMETER */
261 const char *p_request = NULL;
262 const char *p_session_id = NULL;
263 const char *p_accept = NULL;
264 const char *p_accept_encoding = NULL;
265 const char *p_range = NULL;
266 const char *p_referrer = NULL;
267 const char *p_stream_uri = NULL;
268 const char *p_transport = NULL;
269 const char *p_uagent = NULL;
270 const char *p_proxyuserpwd = NULL;
271 const char *p_userpwd = NULL;
275 http = &(rtsp->http_wrapper);
276 /* Assert that no one has changed the RTSP struct in an evil way */
277 DEBUGASSERT((void *)http == (void *)rtsp);
279 rtsp->CSeq_sent = data->state.rtsp_next_client_CSeq;
282 /* Setup the 'p_request' pointer to the proper p_request string
283 * Since all RTSP requests are included here, there is no need to
284 * support custom requests like HTTP.
286 data->set.opt_no_body = TRUE; /* most requests don't contain a body */
289 failf(data, "Got invalid RTSP request");
290 return CURLE_BAD_FUNCTION_ARGUMENT;
291 case RTSPREQ_OPTIONS:
292 p_request = "OPTIONS";
294 case RTSPREQ_DESCRIBE:
295 p_request = "DESCRIBE";
296 data->set.opt_no_body = FALSE;
298 case RTSPREQ_ANNOUNCE:
299 p_request = "ANNOUNCE";
310 case RTSPREQ_TEARDOWN:
311 p_request = "TEARDOWN";
313 case RTSPREQ_GET_PARAMETER:
314 /* GET_PARAMETER's no_body status is determined later */
315 p_request = "GET_PARAMETER";
316 data->set.opt_no_body = FALSE;
318 case RTSPREQ_SET_PARAMETER:
319 p_request = "SET_PARAMETER";
322 p_request = "RECORD";
324 case RTSPREQ_RECEIVE:
326 /* Treat interleaved RTP as body*/
327 data->set.opt_no_body = FALSE;
330 failf(data, "Got invalid RTSP request: RTSPREQ_LAST");
331 return CURLE_BAD_FUNCTION_ARGUMENT;
334 if(rtspreq == RTSPREQ_RECEIVE) {
335 Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE,
336 &http->readbytecount, -1, NULL);
341 p_session_id = data->set.str[STRING_RTSP_SESSION_ID];
343 (rtspreq & ~(RTSPREQ_OPTIONS | RTSPREQ_DESCRIBE | RTSPREQ_SETUP))) {
344 failf(data, "Refusing to issue an RTSP request [%s] without a session ID.",
346 return CURLE_BAD_FUNCTION_ARGUMENT;
351 /* Stream URI. Default to server '*' if not specified */
352 if(data->set.str[STRING_RTSP_STREAM_URI]) {
353 p_stream_uri = data->set.str[STRING_RTSP_STREAM_URI];
359 /* Transport Header for SETUP requests */
360 p_transport = Curl_checkheaders(conn, "Transport");
361 if(rtspreq == RTSPREQ_SETUP && !p_transport) {
362 /* New Transport: setting? */
363 if(data->set.str[STRING_RTSP_TRANSPORT]) {
364 Curl_safefree(conn->allocptr.rtsp_transport);
366 conn->allocptr.rtsp_transport =
367 aprintf("Transport: %s\r\n",
368 data->set.str[STRING_RTSP_TRANSPORT]);
369 if(!conn->allocptr.rtsp_transport)
370 return CURLE_OUT_OF_MEMORY;
374 "Refusing to issue an RTSP SETUP without a Transport: header.");
375 return CURLE_BAD_FUNCTION_ARGUMENT;
378 p_transport = conn->allocptr.rtsp_transport;
381 /* Accept Headers for DESCRIBE requests */
382 if(rtspreq == RTSPREQ_DESCRIBE) {
384 p_accept = Curl_checkheaders(conn, "Accept")?
385 NULL:"Accept: application/sdp\r\n";
387 /* Accept-Encoding header */
388 if(!Curl_checkheaders(conn, "Accept-Encoding") &&
389 data->set.str[STRING_ENCODING]) {
390 Curl_safefree(conn->allocptr.accept_encoding);
391 conn->allocptr.accept_encoding =
392 aprintf("Accept-Encoding: %s\r\n", data->set.str[STRING_ENCODING]);
394 if(!conn->allocptr.accept_encoding)
395 return CURLE_OUT_OF_MEMORY;
397 p_accept_encoding = conn->allocptr.accept_encoding;
401 /* The User-Agent string might have been allocated in url.c already, because
402 it might have been used in the proxy connect, but if we have got a header
403 with the user-agent string specified, we erase the previously made string
405 if(Curl_checkheaders(conn, "User-Agent") && conn->allocptr.uagent) {
406 Curl_safefree(conn->allocptr.uagent);
407 conn->allocptr.uagent = NULL;
409 else if(!Curl_checkheaders(conn, "User-Agent") &&
410 data->set.str[STRING_USERAGENT]) {
411 p_uagent = conn->allocptr.uagent;
414 /* setup the authentication headers */
415 result = Curl_http_output_auth(conn, p_request, p_stream_uri, FALSE);
419 p_proxyuserpwd = conn->allocptr.proxyuserpwd;
420 p_userpwd = conn->allocptr.userpwd;
423 Curl_safefree(conn->allocptr.ref);
424 if(data->change.referer && !Curl_checkheaders(conn, "Referer"))
425 conn->allocptr.ref = aprintf("Referer: %s\r\n", data->change.referer);
427 conn->allocptr.ref = NULL;
429 p_referrer = conn->allocptr.ref;
433 * Only applies to PLAY, PAUSE, RECORD
435 * Go ahead and use the Range stuff supplied for HTTP
437 if(data->state.use_range &&
438 (rtspreq & (RTSPREQ_PLAY | RTSPREQ_PAUSE | RTSPREQ_RECORD))) {
440 /* Check to see if there is a range set in the custom headers */
441 if(!Curl_checkheaders(conn, "Range") && data->state.range) {
442 Curl_safefree(conn->allocptr.rangeline);
443 conn->allocptr.rangeline = aprintf("Range: %s\r\n", data->state.range);
444 p_range = conn->allocptr.rangeline;
449 * Sanity check the custom headers
451 if(Curl_checkheaders(conn, "CSeq")) {
452 failf(data, "CSeq cannot be set as a custom header.");
453 return CURLE_RTSP_CSEQ_ERROR;
455 if(Curl_checkheaders(conn, "Session")) {
456 failf(data, "Session ID cannot be set as a custom header.");
457 return CURLE_BAD_FUNCTION_ARGUMENT;
460 /* Initialize a dynamic send buffer */
461 req_buffer = Curl_add_buffer_init();
464 return CURLE_OUT_OF_MEMORY;
467 Curl_add_bufferf(req_buffer,
468 "%s %s RTSP/1.0\r\n" /* Request Stream-URI RTSP/1.0 */
469 "CSeq: %ld\r\n", /* CSeq */
470 p_request, p_stream_uri, rtsp->CSeq_sent);
475 * Rather than do a normal alloc line, keep the session_id unformatted
476 * to make comparison easier
479 result = Curl_add_bufferf(req_buffer, "Session: %s\r\n", p_session_id);
485 * Shared HTTP-like options
487 result = Curl_add_bufferf(req_buffer,
490 "%s" /* accept-encoding */
493 "%s" /* user-agent */
494 "%s" /* proxyuserpwd */
497 p_transport ? p_transport : "",
498 p_accept ? p_accept : "",
499 p_accept_encoding ? p_accept_encoding : "",
500 p_range ? p_range : "",
501 p_referrer ? p_referrer : "",
502 p_uagent ? p_uagent : "",
503 p_proxyuserpwd ? p_proxyuserpwd : "",
504 p_userpwd ? p_userpwd : "");
507 * Free userpwd now --- cannot reuse this for Negotiate and possibly NTLM
508 * with basic and digest, it will be freed anyway by the next request
510 Curl_safefree(conn->allocptr.userpwd);
511 conn->allocptr.userpwd = NULL;
516 if((rtspreq == RTSPREQ_SETUP) || (rtspreq == RTSPREQ_DESCRIBE)) {
517 result = Curl_add_timecondition(data, req_buffer);
522 result = Curl_add_custom_headers(conn, FALSE, req_buffer);
526 if(rtspreq == RTSPREQ_ANNOUNCE ||
527 rtspreq == RTSPREQ_SET_PARAMETER ||
528 rtspreq == RTSPREQ_GET_PARAMETER) {
530 if(data->set.upload) {
531 putsize = data->state.infilesize;
532 data->set.httpreq = HTTPREQ_PUT;
536 postsize = (data->state.infilesize != -1)?
537 data->state.infilesize:
538 (data->set.postfields? (curl_off_t)strlen(data->set.postfields):0);
539 data->set.httpreq = HTTPREQ_POST;
542 if(putsize > 0 || postsize > 0) {
543 /* As stated in the http comments, it is probably not wise to
544 * actually set a custom Content-Length in the headers */
545 if(!Curl_checkheaders(conn, "Content-Length")) {
546 result = Curl_add_bufferf(req_buffer,
547 "Content-Length: %" CURL_FORMAT_CURL_OFF_T"\r\n",
548 (data->set.upload ? putsize : postsize));
553 if(rtspreq == RTSPREQ_SET_PARAMETER ||
554 rtspreq == RTSPREQ_GET_PARAMETER) {
555 if(!Curl_checkheaders(conn, "Content-Type")) {
556 result = Curl_add_bufferf(req_buffer,
557 "Content-Type: text/parameters\r\n");
563 if(rtspreq == RTSPREQ_ANNOUNCE) {
564 if(!Curl_checkheaders(conn, "Content-Type")) {
565 result = Curl_add_bufferf(req_buffer,
566 "Content-Type: application/sdp\r\n");
572 data->state.expect100header = FALSE; /* RTSP posts are simple/small */
574 else if(rtspreq == RTSPREQ_GET_PARAMETER) {
575 /* Check for an empty GET_PARAMETER (heartbeat) request */
576 data->set.httpreq = HTTPREQ_HEAD;
577 data->set.opt_no_body = TRUE;
581 /* RTSP never allows chunked transfer */
582 data->req.forbidchunk = TRUE;
583 /* Finish the request buffer */
584 result = Curl_add_buffer(req_buffer, "\r\n", 2);
589 result = Curl_add_buffer(req_buffer, data->set.postfields,
595 /* issue the request */
596 result = Curl_add_buffer_send(req_buffer, conn,
597 &data->info.request_size, 0, FIRSTSOCKET);
599 failf(data, "Failed sending RTSP request");
603 Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, &http->readbytecount,
604 putsize?FIRSTSOCKET:-1,
605 putsize?&http->writebytecount:NULL);
607 /* Increment the CSeq on success */
608 data->state.rtsp_next_client_CSeq++;
610 if(http->writebytecount) {
611 /* if a request-body has been sent off, we make sure this progress is
613 Curl_pgrsSetUploadCounter(data, http->writebytecount);
614 if(Curl_pgrsUpdate(conn))
615 result = CURLE_ABORTED_BY_CALLBACK;
622 static CURLcode rtsp_rtp_readwrite(struct Curl_easy *data,
623 struct connectdata *conn,
626 struct SingleRequest *k = &data->req;
627 struct rtsp_conn *rtspc = &(conn->proto.rtspc);
629 char *rtp; /* moving pointer to rtp data */
630 ssize_t rtp_dataleft; /* how much data left to parse in this round */
635 /* There was some leftover data the last time. Merge buffers */
636 char *newptr = Curl_saferealloc(rtspc->rtp_buf,
637 rtspc->rtp_bufsize + *nread);
639 rtspc->rtp_buf = NULL;
640 rtspc->rtp_bufsize = 0;
641 return CURLE_OUT_OF_MEMORY;
643 rtspc->rtp_buf = newptr;
644 memcpy(rtspc->rtp_buf + rtspc->rtp_bufsize, k->str, *nread);
645 rtspc->rtp_bufsize += *nread;
646 rtp = rtspc->rtp_buf;
647 rtp_dataleft = rtspc->rtp_bufsize;
650 /* Just parse the request buffer directly */
652 rtp_dataleft = *nread;
655 while((rtp_dataleft > 0) &&
657 if(rtp_dataleft > 4) {
660 /* Parse the header */
661 /* The channel identifier immediately follows and is 1 byte */
662 rtspc->rtp_channel = RTP_PKT_CHANNEL(rtp);
664 /* The length is two bytes */
665 rtp_length = RTP_PKT_LENGTH(rtp);
667 if(rtp_dataleft < rtp_length + 4) {
668 /* Need more - incomplete payload*/
672 /* We have the full RTP interleaved packet
673 * Write out the header including the leading '$' */
674 DEBUGF(infof(data, "RTP write channel %d rtp_length %d\n",
675 rtspc->rtp_channel, rtp_length));
676 result = rtp_client_write(conn, &rtp[0], rtp_length + 4);
678 failf(data, "Got an error writing an RTP packet");
680 Curl_safefree(rtspc->rtp_buf);
681 rtspc->rtp_buf = NULL;
682 rtspc->rtp_bufsize = 0;
686 /* Move forward in the buffer */
687 rtp_dataleft -= rtp_length + 4;
688 rtp += rtp_length + 4;
690 if(data->set.rtspreq == RTSPREQ_RECEIVE) {
691 /* If we are in a passive receive, give control back
692 * to the app as often as we can.
694 k->keepon &= ~KEEP_RECV;
698 /* Need more - incomplete header */
704 if(rtp_dataleft != 0 && rtp[0] == '$') {
705 DEBUGF(infof(data, "RTP Rewinding %zd %s\n", rtp_dataleft,
706 *readmore ? "(READMORE)" : ""));
708 /* Store the incomplete RTP packet for a "rewind" */
709 scratch = malloc(rtp_dataleft);
711 Curl_safefree(rtspc->rtp_buf);
712 rtspc->rtp_buf = NULL;
713 rtspc->rtp_bufsize = 0;
714 return CURLE_OUT_OF_MEMORY;
716 memcpy(scratch, rtp, rtp_dataleft);
717 Curl_safefree(rtspc->rtp_buf);
718 rtspc->rtp_buf = scratch;
719 rtspc->rtp_bufsize = rtp_dataleft;
721 /* As far as the transfer is concerned, this data is consumed */
725 /* Fix up k->str to point just after the last RTP packet */
726 k->str += *nread - rtp_dataleft;
728 /* either all of the data has been read or...
729 * rtp now points at the next byte to parse
732 DEBUGASSERT(k->str[0] == rtp[0]);
734 DEBUGASSERT(rtp_dataleft <= *nread); /* sanity check */
736 *nread = rtp_dataleft;
738 /* If we get here, we have finished with the leftover/merge buffer */
739 Curl_safefree(rtspc->rtp_buf);
740 rtspc->rtp_buf = NULL;
741 rtspc->rtp_bufsize = 0;
747 CURLcode rtp_client_write(struct connectdata *conn, char *ptr, size_t len)
749 struct Curl_easy *data = conn->data;
751 curl_write_callback writeit;
755 failf(data, "Cannot write a 0 size RTP packet.");
756 return CURLE_WRITE_ERROR;
759 /* If the user has configured CURLOPT_INTERLEAVEFUNCTION then use that
760 function and any configured CURLOPT_INTERLEAVEDATA to write out the RTP
761 data. Otherwise, use the CURLOPT_WRITEFUNCTION with the CURLOPT_WRITEDATA
762 pointer to write out the RTP data. */
763 if(data->set.fwrite_rtp) {
764 writeit = data->set.fwrite_rtp;
765 user_ptr = data->set.rtp_out;
769 writeit = data->set.fwrite_func;
770 user_ptr = data->set.out;
773 Curl_set_in_callback(data, true);
774 wrote = writeit(ptr, 1, len, user_ptr);
775 Curl_set_in_callback(data, false);
777 if(CURL_WRITEFUNC_PAUSE == wrote) {
778 failf(data, "Cannot pause RTP");
779 return CURLE_WRITE_ERROR;
783 failf(data, "Failed writing RTP data");
784 return CURLE_WRITE_ERROR;
790 CURLcode Curl_rtsp_parseheader(struct connectdata *conn,
793 struct Curl_easy *data = conn->data;
796 if(checkprefix("CSeq:", header)) {
797 /* Store the received CSeq. Match is verified in rtsp_done */
798 int nc = sscanf(&header[4], ": %ld", &CSeq);
800 struct RTSP *rtsp = data->req.protop;
801 rtsp->CSeq_recv = CSeq; /* mark the request */
802 data->state.rtsp_CSeq_recv = CSeq; /* update the handle */
805 failf(data, "Unable to read the CSeq header: [%s]", header);
806 return CURLE_RTSP_CSEQ_ERROR;
809 else if(checkprefix("Session:", header)) {
812 /* Find the first non-space letter */
814 while(*start && ISSPACE(*start))
818 failf(data, "Got a blank Session ID");
820 else if(data->set.str[STRING_RTSP_SESSION_ID]) {
821 /* If the Session ID is set, then compare */
822 if(strncmp(start, data->set.str[STRING_RTSP_SESSION_ID],
823 strlen(data->set.str[STRING_RTSP_SESSION_ID])) != 0) {
824 failf(data, "Got RTSP Session ID Line [%s], but wanted ID [%s]",
825 start, data->set.str[STRING_RTSP_SESSION_ID]);
826 return CURLE_RTSP_SESSION_ERROR;
830 /* If the Session ID is not set, and we find it in a response, then set
833 * Allow any non whitespace content, up to the field separator or end of
834 * line. RFC 2326 isn't 100% clear on the session ID and for example
835 * gstreamer does url-encoded session ID's not covered by the standard.
838 while(*end && *end != ';' && !ISSPACE(*end))
841 /* Copy the id substring into a new buffer */
842 data->set.str[STRING_RTSP_SESSION_ID] = malloc(end - start + 1);
843 if(data->set.str[STRING_RTSP_SESSION_ID] == NULL)
844 return CURLE_OUT_OF_MEMORY;
845 memcpy(data->set.str[STRING_RTSP_SESSION_ID], start, end - start);
846 (data->set.str[STRING_RTSP_SESSION_ID])[end - start] = '\0';
852 #endif /* CURL_DISABLE_RTSP */