1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2022, 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.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 * SPDX-License-Identifier: curl
23 ***************************************************************************/
25 #include "curl_setup.h"
27 #if !defined(CURL_DISABLE_RTSP) && !defined(USE_HYPER)
30 #include <curl/curl.h>
42 /* The last 3 #include files should be in this order */
43 #include "curl_printf.h"
44 #include "curl_memory.h"
47 #define RTP_PKT_CHANNEL(p) ((int)((unsigned char)((p)[1])))
49 #define RTP_PKT_LENGTH(p) ((((int)((unsigned char)((p)[2]))) << 8) | \
50 ((int)((unsigned char)((p)[3]))))
52 /* protocol-specific functions set up to be called by the main engine */
53 static CURLcode rtsp_do(struct Curl_easy *data, bool *done);
54 static CURLcode rtsp_done(struct Curl_easy *data, CURLcode, bool premature);
55 static CURLcode rtsp_connect(struct Curl_easy *data, bool *done);
56 static CURLcode rtsp_disconnect(struct Curl_easy *data,
57 struct connectdata *conn, bool dead);
58 static int rtsp_getsock_do(struct Curl_easy *data,
59 struct connectdata *conn, curl_socket_t *socks);
62 * Parse and write out any available RTP data.
64 * nread: amount of data left after k->str. will be modified if RTP
65 * data is parsed and k->str is moved up
66 * readmore: whether or not the RTP parser needs more data right away
68 static CURLcode rtsp_rtp_readwrite(struct Curl_easy *data,
69 struct connectdata *conn,
73 static CURLcode rtsp_setup_connection(struct Curl_easy *data,
74 struct connectdata *conn);
75 static unsigned int rtsp_conncheck(struct Curl_easy *data,
76 struct connectdata *check,
77 unsigned int checks_to_perform);
79 /* this returns the socket to wait for in the DO and DOING state for the multi
80 interface and then we're always _sending_ a request and thus we wait for
81 the single socket to become writable only */
82 static int rtsp_getsock_do(struct Curl_easy *data, struct connectdata *conn,
87 socks[0] = conn->sock[FIRSTSOCKET];
88 return GETSOCK_WRITESOCK(0);
92 CURLcode rtp_client_write(struct Curl_easy *data, char *ptr, size_t len);
96 * RTSP handler interface.
98 const struct Curl_handler Curl_handler_rtsp = {
100 rtsp_setup_connection, /* setup_connection */
102 rtsp_done, /* done */
103 ZERO_NULL, /* do_more */
104 rtsp_connect, /* connect_it */
105 ZERO_NULL, /* connecting */
106 ZERO_NULL, /* doing */
107 ZERO_NULL, /* proto_getsock */
108 rtsp_getsock_do, /* doing_getsock */
109 ZERO_NULL, /* domore_getsock */
110 ZERO_NULL, /* perform_getsock */
111 rtsp_disconnect, /* disconnect */
112 rtsp_rtp_readwrite, /* readwrite */
113 rtsp_conncheck, /* connection_check */
114 ZERO_NULL, /* attach connection */
115 PORT_RTSP, /* defport */
116 CURLPROTO_RTSP, /* protocol */
117 CURLPROTO_RTSP, /* family */
118 PROTOPT_NONE /* flags */
122 static CURLcode rtsp_setup_connection(struct Curl_easy *data,
123 struct connectdata *conn)
128 data->req.p.rtsp = rtsp = calloc(1, sizeof(struct RTSP));
130 return CURLE_OUT_OF_MEMORY;
137 * The server may send us RTP data at any point, and RTSPREQ_RECEIVE does not
138 * want to block the application forever while receiving a stream. Therefore,
139 * we cannot assume that an RTSP socket is dead just because it is readable.
141 * Instead, if it is readable, run Curl_connalive() to peek at the socket
142 * and distinguish between closed and data.
144 static bool rtsp_connisdead(struct connectdata *check)
149 sval = SOCKET_READABLE(check->sock[FIRSTSOCKET], 0);
154 else if(sval & CURL_CSELECT_ERR) {
155 /* socket is in an error state */
158 else if(sval & CURL_CSELECT_IN) {
159 /* readable with no error. could still be closed */
160 ret_val = !Curl_connalive(check);
167 * Function to check on various aspects of a connection.
169 static unsigned int rtsp_conncheck(struct Curl_easy *data,
170 struct connectdata *conn,
171 unsigned int checks_to_perform)
173 unsigned int ret_val = CONNRESULT_NONE;
176 if(checks_to_perform & CONNCHECK_ISDEAD) {
177 if(rtsp_connisdead(conn))
178 ret_val |= CONNRESULT_DEAD;
185 static CURLcode rtsp_connect(struct Curl_easy *data, bool *done)
189 httpStatus = Curl_http_connect(data, done);
191 /* Initialize the CSeq if not already done */
192 if(data->state.rtsp_next_client_CSeq == 0)
193 data->state.rtsp_next_client_CSeq = 1;
194 if(data->state.rtsp_next_server_CSeq == 0)
195 data->state.rtsp_next_server_CSeq = 1;
197 data->conn->proto.rtspc.rtp_channel = -1;
202 static CURLcode rtsp_disconnect(struct Curl_easy *data,
203 struct connectdata *conn, bool dead)
207 Curl_safefree(conn->proto.rtspc.rtp_buf);
212 static CURLcode rtsp_done(struct Curl_easy *data,
213 CURLcode status, bool premature)
215 struct RTSP *rtsp = data->req.p.rtsp;
218 /* Bypass HTTP empty-reply checks on receive */
219 if(data->set.rtspreq == RTSPREQ_RECEIVE)
222 httpStatus = Curl_http_done(data, status, premature);
224 if(rtsp && !status && !httpStatus) {
225 /* Check the sequence numbers */
226 long CSeq_sent = rtsp->CSeq_sent;
227 long CSeq_recv = rtsp->CSeq_recv;
228 if((data->set.rtspreq != RTSPREQ_RECEIVE) && (CSeq_sent != CSeq_recv)) {
230 "The CSeq of this request %ld did not match the response %ld",
231 CSeq_sent, CSeq_recv);
232 return CURLE_RTSP_CSEQ_ERROR;
234 if(data->set.rtspreq == RTSPREQ_RECEIVE &&
235 (data->conn->proto.rtspc.rtp_channel == -1)) {
236 infof(data, "Got an RTP Receive with a CSeq of %ld", CSeq_recv);
243 static CURLcode rtsp_do(struct Curl_easy *data, bool *done)
245 struct connectdata *conn = data->conn;
246 CURLcode result = CURLE_OK;
247 Curl_RtspReq rtspreq = data->set.rtspreq;
248 struct RTSP *rtsp = data->req.p.rtsp;
249 struct dynbuf req_buffer;
250 curl_off_t postsize = 0; /* for ANNOUNCE and SET_PARAMETER */
251 curl_off_t putsize = 0; /* for ANNOUNCE and SET_PARAMETER */
253 const char *p_request = NULL;
254 const char *p_session_id = NULL;
255 const char *p_accept = NULL;
256 const char *p_accept_encoding = NULL;
257 const char *p_range = NULL;
258 const char *p_referrer = NULL;
259 const char *p_stream_uri = NULL;
260 const char *p_transport = NULL;
261 const char *p_uagent = NULL;
262 const char *p_proxyuserpwd = NULL;
263 const char *p_userpwd = NULL;
267 rtsp->CSeq_sent = data->state.rtsp_next_client_CSeq;
270 /* Setup the 'p_request' pointer to the proper p_request string
271 * Since all RTSP requests are included here, there is no need to
272 * support custom requests like HTTP.
274 data->set.opt_no_body = TRUE; /* most requests don't contain a body */
277 failf(data, "Got invalid RTSP request");
278 return CURLE_BAD_FUNCTION_ARGUMENT;
279 case RTSPREQ_OPTIONS:
280 p_request = "OPTIONS";
282 case RTSPREQ_DESCRIBE:
283 p_request = "DESCRIBE";
284 data->set.opt_no_body = FALSE;
286 case RTSPREQ_ANNOUNCE:
287 p_request = "ANNOUNCE";
298 case RTSPREQ_TEARDOWN:
299 p_request = "TEARDOWN";
301 case RTSPREQ_GET_PARAMETER:
302 /* GET_PARAMETER's no_body status is determined later */
303 p_request = "GET_PARAMETER";
304 data->set.opt_no_body = FALSE;
306 case RTSPREQ_SET_PARAMETER:
307 p_request = "SET_PARAMETER";
310 p_request = "RECORD";
312 case RTSPREQ_RECEIVE:
314 /* Treat interleaved RTP as body*/
315 data->set.opt_no_body = FALSE;
318 failf(data, "Got invalid RTSP request: RTSPREQ_LAST");
319 return CURLE_BAD_FUNCTION_ARGUMENT;
322 if(rtspreq == RTSPREQ_RECEIVE) {
323 Curl_setup_transfer(data, FIRSTSOCKET, -1, TRUE, -1);
328 p_session_id = data->set.str[STRING_RTSP_SESSION_ID];
330 (rtspreq & ~(RTSPREQ_OPTIONS | RTSPREQ_DESCRIBE | RTSPREQ_SETUP))) {
331 failf(data, "Refusing to issue an RTSP request [%s] without a session ID.",
333 return CURLE_BAD_FUNCTION_ARGUMENT;
336 /* Stream URI. Default to server '*' if not specified */
337 if(data->set.str[STRING_RTSP_STREAM_URI]) {
338 p_stream_uri = data->set.str[STRING_RTSP_STREAM_URI];
344 /* Transport Header for SETUP requests */
345 p_transport = Curl_checkheaders(data, STRCONST("Transport"));
346 if(rtspreq == RTSPREQ_SETUP && !p_transport) {
347 /* New Transport: setting? */
348 if(data->set.str[STRING_RTSP_TRANSPORT]) {
349 Curl_safefree(data->state.aptr.rtsp_transport);
351 data->state.aptr.rtsp_transport =
352 aprintf("Transport: %s\r\n",
353 data->set.str[STRING_RTSP_TRANSPORT]);
354 if(!data->state.aptr.rtsp_transport)
355 return CURLE_OUT_OF_MEMORY;
359 "Refusing to issue an RTSP SETUP without a Transport: header.");
360 return CURLE_BAD_FUNCTION_ARGUMENT;
363 p_transport = data->state.aptr.rtsp_transport;
366 /* Accept Headers for DESCRIBE requests */
367 if(rtspreq == RTSPREQ_DESCRIBE) {
369 p_accept = Curl_checkheaders(data, STRCONST("Accept"))?
370 NULL:"Accept: application/sdp\r\n";
372 /* Accept-Encoding header */
373 if(!Curl_checkheaders(data, STRCONST("Accept-Encoding")) &&
374 data->set.str[STRING_ENCODING]) {
375 Curl_safefree(data->state.aptr.accept_encoding);
376 data->state.aptr.accept_encoding =
377 aprintf("Accept-Encoding: %s\r\n", data->set.str[STRING_ENCODING]);
379 if(!data->state.aptr.accept_encoding)
380 return CURLE_OUT_OF_MEMORY;
382 p_accept_encoding = data->state.aptr.accept_encoding;
386 /* The User-Agent string might have been allocated in url.c already, because
387 it might have been used in the proxy connect, but if we have got a header
388 with the user-agent string specified, we erase the previously made string
390 if(Curl_checkheaders(data, STRCONST("User-Agent")) &&
391 data->state.aptr.uagent) {
392 Curl_safefree(data->state.aptr.uagent);
393 data->state.aptr.uagent = NULL;
395 else if(!Curl_checkheaders(data, STRCONST("User-Agent")) &&
396 data->set.str[STRING_USERAGENT]) {
397 p_uagent = data->state.aptr.uagent;
400 /* setup the authentication headers */
401 result = Curl_http_output_auth(data, conn, p_request, HTTPREQ_GET,
402 p_stream_uri, FALSE);
406 p_proxyuserpwd = data->state.aptr.proxyuserpwd;
407 p_userpwd = data->state.aptr.userpwd;
410 Curl_safefree(data->state.aptr.ref);
411 if(data->state.referer && !Curl_checkheaders(data, STRCONST("Referer")))
412 data->state.aptr.ref = aprintf("Referer: %s\r\n", data->state.referer);
414 data->state.aptr.ref = NULL;
416 p_referrer = data->state.aptr.ref;
420 * Only applies to PLAY, PAUSE, RECORD
422 * Go ahead and use the Range stuff supplied for HTTP
424 if(data->state.use_range &&
425 (rtspreq & (RTSPREQ_PLAY | RTSPREQ_PAUSE | RTSPREQ_RECORD))) {
427 /* Check to see if there is a range set in the custom headers */
428 if(!Curl_checkheaders(data, STRCONST("Range")) && data->state.range) {
429 Curl_safefree(data->state.aptr.rangeline);
430 data->state.aptr.rangeline = aprintf("Range: %s\r\n", data->state.range);
431 p_range = data->state.aptr.rangeline;
436 * Sanity check the custom headers
438 if(Curl_checkheaders(data, STRCONST("CSeq"))) {
439 failf(data, "CSeq cannot be set as a custom header.");
440 return CURLE_RTSP_CSEQ_ERROR;
442 if(Curl_checkheaders(data, STRCONST("Session"))) {
443 failf(data, "Session ID cannot be set as a custom header.");
444 return CURLE_BAD_FUNCTION_ARGUMENT;
447 /* Initialize a dynamic send buffer */
448 Curl_dyn_init(&req_buffer, DYN_RTSP_REQ_HEADER);
451 Curl_dyn_addf(&req_buffer,
452 "%s %s RTSP/1.0\r\n" /* Request Stream-URI RTSP/1.0 */
453 "CSeq: %ld\r\n", /* CSeq */
454 p_request, p_stream_uri, rtsp->CSeq_sent);
459 * Rather than do a normal alloc line, keep the session_id unformatted
460 * to make comparison easier
463 result = Curl_dyn_addf(&req_buffer, "Session: %s\r\n", p_session_id);
469 * Shared HTTP-like options
471 result = Curl_dyn_addf(&req_buffer,
474 "%s" /* accept-encoding */
477 "%s" /* user-agent */
478 "%s" /* proxyuserpwd */
481 p_transport ? p_transport : "",
482 p_accept ? p_accept : "",
483 p_accept_encoding ? p_accept_encoding : "",
484 p_range ? p_range : "",
485 p_referrer ? p_referrer : "",
486 p_uagent ? p_uagent : "",
487 p_proxyuserpwd ? p_proxyuserpwd : "",
488 p_userpwd ? p_userpwd : "");
491 * Free userpwd now --- cannot reuse this for Negotiate and possibly NTLM
492 * with basic and digest, it will be freed anyway by the next request
494 Curl_safefree(data->state.aptr.userpwd);
495 data->state.aptr.userpwd = NULL;
500 if((rtspreq == RTSPREQ_SETUP) || (rtspreq == RTSPREQ_DESCRIBE)) {
501 result = Curl_add_timecondition(data, &req_buffer);
506 result = Curl_add_custom_headers(data, FALSE, &req_buffer);
510 if(rtspreq == RTSPREQ_ANNOUNCE ||
511 rtspreq == RTSPREQ_SET_PARAMETER ||
512 rtspreq == RTSPREQ_GET_PARAMETER) {
514 if(data->set.upload) {
515 putsize = data->state.infilesize;
516 data->state.httpreq = HTTPREQ_PUT;
520 postsize = (data->state.infilesize != -1)?
521 data->state.infilesize:
522 (data->set.postfields? (curl_off_t)strlen(data->set.postfields):0);
523 data->state.httpreq = HTTPREQ_POST;
526 if(putsize > 0 || postsize > 0) {
527 /* As stated in the http comments, it is probably not wise to
528 * actually set a custom Content-Length in the headers */
529 if(!Curl_checkheaders(data, STRCONST("Content-Length"))) {
531 Curl_dyn_addf(&req_buffer,
532 "Content-Length: %" CURL_FORMAT_CURL_OFF_T"\r\n",
533 (data->set.upload ? putsize : postsize));
538 if(rtspreq == RTSPREQ_SET_PARAMETER ||
539 rtspreq == RTSPREQ_GET_PARAMETER) {
540 if(!Curl_checkheaders(data, STRCONST("Content-Type"))) {
541 result = Curl_dyn_addn(&req_buffer,
542 STRCONST("Content-Type: "
543 "text/parameters\r\n"));
549 if(rtspreq == RTSPREQ_ANNOUNCE) {
550 if(!Curl_checkheaders(data, STRCONST("Content-Type"))) {
551 result = Curl_dyn_addn(&req_buffer,
552 STRCONST("Content-Type: "
553 "application/sdp\r\n"));
559 data->state.expect100header = FALSE; /* RTSP posts are simple/small */
561 else if(rtspreq == RTSPREQ_GET_PARAMETER) {
562 /* Check for an empty GET_PARAMETER (heartbeat) request */
563 data->state.httpreq = HTTPREQ_HEAD;
564 data->set.opt_no_body = TRUE;
568 /* RTSP never allows chunked transfer */
569 data->req.forbidchunk = TRUE;
570 /* Finish the request buffer */
571 result = Curl_dyn_addn(&req_buffer, STRCONST("\r\n"));
576 result = Curl_dyn_addn(&req_buffer, data->set.postfields,
582 /* issue the request */
583 result = Curl_buffer_send(&req_buffer, data,
584 &data->info.request_size, 0, FIRSTSOCKET);
586 failf(data, "Failed sending RTSP request");
590 Curl_setup_transfer(data, FIRSTSOCKET, -1, TRUE, putsize?FIRSTSOCKET:-1);
592 /* Increment the CSeq on success */
593 data->state.rtsp_next_client_CSeq++;
595 if(data->req.writebytecount) {
596 /* if a request-body has been sent off, we make sure this progress is
598 Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
599 if(Curl_pgrsUpdate(data))
600 result = CURLE_ABORTED_BY_CALLBACK;
607 static CURLcode rtsp_rtp_readwrite(struct Curl_easy *data,
608 struct connectdata *conn,
611 struct SingleRequest *k = &data->req;
612 struct rtsp_conn *rtspc = &(conn->proto.rtspc);
614 char *rtp; /* moving pointer to rtp data */
615 ssize_t rtp_dataleft; /* how much data left to parse in this round */
620 /* There was some leftover data the last time. Merge buffers */
621 char *newptr = Curl_saferealloc(rtspc->rtp_buf,
622 rtspc->rtp_bufsize + *nread);
624 rtspc->rtp_buf = NULL;
625 rtspc->rtp_bufsize = 0;
626 return CURLE_OUT_OF_MEMORY;
628 rtspc->rtp_buf = newptr;
629 memcpy(rtspc->rtp_buf + rtspc->rtp_bufsize, k->str, *nread);
630 rtspc->rtp_bufsize += *nread;
631 rtp = rtspc->rtp_buf;
632 rtp_dataleft = rtspc->rtp_bufsize;
635 /* Just parse the request buffer directly */
637 rtp_dataleft = *nread;
640 while((rtp_dataleft > 0) &&
642 if(rtp_dataleft > 4) {
645 /* Parse the header */
646 /* The channel identifier immediately follows and is 1 byte */
647 rtspc->rtp_channel = RTP_PKT_CHANNEL(rtp);
649 /* The length is two bytes */
650 rtp_length = RTP_PKT_LENGTH(rtp);
652 if(rtp_dataleft < rtp_length + 4) {
653 /* Need more - incomplete payload*/
657 /* We have the full RTP interleaved packet
658 * Write out the header including the leading '$' */
659 DEBUGF(infof(data, "RTP write channel %d rtp_length %d",
660 rtspc->rtp_channel, rtp_length));
661 result = rtp_client_write(data, &rtp[0], rtp_length + 4);
663 failf(data, "Got an error writing an RTP packet");
665 Curl_safefree(rtspc->rtp_buf);
666 rtspc->rtp_buf = NULL;
667 rtspc->rtp_bufsize = 0;
671 /* Move forward in the buffer */
672 rtp_dataleft -= rtp_length + 4;
673 rtp += rtp_length + 4;
675 if(data->set.rtspreq == RTSPREQ_RECEIVE) {
676 /* If we are in a passive receive, give control back
677 * to the app as often as we can.
679 k->keepon &= ~KEEP_RECV;
683 /* Need more - incomplete header */
689 if(rtp_dataleft && rtp[0] == '$') {
690 DEBUGF(infof(data, "RTP Rewinding %zd %s", rtp_dataleft,
691 *readmore ? "(READMORE)" : ""));
693 /* Store the incomplete RTP packet for a "rewind" */
694 scratch = malloc(rtp_dataleft);
696 Curl_safefree(rtspc->rtp_buf);
697 rtspc->rtp_buf = NULL;
698 rtspc->rtp_bufsize = 0;
699 return CURLE_OUT_OF_MEMORY;
701 memcpy(scratch, rtp, rtp_dataleft);
702 Curl_safefree(rtspc->rtp_buf);
703 rtspc->rtp_buf = scratch;
704 rtspc->rtp_bufsize = rtp_dataleft;
706 /* As far as the transfer is concerned, this data is consumed */
710 /* Fix up k->str to point just after the last RTP packet */
711 k->str += *nread - rtp_dataleft;
713 /* either all of the data has been read or...
714 * rtp now points at the next byte to parse
717 DEBUGASSERT(k->str[0] == rtp[0]);
719 DEBUGASSERT(rtp_dataleft <= *nread); /* sanity check */
721 *nread = rtp_dataleft;
723 /* If we get here, we have finished with the leftover/merge buffer */
724 Curl_safefree(rtspc->rtp_buf);
725 rtspc->rtp_buf = NULL;
726 rtspc->rtp_bufsize = 0;
732 CURLcode rtp_client_write(struct Curl_easy *data, char *ptr, size_t len)
735 curl_write_callback writeit;
739 failf(data, "Cannot write a 0 size RTP packet.");
740 return CURLE_WRITE_ERROR;
743 /* If the user has configured CURLOPT_INTERLEAVEFUNCTION then use that
744 function and any configured CURLOPT_INTERLEAVEDATA to write out the RTP
745 data. Otherwise, use the CURLOPT_WRITEFUNCTION with the CURLOPT_WRITEDATA
746 pointer to write out the RTP data. */
747 if(data->set.fwrite_rtp) {
748 writeit = data->set.fwrite_rtp;
749 user_ptr = data->set.rtp_out;
752 writeit = data->set.fwrite_func;
753 user_ptr = data->set.out;
756 Curl_set_in_callback(data, true);
757 wrote = writeit(ptr, 1, len, user_ptr);
758 Curl_set_in_callback(data, false);
760 if(CURL_WRITEFUNC_PAUSE == wrote) {
761 failf(data, "Cannot pause RTP");
762 return CURLE_WRITE_ERROR;
766 failf(data, "Failed writing RTP data");
767 return CURLE_WRITE_ERROR;
773 CURLcode Curl_rtsp_parseheader(struct Curl_easy *data, char *header)
777 if(checkprefix("CSeq:", header)) {
778 /* Store the received CSeq. Match is verified in rtsp_done */
779 int nc = sscanf(&header[4], ": %ld", &CSeq);
781 struct RTSP *rtsp = data->req.p.rtsp;
782 rtsp->CSeq_recv = CSeq; /* mark the request */
783 data->state.rtsp_CSeq_recv = CSeq; /* update the handle */
786 failf(data, "Unable to read the CSeq header: [%s]", header);
787 return CURLE_RTSP_CSEQ_ERROR;
790 else if(checkprefix("Session:", header)) {
795 /* Find the first non-space letter */
797 while(*start && ISBLANK(*start))
801 failf(data, "Got a blank Session ID");
802 return CURLE_RTSP_SESSION_ERROR;
805 /* Find the end of Session ID
807 * Allow any non whitespace content, up to the field separator or end of
808 * line. RFC 2326 isn't 100% clear on the session ID and for example
809 * gstreamer does url-encoded session ID's not covered by the standard.
812 while(*end && *end != ';' && !ISSPACE(*end))
816 if(data->set.str[STRING_RTSP_SESSION_ID]) {
818 /* If the Session ID is set, then compare */
819 if(strlen(data->set.str[STRING_RTSP_SESSION_ID]) != idlen ||
820 strncmp(start, data->set.str[STRING_RTSP_SESSION_ID], idlen) != 0) {
821 failf(data, "Got RTSP Session ID Line [%s], but wanted ID [%s]",
822 start, data->set.str[STRING_RTSP_SESSION_ID]);
823 return CURLE_RTSP_SESSION_ERROR;
827 /* If the Session ID is not set, and we find it in a response, then set
831 /* Copy the id substring into a new buffer */
832 data->set.str[STRING_RTSP_SESSION_ID] = malloc(idlen + 1);
833 if(!data->set.str[STRING_RTSP_SESSION_ID])
834 return CURLE_OUT_OF_MEMORY;
835 memcpy(data->set.str[STRING_RTSP_SESSION_ID], start, idlen);
836 (data->set.str[STRING_RTSP_SESSION_ID])[idlen] = '\0';
842 #endif /* CURL_DISABLE_RTSP or using Hyper */