Changeset 3083
- Timestamp:
- 06/22/09 21:51:10 (9 months ago)
- Location:
- trunk/tvheadend/src
- Files:
-
- 6 modified
-
dvb/dvb_adapter.c (modified) (1 diff)
-
psi.c (modified) (8 diffs)
-
rawtsinput.c (modified) (1 diff)
-
transports.c (modified) (3 diffs)
-
transports.h (modified) (1 diff)
-
tvhead.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tvheadend/src/dvb/dvb_adapter.c
r3040 r3083 372 372 LIST_FOREACH(st_src, &t_src->tht_components, st_link) { 373 373 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); 377 377 378 378 st_dst->st_tb = (AVRational){1, 90000}; -
trunk/tvheadend/src/psi.c
r3077 r3083 93 93 94 94 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 } 99 100 } 100 101 ptr += 4; … … 165 166 166 167 168 /** 169 * Parser for CA descriptor 170 */ 171 static int 172 psi_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 } 167 190 168 191 /** 169 192 * PMT parser, from ISO 13818-1 and ETSI EN 300 468 170 193 */ 171 172 194 int 173 195 psi_parse_pmt(th_transport_t *t, uint8_t *ptr, int len, int chksvcid) … … 182 204 char lang[4]; 183 205 int frameduration; 206 int need_save = 0; 207 184 208 if(len < 9) 185 209 return -1; … … 191 215 dllen = (ptr[7] & 0xf) << 8 | ptr[8]; 192 216 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 } 194 224 195 225 ptr += 9; 196 226 len -= 9; 197 198 if(chksvcid && sid != t->tht_dvb_service_id)199 return -1;200 227 201 228 while(dllen > 1) { … … 209 236 switch(dtag) { 210 237 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); 213 239 break; 214 240 … … 263 289 switch(dtag) { 264 290 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); 267 292 break; 268 293 … … 297 322 298 323 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 300 330 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) { 304 338 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) 309 345 t->tht_config_change(t); 310 346 311 t->tht_pmt_seen = 1;312 347 return 0; 313 348 } … … 636 671 continue; 637 672 638 st = transport_ add_stream(t, pid, type);673 st = transport_stream_create(t, pid, type); 639 674 st->st_tb = (AVRational){1, 90000}; 640 675 -
trunk/tvheadend/src/rawtsinput.c
r3081 r3083 196 196 if(t != NULL) { 197 197 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 } 201 204 pthread_mutex_unlock(&t->tht_stream_mutex); 202 205 } -
trunk/tvheadend/src/transports.c
r3078 r3083 472 472 /** 473 473 * Add a new stream to a transport 474 *475 *476 474 */ 477 475 th_stream_t * 478 transport_ add_stream(th_transport_t *t, int pid,479 streaming_component_type_t type)476 transport_stream_create(th_transport_t *t, int pid, 477 streaming_component_type_t type) 480 478 { 481 479 th_stream_t *st; 482 480 int i = 0; 483 481 484 482 lock_assert(&t->tht_stream_mutex); 485 483 … … 491 489 492 490 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); 495 493 496 494 st = calloc(1, sizeof(th_stream_t)); … … 507 505 avgstat_init(&st->st_rate, 10); 508 506 avgstat_init(&st->st_cc_errors, 10); 507 509 508 return st; 510 509 } 510 511 512 513 /** 514 * Add a new stream to a transport 515 */ 516 th_stream_t * 517 transport_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 511 530 512 531 -
trunk/tvheadend/src/transports.h
r3026 r3083 43 43 th_transport_t *transport_find(channel_t *ch, unsigned int weight); 44 44 45 th_stream_t *transport_add_stream(th_transport_t *t, int pid, 46 streaming_component_type_t type); 45 th_stream_t *transport_stream_find(th_transport_t *t, int pid); 46 47 th_stream_t *transport_stream_create(th_transport_t *t, int pid, 48 streaming_component_type_t type); 47 49 48 50 void transport_set_priority(th_transport_t *t, int prio); -
trunk/tvheadend/src/tvhead.h
r3077 r3083 579 579 580 580 /** 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 */ 589 583 struct th_stream_list tht_components; 590 584