Changeset d0dd8179b650055dcdf4b095c5690427a767fa2e
- Timestamp:
- 07/04/08 22:22:33 (2 months ago)
- git-parent:
- Files:
-
- modules/demux/ts.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/demux/ts.c
r1d5ae29 rd0dd817 99 99 static void Close ( vlc_object_t * ); 100 100 101 /* TODO 102 * - Rename "extra pmt" to "user pmt" 103 * - Update extra pmt description 104 * pmt_pid[:pmt_number]=pid_description[,pid_description] 105 * where pid_description could take 3 forms: 106 * 1. pid:pcr (to force the pcr pid) 107 * 2. pid:stream_type 108 * 3. pid:type:fourcc where type=(video|audio|spu) 109 */ 101 110 #define PMT_TEXT N_("Extra PMT") 102 111 #define PMT_LONGTEXT N_( \ … … 334 343 335 344 /* All PMT */ 345 bool b_user_pmt; 336 346 int i_pmt; 337 347 ts_pid_t **pmt; … … 390 400 static void IODFree( iod_descriptor_t * ); 391 401 402 #define TS_USER_PMT_NUMBER (0) 392 403 static int UserPmt( demux_t *p_demux, const char * ); 393 404 … … 714 725 var_Create( p_demux, "ts-extra-pmt", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); 715 726 var_Get( p_demux, "ts-extra-pmt", &val ); 716 if( val.psz_string && strchr( val.psz_string, '=' ) != NULL ) 727 p_sys->b_user_pmt = false; 728 if( val.psz_string && *val.psz_string ) 717 729 UserPmt( p_demux, val.psz_string ); 718 730 free( val.psz_string ); … … 1391 1403 char *psz = psz_dup; 1392 1404 int i_pid; 1405 int i_number; 1393 1406 1394 1407 if( !psz_dup ) 1395 1408 return VLC_ENOMEM; 1396 1409 1410 /* Parse PID */ 1397 1411 i_pid = strtol( psz, &psz, 0 ); 1398 1412 if( i_pid < 2 || i_pid >= 8192 ) 1399 1413 goto error; 1400 1414 1415 /* Parse optional program number */ 1416 i_number = 0; 1417 if( *psz == ':' ) 1418 i_number = strtol( &psz[1], &psz, 0 ); 1419 1420 /* */ 1401 1421 ts_pid_t *pmt = &p_sys->pid[i_pid]; 1402 1422 ts_prg_psi_t *prg; 1403 1423 1404 msg_Dbg( p_demux, " extra pmt specified (pid=%d)", i_pid);1424 msg_Dbg( p_demux, "user pmt specified (pid=%d,number=%d)", i_pid, i_number ); 1405 1425 PIDInit( pmt, true, NULL ); 1406 1426 … … 1413 1433 prg->i_pid_pcr = -1; 1414 1434 prg->i_pid_pmt = -1; 1415 prg->i_number = 0; /* special */ 1416 prg->handle = dvbpsi_AttachPMT( 1, (dvbpsi_pmt_callback)PMTCallBack, p_demux ); 1435 prg->i_version = -1; 1436 prg->i_number = i_number != 0 ? i_number : TS_USER_PMT_NUMBER; 1437 prg->handle = dvbpsi_AttachPMT( i_number != TS_USER_PMT_NUMBER ? i_number : 1, (dvbpsi_pmt_callback)PMTCallBack, p_demux ); 1417 1438 TAB_APPEND( pmt->psi->i_prg, pmt->psi->prg, prg ); 1418 1439 1419 psz = strchr( psz, '=' ) + 1; /* can't failed */ 1440 psz = strchr( psz, '=' ); 1441 if( psz ) 1442 psz++; 1420 1443 while( psz && *psz ) 1421 1444 { 1422 1445 char *psz_next = strchr( psz, ',' ); 1423 int i_pid , i_stream_type;1446 int i_pid; 1424 1447 1425 1448 if( psz_next ) 1426 {1427 1449 *psz_next++ = '\0'; 1428 }1429 1450 1430 1451 i_pid = strtol( psz, &psz, 0 ); 1431 if( *psz == ':' ) 1432 { 1433 i_stream_type = strtol( psz + 1, &psz, 0 ); 1434 if( i_pid >= 2 && i_pid < 8192 && 1435 !p_sys->pid[i_pid].b_valid ) 1436 { 1437 ts_pid_t *pid = &p_sys->pid[i_pid]; 1438 1439 PIDInit( pid, false, pmt->psi); 1440 if( pmt->psi->prg[0]->i_pid_pcr <= 0 ) 1441 { 1442 pmt->psi->prg[0]->i_pid_pcr = i_pid; 1443 } 1444 PIDFillFormat( pid, i_stream_type); 1445 if( pid->es->fmt.i_cat != UNKNOWN_ES ) 1446 { 1447 if( p_sys->b_es_id_pid ) 1448 { 1449 pid->es->fmt.i_id = i_pid; 1450 } 1451 msg_Dbg( p_demux, " * es pid=%d type=%d " 1452 "fcc=%4.4s", i_pid, i_stream_type, 1453 (char*)&pid->es->fmt.i_codec ); 1454 pid->es->id = es_out_Add( p_demux->out, 1455 &pid->es->fmt ); 1456 } 1457 } 1458 } 1452 if( *psz != ':' || i_pid < 2 || i_pid >= 8192 ) 1453 goto next; 1454 1455 char *psz_opt = &psz[1]; 1456 if( !strcmp( psz_opt, "pcr" ) ) 1457 { 1458 prg->i_pid_pcr = i_pid; 1459 } 1460 else if( !p_sys->pid[i_pid].b_valid ) 1461 { 1462 ts_pid_t *pid = &p_sys->pid[i_pid]; 1463 1464 char *psz_arg = strchr( psz_opt, '=' ); 1465 if( psz_arg ) 1466 *psz_arg++ = '\0'; 1467 1468 PIDInit( pid, false, pmt->psi); 1469 if( prg->i_pid_pcr <= 0 ) 1470 prg->i_pid_pcr = i_pid; 1471 1472 if( psz_arg && strlen( psz_arg ) == 4 ) 1473 { 1474 const vlc_fourcc_t i_codec = VLC_FOURCC( psz_arg[0], psz_arg[1], 1475 psz_arg[2], psz_arg[3] ); 1476 int i_cat = UNKNOWN_ES; 1477 es_format_t *fmt = &pid->es->fmt; 1478 1479 if( !strcmp( psz_opt, "video" ) ) 1480 i_cat = VIDEO_ES; 1481 else if( !strcmp( psz_opt, "audio" ) ) 1482 i_cat = AUDIO_ES; 1483 else if( !strcmp( psz_opt, "spu" ) ) 1484 i_cat = SPU_ES; 1485 1486 es_format_Init( fmt, i_cat, i_codec ); 1487 fmt->b_packetized = false; 1488 } 1489 else 1490 { 1491 const int i_stream_type = strtol( psz_opt, NULL, 0 ); 1492 PIDFillFormat( pid, i_stream_type ); 1493 } 1494 pid->es->fmt.i_group = i_number; 1495 if( p_sys->b_es_id_pid ) 1496 pid->es->fmt.i_id = i_pid; 1497 1498 if( pid->es->fmt.i_cat != UNKNOWN_ES ) 1499 { 1500 msg_Dbg( p_demux, " * es pid=%d fcc=%4.4s", i_pid, 1501 (char*)&pid->es->fmt.i_codec ); 1502 pid->es->id = es_out_Add( p_demux->out, 1503 &pid->es->fmt ); 1504 } 1505 } 1506 1507 next: 1459 1508 psz = psz_next; 1460 1509 } 1461 1510 1511 p_sys->b_user_pmt = true; 1512 TAB_APPEND( p_sys->i_pmt, p_sys->pmt, pmt ); 1462 1513 free( psz_dup ); 1463 1514 return VLC_SUCCESS; … … 2978 3029 for( i_prg = 0; i_prg < p_sys->pmt[i]->psi->i_prg; i_prg++ ) 2979 3030 { 2980 if( p_sys->pmt[i]->psi->prg[i_prg]->i_number ==2981 p_pmt->i_program_number )3031 const int i_pmt_number = p_sys->pmt[i]->psi->prg[i_prg]->i_number; 3032 if( i_pmt_number != TS_USER_PMT_NUMBER && i_pmt_number == p_pmt->i_program_number ) 2982 3033 { 2983 3034 pmt = p_sys->pmt[i]; … … 3852 3903 msg_Dbg( p_demux, "PATCallBack called" ); 3853 3904 3854 if( pat->psi->i_pat_version != -1 && 3855 ( !p_pat->b_current_next || 3856 p_pat->i_version == pat->psi->i_pat_version ) ) 3905 if( ( pat->psi->i_pat_version != -1 && 3906 ( !p_pat->b_current_next || 3907 p_pat->i_version == pat->psi->i_pat_version ) ) || 3908 p_sys->b_user_pmt ) 3857 3909 { 3858 3910 dvbpsi_DeletePAT( p_pat ); … … 3947 3999 { 3948 4000 const int i_number = pmt_rm[i]->psi->prg[i_prg]->i_number; 3949 if( i_number != 0 ) 3950 es_out_Control( p_demux->out, ES_OUT_DEL_GROUP, i_number ); 4001 es_out_Control( p_demux->out, ES_OUT_DEL_GROUP, i_number ); 3951 4002 } 3952 4003
