| 2575 | } |
| 2576 | |
| 2577 | static int http_start_receive_data(HTTPContext *c) |
| 2578 | { |
| 2579 | int fd; |
| 2580 | |
| 2581 | if (c->stream->feed_opened) |
| 2582 | return -1; |
| 2583 | |
| 2584 | /* Don't permit writing to this one */ |
| 2585 | if (c->stream->readonly) |
| 2586 | return -1; |
| 2587 | |
| 2588 | /* open feed */ |
| 2589 | fd = open(c->stream->feed_filename, O_RDWR); |
| 2590 | if (fd < 0) { |
| 2591 | http_log("Error opening feeder file: %s\n", strerror(errno)); |
| 2592 | return -1; |
| 2593 | } |
| 2594 | c->feed_fd = fd; |
| 2595 | |
| 2596 | if (c->stream->truncate) { |
| 2597 | /* truncate feed file */ |
| 2598 | ffm_write_write_index(c->feed_fd, FFM_PACKET_SIZE); |
| 2599 | ftruncate(c->feed_fd, FFM_PACKET_SIZE); |
| 2600 | http_log("Truncating feed file '%s'\n", c->stream->feed_filename); |
| 2601 | } else { |
| 2602 | if ((c->stream->feed_write_index = ffm_read_write_index(fd)) < 0) { |
| 2603 | http_log("Error reading write index from feed file: %s\n", strerror(errno)); |
| 2604 | return -1; |
| 2605 | } |
| 2606 | } |
| 2607 | |
| 2608 | c->stream->feed_write_index = FFMAX(ffm_read_write_index(fd), FFM_PACKET_SIZE); |
| 2609 | c->stream->feed_size = lseek(fd, 0, SEEK_END); |
| 2610 | lseek(fd, 0, SEEK_SET); |
| 2611 | |
| 2612 | /* init buffer input */ |
| 2613 | c->buffer_ptr = c->buffer; |
| 2614 | c->buffer_end = c->buffer + FFM_PACKET_SIZE; |
| 2615 | c->stream->feed_opened = 1; |
| 2616 | c->chunked_encoding = !!av_stristr(c->buffer, "Transfer-Encoding: chunked"); |
| 2617 | return 0; |
| 2618 | } |
| 2619 | |
| 2620 | static int http_receive_data(HTTPContext *c) |
| 2621 | { |
no test coverage detected