Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DVR: add gracefull stop, fixes #2947, fixes #2931
  • Loading branch information
perexg committed Jun 16, 2015
1 parent 4d5a4eb commit f36e79c
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/api/api_dvr.c
Expand Up @@ -227,6 +227,19 @@ api_dvr_entry_create_by_event
return !count ? EINVAL : 0;
}

static void
api_dvr_stop(access_t *perm, idnode_t *self)
{
dvr_entry_stop((dvr_entry_t *)self);
}

static int
api_dvr_entry_stop
( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
{
return api_idnode_handler(perm, args, resp, api_dvr_stop, "stop");
}

static void
api_dvr_cancel(access_t *perm, idnode_t *self)
{
Expand Down Expand Up @@ -383,6 +396,7 @@ void api_dvr_init ( void )
{ "dvr/entry/grid_failed", ACCESS_RECORDER, api_idnode_grid, api_dvr_entry_grid_failed },
{ "dvr/entry/create", ACCESS_RECORDER, api_dvr_entry_create, NULL },
{ "dvr/entry/create_by_event", ACCESS_RECORDER, api_dvr_entry_create_by_event, NULL },
{ "dvr/entry/stop", ACCESS_RECORDER, api_dvr_entry_stop, NULL },
{ "dvr/entry/cancel", ACCESS_RECORDER, api_dvr_entry_cancel, NULL },

{ "dvr/autorec/class", ACCESS_RECORDER, api_idnode_class, (void*)&dvr_autorec_entry_class },
Expand Down
2 changes: 2 additions & 0 deletions src/dvr/dvr.h
Expand Up @@ -481,6 +481,8 @@ const char *dvr_get_filename(dvr_entry_t *de);

int64_t dvr_get_filesize(dvr_entry_t *de);

dvr_entry_t *dvr_entry_stop(dvr_entry_t *de);

dvr_entry_t *dvr_entry_cancel(dvr_entry_t *de);

void dvr_entry_dec_ref(dvr_entry_t *de);
Expand Down
14 changes: 14 additions & 0 deletions src/dvr/dvr_db.c
Expand Up @@ -2416,6 +2416,20 @@ dvr_entry_delete(dvr_entry_t *de)
dvr_entry_destroy(de, 1);
}

/**
*
*/
dvr_entry_t *
dvr_entry_stop(dvr_entry_t *de)
{
if(de->de_sched_state == DVR_RECORDING) {
dvr_stop_recording(de, SM_CODE_OK, 1);
return de;
}

return dvr_entry_cancel(de);
}

/**
*
*/
Expand Down
33 changes: 32 additions & 1 deletion src/webui/static/app/dvr.js
Expand Up @@ -158,6 +158,36 @@ tvheadend.dvr_upcoming = function(panel, index) {
'channel,config_name,comment';
var elist = tvheadend.accessUpdate.admin ? list + ',owner,creator' : list;

var stopButton = {
name: 'stop',
builder: function() {
return new Ext.Toolbar.Button({
tooltip: 'Stop the selected recording',
iconCls: 'stopRec',
text: 'Stop',
disabled: true
});
},
callback: function(conf, e, store, select) {
var r = select.getSelections();
if (r && r.length > 0) {
var uuids = [];
for (var i = 0; i < r.length; i++)
uuids.push(r[i].id);
tvheadend.AjaxConfirm({
url: 'api/dvr/entry/stop',
params: {
uuid: Ext.encode(uuids)
},
success: function(d) {
store.reload();
},
question: 'Do you really want to gracefully stop/unschedule the selection?'
});
}
}
};

var abortButton = {
name: 'abort',
builder: function() {
Expand Down Expand Up @@ -194,6 +224,7 @@ tvheadend.dvr_upcoming = function(panel, index) {
if (s.data.sched_status.indexOf('recording') == 0)
recording++;
});
abuttons.stop.setDisabled(recording < 1);
abuttons.abort.setDisabled(recording < 1);
}

Expand Down Expand Up @@ -236,7 +267,7 @@ tvheadend.dvr_upcoming = function(panel, index) {
},
plugins: [actions],
lcol: [actions],
tbar: [abortButton],
tbar: [stopButton, abortButton],
selected: selected,
beforeedit: beforeedit,
help: function() {
Expand Down
4 changes: 2 additions & 2 deletions src/webui/static/app/epg.js
Expand Up @@ -269,14 +269,14 @@ tvheadend.epgDetails = function(event) {

function stopDVR() {
tvheadend.AjaxConfirm({
url: 'api/dvr/entry/cancel',
url: 'api/dvr/entry/stop',
params: {
uuid: event.dvrUuid
},
success: function(d) {
win.close();
},
question: 'Do you really want to abort/unschedule this recording?'
question: 'Do you really want to gracefully stop/unschedule this recording?'
});
}

Expand Down

0 comments on commit f36e79c

Please sign in to comment.