Support dynamic pausing

This commit is contained in:
Kamil Trzcinski 2022-04-05 13:53:05 +02:00
parent 7a3e851081
commit 5a81b75684
4 changed files with 12 additions and 12 deletions

View File

@ -20,11 +20,6 @@ http_method_t http_methods[] = {
{ NULL, NULL }
};
bool check_streaming()
{
return http_jpeg_needs_buffer() || http_h264_needs_buffer();
}
int main(int argc, char *argv[])
{
camera_t camera;

View File

@ -91,6 +91,7 @@ retry:
fmt->fmt.pix_mp.field = V4L2_FIELD_ANY;
fmt->fmt.pix_mp.num_planes = 1;
fmt->fmt.pix_mp.plane_fmt[0].bytesperline = bytesperline;
//fmt->fmt.pix_mp.plane_fmt[0].sizeimage = bytesperline * orig_height;
} else {
fmt->fmt.pix.colorspace = V4L2_COLORSPACE_RAW;
fmt->fmt.pix.width = width;
@ -98,6 +99,7 @@ retry:
fmt->fmt.pix.pixelformat = format;
fmt->fmt.pix.field = V4L2_FIELD_ANY;
fmt->fmt.pix.bytesperline = bytesperline;
//fmt->fmt.pix.sizeimage = bytesperline * orig_height;
}
E_LOG_DEBUG(buf_list, "Configuring format ...");
@ -116,7 +118,7 @@ retry:
}
if (bytesperline > 0 && buf_list->fmt_bytesperline != bytesperline) {
E_LOG_ERROR(buf_list, "Requested bytesperline=%u. Got %ux%u.",
E_LOG_ERROR(buf_list, "Requested bytesperline=%u. Got %u.",
bytesperline, buf_list->fmt_bytesperline);
}

View File

@ -109,8 +109,9 @@ int buffer_list_enqueue(buffer_list_t *buf_list, buffer_t *dma_buf)
if (buf_list->do_mmap) {
if (dma_buf->used > buf->length) {
E_LOG_PERROR(buf_list, "The dma_buf (%s) is too long: %zu vs space=%zu",
E_LOG_INFO(buf_list, "The dma_buf (%s) is too long: %zu vs space=%zu",
dma_buf->name, dma_buf->used, buf->length);
dma_buf->used = buf->length;
}
uint64_t before = get_monotonic_time_us(NULL, NULL);

View File

@ -14,13 +14,15 @@ void _update_paused(link_t *all_links)
for (int i = n; i-- > 0; ) {
link_t *link = &all_links[i];
bool paused = false;
if (!link->capture->capture_list->streaming) {
continue;
}
if (link->callbacks.check_streaming) {
paused = !link->callbacks.check_streaming();
bool paused = true;
if (link->callbacks.check_streaming && link->callbacks.check_streaming()) {
paused = false;
}
for (int j = 0; link->outputs[j]; j++) {
@ -34,8 +36,8 @@ void _update_paused(link_t *all_links)
}
int count_enqueued = buffer_list_count_enqueued(output->output_list);
if (count_enqueued == output->output_list->nbufs) {
paused = true;
if (count_enqueued < output->output_list->nbufs) {
paused = false;
}
}