Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mpegts dvb: implement last seen, fixes #2528
  • Loading branch information
perexg committed Dec 2, 2014
1 parent 7db9f44 commit 4e42e04
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/input/mpegts.h
Expand Up @@ -445,6 +445,7 @@ struct mpegts_service
uint16_t s_dvb_prefcapid;
int s_dvb_prefcapid_lock;
uint16_t s_dvb_forcecaid;
time_t s_dvb_last_seen;

/*
* EIT/EPG control
Expand Down
14 changes: 13 additions & 1 deletion src/input/mpegts/mpegts_service.c
Expand Up @@ -183,6 +183,13 @@ const idclass_t mpegts_service_class =
.off = offsetof(mpegts_service_t, s_dvb_forcecaid),
.opts = PO_ADVANCED | PO_HEXA,
},
{
.type = PT_TIME,
.id = "last_seen",
.name = "Last Seen",
.off = offsetof(mpegts_service_t, s_dvb_last_seen),
.opts = PO_ADVANCED | PO_RDONLY,
},
{},
}
};
Expand Down Expand Up @@ -575,16 +582,21 @@ mpegts_service_find
s->s_pmt_pid = pmt_pid;
if (save) *save = 1;
}
if (create && (*save || s->s_dvb_last_seen + 3600 < dispatch_clock)) {
s->s_dvb_last_seen = dispatch_clock;
if (save) *save = 1;
}
return s;
}
}

/* Create */
if (create) {
s = mm->mm_network->mn_create_service(mm, sid, pmt_pid);
s->s_dvb_last_seen = dispatch_clock;
if (save) *save = 1;
}

return s;
}

Expand Down
2 changes: 2 additions & 0 deletions src/prop.c
Expand Up @@ -470,6 +470,8 @@ prop_serialize_value
htsmsg_add_bool(m, "duration", 1);
if (opts & PO_HEXA)
htsmsg_add_bool(m, "hexa", 1);
if (opts & PO_DATE)
htsmsg_add_bool(m, "date", 1);

/* Enum list */
if (pl->list)
Expand Down
1 change: 1 addition & 0 deletions src/prop.h
Expand Up @@ -55,6 +55,7 @@ typedef enum {
#define PO_PASSWORD 0x0080 // String is a password
#define PO_DURATION 0x0100 // For PT_TIME - differentiate between duration and datetime
#define PO_HEXA 0x0200 // Hexadecimal value
#define PO_DATE 0x0400 // Show date only

/*
* Property definition
Expand Down
28 changes: 24 additions & 4 deletions src/webui/static/app/idnode.js
Expand Up @@ -193,6 +193,7 @@ tvheadend.IdNodeField = function(conf)
this.hidden = conf.hidden || conf.advanced;
this.password = conf.showpwd ? false : conf.password;
this.duration = conf.duration;
this.date = conf.date;
this.intsplit = conf.intsplit;
this.hexa = conf.hexa;
this.group = conf.group;
Expand Down Expand Up @@ -234,7 +235,7 @@ tvheadend.IdNodeField = function(conf)
} else if (this.type === 'time') {
w = 120;
ftype = 'date';
if (this.durations) {
if (this.duration) {
ftype = 'numeric';
w = 80;
}
Expand Down Expand Up @@ -294,9 +295,15 @@ tvheadend.IdNodeField = function(conf)
}
return min + ' min';
}
if (this.date) {
return function(v) {
var dt = new Date(v * 1000);
return dt.toLocaleDateString();
}
}
return function(v) {
var dt = new Date(v * 1000);
return dt.format('D j M H:i');
return dt.toLocaleString();
}
}

Expand Down Expand Up @@ -551,12 +558,24 @@ tvheadend.idnode_editor_field = function(f, conf)
});

case 'time':
if (!f.duration)
if (!f.duration) {
if (d) {
var dt = new Date(value * 1000);
value = f.date ? dt.toLocaleDateString() :
dt.toLocaleString();
return new Ext.form.TextField({
fieldLabel: f.caption,
name: f.id,
value: value,
disabled: true,
width: 300
});
}
return new Ext.ux.form.TwinDateTimeField({
fieldLabel: f.caption,
name: f.id,
value: value,
disabled: d,
disabled: false,
width: 300,
timeFormat: 'H:i:s',
timeConfig: {
Expand All @@ -570,6 +589,7 @@ tvheadend.idnode_editor_field = function(f, conf)
allowBlank: true
}
});
}
/* fall thru!!! */

case 'int':
Expand Down

0 comments on commit 4e42e04

Please sign in to comment.