Files
aes67-ESP32-P4/main/hls.h
T

27 lines
1.0 KiB
C

// HLS client: playlists, variant choice, live segment loop. Segment bytes go to a sink callback.
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "cJSON.h"
#include "esp_err.h"
// Receives segment data in chunks (MPEG-TS etc.). Return false to abort the segment.
typedef bool (*hls_sink_t)(const uint8_t *data, size_t len, bool segment_start);
#define HLS_URL_MAX 384
esp_err_t hls_start(hls_sink_t sink);
// Adds status.hls: last segment download (bytes, ms, Mbit/s incl. connect + TLS), failed requests.
void hls_status(cJSON *st);
// The playlist URL to play ("" = none). A different URL restarts fetching with it.
void hls_set_url(const char *url);
// Stop fetching (current download is abandoned) until resumed. Reasons are independent:
// fetching runs only when no reason holds it.
#define HLS_SUSPEND_OTA (1 << 0)
#define HLS_SUSPEND_FAILOVER (1 << 1)
#define HLS_SUSPEND_USER (1 << 2) // paused via the player API
void hls_suspend(unsigned reason, bool suspend);