Changeset 1171979d73a6ddd4da292e772aa8d29d0e581996

Show
Ignore:
Timestamp:
12/03/03 00:56:54 (6 years ago)
Author:
Gildas Bazin <gbazin@videolan.org>
git-committer:
Gildas Bazin <gbazin@videolan.org> 1047427014 +0000
git-parent:

[cfcd2ca2d8bba26b935b744c78f7cf068be92562]

git-author:
Gildas Bazin <gbazin@videolan.org> 1047427014 +0000
Message:

* ALL: experimental code for stream (dvd) navigation through object variables.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/input_ext-plugins.h

    r47e65c0 r1171979  
    44 ***************************************************************************** 
    55 * Copyright (C) 1999-2002 VideoLAN 
    6  * $Id: input_ext-plugins.h,v 1.40 2003/03/04 13:21:19 massiot Exp $ 
     6 * $Id: input_ext-plugins.h,v 1.41 2003/03/11 23:56:53 gbazin Exp $ 
    77 * 
    88 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    4545VLC_EXPORT( void, input_DelProgram,( input_thread_t *, pgrm_descriptor_t * ) ); 
    4646VLC_EXPORT( int, input_SetProgram,( input_thread_t *, pgrm_descriptor_t * ) ); 
    47 VLC_EXPORT( input_area_t *, input_AddArea,( input_thread_t * ) ); 
     47VLC_EXPORT( input_area_t *, input_AddArea,( input_thread_t *, uint16_t, uint16_t ) ); 
    4848VLC_EXPORT( void, input_DelArea,   ( input_thread_t *, input_area_t * ) ); 
    4949VLC_EXPORT( es_descriptor_t *, input_FindES,( input_thread_t *, uint16_t ) ); 
  • include/variables.h

    r215c1a8 r1171979  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: variables.h,v 1.11 2002/12/14 19:34:07 gbazin Exp $ 
     5 * $Id: variables.h,v 1.12 2003/03/11 23:56:53 gbazin Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    7676#define VLC_VAR_FILE      0x0042 
    7777#define VLC_VAR_DIRECTORY 0x0043 
     78#define VLC_VAR_VARIABLE  0x0044 
    7879#define VLC_VAR_FLOAT     0x0050 
    7980#define VLC_VAR_TIME      0x0060 
     
    9899#define VLC_VAR_SETSTEP       0x0012 
    99100 
     101#define VLC_VAR_SETVALUE      0x0013 
     102 
    100103#define VLC_VAR_ADDCHOICE     0x0020 
    101104#define VLC_VAR_DELCHOICE     0x0021 
    102 #define VLC_VAR_SETDEFAULT    0x0022 
    103 #define VLC_VAR_GETLIST       0x0023 
    104 #define VLC_VAR_FREELIST      0x0024 
     105#define VLC_VAR_CLEARCHOICES  0x0022 
     106#define VLC_VAR_SETDEFAULT    0x0023 
     107#define VLC_VAR_GETLIST       0x0024 
     108#define VLC_VAR_FREELIST      0x0025 
    105109 
    106110/***************************************************************************** 
  • modules/access/dvd/access.c

    r461358e r1171979  
    99 ***************************************************************************** 
    1010 * Copyright (C) 1998-2001 VideoLAN 
    11  * $Id: access.c,v 1.10 2003/02/08 22:20:28 massiot Exp $ 
     11 * $Id: access.c,v 1.11 2003/03/11 23:56:53 gbazin Exp $ 
    1212 * 
    1313 * Author: St�ane Borel <stef@via.ecp.fr> 
     
    207207    for( i = 1 ; i <= title_inf.i_title_nb ; i++ ) 
    208208    { 
    209         input_AddArea( p_input ); 
    210  
    211209        /* Titles are Program Chains */ 
    212         area[i]->i_id = i
     210        input_AddArea( p_input, i, title_inf.p_attr[i-1].i_chapter_nb )
    213211 
    214212        /* Absolute start offset and size 
     
    218216        area[i]->i_size = 0; 
    219217 
    220         /* Number of chapters */ 
    221         area[i]->i_part_nb = title_inf.p_attr[i-1].i_chapter_nb; 
     218        /* Default Chapter */ 
    222219        area[i]->i_part = 1; 
    223220 
     
    292289        thread_dvd_data_t *  p_dvd; 
    293290        int                  i_angle; 
     291        vlc_value_t          val; 
    294292 
    295293        p_dvd   = (thread_dvd_data_t*)(p_input->p_access_data); 
     
    326324#undef title 
    327325        msg_Dbg( p_input, "angle %d selected", p_dvd->i_angle ); 
     326 
     327        /* Update the navigation variables without triggering a callback */ 
     328        val.i_int = p_program->i_number; 
     329        var_Change( p_input, "program", VLC_VAR_SETVALUE, &val ); 
    328330    } 
    329331 
     
    391393{ 
    392394    thread_dvd_data_t *  p_dvd; 
     395    vlc_value_t          val; 
    393396 
    394397    p_dvd = (thread_dvd_data_t*)(p_input->p_access_data); 
     
    402405        u32     i_first; 
    403406        u32     i_last; 
     407        unsigned int i; 
    404408 
    405409        /* Reset the Chapter position of the old title */ 
     
    496500        } 
    497501 
     502        /* Update the navigation variables without triggering a callback */ 
     503        val.i_int = p_area->i_id; 
     504        var_Change( p_input, "title", VLC_VAR_SETVALUE, &val ); 
     505        var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL ); 
     506    for( i = 1; i <= p_area->i_part_nb; i++ ) 
     507    { 
     508        val.i_int = i; 
     509        var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val ); 
     510    } 
     511 
    498512    } /* i_title >= 0 */ 
    499513    else 
     
    510524    p_input->stream.b_seekable = 1; 
    511525    p_input->stream.b_changed  = 1; 
     526 
     527    /* Update the navigation variables without triggering a callback */ 
     528    val.i_int = p_area->i_part; 
     529    var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val ); 
    512530 
    513531    return 0; 
  • modules/access/dvdplay/access.c

    rec22d73 r1171979  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: access.c,v 1.12 2003/03/09 19:25:09 gbazin Exp $ 
     5 * $Id: access.c,v 1.13 2003/03/11 23:56:53 gbazin Exp $ 
    66 * 
    77 * Author: St�ane Borel <stef@via.ecp.fr> 
     
    4646#endif 
    4747 
    48 #if defined( WIN32 ) 
    49 #   include <io.h>                                                 /* read() */ 
    50 #endif 
    51  
    5248#include "dvd.h" 
    5349#include "es.h" 
     
    148144    /* Area 0 for menu */ 
    149145    area[0]->i_plugin_data = 0; 
     146    input_DelArea( p_input, p_input->stream.pp_areas[0] ); 
     147    input_AddArea( p_input, 0, 1 ); 
    150148 
    151149    for( i = 1 ; i <= i_title_nr ; i++ ) 
    152150    { 
    153         input_AddArea( p_input ); 
    154  
    155         /* Titles id */ 
    156         area[i]->i_id = i; 
    157  
    158         /* Number of chapters */ 
    159         area[i]->i_part_nb = dvdplay_chapter_nr( p_dvd->vmg, i ); 
    160  
     151        input_AddArea( p_input, i, dvdplay_chapter_nr( p_dvd->vmg, i ) ); 
    161152        area[i]->i_plugin_data = 0; 
    162153    } 
     
    245236        dvd_data_t *    p_dvd; 
    246237        int             i_angle; 
     238        vlc_value_t     val; 
    247239 
    248240        p_dvd = (dvd_data_t*)(p_input->p_access_data); 
     
    258250            msg_Dbg( p_input, "angle %d selected", i_angle ); 
    259251        } 
     252 
     253        /* Update the navigation variables without triggering a callback */ 
     254        val.i_int = p_program->i_number; 
     255        var_Change( p_input, "program", VLC_VAR_SETVALUE, &val ); 
    260256    } 
    261257 
     
    273269{ 
    274270    dvd_data_t *    p_dvd; 
     271    vlc_value_t     val; 
    275272 
    276273    p_dvd = (dvd_data_t*)p_input->p_access_data; 
     
    323320    p_input->stream.b_changed = 1; 
    324321 
     322    /* Update the navigation variables without triggering a callback */ 
     323    val.i_int = p_area->i_part; 
     324    var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val ); 
     325 
    325326    return 0; 
    326327} 
     
    396397        break; 
    397398    case NEW_FILE: 
    398  
    399399        break; 
    400400    case NEW_PGC: 
     
    429429        /* warn interface that something has changed */ 
    430430        p_input->stream.b_changed = 1; 
     431 
     432        /* Update the navigation variables without triggering a callback */ 
     433        val.i_int = p_input->stream.p_selected_area->i_part; 
     434        var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val ); 
    431435        break; 
    432436    case NEW_CELL: 
     
    498502    dvd_data_t *    p_dvd; 
    499503    int             i_angle_nb, i_angle; 
     504    vlc_value_t     val; 
    500505    int             i; 
    501506 
     
    526531    /* No PSM to read in DVD mode, we already have all information */ 
    527532    p_input->stream.p_selected_program->b_is_ok = 1; 
     533 
     534    /* Update the navigation variables without triggering a callback */ 
     535    val.i_int = p_area->i_id; 
     536    var_Change( p_input, "title", VLC_VAR_SETVALUE, &val ); 
     537    var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL ); 
     538    for( i = 1; (unsigned int)i <= p_area->i_part_nb; i++ ) 
     539    { 
     540        val.i_int = i; 
     541        var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val ); 
     542    } 
     543 
     544    /* Update the navigation variables without triggering a callback */ 
     545    val.i_int = p_area->i_part; 
     546    var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val ); 
    528547 
    529548    return 0; 
     
    569588    return 0; 
    570589} 
    571  
  • modules/access/dvdread/input.c

    r9722e20 r1171979  
    77 ***************************************************************************** 
    88 * Copyright (C) 2001, 2003 VideoLAN 
    9  * $Id: input.c,v 1.16 2003/02/02 00:49:40 massiot Exp $ 
     9 * $Id: input.c,v 1.17 2003/03/11 23:56:53 gbazin Exp $ 
    1010 * 
    1111 * Author: St�ane Borel <stef@via.ecp.fr> 
     
    384384    for( i = 1 ; i <= tt_srpt->nr_of_srpts ; i++ ) 
    385385    { 
    386         input_AddArea( p_input ); 
    387  
    388386        /* Titles are Program Chains */ 
    389         area[i]->i_id = i
     387        input_AddArea( p_input, i, tt_srpt->title[i-1].nr_of_ptts )
    390388 
    391389        /* Absolute start offset and size 
     
    395393        area[i]->i_size = 0; 
    396394 
    397         /* Number of chapters */ 
    398         area[i]->i_part_nb = tt_srpt->title[i-1].nr_of_ptts; 
     395        /* Default Chapter */ 
    399396        area[i]->i_part = 1; 
    400397 
     
    466463    { 
    467464        thread_dvd_data_t *  p_dvd; 
     465        vlc_value_t val; 
    468466 
    469467        p_dvd = (thread_dvd_data_t*)(p_input->p_access_data); 
     
    476474 
    477475        msg_Dbg( p_input, "angle %d selected", p_dvd->i_angle ); 
     476 
     477        /* Update the navigation variables without triggering a callback */ 
     478        val.i_int = p_program->i_number; 
     479        var_Change( p_input, "program", VLC_VAR_SETVALUE, &val ); 
    478480    } 
    479481 
     
    495497    int                  pgc_id = 0; 
    496498    int                  pgn = 0; 
     499    vlc_value_t          val; 
    497500 
    498501    p_dvd = (thread_dvd_data_t*)p_input->p_access_data; 
     
    795798        } 
    796799 
     800        /* Update the navigation variables without triggering a callback */ 
     801        val.i_int = p_area->i_id; 
     802        var_Change( p_input, "title", VLC_VAR_SETVALUE, &val ); 
     803        var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL ); 
     804        for( i = 1; i <= p_area->i_part_nb; i++ ) 
     805        { 
     806            val.i_int = i; 
     807            var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val ); 
     808        } 
     809 
    797810    } /* i_title >= 0 */ 
    798811    else 
     
    838851    p_input->stream.b_seekable = VLC_TRUE; 
    839852    p_input->stream.b_changed = VLC_TRUE; 
     853 
     854    /* Update the navigation variables without triggering a callback */ 
     855    val.i_int = p_area->i_part; 
     856    var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val ); 
    840857 
    841858    return VLC_SUCCESS; 
  • modules/access/satellite/access.c

    ra793be3 r1171979  
    383383{ 
    384384    unsigned int i_es_index; 
     385    vlc_value_t val; 
    385386 
    386387    if ( p_input->stream.p_selected_program ) 
     
    435436    p_input->stream.p_selected_program = p_new_prg; 
    436437 
     438    /* Update the navigation variables without triggering a callback */ 
     439    val.i_int = p_new_prg->i_number; 
     440    var_Change( p_input, "program", VLC_VAR_SETVALUE, &val ); 
     441 
    437442    return 0; 
    438443} 
  • modules/access/vcd/vcd.c

    r56b7cbf r1171979  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000 VideoLAN 
    5  * $Id: vcd.c,v 1.15 2003/02/12 17:13:33 jobi Exp $ 
     5 * $Id: vcd.c,v 1.16 2003/03/11 23:56:54 gbazin Exp $ 
    66 * 
    77 * Author: Johan Bilien <jobi@via.ecp.fr> 
     
    225225    for( i = 1 ; i <= p_vcd->i_nb_tracks - 1 ; i++ ) 
    226226    { 
    227         input_AddArea( p_input ); 
    228  
    229227        /* Titles are Program Chains */ 
    230         area[i]->i_id = i
     228        input_AddArea( p_input, i, 1 )
    231229 
    232230        /* Absolute start offset and size */ 
     
    235233                           * (off_t)VCD_DATA_SIZE; 
    236234 
    237         /* Number of chapters */ 
    238         area[i]->i_part_nb = 1;   /* will be the entry points */ 
     235        /* Default Chapter */ 
    239236        area[i]->i_part = 1; 
    240237 
     
    389386{ 
    390387    thread_vcd_data_t *     p_vcd; 
     388    vlc_value_t val; 
    391389 
    392390    p_vcd = (thread_vcd_data_t*)p_input->p_access_data; 
     
    397395    if( p_area != p_input->stream.p_selected_area ) 
    398396    { 
     397        unsigned int i; 
     398 
    399399        /* Reset the Chapter position of the current title */ 
    400400        p_input->stream.p_selected_area->i_part = 1; 
     
    408408        p_vcd->i_track = p_area->i_id; 
    409409        p_vcd->i_sector = p_vcd->p_sectors[p_vcd->i_track]; 
     410 
     411        /* Update the navigation variables without triggering a callback */ 
     412        val.i_int = p_area->i_id; 
     413        var_Change( p_input, "title", VLC_VAR_SETVALUE, &val ); 
     414        var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL ); 
     415        for( i = 1; i <= p_area->i_part_nb; i++ ) 
     416        { 
     417            val.i_int = i; 
     418            var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val ); 
     419        } 
    410420    } 
    411421 
     
    427437    p_input->stream.b_seekable = 1; 
    428438    p_input->stream.b_changed = 1; 
     439 
     440    /* Update the navigation variables without triggering a callback */ 
     441    val.i_int = p_area->i_part; 
     442    var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val ); 
    429443 
    430444    return 0; 
  • modules/gui/wxwindows/popup.cpp

    r437957a r1171979  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000-2001 VideoLAN 
    5  * $Id: popup.cpp,v 1.3 2003/01/26 10:36:10 gbazin Exp $ 
     5 * $Id: popup.cpp,v 1.4 2003/03/11 23:56:54 gbazin Exp $ 
    66 * 
    77 * Authors: Gildas Bazin <gbazin@netcourrier.com> 
     
    119119    CreateMenuEntry( "title", p_object ); 
    120120    CreateMenuEntry( "chapter", p_object ); 
     121    CreateMenuEntry( "navigation", p_object ); 
    121122 
    122123    vlc_object_release( p_object ); 
     
    208209    wxMenu *menu = new wxMenu; 
    209210    vlc_value_t val; 
    210     char *psz_value
     211    vlc_value_t val_list
    211212    int i_type, i; 
    212213 
     
    214215    i_type = var_Type( p_object, psz_var ); 
    215216 
    216     switch( i_type ) 
    217     { 
    218     case VLC_VAR_VOID: 
    219     case VLC_VAR_STRING: 
    220         break; 
    221  
    222     default: 
    223         break; 
    224     } 
    225  
    226217    if( var_Get( p_object, psz_var, &val ) < 0 ) 
    227218    { 
    228219        return NULL; 
    229220    } 
    230     psz_value = val.psz_string; 
    231  
    232     if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val ) < 0 ) 
     221 
     222    if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list ) < 0 ) 
    233223    { 
    234224        return NULL; 
    235225    } 
    236226 
    237     for( i = 0; i < val.p_list->i_count; i++ ) 
     227    for( i = 0; i < val_list.p_list->i_count; i++ ) 
    238228    { 
    239229        vlc_value_t another_val; 
     
    242232        switch( i_type & VLC_VAR_TYPE ) 
    243233        { 
     234        case VLC_VAR_VARIABLE: 
     235          menu->Append( MenuDummy_Event, 
     236                        val_list.p_list->p_values[i].psz_string, 
     237                        CreateSubMenu( val_list.p_list->p_values[i].psz_string, 
     238                                       p_object ), 
     239                        "YEAAAARRRGGGHHH HEEELLPPPPPP" ); 
     240          break; 
     241 
    244242        case VLC_VAR_STRING: 
    245243          another_val.psz_string = 
    246               strdup(val.p_list->p_values[i].psz_string); 
     244              strdup(val_list.p_list->p_values[i].psz_string); 
    247245          menuitem = 
    248246              new wxMenuItemExt( this, i_item_id++, another_val.psz_string, 
     
    253251          menu->Append( menuitem ); 
    254252 
    255           if( !strcmp( psz_value, val.p_list->p_values[i].psz_string ) ) 
     253          if( !strcmp( val.psz_string, 
     254                       val_list.p_list->p_values[i].psz_string ) ) 
    256255              menu->Check( i_item_id - 1, TRUE ); 
    257256          break; 
     
    261260              new wxMenuItemExt( this, i_item_id++, 
    262261                                 wxString::Format(_("%d"), 
    263                                  val.p_list->p_values[i].i_int), 
     262                                 val_list.p_list->p_values[i].i_int), 
    264263                                 "", wxITEM_RADIO, strdup(psz_var), 
    265264                                 p_object->i_object_id, 
    266                                  val.p_list->p_values[i] ); 
     265                                 val_list.p_list->p_values[i] ); 
    267266 
    268267          menu->Append( menuitem ); 
     268 
     269          if( !((i_type & VLC_VAR_FLAGS) & VLC_VAR_ISCOMMAND) && 
     270              val_list.p_list->p_values[i].i_int == val.i_int ) 
     271              menu->Check( i_item_id - 1, TRUE ); 
    269272          break; 
    270273 
     
    274277    } 
    275278 
    276     var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val ); 
     279    var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list ); 
    277280 
    278281    return menu; 
  • src/input/input.c

    r65a1532 r1171979  
    55 ***************************************************************************** 
    66 * Copyright (C) 1998-2002 VideoLAN 
    7  * $Id: input.c,v 1.223 2003/02/08 22:43:02 massiot Exp $ 
     7 * $Id: input.c,v 1.224 2003/03/11 23:56:54 gbazin Exp $ 
    88 * 
    99 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    127127 
    128128    /* By default there is one area in a stream */ 
    129     input_AddArea( p_input ); 
     129    input_AddArea( p_input, 0, 1 ); 
    130130    p_input->stream.p_selected_area = p_input->stream.pp_areas[0]; 
    131131 
  • src/input/input_ext-intf.c

    rfca9baf r1171979  
    33 ***************************************************************************** 
    44 * Copyright (C) 1998-2001 VideoLAN 
    5  * $Id: input_ext-intf.c,v 1.47 2003/01/21 14:15:05 hartman Exp $ 
     5 * $Id: input_ext-intf.c,v 1.48 2003/03/11 23:56:54 gbazin Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    367367{ 
    368368    pgrm_descriptor_t *       p_program; 
     369    vlc_value_t val; 
    369370 
    370371    vlc_mutex_lock( &p_input->stream.stream_lock ); 
     
    381382 
    382383    vlc_mutex_unlock( &p_input->stream.stream_lock ); 
     384 
     385    /* Update the navigation variables without triggering a callback */ 
     386    val.i_int = i_program_number; 
     387    var_Change( p_input, "program", VLC_VAR_SETVALUE, &val ); 
    383388 
    384389    return 0; 
  • src/input/input_programs.c

    ra4495b8 r1171979  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2002 VideoLAN 
    5  * $Id: input_programs.c,v 1.101 2003/01/31 11:23:37 massiot Exp $ 
     5 * $Id: input_programs.c,v 1.102 2003/03/11 23:56:54 gbazin Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    4040 */ 
    4141 
     42/* Navigation callbacks */ 
     43static int ProgramCallback( vlc_object_t *, char const *, 
     44                            vlc_value_t, vlc_value_t, void * ); 
     45static int TitleCallback( vlc_object_t *, char const *, 
     46                          vlc_value_t, vlc_value_t, void * ); 
     47static int ChapterCallback( vlc_object_t *, char const *, 
     48                            vlc_value_t, vlc_value_t, void * ); 
     49static int NavigationCallback( vlc_object_t *, char const *, 
     50                               vlc_value_t, vlc_value_t, void * ); 
     51 
    4252/***************************************************************************** 
    4353 * input_InitStream: init the stream descriptor of the given input 
     
    7383    } 
    7484 
     85    /* Create a few object variables used for navigation in the interfaces */ 
     86    var_Create( p_input, "program", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); 
     87    var_Create( p_input, "title", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); 
     88    var_Create( p_input, "chapter", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); 
     89    var_Create( p_input, "navigation", VLC_VAR_VARIABLE | VLC_VAR_HASCHOICE ); 
     90    var_AddCallback( p_input, "program", ProgramCallback, NULL ); 
     91    var_AddCallback( p_input, "title", TitleCallback, NULL ); 
     92    var_AddCallback( p_input, "chapter", ChapterCallback, NULL ); 
     93 
    7594    return 0; 
    7695} 
     
    81100void input_EndStream( input_thread_t * p_input ) 
    82101{ 
     102    /* Free navigation variables */ 
     103    var_Destroy( p_input, "program" ); 
     104    var_Destroy( p_input, "title" ); 
     105    var_Destroy( p_input, "chapter" ); 
     106 
    83107    /* Free all programs and associated ES, and associated decoders. */ 
    84108    while( p_input->stream.i_pgrm_number ) 
     
    140164    /* Where to add the pgrm */ 
    141165    pgrm_descriptor_t * p_pgrm = malloc( sizeof(pgrm_descriptor_t) ); 
     166    vlc_value_t val; 
    142167 
    143168    if( p_pgrm == NULL ) 
     
    180205                 p_pgrm ); 
    181206 
     207    val.i_int = i_pgrm_id; 
     208    var_Change( p_input, "program", VLC_VAR_ADDCHOICE, &val ); 
     209 
    182210    return p_pgrm; 
    183211} 
     
    191219{ 
    192220    unsigned int i_pgrm_index; 
     221    vlc_value_t val; 
    193222 
    194223    /* Find the program in the programs table */ 
     
    206235        return; 
    207236    } 
     237 
     238    val.i_int = i_pgrm_index; 
     239    var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val ); 
    208240 
    209241    /* Free the structures that describe the es that belongs to that program */ 
     
    233265 * This area descriptor will be referenced in the given stream descriptor 
    234266 *****************************************************************************/ 
    235 input_area_t * input_AddArea( input_thread_t * p_input ) 
     267input_area_t * input_AddArea( input_thread_t * p_input, 
     268                              uint16_t i_area_id, uint16_t i_part_nb ) 
    236269{ 
    237270    /* Where to add the pgrm */ 
    238271    input_area_t * p_area = malloc( sizeof(input_area_t) ); 
     272    vlc_value_t val; 
     273    int i; 
    239274 
    240275    if( p_area == NULL ) 
     
    245280 
    246281    /* Init this entry */ 
    247     p_area->i_id = 0; 
     282    p_area->i_id = i_area_id; 
     283    p_area->i_part_nb = i_part_nb; 
     284    p_area->i_part= 0; 
    248285    p_area->i_start = 0; 
    249286    p_area->i_size = 0; 
    250287    p_area->i_tell = 0; 
    251288    p_area->i_seek = NO_SEEK; 
    252     p_area->i_part_nb = 1; 
    253     p_area->i_part= 0; 
    254289 
    255290    /* Add an entry to the list of program associated with the stream */ 
     
    259294                 p_area ); 
    260295 
     296    /* Don't add empty areas */ 
     297    if( i_part_nb == 0 ) 
     298        return NULL; 
     299 
     300    /* Take care of the navigation variables */ 
     301    val.i_int = i_area_id; 
     302    var_Change( p_input, "title", VLC_VAR_ADDCHOICE, &val ); 
     303 
     304    val.psz_string = malloc( sizeof("title ") + 5 ); 
     305    if( val.psz_string ) 
     306    { 
     307        vlc_value_t val2; 
     308 
     309        sprintf( val.psz_string, "title %2i", i_area_id ); 
     310    var_Destroy( p_input, val.psz_string ); 
     311    var_Create( p_input, val.psz_string, VLC_VAR_INTEGER | 
     312            VLC_VAR_HASCHOICE | VLC_VAR_ISCOMMAND ); 
     313    var_AddCallback( p_input, val.psz_string, NavigationCallback, 
     314             (void *)(int)i_area_id ); 
     315 
     316    var_Change( p_input, "navigation", VLC_VAR_ADDCHOICE, &val ); 
     317 
     318    for( i = 1; i <= i_part_nb; i++ ) 
     319    { 
     320        val2.i_int = i; 
     321        var_Change( p_input, val.psz_string, VLC_VAR_ADDCHOICE, &val2 ); 
     322    } 
     323    } 
     324 
    261325    return p_area; 
    262326} 
     
    272336    int i_audio_es = 0; 
    273337    int i_spu_es = 0; 
     338    vlc_value_t val; 
    274339 
    275340    if ( p_input->stream.p_selected_program ) 
     
    357422    p_input->stream.p_selected_program = p_new_prg; 
    358423 
     424    /* Update the navigation variables without triggering a callback */ 
     425    val.i_int = p_new_prg->i_number; 
     426    var_Change( p_input, "program", VLC_VAR_SETVALUE, &val ); 
     427 
    359428    return( 0 ); 
    360429} 
    361  
    362430 
    363431/***************************************************************************** 
     
    369437{ 
    370438    unsigned int i_area_index; 
     439    vlc_value_t val; 
    371440 
    372441    /* Find the area in the areas table */ 
     
    383452        msg_Err( p_input, "area does not belong to this input" ); 
    384453        return; 
     454    } 
     455 
     456    /* Take care of the navigation variables */ 
     457    val.psz_string = malloc( sizeof("title ") + 5 ); 
     458    if( val.psz_string ) 
     459    { 
     460        sprintf( val.psz_string, "title %i", p_area->i_id ); 
     461    var_Change( p_input, "navigation", VLC_VAR_DELCHOICE, &val ); 
     462    var_Destroy( p_input, val.psz_string ); 
    385463    } 
    386464 
     
    659737    return 0; 
    660738} 
     739 
     740/***************************************************************************** 
     741 * Navigation callback: a bunch of navigation variables are used as an 
     742 *  alternative to the navigation API. 
     743 *****************************************************************************/ 
     744static int ProgramCallback( vlc_object_t *p_this, char const *psz_cmd, 
     745                  vlc_value_t oldval, vlc_value_t newval, void *p_data ) 
     746{ 
     747    input_thread_t *p_input = (input_thread_t *)p_this; 
     748 
     749    if( oldval.i_int == newval.i_int ) 
     750       return VLC_SUCCESS; 
     751 
     752    vlc_mutex_lock( &p_input->stream.stream_lock ); 
     753    if( ( newval.i_int > 0 ) ) 
     754    { 
     755        vlc_mutex_unlock( &p_input->stream.stream_lock ); 
     756        input_ChangeProgram( p_input, newval.i_int ); 
     757        input_SetStatus( p_input, INPUT_STATUS_PLAY ); 
     758        vlc_mutex_lock( &p_input->stream.stream_lock ); 
     759    } 
     760    vlc_mutex_unlock( &p_input->stream.stream_lock ); 
     761 
     762    return VLC_SUCCESS; 
     763} 
     764 
     765static int TitleCallback( vlc_object_t *p_this, char const *psz_cmd, 
     766                  vlc_value_t oldval, vlc_value_t newval, void *p_data ) 
     767{ 
     768    input_thread_t *p_input = (input_thread_t *)p_this; 
     769    input_area_t *p_area; 
     770 
     771    if( oldval.i_int == newval.i_int ) 
     772       return VLC_SUCCESS; 
     773 
     774    /* Sanity check should have already be done by var_Set(). */ 
     775    vlc_mutex_lock( &p_input->stream.stream_lock ); 
     776    p_area = p_input->stream.pp_areas[newval.i_int]; 
     777    p_area->i_part = 1; 
     778    vlc_mutex_unlock( &p_input->stream.stream_lock ); 
     779    input_ChangeArea( p_input, p_area ); 
     780    input_SetStatus( p_input, INPUT_STATUS_PLAY ); 
     781 
     782    return VLC_SUCCESS; 
     783} 
     784 
     785static int ChapterCallback( vlc_object_t *p_this, char const *psz_cmd, 
     786                  vlc_value_t oldval, vlc_value_t newval, void *p_data ) 
     787{ 
     788    input_thread_t *p_input = (input_thread_t *)p_this; 
     789    input_area_t *p_area; 
     790 
     791    if( oldval.i_int == newval.i_int ) 
     792       return VLC_SUCCESS; 
     793 
     794    /* Sanity check will have already be done by var_Set(). */ 
     795    vlc_mutex_lock( &p_input->stream.stream_lock ); 
     796    p_area = p_input->stream.p_selected_area; 
     797    p_input->stream.p_selected_area->i_part = newval.i_int; 
     798    vlc_mutex_unlock( &p_input->stream.stream_lock ); 
     799 
     800    input_ChangeArea( p_input, p_area ); 
     801    input_SetStatus( p_input, INPUT_STATUS_PLAY ); 
     802 
     803    return VLC_SUCCESS; 
     804} 
     805 
     806static int NavigationCallback( vlc_object_t *p_this, char const *psz_cmd, 
     807                  vlc_value_t oldval, vlc_value_t newval, void *p_data ) 
     808{ 
     809    input_thread_t *p_input = (input_thread_t *)p_this; 
     810    uint16_t i_area_id = (int)p_data; 
     811 
     812    vlc_mutex_lock( &p_input->stream.stream_lock ); 
     813 
     814    if( p_input->stream.p_selected_area->i_id == i_area_id && 
     815        oldval.i_int == newval.i_int ) 
     816    { 
     817        /* Nothing to do */ 
     818        vlc_mutex_unlock( &p_input->stream.stream_lock ); 
     819        return VLC_SUCCESS; 
     820    } 
     821 
     822    if( ( i_area_id < p_input->stream.i_area_nb ) && ( newval.i_int > 0 ) && 
     823        ( (uint16_t)newval.i_int <= 
     824          p_input->stream.pp_areas[i_area_id]->i_part_nb ) ) 
     825    { 
     826        input_area_t *p_area = p_input->stream.pp_areas[i_area_id]; 
     827        p_input->stream.p_selected_area->i_part = newval.i_int; 
     828        vlc_mutex_unlock( &p_input->stream.stream_lock ); 
     829        input_ChangeArea( p_input, p_area ); 
     830        input_SetStatus( p_input, INPUT_STATUS_PLAY ); 
     831        vlc_mutex_lock( &p_input->stream.stream_lock ); 
     832    } 
     833    vlc_mutex_unlock( &p_input->stream.stream_lock ); 
     834 
     835    return VLC_SUCCESS; 
     836} 
  • src/misc/variables.c

    rec22d73 r1171979  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: variables.c,v 1.20 2003/03/09 19:25:08 gbazin Exp $ 
     5 * $Id: variables.c,v 1.21 2003/03/11 23:56:54 gbazin Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    156156        case VLC_VAR_MODULE: 
    157157        case VLC_VAR_FILE: 
     158        case VLC_VAR_DIRECTORY: 
     159        case VLC_VAR_VARIABLE: 
    158160            p_var->pf_cmp = CmpString; 
    159161            p_var->pf_dup = DupString; 
     
    265267    int i_var, i; 
    266268    variable_t *p_var; 
     269    vlc_value_t oldval; 
    267270 
    268271    vlc_mutex_lock( &p_this->var_lock ); 
     
    365368            CheckValue( p_var, &p_var->val ); 
    366369            break; 
     370        case VLC_VAR_CLEARCHOICES: 
     371            for( i = 0 ; i < p_var->choices.i_count ; i++ ) 
     372            { 
     373                p_var->pf_free( &p_var->choices.p_values[i] ); 
     374            } 
     375            if( p_var->choices.i_count ) 
     376                free( p_var->choices.p_values ); 
     377 
     378            p_var->choices.i_count = 0; 
     379            p_var->choices.p_values = NULL; 
     380            p_var->i_default = -1; 
     381            break; 
    367382        case VLC_VAR_SETDEFAULT: 
    368383            /* FIXME: the list is sorted, dude. Use something cleverer. */ 
     
    384399            CheckValue( p_var, &p_var->val ); 
    385400            break; 
    386  
     401        case VLC_VAR_SETVALUE: 
     402            /* Duplicate data if needed */ 
     403            p_var->pf_dup( p_val ); 
     404            /* Backup needed stuff */ 
     405            oldval = p_var->val; 
     406            /* Check boundaries and list */ 
     407            CheckValue( p_var, p_val ); 
     408            /* Set the variable */ 
     409            p_var->val = *p_val; 
     410            /* Free data if needed */ 
     411            p_var->pf_free( &oldval ); 
     412            break; 
    387413        case VLC_VAR_GETLIST: 
    388414            p_val->p_list = malloc( sizeof(vlc_list_t) );