static inline int
iptv_input_pause_check ( iptv_mux_t *im )
{
- int64_t s64;
+ int64_t s64, limit;
if (im->im_pcr == PTS_UNSET)
return 0;
+ limit = im->mm_iptv_buffer_limit;
+ if (!limit)
+ limit = im->im_handler->buffer_limit;
+ if (limit == UINT32_MAX)
+ return 0;
+ limit *= 1000;
s64 = getmonoclock() - im->im_pcr_start;
im->im_pcr_start += s64;
im->im_pcr += (((s64 / 10LL) * 9LL) + 4LL) / 10LL;
im->im_pcr &= PTS_MASK;
- tvhtrace("iptv-pcr", "pcr: updated %"PRId64", time start %"PRId64, im->im_pcr, im->im_pcr_start);
+ tvhtrace("iptv-pcr", "pcr: updated %"PRId64", time start %"PRId64", limit %"PRId64,
+ im->im_pcr, im->im_pcr_start, limit);
/* queued more than 3 seconds? trigger the pause */
- return im->im_pcr_end - im->im_pcr_start >= 3000000LL;
+ return im->im_pcr_end - im->im_pcr_start >= limit;
}
void
static iptv_handler_t ih[] = {
{
.scheme = "file",
+ .buffer_limit = 5000,
.start = iptv_file_start,
.stop = iptv_file_stop
},
static iptv_handler_t ih[] = {
{
.scheme = "http",
+ .buffer_limit = 5000,
.start = iptv_http_start,
.stop = iptv_http_stop,
.pause = iptv_http_pause
},
{
.scheme = "https",
+ .buffer_limit = 5000,
.start = iptv_http_start,
.stop = iptv_http_stop,
.pause = iptv_http_pause
.off = offsetof(iptv_mux_t, mm_iptv_satip_dvbt_freq),
.opts = PO_ADVANCED
},
+ {
+ .type = PT_U32,
+ .id = "iptv_buffer_limit",
+ .name = N_("Buffering limit (ms)"),
+ .desc = N_("Specifies the incoming buffering limit in milliseconds (PCR based). "
+ "If PCR time difference from the system clock is higher, the incoming "
+ "stream is paused."),
+ .off = offsetof(iptv_mux_t, mm_iptv_buffer_limit),
+ .opts = PO_ADVANCED,
+ },
{}
}
};
static iptv_handler_t ih[] = {
{
.scheme = "pipe",
+ .buffer_limit = 5000,
.start = iptv_pipe_start,
.stop = iptv_pipe_stop,
.read = iptv_pipe_read,
struct iptv_handler
{
const char *scheme;
+
+ uint32_t buffer_limit;
+
int (*start) ( iptv_mux_t *im, const char *raw, const url_t *url );
void (*stop) ( iptv_mux_t *im );
ssize_t (*read) ( iptv_mux_t *im );
sbuf_t mm_iptv_buffer;
+ uint32_t mm_iptv_buffer_limit;
+
iptv_handler_t *im_handler;
gtimer_t im_pause_timer;
static iptv_handler_t ih[] = {
{
.scheme = "udp",
+ .buffer_limit = UINT32_MAX, /* unlimited */
.start = iptv_udp_start,
.stop = iptv_udp_stop,
.read = iptv_udp_read,
},
{
.scheme = "rtp",
+ .buffer_limit = UINT32_MAX, /* unlimited */
.start = iptv_udp_start,
.stop = iptv_udp_stop,
.read = iptv_udp_rtp_read,