channel: make channel number like name
This allows user configuration which in the event of no setting will fallback to information automatically determined from the services. I have also updated the name stuff and simplified it a bit (with one minor change to idnode to support).
This commit is contained in:
parent
822b70928e
commit
8ffd24c727
7 changed files with 38 additions and 27 deletions
|
@ -197,10 +197,12 @@ channel_class_get_name ( void *p )
|
|||
return &s;
|
||||
}
|
||||
|
||||
static int
|
||||
channel_class_set_name ( void *o, const void *p )
|
||||
static const void *
|
||||
channel_class_get_number ( void *p )
|
||||
{
|
||||
return channel_set_name(o, p);
|
||||
static int i;
|
||||
i = channel_get_number(p);
|
||||
return &i;
|
||||
}
|
||||
|
||||
const idclass_t channel_class = {
|
||||
|
@ -224,13 +226,13 @@ const idclass_t channel_class = {
|
|||
.name = "Name",
|
||||
.off = offsetof(channel_t, ch_name),
|
||||
.get = channel_class_get_name,
|
||||
.set = channel_class_set_name,
|
||||
},
|
||||
{
|
||||
.type = PT_INT,
|
||||
.id = "number",
|
||||
.name = "Number",
|
||||
.off = offsetof(channel_t, ch_number),
|
||||
.get = channel_class_get_number,
|
||||
},
|
||||
{
|
||||
.type = PT_STR,
|
||||
|
@ -380,8 +382,7 @@ channel_get_name ( channel_t *ch )
|
|||
static const char *blank = "";
|
||||
const char *s;
|
||||
channel_service_mapping_t *csm;
|
||||
|
||||
if (ch->ch_name) return ch->ch_name;
|
||||
if (ch->ch_name && *ch->ch_name) return ch->ch_name;
|
||||
LIST_FOREACH(csm, &ch->ch_services, csm_chn_link)
|
||||
if ((s = service_get_channel_name(csm->csm_svc)))
|
||||
return s;
|
||||
|
@ -389,24 +390,14 @@ channel_get_name ( channel_t *ch )
|
|||
}
|
||||
|
||||
int
|
||||
channel_set_name ( channel_t *ch, const char *s )
|
||||
channel_get_number ( channel_t *ch )
|
||||
{
|
||||
if (!s || !*s) {
|
||||
if (ch->ch_name) {
|
||||
free(ch->ch_name);
|
||||
ch->ch_name = NULL;
|
||||
}
|
||||
return 1; // NOTE: we always return this, else UI gets confused
|
||||
// if user see's generated name clears to "" and tries to set
|
||||
// and nosave is returned (so UI doesn't update)
|
||||
}
|
||||
|
||||
if (!ch->ch_name || strcmp(ch->ch_name, s)) {
|
||||
free(ch->ch_name);
|
||||
ch->ch_name = strdup(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int n;
|
||||
channel_service_mapping_t *csm;
|
||||
if (ch->ch_number) return ch->ch_number;
|
||||
LIST_FOREACH(csm, &ch->ch_services, csm_chn_link)
|
||||
if ((n = service_get_channel_number(csm->csm_svc)))
|
||||
return n;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -149,6 +149,10 @@ void channel_save(channel_t *ch);
|
|||
const char *channel_get_name ( channel_t *ch );
|
||||
int channel_set_name ( channel_t *ch, const char *s );
|
||||
|
||||
int channel_get_number ( channel_t *ch );
|
||||
|
||||
const char *channel_get_icon ( channel_t *ch );
|
||||
|
||||
#define channel_get_uuid(ch) idnode_uuid_as_str(&ch->ch_id)
|
||||
|
||||
#define channel_get_id(ch) idnode_get_short_uuid((&ch->ch_id))
|
||||
|
|
|
@ -514,7 +514,7 @@ htsp_build_channel(channel_t *ch, const char *method, htsp_connection_t *htsp)
|
|||
htsmsg_t *services = htsmsg_create_list();
|
||||
|
||||
htsmsg_add_u32(out, "channelId", channel_get_id(ch));
|
||||
htsmsg_add_u32(out, "channelNumber", ch->ch_number);
|
||||
htsmsg_add_u32(out, "channelNumber", channel_get_number(ch));
|
||||
|
||||
htsmsg_add_str(out, "channelName", channel_get_name(ch));
|
||||
if(ch->ch_icon != NULL) {
|
||||
|
|
|
@ -711,10 +711,15 @@ idnode_write0 ( idnode_t *self, htsmsg_t *c, int optmask, int dosave )
|
|||
int save = 0;
|
||||
const idclass_t *idc = self->in_class;
|
||||
save = idnode_class_write_values(self, idc, c, optmask);
|
||||
if (save && dosave) {
|
||||
if (save && dosave)
|
||||
idnode_savefn(self);
|
||||
if (dosave)
|
||||
idnode_notify(self, NULL, 0, 0);
|
||||
}
|
||||
// Note: always output event if "dosave", reason is that UI updates on
|
||||
// these, but there are some subtle cases where it will expect
|
||||
// an update and not get one. This include fields being set for
|
||||
// which there is user-configurable value and auto fallback so
|
||||
// the UI state might not atually reflect the user config
|
||||
return save;
|
||||
}
|
||||
|
||||
|
|
|
@ -1194,6 +1194,16 @@ service_get_channel_name ( service_t *s )
|
|||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get number for service
|
||||
*/
|
||||
int
|
||||
service_get_channel_number ( service_t *s )
|
||||
{
|
||||
if (s->s_channel_number) return s->s_channel_number(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the encryption CAID from a service
|
||||
* only the first CA stream in a service is returned
|
||||
|
|
|
@ -526,5 +526,6 @@ void service_save ( service_t *s, htsmsg_t *c );
|
|||
void sort_elementary_streams(service_t *t);
|
||||
|
||||
const char *service_get_channel_name (service_t *s);
|
||||
int service_get_channel_number (service_t *s);
|
||||
|
||||
#endif // SERVICE_H__
|
||||
|
|
|
@ -65,7 +65,7 @@ dumpchannels(htsbuf_queue_t *hq)
|
|||
" icon = %s\n\n",
|
||||
ch->ch_refcount,
|
||||
ch->ch_zombie,
|
||||
ch->ch_number,
|
||||
channel_get_number(ch),
|
||||
ch->ch_icon ?: "<none set>");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue