Changeset 46e872e431f01dcdd98c018553574fbee8a7ca8b

Show
Ignore:
Timestamp:
27/11/03 05:11:40 (5 years ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1069906300 +0000
git-parent:

[fc1221c11bfd3b4b3c66f823d9fbf43c475e35a3]

git-author:
Laurent Aimar <fenrir@videolan.org> 1069906300 +0000
Message:
  • all: implement more es_out_* control, audio-channel and spu-channel are
    implemented.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/ninput.h

    r231d047 r46e872e  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2001 VideoLAN 
    5  * $Id: ninput.h,v 1.18 2003/11/21 00:38:01 gbazin Exp $ 
     5 * $Id: ninput.h,v 1.19 2003/11/27 04:11:40 fenrir Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    2727#include "vlc_es.h" 
    2828 
     29enum es_out_mode_e 
     30{ 
     31    ES_OUT_MODE_NONE,   /* don't select anything */ 
     32    ES_OUT_MODE_ALL,    /* eg for stream output */ 
     33    ES_OUT_MODE_AUTO    /* best audio/video or for input follow audio-channel, spu-channel */ 
     34}; 
     35 
    2936enum es_out_query_e 
    3037{ 
    31     ES_OUT_SET_SELECT,  /* arg1= es_out_id_t* arg2=vlc_bool_t   */ 
    32     ES_OUT_GET_SELECT   /* arg1= es_out_id_t* arg2=vlc_bool_t*  */ 
     38    /* activate apply of mode */ 
     39    ES_OUT_SET_ACTIVE,  /* arg1= vlc_bool_t                     */ 
     40    /* see if mode is currently aplied or not */ 
     41    ES_OUT_GET_ACTIVE,  /* arg1= vlc_bool_t*                    */ 
     42 
     43    /* set/get mode */ 
     44    ES_OUT_SET_MODE,    /* arg1= int                            */ 
     45    ES_OUT_GET_MODE,    /* arg2= int*                           */ 
     46 
     47    /* set es selected for the es category(audio/video/spu) */ 
     48    ES_OUT_SET_ES,      /* arg1= es_out_id_t*                   */ 
     49 
     50    /* force selection/unselection of the ES (bypass current mode)*/ 
     51    ES_OUT_SET_ES_STATE,/* arg1= es_out_id_t* arg2=vlc_bool_t   */ 
     52    ES_OUT_GET_ES_STATE,/* arg1= es_out_id_t* arg2=vlc_bool_t*  */ 
    3353}; 
    3454 
     
    3757    es_out_id_t *(*pf_add)    ( es_out_t *, es_format_t * ); 
    3858    int          (*pf_send)   ( es_out_t *, es_out_id_t *, block_t * ); 
    39     int          (*pf_send_pes)( es_out_t *, es_out_id_t *, pes_packet_t * ); 
    4059    void         (*pf_del)    ( es_out_t *, es_out_id_t * ); 
    4160    int          (*pf_control)( es_out_t *, int i_query, va_list ); 
     
    5372} 
    5473static inline int es_out_Send( es_out_t *out, es_out_id_t *id, 
    55                   block_t *p_block ) 
     74                               block_t *p_block ) 
    5675{ 
    5776    return out->pf_send( out, id, p_block ); 
    5877} 
    59 static inline int es_out_SendPES( es_out_t *out, es_out_id_t *id, 
    60                                   pes_packet_t *p_pes ) 
    61 
    62     return out->pf_send_pes( out, id, p_pes ); 
    63 
     78 
    6479static inline int es_out_vaControl( es_out_t *out, int i_query, va_list args ) 
    6580{ 
  • modules/demux/avi/avi.c

    r380edba r46e872e  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: avi.c,v 1.77 2003/11/26 08:18:09 gbazin Exp $ 
     5 * $Id: avi.c,v 1.78 2003/11/27 04:11:40 fenrir Exp $ 
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    77 * 
     
    470470        vlc_bool_t  b; 
    471471 
    472         es_out_Control( p_input->p_es_out, ES_OUT_GET_SELECT, tk->p_es, &b ); 
     472        es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE, tk->p_es, &b ); 
    473473        if( b && !tk->b_activated ) 
    474474        { 
     
    795795        vlc_bool_t  b; 
    796796 
    797         es_out_Control( p_input->p_es_out, ES_OUT_GET_SELECT, tk->p_es, &b ); 
     797        es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE, tk->p_es, &b ); 
    798798 
    799799        if( b && tk->i_cat == VIDEO_ES ) 
  • modules/demux/mkv.cpp

    r9c37455 r46e872e  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: mkv.cpp,v 1.44 2003/11/23 13:15:27 gbazin Exp $ 
     5 * $Id: mkv.cpp,v 1.45 2003/11/27 04:11:40 fenrir Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    14021402    } 
    14031403 
    1404     es_out_Control( p_input->p_es_out, ES_OUT_GET_SELECT, tk.p_es, &b ); 
     1404    es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE, tk.p_es, &b ); 
    14051405    if( !b ) 
    14061406    { 
  • modules/demux/ogg.c

    r380edba r46e872e  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001-2003 VideoLAN 
    5  * $Id: ogg.c,v 1.47 2003/11/26 08:18:09 gbazin Exp $ 
     5 * $Id: ogg.c,v 1.48 2003/11/27 04:11:40 fenrir Exp $ 
    66 * 
    77 * Authors: Gildas Bazin <gbazin@netcourrier.com> 
     
    360360 
    361361    /* Check the ES is selected */ 
    362     es_out_Control( p_input->p_es_out, ES_OUT_GET_SELECT
     362    es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE
    363363                    p_stream->p_es, &b_selected ); 
    364364 
  • modules/demux/rawdv.c

    r3106fa7 r46e872e  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: rawdv.c,v 1.12 2003/11/24 19:19:02 fenrir Exp $ 
     5 * $Id: rawdv.c,v 1.13 2003/11/27 04:11:40 fenrir Exp $ 
    66 * 
    77 * Authors: Gildas Bazin <gbazin@netcourrier.com> 
     
    298298    } 
    299299 
    300     es_out_Control( p_input->p_es_out, ES_OUT_GET_SELECT
     300    es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE
    301301                    p_sys->p_es_audio, &b_audio ); 
    302     es_out_Control( p_input->p_es_out, ES_OUT_GET_SELECT
     302    es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE
    303303                    p_sys->p_es_video, &b_video ); 
    304304 
  • modules/demux/util/sub.c

    r231d047 r46e872e  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2003 VideoLAN 
    5  * $Id: sub.c,v 1.38 2003/11/21 00:38:01 gbazin Exp $ 
     5 * $Id: sub.c,v 1.39 2003/11/27 04:11:40 fenrir Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    503503    vlc_bool_t     b; 
    504504 
    505     es_out_Control( p_input->p_es_out, ES_OUT_GET_SELECT, p_sub->p_es, &b ); 
     505    es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE, p_sub->p_es, &b ); 
    506506    if( b && !p_sub->i_previously_selected ) 
    507507    { 
  • src/input/es_out.c

    r3adaad5 r46e872e  
    33 ***************************************************************************** 
    44 * Copyright (C) 2003 VideoLAN 
    5  * $Id: es_out.c,v 1.1 2003/11/24 20:50:45 fenrir Exp $ 
     5 * $Id: es_out.c,v 1.2 2003/11/27 04:11:40 fenrir Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    3636 * Local prototypes 
    3737 *****************************************************************************/ 
    38 struct es_out_sys_t 
    39 { 
    40     input_thread_t *p_input; 
    41  
    42     int         i_id; 
    43     es_out_id_t **id; 
    44  
    45     vlc_bool_t  i_audio; 
    46     vlc_bool_t  i_video; 
    47 }; 
    48  
    4938struct es_out_id_t 
    5039{ 
     40    int             i_channel; 
    5141    es_descriptor_t *p_es; 
    5242}; 
    5343 
     44struct es_out_sys_t 
     45{ 
     46    input_thread_t *p_input; 
     47 
     48    /* all es */ 
     49    int         i_id; 
     50 
     51    int         i_es; 
     52    es_out_id_t **es; 
     53 
     54    /* mode gestion */ 
     55    vlc_bool_t  b_active; 
     56    int         i_mode; 
     57 
     58    /* es count */ 
     59    int         i_audio; 
     60    int         i_video; 
     61    int         i_sub; 
     62 
     63    /* es to select */ 
     64    int         i_audio_last; 
     65    int         i_sub_last; 
     66 
     67    /* current main es */ 
     68    es_out_id_t *p_es_audio; 
     69    es_out_id_t *p_es_video; 
     70    es_out_id_t *p_es_sub; 
     71}; 
     72 
    5473static es_out_id_t *EsOutAdd    ( es_out_t *, es_format_t * ); 
    5574static int          EsOutSend   ( es_out_t *, es_out_id_t *, block_t * ); 
    56 static int          EsOutSendPES( es_out_t *, es_out_id_t *, pes_packet_t * ); 
    5775static void         EsOutDel    ( es_out_t *, es_out_id_t * ); 
    5876static int          EsOutControl( es_out_t *, int i_query, va_list ); 
     
    6482es_out_t *input_EsOutNew( input_thread_t *p_input ) 
    6583{ 
    66     es_out_t *out = malloc( sizeof( es_out_t ) ); 
     84    es_out_t     *out = malloc( sizeof( es_out_t ) ); 
     85    es_out_sys_t *p_sys = malloc( sizeof( es_out_sys_t ) ); 
     86    vlc_value_t  val; 
    6787 
    6888    out->pf_add     = EsOutAdd; 
    6989    out->pf_send    = EsOutSend; 
    70     out->pf_send_pes= EsOutSendPES; 
    7190    out->pf_del     = EsOutDel; 
    7291    out->pf_control = EsOutControl; 
    73  
    74     out->p_sys = malloc( sizeof( es_out_sys_t ) ); 
    75     out->p_sys->p_input = p_input; 
    76     out->p_sys->i_id    = 0; 
    77     out->p_sys->id      = NULL; 
    78     out->p_sys->i_audio = -1; 
    79     out->p_sys->i_video = -1; 
     92    out->p_sys      = p_sys; 
     93 
     94    p_sys->p_input = p_input; 
     95 
     96    p_sys->b_active = VLC_FALSE; 
     97    p_sys->i_mode   = ES_OUT_MODE_AUTO; 
     98 
     99    p_sys->i_id    = 1; 
     100 
     101    p_sys->i_es    = 0; 
     102    p_sys->es      = NULL; 
     103 
     104    p_sys->i_audio = 0; 
     105    p_sys->i_video = 0; 
     106    p_sys->i_sub   = 0; 
     107 
     108    var_Get( p_input, "audio-channel", &val ); 
     109    p_sys->i_audio_last = val.i_int; 
     110 
     111    var_Get( p_input, "spu-channel", &val ); 
     112    p_sys->i_sub_last = val.i_int; 
     113 
     114    p_sys->p_es_audio = NULL; 
     115    p_sys->p_es_video = NULL; 
     116    p_sys->p_es_sub   = NULL; 
     117 
    80118    return out; 
    81119} 
     
    89127    int i; 
    90128 
    91     for( i = 0; i < p_sys->i_id; i++ ) 
    92     { 
    93         free( p_sys->id[i] ); 
    94     } 
    95     if( p_sys->id
    96     { 
    97         free( p_sys->id ); 
     129    for( i = 0; i < p_sys->i_es; i++ ) 
     130    { 
     131        free( p_sys->es[i] ); 
     132    } 
     133    if( p_sys->es
     134    { 
     135        free( p_sys->es ); 
    98136    } 
    99137    free( p_sys ); 
     
    102140 
    103141/***************************************************************************** 
    104  * EsOutAdd: 
    105  *****************************************************************************/ 
    106 static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt ) 
     142 * EsOutSelect: Select an ES given the current mode 
     143 * XXX: you need to take a the lock before (stream.stream_lock) 
     144 *****************************************************************************/ 
     145static void EsOutSelect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_force ) 
    107146{ 
    108147    es_out_sys_t      *p_sys = out->p_sys; 
    109148    input_thread_t    *p_input = p_sys->p_input; 
    110     es_out_id_t       *id = malloc( sizeof( es_out_id_t ) ); 
     149 
     150    int i_cat = es->p_es->i_cat; 
     151 
     152    if( !p_sys->b_active || ( !b_force && es->p_es->fmt.i_priority < 0 ) ) 
     153    { 
     154        return; 
     155    } 
     156 
     157    if( p_sys->i_mode == ES_OUT_MODE_ALL || b_force ) 
     158    { 
     159        input_SelectES( p_input, es->p_es ); 
     160    } 
     161    else if( p_sys->i_mode == ES_OUT_MODE_AUTO ) 
     162    { 
     163        int i_wanted  = -1; 
     164 
     165        if( i_cat == AUDIO_ES ) 
     166        { 
     167            if( p_sys->p_es_audio && p_sys->p_es_audio->p_es->fmt.i_priority >= es->p_es->fmt.i_priority ) 
     168            { 
     169                return; 
     170            } 
     171            i_wanted  = p_sys->i_audio_last >= 0 ? p_sys->i_audio_last : es->i_channel; 
     172        } 
     173        else if( i_cat == SPU_ES ) 
     174        { 
     175            if( p_sys->p_es_sub && p_sys->p_es_sub->p_es->fmt.i_priority >= es->p_es->fmt.i_priority ) 
     176            { 
     177                return; 
     178            } 
     179            i_wanted  = p_sys->i_sub_last; 
     180        } 
     181        else if( i_cat == VIDEO_ES ) 
     182        { 
     183            i_wanted  = es->i_channel; 
     184        } 
     185 
     186        if( i_wanted == es->i_channel ) 
     187        { 
     188            input_SelectES( p_input, es->p_es ); 
     189        } 
     190    } 
     191 
     192    /* FIXME TODO handle priority here */ 
     193    if( es->p_es->p_dec ) 
     194    { 
     195        if( i_cat == AUDIO_ES ) 
     196        { 
     197            if( p_sys->i_mode == ES_OUT_MODE_AUTO && 
     198                p_sys->p_es_audio && p_sys->p_es_audio->p_es->p_dec ) 
     199            { 
     200                input_UnselectES( p_input, p_sys->p_es_audio->p_es ); 
     201            } 
     202            p_sys->p_es_audio = es; 
     203        } 
     204        else if( i_cat == SPU_ES ) 
     205        { 
     206            if( p_sys->i_mode == ES_OUT_MODE_AUTO && 
     207                p_sys->p_es_sub && p_sys->p_es_sub->p_es->p_dec ) 
     208            { 
     209                input_UnselectES( p_input, p_sys->p_es_sub->p_es ); 
     210            } 
     211            p_sys->p_es_sub = es; 
     212        } 
     213        else if( i_cat == VIDEO_ES ) 
     214        { 
     215            p_sys->p_es_video = es; 
     216        } 
     217    } 
     218
     219 
     220/***************************************************************************** 
     221 * EsOutAdd: 
     222 *****************************************************************************/ 
     223static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt ) 
     224
     225    es_out_sys_t      *p_sys = out->p_sys; 
     226    input_thread_t    *p_input = p_sys->p_input; 
     227    es_out_id_t       *es = malloc( sizeof( es_out_id_t ) ); 
    111228    pgrm_descriptor_t *p_prgm = NULL; 
    112229    char              psz_cat[strlen( "Stream " ) + 10]; 
     
    132249    } 
    133250 
    134     id->p_es = input_AddES( p_input, 
     251    es->p_es = input_AddES( p_input, 
    135252                            p_prgm, 
    136                             1 + out->p_sys->i_id, 
     253                            out->p_sys->i_id, 
    137254                            fmt->i_cat, 
    138255                            fmt->psz_description, 0 ); 
    139     id->p_es->i_stream_id = 1 + out->p_sys->i_id; 
    140     id->p_es->i_fourcc = fmt->i_codec; 
     256    es->p_es->i_stream_id = out->p_sys->i_id; 
     257    es->p_es->i_fourcc = fmt->i_codec; 
    141258 
    142259    switch( fmt->i_cat ) 
     
    158275                memcpy( &p_wf[1], fmt->p_extra, fmt->i_extra ); 
    159276            } 
    160             id->p_es->p_waveformatex = p_wf; 
     277            es->p_es->p_waveformatex = p_wf; 
     278 
     279            es->i_channel = p_sys->i_audio; 
    161280            break; 
    162281        } 
     
    182301                memcpy( &p_bih[1], fmt->p_extra, fmt->i_extra ); 
    183302            } 
    184             id->p_es->p_bitmapinfoheader = p_bih; 
     303            es->p_es->p_bitmapinfoheader = p_bih; 
     304 
     305            es->i_channel = p_sys->i_video; 
    185306            break; 
    186307        } 
     
    191312            if( fmt->i_extra > 0 ) 
    192313            { 
    193                 p_sub->psz_header = malloc( fmt->i_extra  ); 
     314                p_sub->psz_header = malloc( fmt->i_extra  + 1 ); 
    194315                memcpy( p_sub->psz_header, fmt->p_extra , fmt->i_extra ); 
     316                /* just to be sure */ 
     317                ((uint8_t*)fmt->p_extra)[fmt->i_extra] = '\0'; 
    195318            } 
    196319            /* FIXME beuuuuuurk */ 
    197             id->p_es->p_demux_data = p_sub; 
    198             break; 
    199         } 
     320            es->p_es->p_demux_data = p_sub; 
     321 
     322            es->i_channel = p_sys->i_sub; 
     323            break; 
     324        } 
     325 
    200326        default: 
    201             break; 
    202     } 
    203  
    204     if( fmt->i_cat == AUDIO_ES && fmt->i_priority > out->p_sys->i_audio ) 
    205     { 
    206         if( out->p_sys->i_audio >= 0 ) 
    207         { 
    208             msg_Err( p_input, "FIXME unselect es in es_out_Add" ); 
    209         } 
    210         input_SelectES( p_input, id->p_es ); 
    211         if( id->p_es->p_dec ) 
    212         { 
    213             out->p_sys->i_audio = fmt->i_priority; 
    214         } 
    215     } 
    216     else if( fmt->i_cat == VIDEO_ES && fmt->i_priority > out->p_sys->i_video ) 
    217     { 
    218         if( out->p_sys->i_video >= 0 ) 
    219         { 
    220             msg_Err( p_input, "FIXME unselect es in es_out_Add" ); 
    221         } 
    222         input_SelectES( p_input, id->p_es ); 
    223         if( id->p_es->p_dec ) 
    224         { 
    225             out->p_sys->i_video = fmt->i_priority; 
    226         } 
    227     } 
    228  
    229     sprintf( psz_cat, _("Stream %d"), out->p_sys->i_id ); 
     327            es->i_channel = 0; 
     328            break; 
     329    } 
     330 
     331    sprintf( psz_cat, _("Stream %d"), out->p_sys->i_id - 1 ); 
    230332    if( ( p_cat = input_InfoCategory( p_input, psz_cat ) ) ) 
    231333    { 
     
    285387        } 
    286388    } 
     389 
     390 
     391    /* Apply mode 
     392     * XXX change that when we do group too */ 
     393    if( 1 ) 
     394    { 
     395        EsOutSelect( out, es, VLC_FALSE ); 
     396    } 
     397 
    287398    vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    288399 
    289     id->p_es->fmt = *fmt; 
    290  
    291     TAB_APPEND( out->p_sys->i_id, out->p_sys->id, id ); 
    292     return id; 
     400    es->p_es->fmt = *fmt; 
     401 
     402    TAB_APPEND( out->p_sys->i_es, out->p_sys->es, es ); 
     403    p_sys->i_id++;  /* always incremented */ 
     404    switch( fmt->i_cat ) 
     405    { 
     406        case AUDIO_ES: 
     407            p_sys->i_audio++; 
     408            break; 
     409        case SPU_ES: 
     410            p_sys->i_sub++; 
     411            break; 
     412        case VIDEO_ES: 
     413            p_sys->i_video++; 
     414            break; 
     415    } 
     416 
     417    return es; 
    293418} 
    294419 
     
    296421 * EsOutSend: 
    297422 *****************************************************************************/ 
    298 static int EsOutSend( es_out_t *out, es_out_id_t *id, block_t *p_block ) 
    299 
    300     if( id->p_es->p_dec ) 
    301     { 
    302         input_DecodeBlock( id->p_es->p_dec, p_block ); 
     423static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block ) 
     424
     425    vlc_mutex_lock( &out->p_sys->p_input->stream.stream_lock ); 
     426    if( es->p_es->p_dec ) 
     427    { 
     428        input_DecodeBlock( es->p_es->p_dec, p_block ); 
    303429    } 
    304430    else 
     
    306432        block_Release( p_block ); 
    307433    } 
     434    vlc_mutex_unlock( &out->p_sys->p_input->stream.stream_lock ); 
    308435    return VLC_SUCCESS; 
    309436} 
    310437 
    311438/***************************************************************************** 
    312  * EsOutSendPES: 
    313  *****************************************************************************/ 
    314 static int EsOutSendPES( es_out_t *out, es_out_id_t *id, pes_packet_t *p_pes ) 
    315 { 
    316     if( id->p_es->p_dec ) 
    317     { 
    318         input_DecodePES( id->p_es->p_dec, p_pes ); 
    319     } 
    320     else 
    321     { 
    322         input_DeletePES( out->p_sys->p_input->p_method_data, p_pes ); 
    323     } 
    324     return VLC_SUCCESS; 
    325 } 
    326  
    327 /***************************************************************************** 
    328439 * EsOutDel: 
    329440 *****************************************************************************/ 
    330 static void EsOutDel( es_out_t *out, es_out_id_t *id
     441static void EsOutDel( es_out_t *out, es_out_id_t *es
    331442{ 
    332443    es_out_sys_t *p_sys = out->p_sys; 
    333444 
    334     TAB_REMOVE( p_sys->i_id, p_sys->id, id ); 
    335  
     445    TAB_REMOVE( p_sys->i_es, p_sys->es, es ); 
     446 
     447    switch( es->p_es->i_cat ) 
     448    { 
     449        case AUDIO_ES: 
     450            p_sys->i_audio--; 
     451            break; 
     452        case SPU_ES: 
     453            p_sys->i_sub--; 
     454            break; 
     455        case VIDEO_ES: 
     456            p_sys->i_video--; 
     457            break; 
     458    } 
     459 
     460    /* We don't try to reselect */ 
    336461    vlc_mutex_lock( &p_sys->p_input->stream.stream_lock ); 
    337     if( id->p_es->p_dec ) 
    338     { 
    339         input_UnselectES( p_sys->p_input, id->p_es ); 
    340     } 
    341     if( id->p_es->p_waveformatex ) 
    342     { 
    343         free( id->p_es->p_waveformatex ); 
    344         id->p_es->p_waveformatex = NULL; 
    345     } 
    346     if( id->p_es->p_bitmapinfoheader ) 
    347     { 
    348         free( id->p_es->p_bitmapinfoheader ); 
    349         id->p_es->p_bitmapinfoheader = NULL; 
    350     } 
    351     input_DelES( p_sys->p_input, id->p_es ); 
     462    if( es->p_es->p_dec ) 
     463    { 
     464        input_UnselectES( p_sys->p_input, es->p_es ); 
     465    } 
     466 
     467    if( es->p_es->p_waveformatex ) 
     468    { 
     469        free( es->p_es->p_waveformatex ); 
     470        es->p_es->p_waveformatex = NULL; 
     471    } 
     472    if( es->p_es->p_bitmapinfoheader ) 
     473    { 
     474        free( es->p_es->p_bitmapinfoheader ); 
     475        es->p_es->p_bitmapinfoheader = NULL; 
     476    } 
     477    input_DelES( p_sys->p_input, es->p_es ); 
     478 
    352479    vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock ); 
    353480 
    354     free( id ); 
     481    free( es ); 
    355482} 
    356483 
     
    362489    es_out_sys_t *p_sys = out->p_sys; 
    363490    vlc_bool_t  b, *pb; 
    364     es_out_id_t *id; 
     491    int         i, *pi; 
     492 
     493    es_out_id_t *es; 
     494 
    365495    switch( i_query ) 
    366496    { 
    367         case ES_OUT_SET_SELECT
     497        case ES_OUT_SET_ES_STATE
    368498            vlc_mutex_lock( &p_sys->p_input->stream.stream_lock ); 
    369             id = (es_out_id_t*) va_arg( args, es_out_id_t * ); 
     499            es = (es_out_id_t*) va_arg( args, es_out_id_t * ); 
    370500            b = (vlc_bool_t) va_arg( args, vlc_bool_t ); 
    371             if( b && id->p_es->p_dec == NULL ) 
    372             { 
    373                 input_SelectES( p_sys->p_input, id->p_es ); 
     501            if( b && es->p_es->p_dec == NULL ) 
     502            { 
     503                input_SelectES( p_sys->p_input, es->p_es ); 
    374504                vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock ); 
    375                 return id->p_es->p_dec ? VLC_SUCCESS : VLC_EGENERIC; 
    376             } 
    377             else if( !b && id->p_es->p_dec ) 
    378             { 
    379                 input_UnselectES( p_sys->p_input, id->p_es ); 
     505                return es->p_es->p_dec ? VLC_SUCCESS : VLC_EGENERIC; 
     506            } 
     507            else if( !b && es->p_es->p_dec ) 
     508            { 
     509                input_UnselectES( p_sys->p_input, es->p_es ); 
    380510                vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock ); 
    381511                return VLC_SUCCESS; 
    382512            } 
    383         case ES_OUT_GET_SELECT
    384             id = (es_out_id_t*) va_arg( args, es_out_id_t * ); 
     513        case ES_OUT_GET_ES_STATE
     514            es = (es_out_id_t*) va_arg( args, es_out_id_t * ); 
    385515            pb = (vlc_bool_t*) va_arg( args, vlc_bool_t * ); 
    386516 
    387             *pb = id->p_es->p_dec ? VLC_TRUE : VLC_FALSE; 
     517            *pb = es->p_es->p_dec ? VLC_TRUE : VLC_FALSE; 
     518            return VLC_SUCCESS; 
     519 
     520        case ES_OUT_SET_ACTIVE: 
     521            b = (vlc_bool_t) va_arg( args, vlc_bool_t ); 
     522            p_sys->b_active = b; 
     523            return VLC_SUCCESS; 
     524 
     525        case ES_OUT_GET_ACTIVE: 
     526            pb = (vlc_bool_t*) va_arg( args, vlc_bool_t * ); 
     527            *pb = p_sys->b_active; 
     528            return VLC_SUCCESS; 
     529 
     530        case ES_OUT_SET_MODE: 
     531            i = (int) va_arg( args, int ); 
     532            if( i == ES_OUT_MODE_NONE || i == ES_OUT_MODE_ALL || i == ES_OUT_MODE_AUTO ) 
     533            { 
     534                p_sys->i_mode = i; 
     535 
     536                /* Reapply policy mode */ 
     537                vlc_mutex_lock( &p_sys->p_input->stream.stream_lock ); 
     538                for( i = 0; i < p_sys->i_es; i++ ) 
     539                { 
     540                    if( p_sys->es[i]->p_es->p_dec ) 
     541                    { 
     542                        input_UnselectES( p_sys->p_input, p_sys->es[i]->p_es ); 
     543                    } 
     544                } 
     545                for( i = 0; i < p_sys->i_es; i++ ) 
     546                { 
     547                    EsOutSelect( out, p_sys->es[i], VLC_FALSE ); 
     548                } 
     549                vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock ); 
     550                return VLC_SUCCESS; 
     551            } 
     552            return VLC_EGENERIC; 
     553 
     554        case ES_OUT_GET_MODE: 
     555            pi = (int*) va_arg( args, int* ); 
     556            *pi = p_sys->i_mode; 
     557            return VLC_SUCCESS; 
     558 
     559        case ES_OUT_SET_ES: 
     560            es = (es_out_id_t*) va_arg( args, es_out_id_t * ); 
     561            if( es == NULL ) 
     562            { 
     563                for( i = 0; i < p_sys->i_es; i++ ) 
     564                { 
     565                    vlc_mutex_lock( &p_sys->p_input->stream.stream_lock ); 
     566                    if( p_sys->es[i]->p_es->p_dec ) 
     567                    { 
     568                        input_UnselectES( p_sys->p_input, p_sys->es[i]->p_es ); 
     569                    } 
     570                    vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock ); 
     571                } 
     572            } 
     573            else 
     574            { 
     575                vlc_mutex_lock( &p_sys->p_input->stream.stream_lock ); 
     576                EsOutSelect( out, es, VLC_TRUE ); 
     577                vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock ); 
     578            } 
    388579            return VLC_SUCCESS; 
    389580 
     
    394585} 
    395586 
     587 
     588 
     589 
  • src/input/input.c

    rf78aa8e r46e872e  
    55 ***************************************************************************** 
    66 * Copyright (C) 1998-2002 VideoLAN 
    7  * $Id: input.c,v 1.264 2003/11/26 18:48:24 gbazin Exp $ 
     7 * $Id: input.c,v 1.265 2003/11/27 04:11:40 fenrir Exp $ 
    88 * 
    99 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    623623 
    624624    p_input->p_es_out = input_EsOutNew( p_input ); 
     625    es_out_Control( p_input->p_es_out, ES_OUT_SET_ACTIVE, VLC_FALSE ); 
     626    es_out_Control( p_input->p_es_out, ES_OUT_SET_MODE, ES_OUT_MODE_NONE ); 
    625627 
    626628    /* Find and open appropriate access module */ 
     
    745747        { 
    746748            /* Select this ES by default */ 
    747             es_out_Control( p_input->p_es_out, ES_OUT_SET_SELECT, p_sub->p_es, VLC_TRUE ); 
     749            es_out_Control( p_input->p_es_out, ES_OUT_SET_ES_STATE, p_sub->p_es, VLC_TRUE ); 
    748750 
    749751            TAB_APPEND( p_input->p_sys->i_sub, p_input->p_sys->sub, p_sub ); 
     
    767769        free(tmp); 
    768770    } 
     771 
     772    es_out_Control( p_input->p_es_out, ES_OUT_SET_ACTIVE, VLC_TRUE ); 
     773    es_out_Control( p_input->p_es_out, ES_OUT_SET_MODE, ES_OUT_MODE_AUTO ); 
    769774 
    770775    return VLC_SUCCESS;