MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / http_send_data

Function http_send_data

ffserver.c:2458–2575  ·  view source on GitHub ↗

should convert the format at the same time */ send data starting at c->buffer_ptr to the output connection (either UDP or TCP connection) */

Source from the content-addressed store, hash-verified

2456/* send data starting at c->buffer_ptr to the output connection
2457 (either UDP or TCP connection) */
2458static int http_send_data(HTTPContext *c)
2459{
2460 int len, ret;
2461
2462 for(;;) {
2463 if (c->buffer_ptr >= c->buffer_end) {
2464 ret = http_prepare_data(c);
2465 if (ret < 0)
2466 return -1;
2467 else if (ret != 0)
2468 /* state change requested */
2469 break;
2470 } else {
2471 if (c->is_packetized) {
2472 /* RTP data output */
2473 len = c->buffer_end - c->buffer_ptr;
2474 if (len < 4) {
2475 /* fail safe - should never happen */
2476 fail1:
2477 c->buffer_ptr = c->buffer_end;
2478 return 0;
2479 }
2480 len = (c->buffer_ptr[0] << 24) |
2481 (c->buffer_ptr[1] << 16) |
2482 (c->buffer_ptr[2] << 8) |
2483 (c->buffer_ptr[3]);
2484 if (len > (c->buffer_end - c->buffer_ptr))
2485 goto fail1;
2486 if ((get_packet_send_clock(c) - get_server_clock(c)) > 0) {
2487 /* nothing to send yet: we can wait */
2488 return 0;
2489 }
2490
2491 c->data_count += len;
2492 update_datarate(&c->datarate, c->data_count);
2493 if (c->stream)
2494 c->stream->bytes_served += len;
2495
2496 if (c->rtp_protocol == RTSP_LOWER_TRANSPORT_TCP) {
2497 /* RTP packets are sent inside the RTSP TCP connection */
2498 ByteIOContext *pb;
2499 int interleaved_index, size;
2500 uint8_t header[4];
2501 HTTPContext *rtsp_c;
2502
2503 rtsp_c = c->rtsp_c;
2504 /* if no RTSP connection left, error */
2505 if (!rtsp_c)
2506 return -1;
2507 /* if already sending something, then wait. */
2508 if (rtsp_c->state != RTSPSTATE_WAIT_REQUEST)
2509 break;
2510 if (url_open_dyn_buf(&pb) < 0)
2511 goto fail1;
2512 interleaved_index = c->packet_stream_index * 2;
2513 /* RTCP packets are sent at odd indexes */
2514 if (c->buffer_ptr[1] == 200)
2515 interleaved_index++;

Callers 1

handle_connectionFunction · 0.85

Calls 9

http_prepare_dataFunction · 0.85
get_packet_send_clockFunction · 0.85
get_server_clockFunction · 0.85
update_datarateFunction · 0.85
url_open_dyn_bufFunction · 0.85
put_bufferFunction · 0.85
url_close_dyn_bufFunction · 0.85
av_freepFunction · 0.85
url_writeFunction · 0.85

Tested by

no test coverage detected