static void htsp_subscription_destroy(htsp_connection_t *htsp, htsp_subscription_t *hs) { LIST_REMOVE(hs, hs_link); subscription_unsubscribe(hs->hs_s); htsp_flush_queue(htsp, &hs->hs_q); free(hs); }
void mware_unsubscribe(struct identifier *i) { struct subscription_item *si; si = subscription_get(i); if (si != NULL) { subscription_unsubscribe(si); } }
void packet_received(struct broadcast_conn *connection, const rimeaddr_t *from) { struct subscription_item *si; switch(packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE)) { case MWARE_MSG_SUB: si = subscription_get(&(packetbuf_msg_sub())->id); if (si != NULL) { if (subscription_is_unsubscribed(si)) { subscription_reset_last_shout(si); } else { if (!subscription_update(si, from, (packetbuf_msg_sub())->sub.hops + 1)) { si = NULL; } } } else if (!subscription_is_too_far(&(packetbuf_msg_sub())->sub)) { const rimeaddr_t * parent; parent = (identifier_is_mine(&(packetbuf_msg_sub())->id) ? &rimeaddr_null : from); si = subscription_insert( &(packetbuf_msg_sub())->id, &(packetbuf_msg_sub())->sub, parent, (packetbuf_msg_sub())->sub.hops + 1); } if (si != NULL) { subscription_print(si, "rs"); subscription_sync_epoch(si, &(packetbuf_msg_sub())->sub); wind_item_timer(si, subscription_desync_jitter(si, &(packetbuf_msg_sub())->sub)); } break; case MWARE_MSG_PUB: si = subscription_get(&(packetbuf_msg_pub())->id); if (si == NULL || subscription_is_unsubscribed(si)) { break; } if (rimeaddr_cmp(&si->next_hop, from)) { subscription_update_last_heard(si); } else if (message_is_published_to_me()) { subscription_data_input(si, (packetbuf_msg_pub())->data, (packetbuf_msg_pub())->node_count); } break; case MWARE_MSG_UNSUB: si = subscription_get(&(packetbuf_msg_unsub())->id); if (si == NULL) { break; } subscription_print(si, "ru"); subscription_unsubscribe(si); break; } packetbuf_clear(); }
void dvr_rec_unsubscribe(dvr_entry_t *de, int stopcode) { assert(de->de_s != NULL); subscription_unsubscribe(de->de_s); streaming_target_deliver(&de->de_sq.sq_st, streaming_msg_create(SMT_EXIT)); pthread_join(de->de_thread, NULL); de->de_s = NULL; if(de->de_tsfix) tsfix_destroy(de->de_tsfix); if(de->de_gh) globalheaders_destroy(de->de_gh); de->de_last_error = stopcode; }
void dvr_rec_unsubscribe(dvr_entry_t *de, int stopcode) { profile_chain_t *prch = de->de_chain; assert(de->de_s != NULL); assert(prch != NULL); streaming_target_deliver(prch->prch_st, streaming_msg_create(SMT_EXIT)); pthread_join(de->de_thread, NULL); subscription_unsubscribe(de->de_s); de->de_s = NULL; de->de_chain = NULL; profile_chain_close(prch); free(prch); de->de_last_error = stopcode; }
void dvr_rec_unsubscribe(dvr_entry_t *de, int stopcode) { dvr_config_t *cfg = dvr_config_find_by_name_default(de->de_config_name); assert(de->de_s != NULL); subscription_unsubscribe(de->de_s); streaming_target_deliver(&de->de_sq.sq_st, streaming_msg_create(SMT_EXIT)); pthread_join(de->de_thread, NULL); de->de_s = NULL; if(strcmp(cfg->dvr_format, "matroska") == 0) { tsfix_destroy(de->de_tsfix); globalheaders_destroy(de->de_gh); // } else if { (Other containers) // mpegts works like rawts } de->de_last_error = stopcode; }
static void * serviceprobe_thread(void *aux) { service_t *t; th_subscription_t *s; int was_doing_work = 0; streaming_queue_t sq; streaming_message_t *sm; // transport_feed_status_t status; int run; const char *err; channel_t *ch; uint32_t checksubscr; pthread_mutex_lock(&global_lock); streaming_queue_init(&sq, 0); err = NULL; while(1) { while((t = TAILQ_FIRST(&serviceprobe_queue)) == NULL) { if(was_doing_work) { tvhlog(LOG_INFO, "serviceprobe", "Now idle"); was_doing_work = 0; } pthread_cond_wait(&serviceprobe_cond, &global_lock); } if(!was_doing_work) { tvhlog(LOG_INFO, "serviceprobe", "Starting"); was_doing_work = 1; } if (t->s_dvb_mux_instance) checksubscr = !t->s_dvb_mux_instance->tdmi_adapter->tda_skip_checksubscr; else checksubscr = 1; if (checksubscr) { tvhlog(LOG_INFO, "serviceprobe", "%20s: checking...", t->s_svcname); s = subscription_create_from_service(t, "serviceprobe", &sq.sq_st, 0, NULL, NULL, "serviceprobe"); if(s == NULL) { t->s_sp_onqueue = 0; TAILQ_REMOVE(&serviceprobe_queue, t, s_sp_link); tvhlog(LOG_INFO, "serviceprobe", "%20s: could not subscribe", t->s_svcname); continue; } } service_ref(t); pthread_mutex_unlock(&global_lock); if (checksubscr) { run = 1; pthread_mutex_lock(&sq.sq_mutex); while(run) { while((sm = TAILQ_FIRST(&sq.sq_queue)) == NULL) pthread_cond_wait(&sq.sq_cond, &sq.sq_mutex); TAILQ_REMOVE(&sq.sq_queue, sm, sm_link); pthread_mutex_unlock(&sq.sq_mutex); if(sm->sm_type == SMT_SERVICE_STATUS) { int status = sm->sm_code; if(status & TSS_PACKETS) { run = 0; err = NULL; } else if(status & (TSS_GRACEPERIOD | TSS_ERRORS)) { run = 0; err = service_tss2text(status); } } streaming_msg_free(sm); pthread_mutex_lock(&sq.sq_mutex); } streaming_queue_clear(&sq.sq_queue); pthread_mutex_unlock(&sq.sq_mutex); } else { err = NULL; } pthread_mutex_lock(&global_lock); if (checksubscr) { subscription_unsubscribe(s); } if(t->s_status != SERVICE_ZOMBIE) { if(err != NULL) { tvhlog(LOG_INFO, "serviceprobe", "%20s: skipped: %s", t->s_svcname, err); } else if(t->s_ch == NULL) { int channum = t->s_channel_number; const char *str; if (!channum && t->s_dvb_mux_instance->tdmi_adapter->tda_sidtochan) channum = t->s_dvb_service_id; ch = channel_find_by_name(t->s_svcname, 1, channum); service_map_channel(t, ch, 1); tvhlog(LOG_INFO, "serviceprobe", "%20s: mapped to channel \"%s\"", t->s_svcname, t->s_svcname); if(service_is_tv(t)) { channel_tag_map(ch, channel_tag_find_by_name("TV channels", 1), 1); tvhlog(LOG_INFO, "serviceprobe", "%20s: joined tag \"%s\"", t->s_svcname, "TV channels"); } switch(t->s_servicetype) { case ST_SDTV: case ST_AC_SDTV: case ST_EX_SDTV: case ST_DN_SDTV: case ST_SK_SDTV: case ST_NE_SDTV: str = "SDTV"; break; case ST_HDTV: case ST_AC_HDTV: case ST_EX_HDTV: case ST_EP_HDTV: case ST_ET_HDTV: case ST_DN_HDTV: str = "HDTV"; break; case ST_RADIO: str = "Radio"; break; default: str = NULL; } if(str != NULL) { channel_tag_map(ch, channel_tag_find_by_name(str, 1), 1); tvhlog(LOG_INFO, "serviceprobe", "%20s: joined tag \"%s\"", t->s_svcname, str); } if(t->s_provider != NULL) { channel_tag_map(ch, channel_tag_find_by_name(t->s_provider, 1), 1); tvhlog(LOG_INFO, "serviceprobe", "%20s: joined tag \"%s\"", t->s_svcname, t->s_provider); } channel_save(ch); } t->s_sp_onqueue = 0; TAILQ_REMOVE(&serviceprobe_queue, t, s_sp_link); } service_unref(t); } return NULL; }