timeshift: add return to live function to HTSP
This commit is contained in:
parent
f339c08c49
commit
404316f08f
3 changed files with 54 additions and 4 deletions
|
@ -57,7 +57,7 @@
|
|||
|
||||
static void *htsp_server, *htsp_server_2;
|
||||
|
||||
#define HTSP_PROTO_VERSION 8
|
||||
#define HTSP_PROTO_VERSION 9
|
||||
|
||||
#define HTSP_ASYNC_OFF 0x00
|
||||
#define HTSP_ASYNC_ON 0x01
|
||||
|
@ -1463,6 +1463,33 @@ htsp_method_speed(htsp_connection_t *htsp, htsmsg_t *in)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Revert to live
|
||||
*/
|
||||
static htsmsg_t *
|
||||
htsp_method_live(htsp_connection_t *htsp, htsmsg_t *in)
|
||||
{
|
||||
htsp_subscription_t *hs;
|
||||
uint32_t sid;
|
||||
streaming_skip_t skip;
|
||||
|
||||
if(htsmsg_get_u32(in, "subscriptionId", &sid))
|
||||
return htsp_error("Missing argument 'subscriptionId'");
|
||||
|
||||
LIST_FOREACH(hs, &htsp->htsp_subscriptions, hs_link)
|
||||
if(hs->hs_sid == sid)
|
||||
break;
|
||||
|
||||
if(hs == NULL)
|
||||
return htsp_error("Requested subscription does not exist");
|
||||
|
||||
skip.type = SMT_SKIP_LIVE;
|
||||
subscription_set_skip(hs->hs_s, &skip);
|
||||
|
||||
htsp_reply(htsp, in, htsmsg_create_map());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open file
|
||||
*/
|
||||
|
@ -1641,6 +1668,7 @@ struct {
|
|||
{ "subscriptionSeek", htsp_method_skip, ACCESS_STREAMING},
|
||||
{ "subscriptionSkip", htsp_method_skip, ACCESS_STREAMING},
|
||||
{ "subscriptionSpeed", htsp_method_speed, ACCESS_STREAMING},
|
||||
{ "subscriptionLive", htsp_method_live, ACCESS_STREAMING},
|
||||
{ "fileOpen", htsp_method_file_open, ACCESS_RECORDER},
|
||||
{ "fileRead", htsp_method_file_read, ACCESS_RECORDER},
|
||||
{ "fileClose", htsp_method_file_close, ACCESS_RECORDER},
|
||||
|
|
|
@ -534,6 +534,27 @@ void *timeshift_reader ( void *p )
|
|||
} else if (ctrl->sm_type == SMT_SKIP) {
|
||||
skip = ctrl->sm_data;
|
||||
switch (skip->type) {
|
||||
case SMT_SKIP_LIVE:
|
||||
if (ts->state != TS_LIVE) {
|
||||
|
||||
/* Reset */
|
||||
if (ts->full) {
|
||||
pthread_mutex_lock(&ts->rdwr_mutex);
|
||||
timeshift_filemgr_flush(ts, NULL);
|
||||
ts->full = 0;
|
||||
pthread_mutex_unlock(&ts->rdwr_mutex);
|
||||
}
|
||||
|
||||
/* Release */
|
||||
if (sm)
|
||||
streaming_msg_free(sm);
|
||||
|
||||
/* Find end */
|
||||
skip_time = 0x7fffffffffffffff;
|
||||
// TODO: change this sometime!
|
||||
}
|
||||
break;
|
||||
|
||||
case SMT_SKIP_ABS_TIME:
|
||||
if (ts->pts_delta == PTS_UNSET) {
|
||||
tvhlog(LOG_ERR, "timeshift", "ts %d abs skip not possible no PTS delta", ts->id);
|
||||
|
@ -745,8 +766,8 @@ void *timeshift_reader ( void *p )
|
|||
if (!end)
|
||||
end = (cur_speed > 0) ? 1 : -1;
|
||||
|
||||
/* Back to live */
|
||||
if (end == 1) {
|
||||
/* Back to live (unless buffer is full) */
|
||||
if (end == 1 && !ts->full) {
|
||||
tvhlog(LOG_DEBUG, "timeshift", "ts %d eob revert to live mode", ts->id);
|
||||
ts->state = TS_LIVE;
|
||||
cur_speed = 100;
|
||||
|
|
|
@ -220,7 +220,8 @@ typedef struct streaming_skip
|
|||
SMT_SKIP_REL_TIME,
|
||||
SMT_SKIP_ABS_TIME,
|
||||
SMT_SKIP_REL_SIZE,
|
||||
SMT_SKIP_ABS_SIZE
|
||||
SMT_SKIP_ABS_SIZE,
|
||||
SMT_SKIP_LIVE
|
||||
} type;
|
||||
union {
|
||||
off_t size;
|
||||
|
|
Loading…
Add table
Reference in a new issue