| 715 | | { |
|---|
| 716 | | char *psz = val.psz_string; |
|---|
| 717 | | int i_pid = strtol( psz, &psz, 0 ); |
|---|
| 718 | | |
|---|
| 719 | | if( i_pid >= 2 && i_pid < 8192 ) |
|---|
| 720 | | { |
|---|
| 721 | | ts_pid_t *pmt = &p_sys->pid[i_pid]; |
|---|
| 722 | | ts_prg_psi_t *prg; |
|---|
| 723 | | |
|---|
| 724 | | msg_Dbg( p_demux, "extra pmt specified (pid=%d)", i_pid ); |
|---|
| 725 | | PIDInit( pmt, true, NULL ); |
|---|
| 726 | | |
|---|
| 727 | | /* Dummy PMT */ |
|---|
| 728 | | prg = malloc( sizeof( ts_prg_psi_t ) ); |
|---|
| 729 | | if( !prg ) |
|---|
| 730 | | { |
|---|
| 731 | | Close( VLC_OBJECT(p_demux) ); |
|---|
| 732 | | return VLC_ENOMEM; |
|---|
| 733 | | } |
|---|
| 734 | | |
|---|
| 735 | | memset( prg, 0, sizeof( ts_prg_psi_t ) ); |
|---|
| 736 | | prg->i_pid_pcr = -1; |
|---|
| 737 | | prg->i_pid_pmt = -1; |
|---|
| 738 | | prg->i_number = 0; /* special */ |
|---|
| 739 | | prg->handle = dvbpsi_AttachPMT( 1, (dvbpsi_pmt_callback)PMTCallBack, p_demux ); |
|---|
| 740 | | TAB_APPEND( pmt->psi->i_prg, pmt->psi->prg, prg ); |
|---|
| 741 | | |
|---|
| 742 | | psz = strchr( psz, '=' ) + 1; /* can't failed */ |
|---|
| 743 | | while( psz && *psz ) |
|---|
| 744 | | { |
|---|
| 745 | | char *psz_next = strchr( psz, ',' ); |
|---|
| 746 | | int i_pid, i_stream_type; |
|---|
| 747 | | |
|---|
| 748 | | if( psz_next ) |
|---|
| 749 | | { |
|---|
| 750 | | *psz_next++ = '\0'; |
|---|
| 751 | | } |
|---|
| 752 | | |
|---|
| 753 | | i_pid = strtol( psz, &psz, 0 ); |
|---|
| 754 | | if( *psz == ':' ) |
|---|
| 755 | | { |
|---|
| 756 | | i_stream_type = strtol( psz + 1, &psz, 0 ); |
|---|
| 757 | | if( i_pid >= 2 && i_pid < 8192 && |
|---|
| 758 | | !p_sys->pid[i_pid].b_valid ) |
|---|
| 759 | | { |
|---|
| 760 | | ts_pid_t *pid = &p_sys->pid[i_pid]; |
|---|
| 761 | | |
|---|
| 762 | | PIDInit( pid, false, pmt->psi); |
|---|
| 763 | | if( pmt->psi->prg[0]->i_pid_pcr <= 0 ) |
|---|
| 764 | | { |
|---|
| 765 | | pmt->psi->prg[0]->i_pid_pcr = i_pid; |
|---|
| 766 | | } |
|---|
| 767 | | PIDFillFormat( pid, i_stream_type); |
|---|
| 768 | | if( pid->es->fmt.i_cat != UNKNOWN_ES ) |
|---|
| 769 | | { |
|---|
| 770 | | if( p_sys->b_es_id_pid ) |
|---|
| 771 | | { |
|---|
| 772 | | pid->es->fmt.i_id = i_pid; |
|---|
| 773 | | } |
|---|
| 774 | | msg_Dbg( p_demux, " * es pid=%d type=%d " |
|---|
| 775 | | "fcc=%4.4s", i_pid, i_stream_type, |
|---|
| 776 | | (char*)&pid->es->fmt.i_codec ); |
|---|
| 777 | | pid->es->id = es_out_Add( p_demux->out, |
|---|
| 778 | | &pid->es->fmt ); |
|---|
| 779 | | } |
|---|
| 780 | | } |
|---|
| 781 | | } |
|---|
| 782 | | psz = psz_next; |
|---|
| 783 | | } |
|---|
| 784 | | } |
|---|
| 785 | | } |
|---|
| | 717 | UserPmt( p_demux, val.psz_string ); |
|---|
| | 1382 | } |
|---|
| | 1383 | |
|---|
| | 1384 | /***************************************************************************** |
|---|
| | 1385 | * |
|---|
| | 1386 | *****************************************************************************/ |
|---|
| | 1387 | static int UserPmt( demux_t *p_demux, const char *psz_fmt ) |
|---|
| | 1388 | { |
|---|
| | 1389 | demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| | 1390 | char *psz_dup = strdup( psz_fmt ); |
|---|
| | 1391 | char *psz = psz_dup; |
|---|
| | 1392 | int i_pid; |
|---|
| | 1393 | |
|---|
| | 1394 | if( !psz_dup ) |
|---|
| | 1395 | return VLC_ENOMEM; |
|---|
| | 1396 | |
|---|
| | 1397 | i_pid = strtol( psz, &psz, 0 ); |
|---|
| | 1398 | if( i_pid < 2 || i_pid >= 8192 ) |
|---|
| | 1399 | goto error; |
|---|
| | 1400 | |
|---|
| | 1401 | ts_pid_t *pmt = &p_sys->pid[i_pid]; |
|---|
| | 1402 | ts_prg_psi_t *prg; |
|---|
| | 1403 | |
|---|
| | 1404 | msg_Dbg( p_demux, "extra pmt specified (pid=%d)", i_pid ); |
|---|
| | 1405 | PIDInit( pmt, true, NULL ); |
|---|
| | 1406 | |
|---|
| | 1407 | /* Dummy PMT */ |
|---|
| | 1408 | prg = malloc( sizeof( ts_prg_psi_t ) ); |
|---|
| | 1409 | if( !prg ) |
|---|
| | 1410 | goto error; |
|---|
| | 1411 | |
|---|
| | 1412 | memset( prg, 0, sizeof( ts_prg_psi_t ) ); |
|---|
| | 1413 | prg->i_pid_pcr = -1; |
|---|
| | 1414 | prg->i_pid_pmt = -1; |
|---|
| | 1415 | prg->i_number = 0; /* special */ |
|---|
| | 1416 | prg->handle = dvbpsi_AttachPMT( 1, (dvbpsi_pmt_callback)PMTCallBack, p_demux ); |
|---|
| | 1417 | TAB_APPEND( pmt->psi->i_prg, pmt->psi->prg, prg ); |
|---|
| | 1418 | |
|---|
| | 1419 | psz = strchr( psz, '=' ) + 1; /* can't failed */ |
|---|
| | 1420 | while( psz && *psz ) |
|---|
| | 1421 | { |
|---|
| | 1422 | char *psz_next = strchr( psz, ',' ); |
|---|
| | 1423 | int i_pid, i_stream_type; |
|---|
| | 1424 | |
|---|
| | 1425 | if( psz_next ) |
|---|
| | 1426 | { |
|---|
| | 1427 | *psz_next++ = '\0'; |
|---|
| | 1428 | } |
|---|
| | 1429 | |
|---|
| | 1430 | 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 | } |
|---|
| | 1459 | psz = psz_next; |
|---|
| | 1460 | } |
|---|
| | 1461 | |
|---|
| | 1462 | free( psz_dup ); |
|---|
| | 1463 | return VLC_SUCCESS; |
|---|
| | 1464 | |
|---|
| | 1465 | error: |
|---|
| | 1466 | free( psz_dup ); |
|---|
| | 1467 | return VLC_EGENERIC; |
|---|