Changeset d0dd8179b650055dcdf4b095c5690427a767fa2e

Show
Ignore:
Timestamp:
07/04/08 22:22:33 (2 months ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1215202953 +0000
git-parent:

[1d5ae295cd462d70d24cfad65b38638a1bb9407c]

git-author:
Laurent Aimar <fenrir@videolan.org> 1215202926 +0000
Message:

Fixed and improved ts-extra-pmt option (close #1592).
If you specify and extra pmt, the parsing of the PAT will be disabled
(unlike previous behaviour).
You can now just specify the pid and number of your program and it will
automatically be used.
You can specify es by type (video, audio, spu) and fourcc instead of
stream type.
You can specify the pcr pid.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/demux/ts.c

    r1d5ae29 rd0dd817  
    9999static void Close ( vlc_object_t * ); 
    100100 
     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 */ 
    101110#define PMT_TEXT N_("Extra PMT") 
    102111#define PMT_LONGTEXT N_( \ 
     
    334343 
    335344    /* All PMT */ 
     345    bool        b_user_pmt; 
    336346    int         i_pmt; 
    337347    ts_pid_t    **pmt; 
     
    390400static void              IODFree( iod_descriptor_t * ); 
    391401 
     402#define TS_USER_PMT_NUMBER (0) 
    392403static int UserPmt( demux_t *p_demux, const char * ); 
    393404 
     
    714725    var_Create( p_demux, "ts-extra-pmt", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); 
    715726    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 ) 
    717729        UserPmt( p_demux, val.psz_string ); 
    718730    free( val.psz_string ); 
     
    13911403    char *psz = psz_dup; 
    13921404    int  i_pid; 
     1405    int  i_number; 
    13931406 
    13941407    if( !psz_dup ) 
    13951408        return VLC_ENOMEM; 
    13961409 
     1410    /* Parse PID */ 
    13971411    i_pid = strtol( psz, &psz, 0 ); 
    13981412    if( i_pid < 2 || i_pid >= 8192 ) 
    13991413        goto error; 
    14001414 
     1415    /* Parse optional program number */ 
     1416    i_number = 0; 
     1417    if( *psz == ':' ) 
     1418        i_number = strtol( &psz[1], &psz, 0 ); 
     1419 
     1420    /* */ 
    14011421    ts_pid_t *pmt = &p_sys->pid[i_pid]; 
    14021422    ts_prg_psi_t *prg; 
    14031423 
    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 ); 
    14051425    PIDInit( pmt, true, NULL ); 
    14061426 
     
    14131433    prg->i_pid_pcr  = -1; 
    14141434    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 ); 
    14171438    TAB_APPEND( pmt->psi->i_prg, pmt->psi->prg, prg ); 
    14181439 
    1419     psz = strchr( psz, '=' ) + 1;   /* can't failed */ 
     1440    psz = strchr( psz, '=' ); 
     1441    if( psz ) 
     1442        psz++; 
    14201443    while( psz && *psz ) 
    14211444    { 
    14221445        char *psz_next = strchr( psz, ',' ); 
    1423         int i_pid, i_stream_type
     1446        int i_pid
    14241447 
    14251448        if( psz_next ) 
    1426         { 
    14271449            *psz_next++ = '\0'; 
    1428         } 
    14291450 
    14301451        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: 
    14591508        psz = psz_next; 
    14601509    } 
    14611510 
     1511    p_sys->b_user_pmt = true; 
     1512    TAB_APPEND( p_sys->i_pmt, p_sys->pmt, pmt ); 
    14621513    free( psz_dup ); 
    14631514    return VLC_SUCCESS; 
     
    29783029        for( i_prg = 0; i_prg < p_sys->pmt[i]->psi->i_prg; i_prg++ ) 
    29793030        { 
    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 ) 
    29823033            { 
    29833034                pmt = p_sys->pmt[i]; 
     
    38523903    msg_Dbg( p_demux, "PATCallBack called" ); 
    38533904 
    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 ) 
    38573909    { 
    38583910        dvbpsi_DeletePAT( p_pat ); 
     
    39473999            { 
    39484000                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 ); 
    39514002            } 
    39524003