Lines Matching refs:data
52 static CURLcode rtsp_do(struct Curl_easy *data, bool *done);
53 static CURLcode rtsp_done(struct Curl_easy *data, CURLcode, bool premature);
54 static CURLcode rtsp_connect(struct Curl_easy *data, bool *done);
55 static CURLcode rtsp_disconnect(struct Curl_easy *data,
57 static int rtsp_getsock_do(struct Curl_easy *data,
70 static CURLcode rtsp_rtp_write_resp(struct Curl_easy *data,
75 static CURLcode rtsp_setup_connection(struct Curl_easy *data,
77 static unsigned int rtsp_conncheck(struct Curl_easy *data,
84 static int rtsp_getsock_do(struct Curl_easy *data, struct connectdata *conn, in rtsp_getsock_do() argument
88 (void)data; in rtsp_getsock_do()
94 CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr, size_t len);
96 CURLcode rtsp_parse_transport(struct Curl_easy *data, const char *transport);
128 static CURLcode rtsp_setup_connection(struct Curl_easy *data, in rtsp_setup_connection() argument
134 data->req.p.rtsp = rtsp = calloc(1, sizeof(struct RTSP)); in rtsp_setup_connection()
146 static unsigned int rtsp_conncheck(struct Curl_easy *data, in rtsp_conncheck() argument
151 (void)data; in rtsp_conncheck()
155 if(!Curl_conn_is_alive(data, conn, &input_pending)) in rtsp_conncheck()
163 static CURLcode rtsp_connect(struct Curl_easy *data, bool *done) in rtsp_connect() argument
167 httpStatus = Curl_http_connect(data, done); in rtsp_connect()
170 if(data->state.rtsp_next_client_CSeq == 0) in rtsp_connect()
171 data->state.rtsp_next_client_CSeq = 1; in rtsp_connect()
172 if(data->state.rtsp_next_server_CSeq == 0) in rtsp_connect()
173 data->state.rtsp_next_server_CSeq = 1; in rtsp_connect()
175 data->conn->proto.rtspc.rtp_channel = -1; in rtsp_connect()
180 static CURLcode rtsp_disconnect(struct Curl_easy *data, in rtsp_disconnect() argument
184 (void) data; in rtsp_disconnect()
190 static CURLcode rtsp_done(struct Curl_easy *data, in rtsp_done() argument
193 struct RTSP *rtsp = data->req.p.rtsp; in rtsp_done()
197 if(data->set.rtspreq == RTSPREQ_RECEIVE) in rtsp_done()
200 httpStatus = Curl_http_done(data, status, premature); in rtsp_done()
206 if((data->set.rtspreq != RTSPREQ_RECEIVE) && (CSeq_sent != CSeq_recv)) { in rtsp_done()
207 failf(data, in rtsp_done()
212 if(data->set.rtspreq == RTSPREQ_RECEIVE && in rtsp_done()
213 (data->conn->proto.rtspc.rtp_channel == -1)) { in rtsp_done()
214 infof(data, "Got an RTP Receive with a CSeq of %ld", CSeq_recv); in rtsp_done()
221 static CURLcode rtsp_do(struct Curl_easy *data, bool *done) in rtsp_do() argument
223 struct connectdata *conn = data->conn; in rtsp_do()
225 Curl_RtspReq rtspreq = data->set.rtspreq; in rtsp_do()
226 struct RTSP *rtsp = data->req.p.rtsp; in rtsp_do()
245 rtsp->CSeq_sent = data->state.rtsp_next_client_CSeq; in rtsp_do()
251 if(!data->state.first_host) { in rtsp_do()
252 data->state.first_host = strdup(conn->host.name); in rtsp_do()
253 if(!data->state.first_host) in rtsp_do()
256 data->state.first_remote_port = conn->remote_port; in rtsp_do()
257 data->state.first_remote_protocol = conn->handler->protocol; in rtsp_do()
264 data->req.no_body = TRUE; /* most requests do not contain a body */ in rtsp_do()
267 failf(data, "Got invalid RTSP request"); in rtsp_do()
274 data->req.no_body = FALSE; in rtsp_do()
294 data->req.no_body = FALSE; in rtsp_do()
305 data->req.no_body = FALSE; in rtsp_do()
308 failf(data, "Got invalid RTSP request: RTSPREQ_LAST"); in rtsp_do()
313 Curl_xfer_setup1(data, CURL_XFER_RECV, -1, TRUE); in rtsp_do()
317 p_session_id = data->set.str[STRING_RTSP_SESSION_ID]; in rtsp_do()
322 failf(data, "Refusing to issue an RTSP request [%s] without a session ID.", in rtsp_do()
329 if(data->set.str[STRING_RTSP_STREAM_URI]) { in rtsp_do()
330 p_stream_uri = data->set.str[STRING_RTSP_STREAM_URI]; in rtsp_do()
337 p_transport = Curl_checkheaders(data, STRCONST("Transport")); in rtsp_do()
340 if(data->set.str[STRING_RTSP_TRANSPORT]) { in rtsp_do()
341 Curl_safefree(data->state.aptr.rtsp_transport); in rtsp_do()
343 data->state.aptr.rtsp_transport = in rtsp_do()
345 data->set.str[STRING_RTSP_TRANSPORT]); in rtsp_do()
346 if(!data->state.aptr.rtsp_transport) in rtsp_do()
350 failf(data, in rtsp_do()
356 p_transport = data->state.aptr.rtsp_transport; in rtsp_do()
362 p_accept = Curl_checkheaders(data, STRCONST("Accept")) ? in rtsp_do()
366 if(!Curl_checkheaders(data, STRCONST("Accept-Encoding")) && in rtsp_do()
367 data->set.str[STRING_ENCODING]) { in rtsp_do()
368 Curl_safefree(data->state.aptr.accept_encoding); in rtsp_do()
369 data->state.aptr.accept_encoding = in rtsp_do()
370 aprintf("Accept-Encoding: %s\r\n", data->set.str[STRING_ENCODING]); in rtsp_do()
372 if(!data->state.aptr.accept_encoding) { in rtsp_do()
376 p_accept_encoding = data->state.aptr.accept_encoding; in rtsp_do()
384 if(Curl_checkheaders(data, STRCONST("User-Agent")) && in rtsp_do()
385 data->state.aptr.uagent) { in rtsp_do()
386 Curl_safefree(data->state.aptr.uagent); in rtsp_do()
388 else if(!Curl_checkheaders(data, STRCONST("User-Agent")) && in rtsp_do()
389 data->set.str[STRING_USERAGENT]) { in rtsp_do()
390 p_uagent = data->state.aptr.uagent; in rtsp_do()
394 result = Curl_http_output_auth(data, conn, p_request, HTTPREQ_GET, in rtsp_do()
400 p_proxyuserpwd = data->state.aptr.proxyuserpwd; in rtsp_do()
402 p_userpwd = data->state.aptr.userpwd; in rtsp_do()
405 Curl_safefree(data->state.aptr.ref); in rtsp_do()
406 if(data->state.referer && !Curl_checkheaders(data, STRCONST("Referer"))) in rtsp_do()
407 data->state.aptr.ref = aprintf("Referer: %s\r\n", data->state.referer); in rtsp_do()
409 p_referrer = data->state.aptr.ref; in rtsp_do()
417 if(data->state.use_range && in rtsp_do()
421 if(!Curl_checkheaders(data, STRCONST("Range")) && data->state.range) { in rtsp_do()
422 Curl_safefree(data->state.aptr.rangeline); in rtsp_do()
423 data->state.aptr.rangeline = aprintf("Range: %s\r\n", data->state.range); in rtsp_do()
424 p_range = data->state.aptr.rangeline; in rtsp_do()
431 if(Curl_checkheaders(data, STRCONST("CSeq"))) { in rtsp_do()
432 failf(data, "CSeq cannot be set as a custom header."); in rtsp_do()
436 if(Curl_checkheaders(data, STRCONST("Session"))) { in rtsp_do()
437 failf(data, "Session ID cannot be set as a custom header."); in rtsp_do()
486 Curl_safefree(data->state.aptr.userpwd); in rtsp_do()
492 result = Curl_add_timecondition(data, &req_buffer); in rtsp_do()
497 result = Curl_add_custom_headers(data, FALSE, &req_buffer); in rtsp_do()
506 if(data->state.upload) { in rtsp_do()
507 req_clen = data->state.infilesize; in rtsp_do()
508 data->state.httpreq = HTTPREQ_PUT; in rtsp_do()
509 result = Curl_creader_set_fread(data, req_clen); in rtsp_do()
514 if(data->set.postfields) { in rtsp_do()
515 size_t plen = strlen(data->set.postfields); in rtsp_do()
517 result = Curl_creader_set_buf(data, data->set.postfields, plen); in rtsp_do()
519 else if(data->state.infilesize >= 0) { in rtsp_do()
520 req_clen = data->state.infilesize; in rtsp_do()
521 result = Curl_creader_set_fread(data, req_clen); in rtsp_do()
525 result = Curl_creader_set_null(data); in rtsp_do()
534 if(!Curl_checkheaders(data, STRCONST("Content-Length"))) { in rtsp_do()
544 if(!Curl_checkheaders(data, STRCONST("Content-Type"))) { in rtsp_do()
554 if(!Curl_checkheaders(data, STRCONST("Content-Type"))) { in rtsp_do()
565 data->state.httpreq = HTTPREQ_HEAD; in rtsp_do()
566 data->req.no_body = TRUE; in rtsp_do()
570 result = Curl_creader_set_null(data); in rtsp_do()
580 Curl_xfer_setup1(data, CURL_XFER_SENDRECV, -1, TRUE); in rtsp_do()
583 result = Curl_req_send(data, &req_buffer); in rtsp_do()
585 failf(data, "Failed sending RTSP request"); in rtsp_do()
590 data->state.rtsp_next_client_CSeq++; in rtsp_do()
592 if(data->req.writebytecount) { in rtsp_do()
595 Curl_pgrsSetUploadCounter(data, data->req.writebytecount); in rtsp_do()
596 if(Curl_pgrsUpdate(data)) in rtsp_do()
607 static CURLcode rtp_write_body_junk(struct Curl_easy *data, in rtp_write_body_junk() argument
611 struct rtsp_conn *rtspc = &(data->conn->proto.rtspc); in rtp_write_body_junk()
615 in_body = (data->req.headerline && !rtspc->in_header) && in rtp_write_body_junk()
616 (data->req.size >= 0) && in rtp_write_body_junk()
617 (data->req.bytecount < data->req.size); in rtp_write_body_junk()
618 body_remain = in_body ? (data->req.size - data->req.bytecount) : 0; in rtp_write_body_junk()
623 return Curl_client_write(data, CLIENTWRITE_BODY, (char *)buf, blen); in rtp_write_body_junk()
628 static CURLcode rtsp_filter_rtp(struct Curl_easy *data, in rtsp_filter_rtp() argument
633 struct rtsp_conn *rtspc = &(data->conn->proto.rtspc); in rtsp_filter_rtp()
639 bool in_body = (data->req.headerline && !rtspc->in_header) && in rtsp_filter_rtp()
640 (data->req.size >= 0) && in rtsp_filter_rtp()
641 (data->req.bytecount < data->req.size); in rtsp_filter_rtp()
648 data->set.rtspreq != RTSPREQ_RECEIVE) { in rtsp_filter_rtp()
652 DEBUGF(infof(data, "RTP rtsp_filter_rtp[SKIP] RTSP/ prefix, " in rtsp_filter_rtp()
670 result = rtp_write_body_junk(data, in rtsp_filter_rtp()
692 if(!(data->state.rtp_channel_mask[idx] & (1 << off))) { in rtsp_filter_rtp()
697 DEBUGF(infof(data, "RTSP: invalid RTP channel %d, skipping", idx)); in rtsp_filter_rtp()
702 result = rtp_write_body_junk(data, Curl_dyn_ptr(&rtspc->buf), 1); in rtsp_filter_rtp()
759 DEBUGF(infof(data, "RTP write channel %d rtp_len %zu", in rtsp_filter_rtp()
761 result = rtp_client_write(data, Curl_dyn_ptr(&rtspc->buf), in rtsp_filter_rtp()
787 result = rtp_write_body_junk(data, (char *)(buf - skip_len), skip_len); in rtsp_filter_rtp()
791 static CURLcode rtsp_rtp_write_resp(struct Curl_easy *data, in rtsp_rtp_write_resp() argument
796 struct rtsp_conn *rtspc = &(data->conn->proto.rtspc); in rtsp_rtp_write_resp()
800 if(!data->req.header) in rtsp_rtp_write_resp()
806 DEBUGF(infof(data, "rtsp_rtp_write_resp(len=%zu, in_header=%d, eos=%d)", in rtsp_rtp_write_resp()
811 result = rtsp_filter_rtp(data, buf, blen, &consumed); in rtsp_rtp_write_resp()
817 if(blen && !data->req.header) in rtsp_rtp_write_resp()
818 DEBUGF(infof(data, "RTSP: %zu bytes, possibly excess in response body", in rtsp_rtp_write_resp()
823 if(data->req.header && blen) { in rtsp_rtp_write_resp()
825 result = Curl_http_write_resp_hds(data, buf, blen, &consumed); in rtsp_rtp_write_resp()
832 if(!data->req.header) in rtsp_rtp_write_resp()
837 if(data->req.size <= -1) { in rtsp_rtp_write_resp()
840 data->req.size = 0; in rtsp_rtp_write_resp()
841 data->req.download_done = TRUE; in rtsp_rtp_write_resp()
843 result = rtsp_filter_rtp(data, buf, blen, &consumed); in rtsp_rtp_write_resp()
851 data->req.done = FALSE; in rtsp_rtp_write_resp()
855 DEBUGF(infof(data, "rtsp_rtp_write_resp(len=%zu, in_header=%d, done=%d " in rtsp_rtp_write_resp()
857 blen, rtspc->in_header, data->req.done, rtspc->state, in rtsp_rtp_write_resp()
858 data->req.size)); in rtsp_rtp_write_resp()
860 result = Curl_client_write(data, CLIENTWRITE_BODY| in rtsp_rtp_write_resp()
866 if((data->set.rtspreq == RTSPREQ_RECEIVE) && in rtsp_rtp_write_resp()
871 data->req.download_done = TRUE; in rtsp_rtp_write_resp()
877 CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr, size_t len) in rtp_client_write() argument
884 failf(data, "Cannot write a 0 size RTP packet."); in rtp_client_write()
892 if(data->set.fwrite_rtp) { in rtp_client_write()
893 writeit = data->set.fwrite_rtp; in rtp_client_write()
894 user_ptr = data->set.rtp_out; in rtp_client_write()
897 writeit = data->set.fwrite_func; in rtp_client_write()
898 user_ptr = data->set.out; in rtp_client_write()
901 Curl_set_in_callback(data, TRUE); in rtp_client_write()
903 Curl_set_in_callback(data, FALSE); in rtp_client_write()
906 failf(data, "Cannot pause RTP"); in rtp_client_write()
911 failf(data, "Failed writing RTP data"); in rtp_client_write()
918 CURLcode Curl_rtsp_parseheader(struct Curl_easy *data, const char *header) in Curl_rtsp_parseheader() argument
928 struct RTSP *rtsp = data->req.p.rtsp; in Curl_rtsp_parseheader()
930 data->state.rtsp_CSeq_recv = CSeq; /* update the handle */ in Curl_rtsp_parseheader()
933 failf(data, "Unable to read the CSeq header: [%s]", header); in Curl_rtsp_parseheader()
947 failf(data, "Got a blank Session ID"); in Curl_rtsp_parseheader()
962 if(data->set.str[STRING_RTSP_SESSION_ID]) { in Curl_rtsp_parseheader()
965 if(strlen(data->set.str[STRING_RTSP_SESSION_ID]) != idlen || in Curl_rtsp_parseheader()
966 strncmp(start, data->set.str[STRING_RTSP_SESSION_ID], idlen)) { in Curl_rtsp_parseheader()
967 failf(data, "Got RTSP Session ID Line [%s], but wanted ID [%s]", in Curl_rtsp_parseheader()
968 start, data->set.str[STRING_RTSP_SESSION_ID]); in Curl_rtsp_parseheader()
978 data->set.str[STRING_RTSP_SESSION_ID] = Curl_memdup0(start, idlen); in Curl_rtsp_parseheader()
979 if(!data->set.str[STRING_RTSP_SESSION_ID]) in Curl_rtsp_parseheader()
985 result = rtsp_parse_transport(data, header + 10); in Curl_rtsp_parseheader()
993 CURLcode rtsp_parse_transport(struct Curl_easy *data, const char *transport) in rtsp_parse_transport() argument
1011 unsigned char *rtp_channel_mask = data->state.rtp_channel_mask; in rtsp_parse_transport()
1017 infof(data, "Unable to read the interleaved parameter from " in rtsp_parse_transport()
1029 infof(data, "Unable to read the interleaved parameter from " in rtsp_parse_transport()