Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
profile: add 'Preferred Service Video Type'
  • Loading branch information
perexg committed Jun 9, 2015
1 parent 10010f8 commit db77cda
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
20 changes: 20 additions & 0 deletions src/profile.c
Expand Up @@ -258,6 +258,17 @@ profile_class_priority_list ( void *o )
return strtab2htsmsg(tab);
}

static htsmsg_t *
profile_class_svfilter_list ( void *o )
{
static const struct strtab tab[] = {
{ "None", PROFILE_SVF_NONE },
{ "SD: Standard Definition", PROFILE_SVF_SD },
{ "HD: High Definition", PROFILE_SVF_HD },
};
return strtab2htsmsg(tab);
}

const idclass_t profile_class =
{
.ic_class = "profile",
Expand Down Expand Up @@ -340,6 +351,15 @@ const idclass_t profile_class =
.off = offsetof(profile_t, pro_contaccess),
.def.i = 1,
},
{
.type = PT_INT,
.id = "svfilter",
.name = "Preferred Service Video Type",
.list = profile_class_svfilter_list,
.off = offsetof(profile_t, pro_svfilter),
.opts = PO_SORTKEY,
.def.i = PROFILE_SVF_NONE
},
{ }
}
};
Expand Down
7 changes: 7 additions & 0 deletions src/profile.h
Expand Up @@ -37,6 +37,12 @@ typedef enum {
PROFILE_SPRIO_DVR_UNIMPORTANT
} profile_sprio_t;

typedef enum {
PROFILE_SVF_NONE = 0,
PROFILE_SVF_SD,
PROFILE_SVF_HD
} profile_svfilter_t;

struct profile;
struct muxer;
struct streaming_target;
Expand Down Expand Up @@ -123,6 +129,7 @@ typedef struct profile {
int pro_timeout;
int pro_restart;
int pro_contaccess;
int pro_svfilter;

void (*pro_free)(struct profile *pro);
void (*pro_conf_changed)(struct profile *pro);
Expand Down
24 changes: 20 additions & 4 deletions src/service.c
Expand Up @@ -696,12 +696,13 @@ service_start(service_t *t, int instance, int flags, int timeout, int postpone)
service_instance_t *
service_find_instance
(service_t *s, channel_t *ch, tvh_input_t *ti,
service_instance_list_t *sil,
profile_chain_t *prch, service_instance_list_t *sil,
int *error, int weight, int flags, int timeout, int postpone)
{
channel_service_mapping_t *csm;
service_instance_t *si, *next;
int weight2;
profile_t *pro = prch ? prch->prch_pro : NULL;
int enlisted, weight2;

lock_assert(&global_lock);

Expand All @@ -714,10 +715,25 @@ service_find_instance
*error = SM_CODE_SVC_NOT_ENABLED;
return NULL;
}
enlisted = 0;
LIST_FOREACH(csm, &ch->ch_services, csm_chn_link) {
s = csm->csm_svc;
if (s->s_is_enabled(s, flags))
s->s_enlist(s, ti, sil, flags);
if (s->s_is_enabled(s, flags)) {
if (pro == NULL ||
pro->pro_svfilter == PROFILE_SVF_NONE ||
(pro->pro_svfilter == PROFILE_SVF_SD && service_is_sdtv(s)) ||
(pro->pro_svfilter == PROFILE_SVF_HD && service_is_hdtv(s))) {
s->s_enlist(s, ti, sil, flags);
enlisted++;
}
}
}
if (enlisted == 0) {
LIST_FOREACH(csm, &ch->ch_services, csm_chn_link) {
s = csm->csm_svc;
if (s->s_is_enabled(s, flags))
s->s_enlist(s, ti, sil, flags);
}
}
} else {
s->s_enlist(s, ti, sil, flags);
Expand Down
2 changes: 2 additions & 0 deletions src/service.h
Expand Up @@ -21,6 +21,7 @@

#include "htsmsg.h"
#include "idnode.h"
#include "profile.h"
#include "descrambler.h"

extern const idclass_t service_class;
Expand Down Expand Up @@ -500,6 +501,7 @@ static inline service_t *service_find(const char *identifier)
service_instance_t *service_find_instance(struct service *s,
struct channel *ch,
struct tvh_input *source,
profile_chain_t *prch,
service_instance_list_t *sil,
int *error, int weight,
int flags, int timeout,
Expand Down
2 changes: 1 addition & 1 deletion src/subscriptions.c
Expand Up @@ -275,7 +275,7 @@ subscription_start_instance
tvhtrace("subscription", "%04X: find instance for %s weight %d",
shortid(s), s->ths_service->s_nicename, s->ths_weight);
si = service_find_instance(s->ths_service, s->ths_channel,
s->ths_source,
s->ths_source, s->ths_prch,
&s->ths_instances, error, s->ths_weight,
s->ths_flags, s->ths_timeout,
dispatch_clock > s->ths_postpone_end ?
Expand Down

0 comments on commit db77cda

Please sign in to comment.