return NULL;
if (tvheadend_webroot) {
- strcpy(buf, tvheadend_webroot);
- strcat(buf, at->at_resource);
+ snprintf(buf, sizeof(buf), "%s%s", tvheadend_webroot, at->at_resource);
r = buf;
} else {
r = at->at_resource;
{
struct stat st;
char buf[1024];
- const char *homedir = getenv("HOME");
/* Generate default */
if (!path) {
+ const char *homedir = getenv("HOME");
+ if (homedir == NULL) {
+ tvherror("START", "environment variable HOME is not set");
+ exit(EXIT_FAILURE);
+ }
snprintf(buf, sizeof(buf), "%s/.hts/tvheadend", homedir);
path = buf;
}
{
opentv_pattern_t *pattern;
htsmsg_field_t *f;
+ const char *s;
TAILQ_INIT(list);
if (!l) return;
HTSMSG_FOREACH(f, l) {
pattern = calloc(1, sizeof(opentv_pattern_t));
- pattern->text = strdup(htsmsg_field_get_str(f));
+ s = htsmsg_field_get_str(f);
+ if (s == NULL) continue;
+ pattern->text = strdup(s);
if (regcomp(&pattern->compiled, pattern->text, REG_EXTENDED)) {
tvhlog(LOG_WARNING, "opentv", "error compiling pattern \"%s\"", pattern->text);
free(pattern->text);
HTSMSG_FOREACH(f, q) {
node = idnode_find(f->hmf_name, NULL, NULL);
event = htsmsg_field_get_str(f);
- m = htsmsg_create_map();
- htsmsg_add_str(m, "uuid", f->hmf_name);
- if (!node)
- htsmsg_add_u32(m, "removed", 1);
- notify_by_msg(event, m);
+ if (event) {
+ m = htsmsg_create_map();
+ htsmsg_add_str(m, "uuid", f->hmf_name);
+ if (!node)
+ htsmsg_add_u32(m, "removed", 1);
+ notify_by_msg(event, m);
+ }
}
/* Finished */
}
void mpegts_table_release_
(mpegts_table_t *mt);
-static inline void mpegts_table_release
+static inline int mpegts_table_release
(mpegts_table_t *mt)
{
int v = atomic_dec(&mt->mt_arefcount, 1);
if (v == 1) {
assert(mt->mt_destroyed == 1);
mpegts_table_release_(mt);
+ return 1;
}
+ return 0;
}
int mpegts_table_type
( mpegts_table_t *mt );
break;
case 0x81:
if (priv == 0) goto lcn;
+ break;
case 0x82:
if (priv == 0) goto lcn;
+ break;
case 0x83:
if (priv == 0 || priv == 0x28 || priv == 0x29 || priv == 0xa5 ||
priv == 0x233A) goto lcn;
+ break;
case 0x86:
if (priv == 0) goto lcn;
+ break;
case 0x88:
if (priv == 0x28) {
/* HD simulcast */
if (mt->mt_defer_cmd) {
TAILQ_REMOVE(&mm->mm_defer_tables, mt, mt_defer_link);
mt->mt_defer_cmd = 0;
- mpegts_table_release(mt);
+ if (mpegts_table_release(mt))
+ return;
}
mt->mt_subscribed = 0;
LIST_REMOVE(mt, mt_link);
}
mux = malloc(sizeof(dvb_mux_conf_t));
+ mux->dmc_fe_delsys = -1;
x = htsmsg_get_str(l, "DELIVERY_SYSTEM");
parse_aac(service_t *t, elementary_stream_t *st, const uint8_t *data,
int len, int start)
{
- int l, muxlen, p, hdr = 0;
+ int l, muxlen, p;
th_pkt_t *pkt;
int64_t olddts = PTS_UNSET, oldpts = PTS_UNSET;
- int64_t newdts = PTS_UNSET, newpts = PTS_UNSET;
if(st->es_parser_state == 0) {
if (start) {
oldpts = st->es_curpts;
hlen = parse_pes_header(t, st, data + 6, len - 6);
if (hlen >= 0 && st->es_buf.sb_ptr) {
- newdts = st->es_curdts;
- newpts = st->es_curpts;
st->es_curdts = olddts;
st->es_curpts = oldpts;
}
st->es_buf.sb_err = 0;
}
- if (hdr && newdts != PTS_UNSET) {
- st->es_curdts = newdts;
- st->es_curpts = newpts;
- }
p += muxlen + 3;
/* ADTS */
} else if(p == 0 && d[0] == 0xff && (d[1] & 0xf0) == 0xf0) {
sbuf_append(&st->es_buf_a, d, muxlen);
parse_mp4a_data(t, st, 1);
- if (hdr && newdts != PTS_UNSET) {
- st->es_curdts = newdts;
- st->es_curpts = newpts;
- }
p += muxlen;
/* Wrong bytestream */
}
}
- if (hdr && newdts != PTS_UNSET) {
- st->es_curdts = newdts;
- st->es_curpts = newpts;
- }
if (p > 0)
sbuf_cut(&st->es_buf, p);
}
int i, n, what = 0;
p = http_arg_get(&hc->hc_args, "Public");
+ if (p == NULL)
+ return -EIO;
n = http_tokenize(p, argv, 32, ',');
for (i = 1; i < n; i++) {
if (strcmp(argv[i], "DESCRIBE") == 0)
strncpy(buf, s, sizeof(buf));
buf[sizeof(buf)-1] = '\0';
p = strchr(buf, '/');
- while (*p) {
+ while (p && *p) {
*p = *(p+1);
p++;
}
satip_rtp_session_t *rtp;
int r = 0;
- if (buf)
- buf[0] = '\0';
+ buf[0] = '\0';
pthread_mutex_lock(&satip_rtp_lock);
rtp = satip_rtp_find(id);
if (rtp) {
htsbuf_queue_init(&q, 0);
arg = http_arg_get(&hc->hc_args, "Accept");
- if (strcmp(arg, "application/sdp"))
+ if (arg == NULL || strcmp(arg, "application/sdp"))
goto error;
if ((u = rtsp_check_urlbase(u)) == NULL)
pthread_mutex_lock(&rtsp_lock);
if (TAILQ_FIRST(&hc->hc_req_args)) {
- if (stream < 0)
+ if (stream < 0) {
+ pthread_mutex_unlock(&rtsp_lock);
goto error;
+ }
r = rtsp_parse_cmd(hc, stream, -1, &rs, &valid, &oldstate);
if (r) {
pthread_mutex_unlock(&rtsp_lock);
char *u = tvh_strdupa(hc->hc_url);
struct session *rs = NULL;
http_arg_list_t args;
- char addrbuf[50];
+ char addrbuf[50], session[16];
int stream;
tcp_get_ip_str((struct sockaddr*)hc->hc_peer, addrbuf, sizeof(addrbuf));
pthread_mutex_unlock(&rtsp_lock);
http_error(hc, !rs ? HTTP_STATUS_BAD_SESSION : HTTP_STATUS_NOT_FOUND);
} else {
+ strncpy(session, rs->session, sizeof(session));
+ session[sizeof(session)-1] = '\0';
rtsp_close_session(rs);
rtsp_free_session(rs);
pthread_mutex_unlock(&rtsp_lock);
http_arg_init(&args);
- http_arg_set(&args, "Session", rs->session);
+ http_arg_set(&args, "Session", session);
http_send_header(hc, HTTP_STATUS_OK, NULL, 0, NULL, NULL, 0, NULL, NULL, NULL);
http_arg_flush(&args);
}
tvhtrace("satips", "sending byebye");
- for (attempt = 1; attempt < 3; attempt++) {
+ for (attempt = 1; attempt <= 3; attempt++) {
switch (attempt) {
case 1:
nt = "upnp:rootdevice";
}
if (!argv) argv = (void *)local_argv;
- if (!argv[0]) argv[0] = (char*)prog;
+ if (!argv[0]) {
+ if (argv != (void *)local_argv) {
+ for (i = 1, e = argv; *e; i++, e++);
+ i = (i + 1) * sizeof(char *);
+ e = alloca(i);
+ memcpy(e, argv, i);
+ argv = e;
+ }
+ argv[0] = (char *)prog;
+ }
if (!envp || !envp[0]) {
e = environ;
if(s->ths_start_message != NULL) {
streaming_target_deliver(s->ths_output, s->ths_start_message);
s->ths_start_message = NULL;
- if (s->ths_service)
+ if (s->ths_service) {
+ pthread_mutex_lock(&s->ths_service->s_stream_mutex);
s->ths_service->s_running = 1;
+ pthread_mutex_unlock(&s->ths_service->s_stream_mutex);
+ }
}
s->ths_state = SUBSCRIPTION_GOT_SERVICE;
}
return UDP_FATAL_ERROR;
}
+ uc->fd = fd;
+
/* Bind to interface */
ifindex = udp_ifindex_required(uc) ? udp_get_ifindex(ifname) : 0;
if (ifindex < 0) {
tvhwarn(subsystem, "%s - cannot increase UDP tx buffer size [%s]",
name, strerror(errno));
- uc->fd = fd;
return uc;
error: