Changeset 3083

Show
Ignore:
Timestamp:
06/22/09 21:51:10 (9 months ago)
Author:
andoma
Message:

Figure out if we need to re-save a transport configuration instead of relying on if we've seen it once, it can not change

Location:
trunk/tvheadend/src
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/tvheadend/src/dvb/dvb_adapter.c

    r3040 r3083  
    372372      LIST_FOREACH(st_src, &t_src->tht_components, st_link) { 
    373373 
    374         st_dst = transport_add_stream(t_dst,  
    375                                       st_src->st_pid, 
    376                                       st_src->st_type); 
     374        st_dst = transport_stream_create(t_dst,  
     375                                        st_src->st_pid, 
     376                                        st_src->st_type); 
    377377         
    378378        st_dst->st_tb = (AVRational){1, 90000}; 
  • trunk/tvheadend/src/psi.c

    r3077 r3083  
    9393 
    9494    if(prognum != 0) { 
    95       st = transport_add_stream(t, pid, SCT_PMT); 
    96       st->st_section_docrc = 1; 
    97       st->st_got_section = pmt_callback; 
    98  
     95      if(transport_stream_find(t, pid) == NULL) { 
     96        st = transport_stream_create(t, pid, SCT_PMT); 
     97        st->st_section_docrc = 1; 
     98        st->st_got_section = pmt_callback; 
     99      } 
    99100    } 
    100101    ptr += 4; 
     
    165166 
    166167 
     168/** 
     169 * Parser for CA descriptor 
     170 */ 
     171static int 
     172psi_desc_ca(th_transport_t *t, uint8_t *ptr) 
     173{ 
     174  uint16_t pid = (ptr[2] & 0x1f) << 8 | ptr[3]; 
     175  th_stream_t *st; 
     176  int r = 0; 
     177  uint16_t caid = (ptr[0] << 8) | ptr[1]; 
     178 
     179  if((st = transport_stream_find(t, pid)) == NULL) { 
     180    st = transport_stream_create(t, pid, SCT_CA); 
     181    r = 1; 
     182  } 
     183 
     184  if(st->st_caid != caid) { 
     185    st->st_caid = caid; 
     186    r = 1; 
     187  } 
     188  return r; 
     189} 
    167190 
    168191/**  
    169192 * PMT parser, from ISO 13818-1 and ETSI EN 300 468 
    170193 */ 
    171  
    172194int 
    173195psi_parse_pmt(th_transport_t *t, uint8_t *ptr, int len, int chksvcid) 
     
    182204  char lang[4]; 
    183205  int frameduration; 
     206  int need_save = 0; 
     207 
    184208  if(len < 9) 
    185209    return -1; 
     
    191215  dllen   = (ptr[7] & 0xf) << 8 | ptr[8]; 
    192216   
    193   t->tht_pcr_pid = pcr_pid; 
     217  if(chksvcid && sid != t->tht_dvb_service_id) 
     218    return -1; 
     219 
     220  if(t->tht_pcr_pid != pcr_pid) { 
     221    t->tht_pcr_pid = pcr_pid; 
     222    need_save = 1; 
     223  } 
    194224 
    195225  ptr += 9; 
    196226  len -= 9; 
    197  
    198   if(chksvcid && sid != t->tht_dvb_service_id) 
    199     return -1; 
    200227 
    201228  while(dllen > 1) { 
     
    209236    switch(dtag) { 
    210237    case DVB_DESC_CA: 
    211       st = transport_add_stream(t, (ptr[2] & 0x1f) << 8 | ptr[3], SCT_CA); 
    212       st->st_caid = (ptr[0] << 8) | ptr[1]; 
     238      need_save |= psi_desc_ca(t, ptr); 
    213239      break; 
    214240 
     
    263289      switch(dtag) { 
    264290      case DVB_DESC_CA: 
    265         st = transport_add_stream(t, (ptr[2] & 0x1f) << 8 | ptr[3], SCT_CA); 
    266         st->st_caid = (ptr[0] << 8) | ptr[1]; 
     291        need_save |= psi_desc_ca(t, ptr); 
    267292        break; 
    268293 
     
    297322 
    298323    if(hts_stream_type != 0) { 
    299       st = transport_add_stream(t, pid, hts_stream_type); 
     324 
     325      if((st = transport_stream_find(t, pid)) == NULL) { 
     326        need_save = 1; 
     327        st = transport_stream_create(t, pid, hts_stream_type); 
     328      } 
     329 
    300330      st->st_tb = (AVRational){1, 90000}; 
    301       memcpy(st->st_lang, lang, 4); 
    302  
    303       if(st->st_frame_duration == 0) 
     331 
     332      if(memcmp(st->st_lang, lang, 4)) { 
     333        need_save = 1; 
     334        memcpy(st->st_lang, lang, 4); 
     335      } 
     336 
     337      if(st->st_frame_duration == 0 && frameduration != 0) { 
    304338        st->st_frame_duration = frameduration; 
    305     } 
    306   } 
    307  
    308   if(t->tht_pmt_seen == 0) 
     339        need_save = 1; 
     340      } 
     341    } 
     342  } 
     343 
     344  if(need_save) 
    309345    t->tht_config_change(t); 
    310346 
    311   t->tht_pmt_seen = 1; 
    312347  return 0; 
    313348} 
     
    636671      continue; 
    637672 
    638     st = transport_add_stream(t, pid, type); 
     673    st = transport_stream_create(t, pid, type); 
    639674    st->st_tb = (AVRational){1, 90000}; 
    640675     
  • trunk/tvheadend/src/rawtsinput.c

    r3081 r3083  
    196196      if(t != NULL) { 
    197197        pthread_mutex_lock(&t->tht_stream_mutex); 
    198         st = transport_add_stream(t, pid, SCT_PMT); 
    199         st->st_section_docrc = 1; 
    200         st->st_got_section = got_pmt; 
     198 
     199        if(transport_stream_find(t, pid) == NULL) { 
     200          st = transport_stream_create(t, pid, SCT_PMT); 
     201          st->st_section_docrc = 1; 
     202          st->st_got_section = got_pmt; 
     203        } 
    201204        pthread_mutex_unlock(&t->tht_stream_mutex); 
    202205      } 
  • trunk/tvheadend/src/transports.c

    r3078 r3083  
    472472/** 
    473473 * Add a new stream to a transport 
    474  * 
    475  *  
    476474 */ 
    477475th_stream_t * 
    478 transport_add_stream(th_transport_t *t, int pid, 
    479                      streaming_component_type_t type) 
     476transport_stream_create(th_transport_t *t, int pid, 
     477                        streaming_component_type_t type) 
    480478{ 
    481479  th_stream_t *st; 
    482480  int i = 0; 
    483  
     481  
    484482  lock_assert(&t->tht_stream_mutex); 
    485483 
     
    491489 
    492490  if(t->tht_flags & THT_DEBUG) 
    493       tvhlog(LOG_DEBUG, "transport", "%s: Add stream \"%s\", pid: %d", 
    494              t->tht_identifier, streaming_component_type2txt(type), pid); 
     491    tvhlog(LOG_DEBUG, "transport", "%s: Add stream \"%s\", pid: %d", 
     492           t->tht_identifier, streaming_component_type2txt(type), pid); 
    495493 
    496494  st = calloc(1, sizeof(th_stream_t)); 
     
    507505  avgstat_init(&st->st_rate, 10); 
    508506  avgstat_init(&st->st_cc_errors, 10); 
     507 
    509508  return st; 
    510509} 
     510 
     511 
     512 
     513/** 
     514 * Add a new stream to a transport 
     515 */ 
     516th_stream_t * 
     517transport_stream_find(th_transport_t *t, int pid) 
     518{ 
     519  th_stream_t *st; 
     520  
     521  lock_assert(&t->tht_stream_mutex); 
     522 
     523  LIST_FOREACH(st, &t->tht_components, st_link) { 
     524    if(st->st_pid == pid) 
     525      return st; 
     526  } 
     527  return NULL; 
     528} 
     529 
    511530 
    512531 
  • trunk/tvheadend/src/transports.h

    r3026 r3083  
    4343th_transport_t *transport_find(channel_t *ch, unsigned int weight); 
    4444 
    45 th_stream_t *transport_add_stream(th_transport_t *t, int pid, 
    46                                   streaming_component_type_t type); 
     45th_stream_t *transport_stream_find(th_transport_t *t, int pid); 
     46 
     47th_stream_t *transport_stream_create(th_transport_t *t, int pid, 
     48                                     streaming_component_type_t type); 
    4749 
    4850void transport_set_priority(th_transport_t *t, int prio); 
  • trunk/tvheadend/src/tvhead.h

    r3077 r3083  
    579579 
    580580  /** 
    581    * Set if we've seen the PMT. Used to avoid (re)saving the transport 
    582    * for everytime we see a PMT.  
    583    * XXX: Not very good, should be replaced with more intelligent 
    584    * code in psi.c 
    585    */ 
    586   int tht_pmt_seen; 
    587  
    588  
     581   * List of all components. 
     582   */ 
    589583  struct th_stream_list tht_components; 
    590584