Lines Matching +full:close +full:- +full:range
1 /*-
125 pvc->profile->http.rtp_vlanid = vr.vlr_tag;
127 pvc->profile->http.rtp_vlanid = 0;
129 close(fd);
144 if (perr != NULL && fd > -1)
145 close(fd);
155 while (count--)
170 while (count--)
175 length -= 2;
193 uint16_t port = atoi(pvc->profile->http.rtp_port);
203 iov[0].iov_len = 14 + total_ip - len;
208 /* byte swap data - WAV files are 16-bit little endian */
222 pkt.udp.len = htobe16(total_ip - sizeof(pkt.ip));
225 pkt.rtp.header8[1] = ((pvc->channels == 2) ? 10 : 11) | 0x80;
227 pkt.rtp.header16[1] = htobe16(pvc->profile->http.rtp_seqnum);
236 pvc->profile->http.rtp_seqnum++;
237 pvc->profile->http.rtp_ts += len / (2 * pvc->channels);
245 const uint32_t mod = pvc->channels * vclient_sample_bytes(pvc);
246 const uint32_t max = 1420 - (1420 % mod);
250 len -= max;
264 for (x = 0; x < pvc->profile->http.nstate; x++)
265 usage += (pvc->profile->http.state[x].fd != -1);
281 if (size == (linelen - 1))
306 mod = pvc->channels * vclient_sample_bytes(pvc);
308 if (mod == 0 || sizeof(buffer) < (44 + mod - 1))
309 return (-1);
312 len = 44 + mod - 1;
313 len -= len % mod;
321 ptr[len - 8] = 'd';
322 ptr[len - 7] = 'a';
323 ptr[len - 6] = 't';
324 ptr[len - 5] = 'a';
327 ptr[len - 4] = 0x00;
328 ptr[len - 3] = 0xF0;
329 ptr[len - 2] = 0xFF;
330 ptr[len - 1] = 0x7F;
338 /* total chunk size - unknown */
355 len -= 28;
369 len = pvc->channels;
376 len = pvc->sample_rate;
385 len = pvc->sample_rate * pvc->channels * vclient_sample_bytes(pvc);
394 len = pvc->channels * vclient_sample_bytes(pvc);
410 dummy_len = pvc->sample_rate * pvc->channels * vclient_sample_bytes(pvc);
415 r_end = dummy_len - 1;
417 delta = r_end - r_start + 1;
421 "Content-Type: audio/wav\r\n"
423 "Cache-Control: no-cache, no-store\r\n"
425 "Connection: Close\r\n"
426 "Content-Range: bytes %ju-%ju/%ju\r\n"
427 "Content-Length: %ju\r\n"
431 "Content-Type: audio/wav\r\n"
433 "Cache-Control: no-cache, no-store\r\n"
435 "Connection: Close\r\n"
436 "Content-Length: %ju\r\n"
442 buflen -= r_start;
447 return (-1);
460 uintmax_t r_end = -1ULL;
471 page = -1;
487 } else if (strstr(line, "Range: bytes=") == line &&
488 sscanf(line, "Range: bytes=%ju-%ju", &r_start, &r_end) >= 1) {
498 "Content-Type: text/html\r\n"
500 "Cache-Control: no-cache, no-store\r\n"
504 "<meta http-equiv=\"Cache-Control\" content=\"no-cache, no-store, must-revalidate\" />"
505 "<meta http-equiv=\"Pragma\" content=\"no-cache\" />"
506 "<meta http-equiv=\"Expires\" content=\"0\" />"
514 "<li>Install <a href=\"https://www.videolan.org\">VideoLanClient (VLC)</a>, from App- or Play-store free of charge</li>"
526 pvc->profile->http.host, pvc->profile->http.port,
527 pvc->profile->http.host, pvc->profile->http.port);
529 if (x == pvc->profile->http.nstate)
532 fprintf(io, "<h2>There are %zu free slots (%zu active)</h2>", pvc->profile->http.nstate - x, x);
537 for (x = 0; x < pvc->profile->http.nstate; x++) {
538 if (pvc->profile->http.state[x].fd >= 0)
547 close(fd);
550 pvc->profile->http.state[x].ts =
551 virtual_oss_timestamp() - 1000000000ULL;
552 pvc->profile->http.state[x].fd = fd;
558 fprintf(io, "HTTP/1.1 416 Range Not Satisfiable\r\n"
572 "Content-Type: audio/mpegurl\r\n"
574 "Cache-Control: no-cache, no-store\r\n"
577 if (sa->sin_family == AF_INET && pvc->profile->http.rtp_port != NULL) {
578 fprintf(io, "rtp://239.255.0.1:%s\r\n", pvc->profile->http.rtp_port);
581 pvc->profile->http.host, pvc->profile->http.port);
586 "Content-Type: text/html\r\n"
601 close(fd);
623 return (-1);
628 if ((s = socket(res0->ai_family, res0->ai_socktype,
629 res0->ai_protocol)) < 0)
639 if (bind(s, res0->ai_addr, res0->ai_addrlen) == 0) {
640 if (listen(s, pvc->profile->http.nstate) == 0) {
645 close(s);
649 close(s);
650 } while ((res0 = res0->ai_next) != NULL);
661 return ((pvc->sample_rate / 4) *
662 pvc->channels * vclient_sample_bytes(pvc));
669 const char *host = pvc->profile->http.host;
670 const char *port = pvc->profile->http.port;
692 if (poll(fds, ns, -1) < 0)
724 vring_get_read(&pvc->rx_ring[1], &ptr, &len);
727 vring_reset(&pvc->rx_ring[1]);
736 if (pvc->profile->http.rtp_fd > -1) {
737 voss_httpd_send_rtp(pvc, pvc->profile->http.rtp_fd,
738 ptr, len, pvc->profile->http.rtp_ts);
742 for (x = 0; x < pvc->profile->http.nstate; x++) {
743 int fd = pvc->profile->http.state[x].fd;
744 uint64_t delta = ts - pvc->profile->http.state[x].ts;
751 /* no data for 8 seconds - terminate */
752 pvc->profile->http.state[x].fd = -1;
753 close(fd);
754 } else if (read(fd, buf, sizeof(buf)) != -1 || errno != EWOULDBLOCK) {
755 pvc->profile->http.state[x].fd = -1;
756 close(fd);
758 pvc->profile->http.state[x].fd = -1;
759 close(fd);
760 } else if ((ssize_t)(bufferlimit - write_len) < (ssize_t)len) {
763 pvc->profile->http.state[x].fd = -1;
764 close(fd);
767 pvc->profile->http.state[x].ts = ts;
772 vring_inc_read(&pvc->rx_ring[1], len);
784 if (pvp->http.host == NULL || pvp->http.port == NULL || pvp->http.nstate == 0)
787 pvp->http.state = malloc(sizeof(pvp->http.state[0]) * pvp->http.nstate);
788 if (pvp->http.state == NULL)
791 for (x = 0; x != pvp->http.nstate; x++) {
792 pvp->http.state[x].fd = -1;
793 pvp->http.state[x].ts = 0;
800 pvc->profile = pvp;
802 if (pvp->http.rtp_ifname != NULL) {
805 if (pvc->channels > 2)
806 return ("RTP only supports 44.1kHz, 1 or 2 channels at 16-bit depth");
809 perr = voss_httpd_bind_rtp(pvc, pvp->http.rtp_ifname,
810 &pvp->http.rtp_fd);
816 pvp->channels, AFMT_S16_LE, 44100);
818 pvp->http.rtp_fd = -1;
821 error = vclient_setup_buffers(pvc, 0, 0, pvp->channels,
832 pvc->rx_enabled = 1;
834 pvc->type = VTYPE_OSS_DAT;
837 TAILQ_INSERT_TAIL(&pvp->head, pvc, entry);