Add /video to automatically give HLS to supported browser

This commit is contained in:
Kamil Trzcinski
2022-09-06 23:04:55 +02:00
parent 5ee0bee59f
commit 5801152b03
12 changed files with 93 additions and 12 deletions

View File

@ -108,15 +108,20 @@ ret:
return buf;
}
int buffer_lock_write_loop(buffer_lock_t *buf_lock, int nframes, buffer_write_fn fn, void *data)
int buffer_lock_write_loop(buffer_lock_t *buf_lock, int nframes, unsigned timeout_ms, buffer_write_fn fn, void *data)
{
int counter = 0;
int frames = 0;
uint64_t deadline_ms = get_monotonic_time_us(NULL, NULL) + DEFAULT_BUFFER_LOCK_GET_TIMEOUT * 1000LL;
uint64_t frame_stop_ms = get_monotonic_time_us(NULL, NULL) + timeout_ms * 1000LL;
buffer_lock_use(buf_lock, 1);
while (nframes == 0 || frames < nframes) {
if (timeout_ms && frame_stop_ms < get_monotonic_time_us(NULL, NULL)) {
break;
}
buffer_t *buf = buffer_lock_get(buf_lock, 0, &counter);
if (!buf) {
goto error;

View File

@ -52,6 +52,6 @@ buffer_t *buffer_lock_get(buffer_lock_t *buf_lock, int timeout_ms, int *counter)
bool buffer_lock_needs_buffer(buffer_lock_t *buf_lock);
void buffer_lock_use(buffer_lock_t *buf_lock, int ref);
bool buffer_lock_is_used(buffer_lock_t *buf_lock);
int buffer_lock_write_loop(buffer_lock_t *buf_lock, int nframes, buffer_write_fn fn, void *data);
int buffer_lock_write_loop(buffer_lock_t *buf_lock, int nframes, unsigned timeout_ms, buffer_write_fn fn, void *data);
bool buffer_lock_register_check_streaming(buffer_lock_t *buf_lock, buffer_lock_check_streaming check_streaming);
bool buffer_lock_register_notify_buffer(buffer_lock_t *buf_lock, buffer_lock_notify_buffer notify_buffer);