Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
htsp server: pass uuid information in the sourceinfo / subscriptionStart
  • Loading branch information
perexg committed Jan 14, 2016
1 parent b091feb commit 97ea2fc
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/htsp_server.c
Expand Up @@ -3787,6 +3787,7 @@ htsp_subscription_start(htsp_subscription_t *hs, const streaming_start_t *ss)
{
htsmsg_t *m,*streams, *c, *sourceinfo;
const char *type;
tvh_uuid_t hex;
int i;
const source_info_t *si;

Expand Down Expand Up @@ -3860,6 +3861,18 @@ htsp_subscription_start(htsp_subscription_t *hs, const streaming_start_t *ss)
htsmsg_add_msg(m, "streams", streams);

si = &ss->ss_si;
if(!uuid_empty(&si->si_adapter_uuid)) {
uuid_bin2hex(&si->si_adapter_uuid, &hex);
htsmsg_add_str(sourceinfo, "adapter_uuid", hex.hex);
}
if(!uuid_empty(&si->si_mux_uuid)) {
uuid_bin2hex(&si->si_mux_uuid, &hex);
htsmsg_add_str(sourceinfo, "mux_uuid", hex.hex);
}
if(!uuid_empty(&si->si_network_uuid)) {
uuid_bin2hex(&si->si_network_uuid, &hex);
htsmsg_add_str(sourceinfo, "network_uuid", hex.hex);
}
if(si->si_adapter ) htsmsg_add_str(sourceinfo, "adapter", si->si_adapter );
if(si->si_mux ) htsmsg_add_str(sourceinfo, "mux" , si->si_mux );
if(si->si_network ) htsmsg_add_str(sourceinfo, "network", si->si_network );
Expand Down
4 changes: 4 additions & 0 deletions src/input/mpegts/mpegts_service.c
Expand Up @@ -429,6 +429,9 @@ mpegts_service_setsourceinfo(service_t *t, source_info_t *si)
memset(si, 0, sizeof(struct source_info));
si->si_type = S_MPEG_TS;

uuid_copy(&si->si_network_uuid, &m->mm_network->mn_id.in_uuid);
uuid_copy(&si->si_mux_uuid, &m->mm_id.in_uuid);

if(m->mm_network->mn_network_name != NULL)
si->si_network = strdup(m->mm_network->mn_network_name);

Expand All @@ -437,6 +440,7 @@ mpegts_service_setsourceinfo(service_t *t, source_info_t *si)

if(s->s_dvb_active_input) {
mpegts_input_t *mi = s->s_dvb_active_input;
uuid_copy(&si->si_adapter_uuid, &mi->ti_id.in_uuid);
mi->mi_display_name(mi, buf, sizeof(buf));
si->si_adapter = strdup(buf);
}
Expand Down
3 changes: 2 additions & 1 deletion src/service.c
Expand Up @@ -1480,7 +1480,8 @@ service_source_info_free(struct source_info *si)
void
service_source_info_copy(source_info_t *dst, const source_info_t *src)
{
#define COPY(x) dst->si_##x = src->si_##x ? strdup(src->si_##x) : NULL
*dst = *src;
#define COPY(x) if (src->si_##x) dst->si_##x = strdup(src->si_##x)
COPY(adapter);
COPY(network);
COPY(mux);
Expand Down
3 changes: 3 additions & 0 deletions src/service.h
Expand Up @@ -39,6 +39,9 @@ struct mpegts_apids;
* Source information
*/
typedef struct source_info {
tvh_uuid_t si_adapter_uuid;
tvh_uuid_t si_network_uuid;
tvh_uuid_t si_mux_uuid;
char *si_adapter;
char *si_network;
char *si_satpos;
Expand Down
2 changes: 2 additions & 0 deletions src/uuid.c
Expand Up @@ -27,6 +27,8 @@

#define RANDOM_PATH "/dev/urandom"

uint8_t ___uuid_empty[UUID_BIN_SIZE] = { 0 };

static int fd = -1;

/* **************************************************************************
Expand Down
10 changes: 10 additions & 0 deletions src/uuid.h
Expand Up @@ -25,6 +25,8 @@
#define UUID_BIN_SIZE (16)
#define UUID_HEX_SIZE (33) // inc NUL

extern uint8_t ___uuid_empty[UUID_BIN_SIZE];

/* Structure to hold UUID */
typedef struct uuid {
union {
Expand Down Expand Up @@ -75,6 +77,14 @@ static inline int uuid_cmp ( const tvh_uuid_t *a, const tvh_uuid_t *b )
return memcmp(a->bin, b->bin, UUID_BIN_SIZE);
}

/**
* Empty
*/
static inline int uuid_empty ( const tvh_uuid_t *a )
{
return memcmp(a->bin, ___uuid_empty, UUID_BIN_SIZE) == 0;
}

/**
* Valid hex uuid
*/
Expand Down

0 comments on commit 97ea2fc

Please sign in to comment.