Fix a few bugs
This commit is contained in:
@ -40,9 +40,14 @@ void http_video(http_worker_t *worker, FILE *stream)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char *data = buf->start;
|
||||||
|
|
||||||
if (buf->v4l2_buffer.flags & V4L2_BUF_FLAG_KEYFRAME) {
|
if (buf->v4l2_buffer.flags & V4L2_BUF_FLAG_KEYFRAME) {
|
||||||
had_key_frame = true;
|
had_key_frame = true;
|
||||||
E_LOG_DEBUG(buf, "Got key frame!");
|
E_LOG_DEBUG(buf, "Got key frame (from V4L2)!");
|
||||||
|
} else if (buf->used >= 5 && (data[4] & 0x1F) == 0x07) {
|
||||||
|
had_key_frame = true;
|
||||||
|
E_LOG_DEBUG(buf, "Got key frame (from buffer)!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (had_key_frame) {
|
if (had_key_frame) {
|
||||||
|
@ -48,7 +48,7 @@ void http_snapshot(http_worker_t *worker, FILE *stream)
|
|||||||
if (!buf) {
|
if (!buf) {
|
||||||
http_404_header(worker, stream);
|
http_404_header(worker, stream);
|
||||||
fprintf(stream, "No snapshot captured yet.\r\n");
|
fprintf(stream, "No snapshot captured yet.\r\n");
|
||||||
return;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stream, "HTTP/1.1 200 OK\r\n");
|
fprintf(stream, "HTTP/1.1 200 OK\r\n");
|
||||||
|
31
hw/links.c
31
hw/links.c
@ -48,8 +48,9 @@ int _build_fds(link_t *all_links, struct pollfd *fds, link_t **links, buffer_lis
|
|||||||
fds[n].events = POLLHUP;
|
fds[n].events = POLLHUP;
|
||||||
if (count_enqueued > 0)
|
if (count_enqueued > 0)
|
||||||
fds[n].events |= POLLOUT;
|
fds[n].events |= POLLOUT;
|
||||||
buf_lists[n] = source;
|
fds[n].revents = 0;
|
||||||
links[n] = link;
|
buf_lists[n] = sink;
|
||||||
|
links[n] = NULL;
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
// Can this chain pauses
|
// Can this chain pauses
|
||||||
@ -68,6 +69,7 @@ int _build_fds(link_t *all_links, struct pollfd *fds, link_t **links, buffer_lis
|
|||||||
fds[n].events = POLLHUP;
|
fds[n].events = POLLHUP;
|
||||||
if (!source->device->paused)
|
if (!source->device->paused)
|
||||||
fds[n].events |= POLLIN;
|
fds[n].events |= POLLIN;
|
||||||
|
fds[n].revents = 0;
|
||||||
buf_lists[n] = source;
|
buf_lists[n] = source;
|
||||||
links[n] = link;
|
links[n] = link;
|
||||||
n++;
|
n++;
|
||||||
@ -117,6 +119,18 @@ error:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_pollfds(struct pollfd *fds, int n)
|
||||||
|
{
|
||||||
|
if (!getenv("DEBUG_FDS")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
printf("poll(i=%i, fd=%d, events=%08x, revents=%08x)\n", i, fds[i].fd, fds[i].events, fds[i].revents);
|
||||||
|
}
|
||||||
|
printf("pollfds = %d\n", n);
|
||||||
|
}
|
||||||
|
|
||||||
int links_step(link_t *all_links, int timeout)
|
int links_step(link_t *all_links, int timeout)
|
||||||
{
|
{
|
||||||
struct pollfd fds[N_FDS] = {0};
|
struct pollfd fds[N_FDS] = {0};
|
||||||
@ -125,7 +139,9 @@ int links_step(link_t *all_links, int timeout)
|
|||||||
buffer_t *buf;
|
buffer_t *buf;
|
||||||
|
|
||||||
int n = _build_fds(all_links, fds, links, buf_lists, N_FDS);
|
int n = _build_fds(all_links, fds, links, buf_lists, N_FDS);
|
||||||
|
print_pollfds(fds, n);
|
||||||
int ret = poll(fds, n, timeout);
|
int ret = poll(fds, n, timeout);
|
||||||
|
print_pollfds(fds, n);
|
||||||
|
|
||||||
if (ret < 0 && errno != EINTR) {
|
if (ret < 0 && errno != EINTR) {
|
||||||
return errno;
|
return errno;
|
||||||
@ -135,11 +151,12 @@ int links_step(link_t *all_links, int timeout)
|
|||||||
buffer_list_t *buf_list = buf_lists[i];
|
buffer_list_t *buf_list = buf_lists[i];
|
||||||
link_t *link = links[i];
|
link_t *link = links[i];
|
||||||
|
|
||||||
E_LOG_DEBUG(buf_list, "pool event=%s%s%s%s/%08x streaming=%d enqueued=%d/%d",
|
E_LOG_DEBUG(buf_list, "pool event=%s%s%s%s%s%08x streaming=%d enqueued=%d/%d",
|
||||||
!fds[i].revents ? "NONE" : "",
|
!fds[i].revents ? "NONE/" : "",
|
||||||
fds[i].revents & POLLIN ? "IN" : "",
|
fds[i].revents & POLLIN ? "IN/" : "",
|
||||||
fds[i].revents & POLLOUT ? "OUT" : "",
|
fds[i].revents & POLLOUT ? "OUT/" : "",
|
||||||
fds[i].revents & POLLERR ? "ERR" : "",
|
fds[i].revents & POLLHUP ? "HUP/" : "",
|
||||||
|
fds[i].revents & POLLERR ? "ERR/" : "",
|
||||||
fds[i].revents,
|
fds[i].revents,
|
||||||
buf_list->streaming,
|
buf_list->streaming,
|
||||||
buffer_list_count_enqueued(buf_list),
|
buffer_list_count_enqueued(buf_list),
|
||||||
|
Reference in New Issue
Block a user