Пример #1
0
int
htsmsg_store_get_int(const char *store, const char *key, int def)
{
  hts_mutex_lock(&loaded_msg_mutex);
  loaded_msg_t *lm = htsmsg_store_obtain(store, 1);
  int r = htsmsg_get_s32_or_default(lm->lm_msg, key, def);
  hts_mutex_unlock(&loaded_msg_mutex);
  return r;
}
Пример #2
0
static void
htsp_channelAddUpdate(htsp_connection_t *hc, htsmsg_t *m, int create)
{
  uint32_t id, next;
  int chnum;
  char txt[200];
  const char *title, *icon;
  htsp_channel_t *ch;

  if(htsmsg_get_u32(m, "channelId", &id))
    return;

  title = htsmsg_get_str(m, "channelName");
  icon  = htsmsg_get_str(m, "channelIcon");
  chnum = htsmsg_get_s32_or_default(m, "channelNumber", -1);
  snprintf(txt, sizeof(txt), "%d", id);

  hts_mutex_lock(&hc->hc_meta_mutex);

  if(create) {

    ch = htsp_channel_get(hc, id, 1);
    if(prop_set_parent(ch->ch_root, hc->hc_channels_nodes))
      abort();

  } else {

    ch = htsp_channel_get(hc, id, 0);
    if(ch == NULL) {
      TRACE(TRACE_ERROR, "HTSP", "Got update for unknown channel %d", id);
      hts_mutex_unlock(&hc->hc_meta_mutex);
      return;
    }
  }

  hts_mutex_unlock(&hc->hc_meta_mutex);

  if(icon != NULL)
    prop_set_string(ch->ch_prop_icon, icon);
  if(title != NULL) {
    mystrset(&ch->ch_title, title);
    prop_set_string(ch->ch_prop_title, title);
  }
  if(chnum != -1)
    prop_set_int(ch->ch_prop_channelNumber, chnum);


  if(htsmsg_get_u32(m, "eventId", &id))
    id = 0;
  if(htsmsg_get_u32(m, "nextEventId", &next))
    next = 0;
  update_events(hc, ch->ch_prop_events, id, next);
}
Пример #3
0
setting_t *
settings_create_int(prop_t *parent, const char *id, prop_t *title,
		    int initial, htsmsg_t *store,
		    int min, int max, int step,
		    prop_callback_int_t *cb, void *opaque,
		    int flags, const char *unit,
		    prop_courier_t *pc,
		    settings_saver_t *saver, void *saver_opaque)
{
  setting_t *s = setting_create_leaf(parent, title, "integer", "value", flags);
  prop_sub_t *sub;

  s->s_id = strdup(id);
  s->s_callback = cb;
  s->s_opaque = opaque;


  if(store != NULL)
    initial = htsmsg_get_s32_or_default(store, id, initial);

  prop_set_int_clipping_range(s->s_val, min, max);

  prop_set_int(prop_create(s->s_root, "min"), min);
  prop_set_int(prop_create(s->s_root, "max"), max);
  prop_set_int(prop_create(s->s_root, "step"), step);
  prop_set_string(prop_create(s->s_root, "unit"), unit);

  prop_set_int(s->s_val, initial);

  s->s_min = min;
  s->s_max = max;

  if(flags & SETTINGS_INITIAL_UPDATE)
    settings_int_callback(s, initial);

  sub = prop_subscribe(PROP_SUB_NO_INITIAL_UPDATE,
		       PROP_TAG_CALLBACK_INT, settings_int_callback, s,
		       PROP_TAG_ROOT, s->s_val,
		       PROP_TAG_COURIER, pc,
		       NULL);
  s->s_sub = sub;
  s->s_store = store;
  s->s_saver = saver;
  s->s_saver_opaque = saver_opaque;
  return s;
}
Пример #4
0
static void
iptv_auto_network_process_m3u_item(iptv_network_t *in,
                                   const char *last_url,
                                   const http_arg_list_t *remove_args,
                                   const http_arg_list_t *ignore_args,
                                   int ignore_path,
                                   int64_t chnum, htsmsg_t *item,
                                   int *total, int *count)
{
  htsmsg_t *conf;
  htsmsg_field_t *f;
  mpegts_mux_t *mm;
  iptv_mux_t *im;
  url_t u, u2;
  int change, epgcfg, muxprio, smuxprio;
  http_arg_list_t args;
  http_arg_t *ra1, *ra2, *ra2_next;
  size_t l;
  int64_t chnum2, vlcprog;
  const char *url, *url2, *name, *logo, *epgid, *tags;
  char *s;
  char custom[512], name2[128], buf[32], *n;

  url = htsmsg_get_str(item, "m3u-url");

  if (url == NULL ||
      (strncmp(url, "file://", 7) &&
       strncmp(url, "pipe://", 7) &&
       strncmp(url, "http://", 7) &&
       strncmp(url, "https://", 8) &&
       strncmp(url, "rtsp://", 7) &&
       strncmp(url, "rtsps://", 8) &&
       strncmp(url, "udp://", 6) &&
       strncmp(url, "rtp://", 6)))
    return;

  epgid = htsmsg_get_str(item, "tvh-chnum");
  chnum2 = epgid ? prop_intsplit_from_str(epgid, CHANNEL_SPLIT) : 0;

  muxprio = htsmsg_get_s32_or_default(item, "tvh-prio", -1);
  smuxprio = htsmsg_get_s32_or_default(item, "tvh-sprio", -1);

  if (chnum2 > 0) {
    chnum += chnum2;
  } else if (chnum) {
    if (chnum % CHANNEL_SPLIT)
      chnum += *total;
    else
      chnum += (int64_t)*total * CHANNEL_SPLIT;
  }

  name = htsmsg_get_str(item, "m3u-name");
  if (name == NULL)
    name = "";

  logo = htsmsg_get_str(item, "tvg-logo");
  if (logo == NULL)
    logo = htsmsg_get_str(item, "logo");

  epgid = htsmsg_get_str(item, "tvg-id");
  epgcfg = _epgcfg_from_str(htsmsg_get_str(item, "tvh-epg"));
  tags = htsmsg_get_str(item, "tvh-tags");
  if (!tags) tags = htsmsg_get_str(item, "group-title");
  if (tags) {
    tags = n = tvh_strdupa(tags);
    while (*n) {
      if (*n == '|')
        *n = '\n';
      n++;
    }
  }

  urlinit(&u);
  urlinit(&u2);
  url2 = url;
  custom[0] = '\0';

  if (strncmp(url, "pipe://", 7) == 0)
    goto skip_url;

  if (strncmp(url, "http://", 7) == 0 ||
      strncmp(url, "https://", 8) == 0) {
    conf = htsmsg_get_list(item, "m3u-http-headers");
    if (conf) {
      l = 0;
      HTSMSG_FOREACH(f, conf)
        if ((n = (char *)htsmsg_field_get_str(f)) != NULL)
          tvh_strlcatf(custom, sizeof(custom), l, "%s\n", n);
    }
  }
Пример #5
0
static void
htsp_channelAddUpdate(htsp_connection_t *hc, htsmsg_t *m, int create)
{
  uint32_t id, next;
  int chnum;
  prop_t *p;
  char txt[200];
  const char *title, *icon;
  htsp_channel_t *ch, *n;

  if(htsmsg_get_u32(m, "channelId", &id))
    return;

  title = htsmsg_get_str(m, "channelName");
  icon  = htsmsg_get_str(m, "channelIcon");
  chnum = htsmsg_get_s32_or_default(m, "channelNumber", -1);

  if(chnum == 0)
    chnum = INT32_MAX;

  snprintf(txt, sizeof(txt), "%d", id);

  hts_mutex_lock(&hc->hc_meta_mutex);

  if(create) {

    ch = calloc(1, sizeof(htsp_channel_t));
    p = ch->ch_root = prop_create_root(txt);

    prop_t *m = prop_create(p, "metadata");
    ch->ch_prop_icon = prop_create(m, "icon");
    ch->ch_prop_title = prop_create(m, "title");
    ch->ch_prop_channelNumber = prop_create(m, "channelNumber");
    ch->ch_prop_events = prop_create(m, "events");

    ch->ch_id = id;

    snprintf(txt, sizeof(txt), "htsp://%s:%d/channel/%d",
	     hc->hc_hostname, hc->hc_port, id);
    
    prop_set_string(prop_create(p, "url"), txt);
    prop_set_string(prop_create(p, "type"), "tvchannel");

    ch->ch_channel_num = chnum;
    mystrset(&ch->ch_title, title);

    TAILQ_INSERT_SORTED(&hc->hc_channels, ch, ch_link, channel_compar);
    n = TAILQ_NEXT(ch, ch_link);

    if(prop_set_parent_ex(p, hc->hc_channels_nodes,
			  n ? n->ch_root : NULL, NULL))
      abort();

  } else {

    int move = 0;

    ch = htsp_channel_get(hc, id);
    if(ch == NULL) {
      TRACE(TRACE_ERROR, "HTSP", "Got update for unknown channel %d", id);
      hts_mutex_unlock(&hc->hc_meta_mutex);
      return;
    }

    p = ch->ch_root;

    if(title != NULL) {
      move = 1;
      mystrset(&ch->ch_title, title);
    }

    if(chnum != -1) {
      move = 1;
      ch->ch_channel_num = chnum;
    }

    if(move) {
      TAILQ_REMOVE(&hc->hc_channels, ch, ch_link);
      TAILQ_INSERT_SORTED(&hc->hc_channels, ch, ch_link, channel_compar);
      n = TAILQ_NEXT(ch, ch_link);
      prop_move(p, n ? n->ch_root : NULL);
    }
  }

  hts_mutex_unlock(&hc->hc_meta_mutex);

  if(icon != NULL)
    prop_set_string(ch->ch_prop_icon, icon);
  if(title != NULL)
    prop_set_string(ch->ch_prop_title, title);
  if(chnum != -1)
    prop_set_int(ch->ch_prop_channelNumber, chnum);


  if(htsmsg_get_u32(m, "eventId", &id))
    id = 0;
  if(htsmsg_get_u32(m, "nextEventId", &next))
    next = 0;
  update_events(hc, ch->ch_prop_events, id, next);
}