Commit ec126885 authored by Stéphane Borel's avatar Stéphane Borel

-Working menus for run-time audio/spu/title/chapter selection with gtk

interface.

It is a bit buggy yet, and some pieces of code need to change,
especially to handle better menus change when title change but it
eventually works.
parent 66fc868f
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* control the pace of reading. * control the pace of reading.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-intf.h,v 1.27 2001/03/02 03:32:46 stef Exp $ * $Id: input_ext-intf.h,v 1.28 2001/03/07 10:31:10 stef Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -52,6 +52,8 @@ typedef struct es_descriptor_s ...@@ -52,6 +52,8 @@ typedef struct es_descriptor_s
boolean_t b_audio; /* is the stream an audio stream that boolean_t b_audio; /* is the stream an audio stream that
* will need to be discarded with * will need to be discarded with
* fast forward and slow motion ? */ * fast forward and slow motion ? */
boolean_t b_spu;
char psz_desc[20]; /* description of ES: audio language char psz_desc[20]; /* description of ES: audio language
* for instance ; NULL if not * for instance ; NULL if not
* available */ * available */
...@@ -269,6 +271,8 @@ typedef struct input_thread_s ...@@ -269,6 +271,8 @@ typedef struct input_thread_s
void (* pf_delete_pes)( void *, struct pes_packet_s * ); void (* pf_delete_pes)( void *, struct pes_packet_s * );
/* Stream control capabilities */ /* Stream control capabilities */
int (* pf_set_area)( struct input_thread_s *,
struct input_area_s * );
int (* pf_rewind)( struct input_thread_s * ); int (* pf_rewind)( struct input_thread_s * );
/* NULL if we don't support going * /* NULL if we don't support going *
* backwards (it's gonna be fun) */ * backwards (it's gonna be fun) */
...@@ -348,3 +352,4 @@ void input_SetRate ( struct input_thread_s *, int ); ...@@ -348,3 +352,4 @@ void input_SetRate ( struct input_thread_s *, int );
void input_Seek ( struct input_thread_s *, off_t ); void input_Seek ( struct input_thread_s *, off_t );
void input_DumpStream( struct input_thread_s * ); void input_DumpStream( struct input_thread_s * );
char * input_OffsetToTime( struct input_thread_s *, char * psz_buffer, off_t ); char * input_OffsetToTime( struct input_thread_s *, char * psz_buffer, off_t );
int input_ChangeES ( struct input_thread_s *, struct es_descriptor_s *, int );
...@@ -49,6 +49,9 @@ typedef void * module_handle_t; ...@@ -49,6 +49,9 @@ typedef void * module_handle_t;
#define MODULE_CAPABILITY_AFX 1 << 11 /* Audio effects */ #define MODULE_CAPABILITY_AFX 1 << 11 /* Audio effects */
#define MODULE_CAPABILITY_VFX 1 << 12 /* Video effects */ #define MODULE_CAPABILITY_VFX 1 << 12 /* Video effects */
/* FIXME: kludge */
struct input_area_s;
/* FIXME: not yet used */ /* FIXME: not yet used */
typedef struct probedata_s typedef struct probedata_s
{ {
...@@ -81,9 +84,6 @@ typedef struct function_list_s ...@@ -81,9 +84,6 @@ typedef struct function_list_s
void ( * pf_close )( struct input_thread_s * ); void ( * pf_close )( struct input_thread_s * );
void ( * pf_end ) ( struct input_thread_s * ); void ( * pf_end ) ( struct input_thread_s * );
int ( * pf_set_area ) ( struct input_thread_s *,
int, int, int, int );
int ( * pf_read ) ( struct input_thread_s *, int ( * pf_read ) ( struct input_thread_s *,
struct data_packet_s * struct data_packet_s *
pp_packets[] ); pp_packets[] );
...@@ -95,8 +95,11 @@ typedef struct function_list_s ...@@ -95,8 +95,11 @@ typedef struct function_list_s
void ( * pf_delete_packet ) ( void *, struct data_packet_s * ); void ( * pf_delete_packet ) ( void *, struct data_packet_s * );
void ( * pf_delete_pes ) ( void *, struct pes_packet_s * ); void ( * pf_delete_pes ) ( void *, struct pes_packet_s * );
int ( * pf_rewind ) ( struct input_thread_s * );
void ( * pf_seek ) ( struct input_thread_s *, off_t ); int ( * pf_set_area ) ( struct input_thread_s *,
struct input_area_s * );
int ( * pf_rewind ) ( struct input_thread_s * );
void ( * pf_seek ) ( struct input_thread_s *, off_t );
} input; } input;
/* Audio output plugin */ /* Audio output plugin */
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* -dvd_udf to find files * -dvd_udf to find files
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.30 2001/03/06 10:21:59 massiot Exp $ * $Id: input_dvd.c,v 1.31 2001/03/07 10:31:10 stef Exp $
* *
* Author: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -248,7 +248,7 @@ static int DVDRead ( struct input_thread_s *, data_packet_t ** ); ...@@ -248,7 +248,7 @@ static int DVDRead ( struct input_thread_s *, data_packet_t ** );
static void DVDInit ( struct input_thread_s * ); static void DVDInit ( struct input_thread_s * );
static void DVDEnd ( struct input_thread_s * ); static void DVDEnd ( struct input_thread_s * );
static void DVDSeek ( struct input_thread_s *, off_t ); static void DVDSeek ( struct input_thread_s *, off_t );
static int DVDSetArea ( struct input_thread_s *, int, int, int, int ); static int DVDSetArea ( struct input_thread_s *, struct input_area_s * );
static int DVDRewind ( struct input_thread_s * ); static int DVDRewind ( struct input_thread_s * );
/***************************************************************************** /*****************************************************************************
...@@ -441,13 +441,10 @@ static int DVDChapterSelect( thread_dvd_data_t * p_dvd, int i_chapter ) ...@@ -441,13 +441,10 @@ static int DVDChapterSelect( thread_dvd_data_t * p_dvd, int i_chapter )
* i_audio, i_spu start from 1 ; 0 means off. * i_audio, i_spu start from 1 ; 0 means off.
* A negative value for an argument means it does not change * A negative value for an argument means it does not change
*****************************************************************************/ *****************************************************************************/
static int DVDSetArea( input_thread_t * p_input, static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
int i_title, int i_chapter,
int i_audio, int i_spu )
{ {
thread_dvd_data_t * p_dvd; thread_dvd_data_t * p_dvd;
es_descriptor_t * p_es; es_descriptor_t * p_es;
int i_index;
int i_nb; int i_nb;
u16 i_id; u16 i_id;
u8 i_ac3; u8 i_ac3;
...@@ -455,30 +452,29 @@ static int DVDSetArea( input_thread_t * p_input, ...@@ -455,30 +452,29 @@ static int DVDSetArea( input_thread_t * p_input,
u8 i_sub_pic; u8 i_sub_pic;
u8 i; u8 i;
boolean_t b_last; boolean_t b_last;
p_dvd = (thread_dvd_data_t*)p_input->p_plugin_data; p_dvd = (thread_dvd_data_t*)p_input->p_plugin_data;
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
if( i_title >= 0 ) if( p_area != p_input->stream.p_selected_area )
{ {
/* /*
* We have to load all title information * We have to load all title information
*/ */
/* Change the default area */ /* Change the default area */
p_input->stream.p_selected_area = p_input->stream.pp_areas[i_title]; p_input->stream.p_selected_area = p_input->stream.pp_areas[p_area->i_id];
/* title number: it is not vts nb! */ /* title number: it is not vts nb! */
p_dvd->i_title = i_title; p_dvd->i_title = p_area->i_id;
/* title position inside the selected vts */ /* title position inside the selected vts */
p_dvd->i_vts_title = p_dvd->i_vts_title =
p_dvd->ifo.vmg.ptt_srpt.p_tts[i_title-1].i_vts_ttn; p_dvd->ifo.vmg.ptt_srpt.p_tts[p_dvd->i_title-1].i_vts_ttn;
/* vts number */ /* vts number */
p_dvd->ifo.i_title = i_title; p_dvd->ifo.i_title = p_dvd->i_title;
/* ifo vts */ /* ifo vts */
IfoReadVTS( &(p_dvd->ifo) ); IfoReadVTS( &(p_dvd->ifo) );
...@@ -488,7 +484,7 @@ static int DVDSetArea( input_thread_t * p_input, ...@@ -488,7 +484,7 @@ static int DVDSetArea( input_thread_t * p_input,
if( p_dvd->b_encrypted ) if( p_dvd->b_encrypted )
{ {
p_dvd->p_css->i_title = p_dvd->p_css->i_title =
p_dvd->ifo.vmg.ptt_srpt.p_tts[i_title-1].i_tts_nb; p_dvd->ifo.vmg.ptt_srpt.p_tts[p_dvd->i_title-1].i_tts_nb;
p_dvd->p_css->i_title_pos = p_dvd->p_css->i_title_pos =
p_dvd->ifo.vts.i_pos + p_dvd->ifo.vts.i_pos +
p_dvd->ifo.vts.mat.i_tt_vobs_ssector * DVD_LB_SIZE; p_dvd->ifo.vts.mat.i_tt_vobs_ssector * DVD_LB_SIZE;
...@@ -526,11 +522,11 @@ static int DVDSetArea( input_thread_t * p_input, ...@@ -526,11 +522,11 @@ static int DVDSetArea( input_thread_t * p_input,
lseek( p_input->i_handle, p_dvd->i_start, SEEK_SET ); lseek( p_input->i_handle, p_dvd->i_start, SEEK_SET );
intf_WarnMsg( 2, "dvd info: title: %d", i_title ); intf_WarnMsg( 2, "dvd info: title: %d", p_dvd->i_title );
intf_WarnMsg( 2, "dvd info: vobstart at: %lld", p_dvd->i_start ); intf_WarnMsg( 2, "dvd info: vobstart at: %lld", p_dvd->i_start );
intf_WarnMsg( 2, "dvd info: stream size: %lld", p_dvd->i_size ); intf_WarnMsg( 2, "dvd info: stream size: %lld", p_dvd->i_size );
intf_WarnMsg( 2, "dvd info: number of chapters: %d", intf_WarnMsg( 2, "dvd info: number of chapters: %d",
p_dvd->ifo.vmg.ptt_srpt.p_tts[i_title-1].i_ptt_nb ); p_dvd->ifo.vmg.ptt_srpt.p_tts[p_dvd->i_title-1].i_ptt_nb );
/* intf_WarnMsg( 3, "last: %d index: %d", i_last_chapter, i_index );*/ /* intf_WarnMsg( 3, "last: %d index: %d", i_last_chapter, i_index );*/
...@@ -547,7 +543,19 @@ static int DVDSetArea( input_thread_t * p_input, ...@@ -547,7 +543,19 @@ static int DVDSetArea( input_thread_t * p_input,
*/ */
if( p_input->stream.pp_programs != NULL ) if( p_input->stream.pp_programs != NULL )
{ {
/* We don't use input_EndStream here since
* we keep area structures */
for( i = 0 ; i < p_input->stream.i_selected_es_number ; i++ )
{
input_UnselectES( p_input, p_input->stream.pp_selected_es[i] );
}
input_DelProgram( p_input, p_input->stream.pp_programs[0] ); input_DelProgram( p_input, p_input->stream.pp_programs[0] );
free( p_input->stream.pp_selected_es );
p_input->stream.pp_selected_es = NULL;
p_input->stream.i_selected_es_number = 0;
} }
input_AddProgram( p_input, 0, sizeof( stream_ps_data_t ) ); input_AddProgram( p_input, 0, sizeof( stream_ps_data_t ) );
...@@ -560,6 +568,7 @@ static int DVDSetArea( input_thread_t * p_input, ...@@ -560,6 +568,7 @@ static int DVDSetArea( input_thread_t * p_input,
p_es->i_type = MPEG2_VIDEO_ES; p_es->i_type = MPEG2_VIDEO_ES;
input_SelectES( p_input, p_es ); input_SelectES( p_input, p_es );
intf_WarnMsg( 1, "dvd info: video MPEG2 stream" ); intf_WarnMsg( 1, "dvd info: video MPEG2 stream" );
/* Audio ES, in the order they appear in .ifo */ /* Audio ES, in the order they appear in .ifo */
i_nb = p_dvd->ifo.vts.mat.i_audio_nb; i_nb = p_dvd->ifo.vts.mat.i_audio_nb;
...@@ -648,6 +657,7 @@ static int DVDSetArea( input_thread_t * p_input, ...@@ -648,6 +657,7 @@ static int DVDSetArea( input_thread_t * p_input,
p_input->stream.pp_programs[0], i_id, 0 ); p_input->stream.pp_programs[0], i_id, 0 );
p_es->i_stream_id = 0xbd; p_es->i_stream_id = 0xbd;
p_es->i_type = DVD_SPU_ES; p_es->i_type = DVD_SPU_ES;
p_es->b_spu = 1;
strcpy( p_es->psz_desc, Language( hton16( strcpy( p_es->psz_desc, Language( hton16(
p_dvd->ifo.vts.mat.p_subpic_atrt[i-1].i_lang_code ) ) ); p_dvd->ifo.vts.mat.p_subpic_atrt[i-1].i_lang_code ) ) );
intf_WarnMsg( 1, "dvd info: spu stream %d %s\t(0x%x)", intf_WarnMsg( 1, "dvd info: spu stream %d %s\t(0x%x)",
...@@ -660,84 +670,31 @@ static int DVDSetArea( input_thread_t * p_input, ...@@ -660,84 +670,31 @@ static int DVDSetArea( input_thread_t * p_input,
} }
} // i_title >= 0 } // i_title >= 0
else
/*
* Select requested ES
*/
if( ( i_audio >= 0 ) || ( i_title >= 0 ) )
{
/* Audio: we check it is in the range and
* default it to the first if not */
if( i_audio > p_dvd->ifo.vts.mat.i_audio_nb )
{
i_audio = 1;
}
p_es = p_input->stream.pp_programs[0]->pp_es[i_audio];
/* We can only have one audio channel */
/* Look for a preselected one */
i_index = -1;
for( i = 0 ; i < p_input->stream.i_selected_es_number ; i++ )
{
if( p_input->stream.pp_selected_es[i]->b_audio )
{
i_index = i;
break;
}
}
if( i_index != -1 )
{
if( p_input->stream.pp_selected_es[i_index] != p_es )
{
input_UnselectES( p_input,
p_input->stream.pp_selected_es[i_index] );
input_SelectES( p_input, p_es );
intf_WarnMsg( 1, "dvd info: audio %d selected -> %s (0x%x)",
i_audio, p_es->psz_desc, p_es->i_id );
}
}
else
{
input_SelectES( p_input, p_es );
intf_WarnMsg( 1, "dvd info: audio %d selected -> %s (0x%x)",
i_audio, p_es->psz_desc, p_es->i_id );
}
}
if( ( i_spu >= 0 ) || ( i_title >= 0 ) )
{ {
/* For spu: no one if none or a not existing one requested */ p_area = p_input->stream.p_selected_area;
if( ( i_spu <= p_dvd->ifo.vts.mat.i_subpic_nb ) && ( i_spu > 0 ) )
{
input_SelectES( p_input, ( p_es = p_input->stream.pp_programs[0]->
pp_es[ i_spu + p_dvd->ifo.vts.mat.i_audio_nb ] ) );
intf_WarnMsg( 1, "dvd info: spu %d selected -> %s (0x%x)",
i_spu, p_es->psz_desc, p_es->i_id );
}
} }
/* /*
* Chapter selection * Chapter selection
*/ */
if( ( i_chapter > 0 ) && if( ( p_area->i_part > 0 ) &&
( i_chapter <= p_input->stream.p_selected_area->i_part_nb ) ) ( p_area->i_part <= p_area->i_part_nb ) )
{ {
DVDChapterSelect( p_dvd, i_chapter ); DVDChapterSelect( p_dvd, p_area->i_part );
p_input->stream.p_selected_area->i_tell = p_dvd->i_start - p_input->stream.p_selected_area->i_tell = p_dvd->i_start -
p_input->stream.p_selected_area->i_start; p_area->i_start;
p_input->stream.p_selected_area->i_part = p_dvd->i_chapter; p_input->stream.p_selected_area->i_part = p_dvd->i_chapter;
intf_WarnMsg( 2, "dvd info: chapter %d start at: %lld", i_chapter, intf_WarnMsg( 2, "dvd info: chapter %d start at: %lld",
p_input->stream.p_selected_area->i_tell ); p_area->i_part, p_area->i_tell );
} }
/* By default first audio stream and no spu */
input_SelectES( p_input, p_input->stream.pp_es[1] );
/* No PSM to read in DVD mode, we already have all information */ /* No PSM to read in DVD mode, we already have all information */
p_input->stream.pp_programs[0]->b_is_ok = 1; p_input->stream.pp_programs[0]->b_is_ok = 1;
...@@ -779,7 +736,8 @@ static void DVDInit( input_thread_t * p_input ) ...@@ -779,7 +736,8 @@ static void DVDInit( input_thread_t * p_input )
/* Reading structures initialisation */ /* Reading structures initialisation */
p_input->p_method_data = p_input->p_method_data =
DVDNetlistInit( 4096, 8192, 4096, DVD_LB_SIZE, p_dvd->i_block_once ); // DVDNetlistInit( 4096, 8192, 4096, DVD_LB_SIZE, p_dvd->i_block_once );
DVDNetlistInit( 8192, 16384, 16384, DVD_LB_SIZE, p_dvd->i_block_once );
intf_WarnMsg( 2, "dvd info: netlist initialized" ); intf_WarnMsg( 2, "dvd info: netlist initialized" );
/* Ifo initialisation */ /* Ifo initialisation */
...@@ -845,7 +803,6 @@ static void DVDInit( input_thread_t * p_input ) ...@@ -845,7 +803,6 @@ static void DVDInit( input_thread_t * p_input )
i_title = 1; i_title = 1;
} }
#undef srpt #undef srpt
/* Get requested chapter - if none defaults to first one */ /* Get requested chapter - if none defaults to first one */
i_chapter = main_GetIntVariable( INPUT_CHAPTER_VAR, 1 ); i_chapter = main_GetIntVariable( INPUT_CHAPTER_VAR, 1 );
if( i_chapter <= 0 ) if( i_chapter <= 0 )
...@@ -853,6 +810,9 @@ static void DVDInit( input_thread_t * p_input ) ...@@ -853,6 +810,9 @@ static void DVDInit( input_thread_t * p_input )
i_chapter = 1; i_chapter = 1;
} }
p_input->stream.pp_areas[i_title]->i_part = i_chapter;
DVDSetArea( p_input, p_input->stream.pp_areas[i_title] );
/* For audio: first one if none or a not existing one specified */ /* For audio: first one if none or a not existing one specified */
i_audio = main_GetIntVariable( INPUT_CHANNEL_VAR, 1 ); i_audio = main_GetIntVariable( INPUT_CHANNEL_VAR, 1 );
if( i_audio <= 0 ) if( i_audio <= 0 )
...@@ -861,9 +821,17 @@ static void DVDInit( input_thread_t * p_input ) ...@@ -861,9 +821,17 @@ static void DVDInit( input_thread_t * p_input )
i_audio = 1; i_audio = 1;
} }
input_ChangeES( p_input, p_input->stream.pp_es[i_audio], 1 );
i_spu = main_GetIntVariable( INPUT_SUBTITLE_VAR, 0 ); i_spu = main_GetIntVariable( INPUT_SUBTITLE_VAR, 0 );
if( i_spu < 0 )
{
main_PutIntVariable( INPUT_CHANNEL_VAR, 1 );
i_spu = 0;
}
// input_ChangeES( p_input, p_input->stream.pp_es[i_spu], 1 );
DVDSetArea( p_input, i_title, i_chapter, i_audio, i_spu );
return; return;
} }
...@@ -922,7 +890,7 @@ static int DVDRead( input_thread_t * p_input, ...@@ -922,7 +890,7 @@ static int DVDRead( input_thread_t * p_input,
} }
/* Get the position of the next cell if we're at cell end */ /* Get the position of the next cell if we're at cell end */
#if 1
if( p_dvd->i_sector > p_dvd->i_end_sector ) if( p_dvd->i_sector > p_dvd->i_end_sector )
{ {
/* Find cell index in adress map */ /* Find cell index in adress map */
...@@ -949,16 +917,16 @@ static int DVDRead( input_thread_t * p_input, ...@@ -949,16 +917,16 @@ static int DVDRead( input_thread_t * p_input,
p_dvd->i_chapter = i_chapter; p_dvd->i_chapter = i_chapter;
vlc_mutex_lock( &p_input->stream.stream_lock ); // vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.p_selected_area->i_tell = i_off - p_input->stream.p_selected_area->i_tell = i_off -
p_input->stream.p_selected_area->i_start; p_input->stream.p_selected_area->i_start;
p_input->stream.p_selected_area->i_part = p_dvd->i_chapter; p_input->stream.p_selected_area->i_part = p_dvd->i_chapter;
vlc_mutex_unlock( &p_input->stream.stream_lock ); // vlc_mutex_unlock( &p_input->stream.stream_lock );
} }
#endif
/* Reads from DVD */ /* Reads from DVD */
i_read_bytes = readv( p_dvd->i_fd, p_vec, p_dvd->i_block_once ); i_read_bytes = readv( p_dvd->i_fd, p_vec, p_dvd->i_block_once );
i_read_blocks = ( i_read_bytes + 0x7ff ) >> 11; i_read_blocks = ( i_read_bytes + 0x7ff ) >> 11;
...@@ -1036,13 +1004,13 @@ static int DVDRead( input_thread_t * p_input, ...@@ -1036,13 +1004,13 @@ static int DVDRead( input_thread_t * p_input,
pp_packets[i_packet] = NULL; pp_packets[i_packet] = NULL;
vlc_mutex_lock( &p_input->stream.stream_lock ); // vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.p_selected_area->i_tell += p_input->stream.p_selected_area->i_tell +=
p_dvd->i_block_once *DVD_LB_SIZE; p_dvd->i_block_once *DVD_LB_SIZE;
b_eof = p_input->stream.p_selected_area->i_tell < p_dvd->i_size ? 0 : 1; b_eof = p_input->stream.p_selected_area->i_tell < p_dvd->i_size ? 0 : 1;
vlc_mutex_unlock( &p_input->stream.stream_lock ); // vlc_mutex_unlock( &p_input->stream.stream_lock );
if( ( i_read_blocks == p_dvd->i_block_once ) && ( !b_eof ) ) if( ( i_read_blocks == p_dvd->i_block_once ) && ( !b_eof ) )
{ {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* Stphane Borel <stef@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -733,3 +734,101 @@ on_popup_disc_activate (GtkMenuItem *menuitem, ...@@ -733,3 +734,101 @@ on_popup_disc_activate (GtkMenuItem *menuitem,
gdk_window_raise( p_intf->p_sys->p_disc->window ); gdk_window_raise( p_intf->p_sys->p_disc->window );
} }
void
on_popup_audio_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
es_descriptor_t * p_es;
p_es = (es_descriptor_t*)user_data;
input_ChangeES( p_intf->p_input, p_es, 1 );
}
void
on_popup_subpictures_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
es_descriptor_t * p_es;
p_es = (es_descriptor_t*)user_data;
input_ChangeES( p_intf->p_input, p_es, 2 );
}
void
on_menubar_audio_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
es_descriptor_t * p_es;
p_es = (es_descriptor_t*)user_data;
input_ChangeES( p_intf->p_input, p_es, 1 );
}
void
on_menubar_subpictures_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
es_descriptor_t * p_es;
p_es = (es_descriptor_t*)user_data;
input_ChangeES( p_intf->p_input, p_es, 2 );
}
void
on_popup_navigation_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_popup" );
input_area_t * p_area;
gint i_title;
gint i_chapter;
i_title = (gint)(user_data) / 100 ;
i_chapter = (gint)(user_data) - ( 100 * i_title );
fprintf(stderr, "title %d chapter %d\n", i_title, i_chapter );
p_area = p_intf->p_input->stream.pp_areas[i_title];
p_area->i_part = i_chapter;
p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
}
void
on_menubar_title_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)user_data );
p_intf->p_sys->b_menus_update = 1;
input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
}
void
on_menubar_chapter_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
input_area_t * p_area = p_intf->p_input->stream.p_selected_area;
gint i_chapter = (gint)user_data;
p_area->i_part = i_chapter;
p_intf->p_input->pf_set_area( p_intf->p_input, (input_area_t*)p_area );
input_SetStatus( p_intf->p_input, INPUT_STATUS_PLAY );
}
...@@ -185,3 +185,31 @@ on_toolbar_disc_clicked (GtkButton *button, ...@@ -185,3 +185,31 @@ on_toolbar_disc_clicked (GtkButton *button,
void void
on_popup_disc_activate (GtkMenuItem *menuitem, on_popup_disc_activate (GtkMenuItem *menuitem,
gpointer user_data); gpointer user_data);
void
on_popup_audio_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_popup_subpictures_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menubar_audio_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menubar_subpictures_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_popup_navigation_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menubar_title_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menubar_chapter_activate (GtkMenuItem *menuitem,
gpointer user_data);
...@@ -36,11 +36,18 @@ create_intf_window (void) ...@@ -36,11 +36,18 @@ create_intf_window (void)
GtkWidget *menubar_view; GtkWidget *menubar_view;
GtkWidget *menubar_view_menu; GtkWidget *menubar_view_menu;
GtkAccelGroup *menubar_view_menu_accels; GtkAccelGroup *menubar_view_menu_accels;
GtkWidget *menubar_title;
GtkWidget *menubar_chapter;
GtkWidget *separator11;
GtkWidget *menubar_playlist; GtkWidget *menubar_playlist;
GtkWidget *menubar_modules; GtkWidget *menubar_modules;
GtkWidget *menubar_settings; GtkWidget *menubar_settings;
GtkWidget *menubar_settings_menu; GtkWidget *menubar_settings_menu;
GtkAccelGroup *menubar_settings_menu_accels; GtkAccelGroup *menubar_settings_menu_accels;
GtkWidget *separator7;
GtkWidget *menubar_audio;
GtkWidget *menubar_subpictures;
GtkWidget *separator8;
GtkWidget *menubar_preferences; GtkWidget *menubar_preferences;
GtkWidget *menubar_help; GtkWidget *menubar_help;
GtkWidget *menubar_help_menu; GtkWidget *menubar_help_menu;
...@@ -182,6 +189,39 @@ create_intf_window (void) ...@@ -182,6 +189,39 @@ create_intf_window (void)
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menubar_view), menubar_view_menu); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menubar_view), menubar_view_menu);
menubar_view_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (menubar_view_menu)); menubar_view_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (menubar_view_menu));
menubar_title = gtk_menu_item_new_with_label ("");
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menubar_title)->child),
_("_Title"));
gtk_widget_add_accelerator (menubar_title, "activate_item", menubar_view_menu_accels,
tmp_key, 0, 0);
gtk_widget_ref (menubar_title);
gtk_object_set_data_full (GTK_OBJECT (intf_window), "menubar_title", menubar_title,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (menubar_title);
gtk_container_add (GTK_CONTAINER (menubar_view_menu), menubar_title);
gtk_widget_set_sensitive (menubar_title, FALSE);
gtk_tooltips_set_tip (tooltips, menubar_title, _("Navigate through the stream"), NULL);
menubar_chapter = gtk_menu_item_new_with_label ("");
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menubar_chapter)->child),
_("_Chapter"));
gtk_widget_add_accelerator (menubar_chapter, "activate_item", menubar_view_menu_accels,
tmp_key, 0, 0);
gtk_widget_ref (menubar_chapter);
gtk_object_set_data_full (GTK_OBJECT (intf_window), "menubar_chapter", menubar_chapter,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (menubar_chapter);
gtk_container_add (GTK_CONTAINER (menubar_view_menu), menubar_chapter);
gtk_widget_set_sensitive (menubar_chapter, FALSE);
separator11 = gtk_menu_item_new ();
gtk_widget_ref (separator11);
gtk_object_set_data_full (GTK_OBJECT (intf_window), "separator11", separator11,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (separator11);
gtk_container_add (GTK_CONTAINER (menubar_view_menu), separator11);
gtk_widget_set_sensitive (separator11, FALSE);
menubar_playlist = gtk_menu_item_new_with_label (""); menubar_playlist = gtk_menu_item_new_with_label ("");
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menubar_playlist)->child), tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menubar_playlist)->child),
_("_Playlist...")); _("_Playlist..."));
...@@ -226,6 +266,48 @@ create_intf_window (void) ...@@ -226,6 +266,48 @@ create_intf_window (void)
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menubar_settings), menubar_settings_menu); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menubar_settings), menubar_settings_menu);
menubar_settings_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (menubar_settings_menu)); menubar_settings_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (menubar_settings_menu));
separator7 = gtk_menu_item_new ();
gtk_widget_ref (separator7);
gtk_object_set_data_full (GTK_OBJECT (intf_window), "separator7", separator7,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (separator7);
gtk_container_add (GTK_CONTAINER (menubar_settings_menu), separator7);
gtk_widget_set_sensitive (separator7, FALSE);
menubar_audio = gtk_menu_item_new_with_label ("");
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menubar_audio)->child),
_("A_udio"));
gtk_widget_add_accelerator (menubar_audio, "activate_item", menubar_settings_menu_accels,
tmp_key, 0, 0);
gtk_widget_ref (menubar_audio);
gtk_object_set_data_full (GTK_OBJECT (intf_window), "menubar_audio", menubar_audio,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (menubar_audio);
gtk_container_add (GTK_CONTAINER (menubar_settings_menu), menubar_audio);
gtk_widget_set_sensitive (menubar_audio, FALSE);
gtk_tooltips_set_tip (tooltips, menubar_audio, _("Select audio language"), NULL);
menubar_subpictures = gtk_menu_item_new_with_label ("");
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menubar_subpictures)->child),
_("Sub _Pictures"));
gtk_widget_add_accelerator (menubar_subpictures, "activate_item", menubar_settings_menu_accels,
tmp_key, 0, 0);
gtk_widget_ref (menubar_subpictures);
gtk_object_set_data_full (GTK_OBJECT (intf_window), "menubar_subpictures", menubar_subpictures,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (menubar_subpictures);
gtk_container_add (GTK_CONTAINER (menubar_settings_menu), menubar_subpictures);
gtk_widget_set_sensitive (menubar_subpictures, FALSE);
gtk_tooltips_set_tip (tooltips, menubar_subpictures, _("Select sub-title"), NULL);
separator8 = gtk_menu_item_new ();
gtk_widget_ref (separator8);
gtk_object_set_data_full (GTK_OBJECT (intf_window), "separator8", separator8,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (separator8);
gtk_container_add (GTK_CONTAINER (menubar_settings_menu), separator8);
gtk_widget_set_sensitive (separator8, FALSE);
menubar_preferences = gtk_menu_item_new_with_label (""); menubar_preferences = gtk_menu_item_new_with_label ("");
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menubar_preferences)->child), tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menubar_preferences)->child),
_("_Preferences...")); _("_Preferences..."));
...@@ -545,6 +627,11 @@ create_intf_popup (void) ...@@ -545,6 +627,11 @@ create_intf_popup (void)
GtkWidget *popup_open; GtkWidget *popup_open;
GtkWidget *popup_disc; GtkWidget *popup_disc;
GtkWidget *separator5; GtkWidget *separator5;
GtkWidget *popup_navigation;
GtkWidget *separator10;
GtkWidget *popup_audio;
GtkWidget *popup_subpictures;
GtkWidget *separator9;
GtkWidget *popup_about; GtkWidget *popup_about;
GtkWidget *popup_exit; GtkWidget *popup_exit;
GtkTooltips *tooltips; GtkTooltips *tooltips;
...@@ -627,6 +714,54 @@ create_intf_popup (void) ...@@ -627,6 +714,54 @@ create_intf_popup (void)
gtk_container_add (GTK_CONTAINER (intf_popup), separator5); gtk_container_add (GTK_CONTAINER (intf_popup), separator5);
gtk_widget_set_sensitive (separator5, FALSE); gtk_widget_set_sensitive (separator5, FALSE);
popup_navigation = gtk_menu_item_new_with_label (_("Navigation"));
gtk_widget_ref (popup_navigation);
gtk_object_set_data_full (GTK_OBJECT (intf_popup), "popup_navigation", popup_navigation,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (popup_navigation);
gtk_container_add (GTK_CONTAINER (intf_popup), popup_navigation);
gtk_widget_set_sensitive (popup_navigation, FALSE);
separator10 = gtk_menu_item_new ();
gtk_widget_ref (separator10);
gtk_object_set_data_full (GTK_OBJECT (intf_popup), "separator10", separator10,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (separator10);
gtk_container_add (GTK_CONTAINER (intf_popup), separator10);
gtk_widget_set_sensitive (separator10, FALSE);
popup_audio = gtk_menu_item_new_with_label ("");
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (popup_audio)->child),
_("A_udio"));
gtk_widget_add_accelerator (popup_audio, "activate_item", intf_popup_accels,
tmp_key, 0, 0);
gtk_widget_ref (popup_audio);
gtk_object_set_data_full (GTK_OBJECT (intf_popup), "popup_audio", popup_audio,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (popup_audio);
gtk_container_add (GTK_CONTAINER (intf_popup), popup_audio);
gtk_widget_set_sensitive (popup_audio, FALSE);
popup_subpictures = gtk_menu_item_new_with_label ("");
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (popup_subpictures)->child),
_("Sub _Pictures"));
gtk_widget_add_accelerator (popup_subpictures, "activate_item", intf_popup_accels,
tmp_key, 0, 0);
gtk_widget_ref (popup_subpictures);
gtk_object_set_data_full (GTK_OBJECT (intf_popup), "popup_subpictures", popup_subpictures,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (popup_subpictures);
gtk_container_add (GTK_CONTAINER (intf_popup), popup_subpictures);
gtk_widget_set_sensitive (popup_subpictures, FALSE);
separator9 = gtk_menu_item_new ();
gtk_widget_ref (separator9);
gtk_object_set_data_full (GTK_OBJECT (intf_popup), "separator9", separator9,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (separator9);
gtk_container_add (GTK_CONTAINER (intf_popup), separator9);
gtk_widget_set_sensitive (separator9, FALSE);
popup_about = gtk_menu_item_new_with_label (""); popup_about = gtk_menu_item_new_with_label ("");
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (popup_about)->child), tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (popup_about)->child),
_("_About...")); _("_About..."));
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk_sys.h: private Gtk+ interface description * gtk_sys.h: private Gtk+ interface description
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: gtk_sys.h,v 1.2 2001/03/04 03:12:00 sam Exp $ * $Id: gtk_sys.h,v 1.3 2001/03/07 10:31:10 stef Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -38,6 +38,7 @@ typedef struct intf_sys_s ...@@ -38,6 +38,7 @@ typedef struct intf_sys_s
boolean_t b_popup_changed; /* display menu ? */ boolean_t b_popup_changed; /* display menu ? */
boolean_t b_window_changed; /* window display toggled ? */ boolean_t b_window_changed; /* window display toggled ? */
boolean_t b_playlist_changed; /* playlist display toggled ? */ boolean_t b_playlist_changed; /* playlist display toggled ? */
boolean_t b_menus_update; /* menus have changed ? */
boolean_t b_scale_isfree; /* user isn't dragging scale ? */ boolean_t b_scale_isfree; /* user isn't dragging scale ? */
/* intf_Manage callback timeout */ /* intf_Manage callback timeout */
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
* intf_gtk.c: Gtk+ interface * intf_gtk.c: Gtk+ interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: intf_gtk.c,v 1.3 2001/03/05 01:29:25 sam Exp $ * $Id: intf_gtk.c,v 1.4 2001/03/07 10:31:10 stef Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* Stphane Borel <stef@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -50,6 +51,7 @@ ...@@ -50,6 +51,7 @@
#include "interface.h" #include "interface.h"
#include "gtk_sys.h" #include "gtk_sys.h"
#include "gtk_callbacks.h"
#include "gtk_interface.h" #include "gtk_interface.h"
#include "gtk_support.h" #include "gtk_support.h"
...@@ -58,12 +60,19 @@ ...@@ -58,12 +60,19 @@
/***************************************************************************** /*****************************************************************************
* Local prototypes. * Local prototypes.
*****************************************************************************/ *****************************************************************************/
static int intf_Probe ( probedata_t *p_data ); static int intf_Probe ( probedata_t *p_data );
static int intf_Open ( intf_thread_t *p_intf ); static int intf_Open ( intf_thread_t *p_intf );
static void intf_Close ( intf_thread_t *p_intf ); static void intf_Close ( intf_thread_t *p_intf );
static void intf_Run ( intf_thread_t *p_intf ); static void intf_Run ( intf_thread_t *p_intf );
static gint GtkManage ( gpointer p_data );
static gint GtkLanguageMenus( gpointer, GtkWidget *, es_descriptor_t *, gint,
void (*pf_activate)(GtkMenuItem *, gpointer) );
static gint GtkChapterMenu ( gpointer, GtkWidget *,
void (*pf_activate)(GtkMenuItem *, gpointer) );
static gint GtkTitleMenu ( gpointer, GtkWidget *,
void (*pf_activate)(GtkMenuItem *, gpointer) );
static gint GtkManage ( gpointer p_data );
/***************************************************************************** /*****************************************************************************
* g_atexit: kludge to avoid the Gtk+ thread to segfault at exit * g_atexit: kludge to avoid the Gtk+ thread to segfault at exit
...@@ -135,6 +144,7 @@ static int intf_Open( intf_thread_t *p_intf ) ...@@ -135,6 +144,7 @@ static int intf_Open( intf_thread_t *p_intf )
p_intf->p_sys->b_window_changed = 0; p_intf->p_sys->b_window_changed = 0;
p_intf->p_sys->b_playlist_changed = 0; p_intf->p_sys->b_playlist_changed = 0;
p_intf->p_sys->b_menus_update = 1;
p_intf->p_sys->b_scale_isfree = 1; p_intf->p_sys->b_scale_isfree = 1;
p_intf->p_sys->pf_gtk_callback = NULL; p_intf->p_sys->pf_gtk_callback = NULL;
...@@ -214,6 +224,7 @@ static void intf_Run( intf_thread_t *p_intf ) ...@@ -214,6 +224,7 @@ static void intf_Run( intf_thread_t *p_intf )
/* Show the control window */ /* Show the control window */
gtk_widget_show( p_intf->p_sys->p_window ); gtk_widget_show( p_intf->p_sys->p_window );
/* Sleep to avoid using all CPU - since some interfaces needs to access /* Sleep to avoid using all CPU - since some interfaces needs to access
* keyboard events, a 100ms delay is a good compromise */ * keyboard events, a 100ms delay is a good compromise */
p_intf->p_sys->i_timeout = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, p_intf->p_sys->i_timeout = gtk_timeout_add( INTF_IDLE_SLEEP / 1000,
...@@ -263,6 +274,80 @@ static gint GtkManage( gpointer p_data ) ...@@ -263,6 +274,80 @@ static gint GtkManage( gpointer p_data )
p_intf->b_menu_change = 0; p_intf->b_menu_change = 0;
} }
/* Update language/chapter menus after user request */
if( p_intf->p_input != NULL && p_intf->p_sys->p_window != NULL &&
p_intf->p_sys->b_menus_update )
{
es_descriptor_t * p_audio_es;
es_descriptor_t * p_spu_es;
GtkWidget * p_menubar_menu;
GtkWidget * p_popup_menu;
gint i;
p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_window ), "menubar_title" ) );
GtkTitleMenu( p_intf, p_menubar_menu, on_menubar_title_activate );
p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_window ), "menubar_chapter" ) );
GtkChapterMenu( p_intf, p_menubar_menu, on_menubar_chapter_activate );
p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_popup ), "popup_navigation" ) );
GtkTitleMenu( p_intf, p_popup_menu, on_popup_navigation_activate );
/* look for selected ES */
p_audio_es = NULL;
p_spu_es = NULL;
for( i = 0 ; i < p_intf->p_input->stream.i_selected_es_number ; i++ )
{
if( p_intf->p_input->stream.pp_es[i]->b_audio )
{
p_audio_es = p_intf->p_input->stream.pp_es[i];
}
if( p_intf->p_input->stream.pp_es[i]->b_spu )
{
p_spu_es = p_intf->p_input->stream.pp_es[i];
}
}
/* audio menus */
/* find audio root menu */
p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_window ), "menubar_audio" ) );
p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_popup ), "popup_audio" ) );
GtkLanguageMenus( p_intf, p_menubar_menu, p_audio_es, 1,
on_menubar_audio_activate );
GtkLanguageMenus( p_intf, p_popup_menu, p_audio_es, 1,
on_popup_audio_activate );
/* sub picture menus */
/* find spu root menu */
p_menubar_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_window ), "menubar_subpictures" ) );
p_popup_menu = GTK_WIDGET( gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_popup ), "popup_subpictures" ) );
GtkLanguageMenus( p_intf, p_menubar_menu, p_spu_es, 2,
on_menubar_subpictures_activate );
GtkLanguageMenus( p_intf, p_popup_menu, p_spu_es, 2,
on_popup_subpictures_activate );
/* everything is ready */
p_intf->p_sys->b_menus_update = 0;
}
/* Manage the slider */ /* Manage the slider */
if( p_intf->p_input != NULL && p_intf->p_sys->p_window != NULL if( p_intf->p_input != NULL && p_intf->p_sys->p_window != NULL
&& p_intf->p_sys->b_scale_isfree ) && p_intf->p_sys->b_scale_isfree )
...@@ -306,3 +391,289 @@ static gint GtkManage( gpointer p_data ) ...@@ -306,3 +391,289 @@ static gint GtkManage( gpointer p_data )
return( TRUE ); return( TRUE );
} }
/*****************************************************************************
* GtkMenuRadioItem: give a menu item adapted to language/title selection,
* ie the menu item is a radio button.
*****************************************************************************/
static GtkWidget * GtkMenuRadioItem( GtkWidget * p_menu,
GSList ** p_button_group,
gint b_active,
char * psz_name )
{
GtkWidget * p_item;
#if 0
GtkWidget * p_button;
/* create button */
p_button =
gtk_radio_button_new_with_label( *p_button_group, psz_name );
/* add button to group */
*p_button_group =
gtk_radio_button_group( GTK_RADIO_BUTTON( p_button ) );
/* prepare button for display */
gtk_widget_show( p_button );
/* create menu item to store button */
p_item = gtk_menu_item_new();
/* put button inside item */
gtk_container_add( GTK_CONTAINER( p_item ), p_button );
/* add item to menu */
gtk_menu_append( GTK_MENU( p_menu ), p_item );
gtk_signal_connect( GTK_OBJECT( p_item ), "activate",
GTK_SIGNAL_FUNC( on_audio_toggle ),
NULL );
/* prepare item for display */
gtk_widget_show( p_item );
/* is it the selected item ? */
if( b_active )
{
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( p_button ), TRUE );
}
#else
p_item = gtk_menu_item_new_with_label( psz_name );
gtk_menu_append( GTK_MENU( p_menu ), p_item );
gtk_widget_show( p_item );
#endif
return p_item;
}
/*****************************************************************************
* GtkLanguageMenus: update interactive menus of the interface
*****************************************************************************
* Sets up menus with information from input:
* -languages
* -sub-pictures
* Warning: since this function is designed to be called by management
* function, the interface lock has to be taken
*****************************************************************************/
static gint GtkLanguageMenus( gpointer p_data,
GtkWidget * p_root,
es_descriptor_t * p_es,
gint i_type,
void(*pf_activate )( GtkMenuItem *, gpointer ) )
{
intf_thread_t * p_intf;
GtkWidget * p_menu;
GtkWidget * p_separator;
GtkWidget * p_item;
GSList * p_button_group;
char * psz_name;
gint b_active;
gint b_audio;
gint b_spu;
gint i;
/* cast */
p_intf = (intf_thread_t *)p_data;
vlc_mutex_lock( &p_intf->p_input->stream.stream_lock );
b_audio = ( i_type == 1 );
p_button_group = NULL;
/* menu container for audio */
p_menu = gtk_menu_new();
/* create a set of language buttons and append them to the container */
b_active = ( p_es == NULL ) ? 1 : 0;
psz_name = "Off";
p_item = GtkMenuRadioItem( p_menu, &p_button_group, b_active, psz_name );
/* setup signal hanling */
gtk_signal_connect( GTK_OBJECT( p_item ), "activate",
GTK_SIGNAL_FUNC ( pf_activate ), NULL );
p_separator = gtk_menu_item_new();
gtk_widget_show( p_separator );
gtk_menu_append( GTK_MENU( p_menu ), p_separator );
gtk_widget_set_sensitive( p_separator, FALSE );
for( i = 0 ; i < p_intf->p_input->stream.i_es_number ; i++ )
{
b_audio = ( i_type == 1 ) && p_intf->p_input->stream.pp_es[i]->b_audio;
b_spu = ( i_type == 2 ) && p_intf->p_input->stream.pp_es[i]->b_spu;
if( b_audio || b_spu )
{
b_active = ( p_es == p_intf->p_input->stream.pp_es[i] ) ? 1 : 0;
psz_name = p_intf->p_input->stream.pp_es[i]->psz_desc;
p_item = GtkMenuRadioItem( p_menu, &p_button_group,
b_active, psz_name );
/* setup signal hanling */
gtk_signal_connect( GTK_OBJECT( p_item ), "activate",
GTK_SIGNAL_FUNC( pf_activate ),
(gpointer)( p_intf->p_input->stream.pp_es[i] ) );
}
}
/* link the new menu to the menubar item */
gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );
/* be sure that menu is sensitive */
gtk_widget_set_sensitive( p_root, TRUE );
vlc_mutex_unlock( &p_intf->p_input->stream.stream_lock );
return TRUE;
}
/*****************************************************************************
* GtkChapterMenu: generate chapter menu foir current title
*****************************************************************************/
static gint GtkChapterMenu( gpointer p_data, GtkWidget * p_chapter,
void(*pf_activate )( GtkMenuItem *, gpointer ) )
{
intf_thread_t * p_intf;
char psz_name[10];
GtkWidget * p_chapter_menu;
GtkWidget * p_item;
GSList * p_chapter_button_group;
gint i_title;
gint i_chapter;
gint b_active;
/* cast */
p_intf = (intf_thread_t*)p_data;
i_title = p_intf->p_input->stream.p_selected_area->i_id;
p_chapter_menu = gtk_menu_new();
for( i_chapter = 0;
i_chapter < p_intf->p_input->stream.pp_areas[i_title]->i_part_nb ;
i_chapter++ )
{
b_active = ( p_intf->p_input->stream.pp_areas[i_title]->i_part
== i_chapter + 1 ) ? 1 : 0;
sprintf( psz_name, "Chapter %d", i_chapter + 1 );
p_item = GtkMenuRadioItem( p_chapter_menu, &p_chapter_button_group,
b_active, psz_name );
/* setup signal hanling */
gtk_signal_connect( GTK_OBJECT( p_item ),
"activate",
GTK_SIGNAL_FUNC( pf_activate ),
(gpointer)(i_chapter + 1) );
}
/* link the new menu to the title menu item */
gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_chapter ),
p_chapter_menu );
/* be sure that chapter menu is sensitive */
gtk_widget_set_sensitive( p_chapter, TRUE );
return TRUE;
}
/*****************************************************************************
* GtkTitleMenu: sets menus for titles and chapters selection
* ---
* Generates two type of menus:
* -simple list of titles
* -cascaded lists of chapters for each title
*****************************************************************************/
static gint GtkTitleMenu( gpointer p_data,
GtkWidget * p_navigation,
void(*pf_activate )( GtkMenuItem *, gpointer ) )
{
intf_thread_t * p_intf;
char psz_name[10];
GtkWidget * p_title_menu;
GtkWidget * p_title_item;
GtkWidget * p_chapter_menu;
GtkWidget * p_item;
GSList * p_title_button_group;
GSList * p_chapter_button_group;
gint i_title;
gint i_chapter;
gint b_active;
/* cast */
p_intf = (intf_thread_t*)p_data;
p_title_menu = gtk_menu_new();
p_title_button_group = NULL;
p_chapter_button_group = NULL;
/* loop on titles */
for( i_title = 1 ;
i_title < p_intf->p_input->stream.i_area_nb ;
i_title++ )
{
b_active = ( p_intf->p_input->stream.pp_areas[i_title] ==
p_intf->p_input->stream.p_selected_area ) ? 1 : 0;
sprintf( psz_name, "Title %d", i_title );
p_title_item = GtkMenuRadioItem( p_title_menu, &p_title_button_group,
b_active, psz_name );
if( pf_activate == on_menubar_title_activate )
{
/* setup signal hanling */
gtk_signal_connect( GTK_OBJECT( p_title_item ),
"activate",
GTK_SIGNAL_FUNC( pf_activate ),
(gpointer)(p_intf->p_input->stream.pp_areas[i_title]) );
}
else
{
p_chapter_menu = gtk_menu_new();
for( i_chapter = 0;
i_chapter <
p_intf->p_input->stream.pp_areas[i_title]->i_part_nb ;
i_chapter++ )
{
b_active = ( p_intf->p_input->stream.pp_areas[i_title]->i_part
== i_chapter + 1 ) ? 1 : 0;
sprintf( psz_name, "Chapter %d", i_chapter + 1 );
p_item = GtkMenuRadioItem( p_chapter_menu,
&p_chapter_button_group,
b_active, psz_name );
/* setup signal hanling */
gtk_signal_connect( GTK_OBJECT( p_item ),
"activate",
GTK_SIGNAL_FUNC( pf_activate ),
(gpointer)( ( i_title * 100 ) + ( i_chapter + 1) ) );
}
/* link the new menu to the title menu item */
gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_title_item ),
p_chapter_menu );
}
/* be sure that chapter menu is sensitive */
gtk_widget_set_sensitive( p_title_menu, TRUE );
}
/* link the new menu to the menubar audio item */
gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_navigation ), p_title_menu );
/* be sure that audio menu is sensitive */
gtk_widget_set_sensitive( p_navigation, TRUE );
return TRUE;
}
...@@ -142,6 +142,29 @@ ...@@ -142,6 +142,29 @@
<class>GtkMenu</class> <class>GtkMenu</class>
<name>menubar_view_menu</name> <name>menubar_view_menu</name>
<widget>
<class>GtkMenuItem</class>
<name>menubar_title</name>
<sensitive>False</sensitive>
<tooltip>Navigate through the stream</tooltip>
<label>_Title</label>
<right_justify>False</right_justify>
</widget>
<widget>
<class>GtkMenuItem</class>
<name>menubar_chapter</name>
<sensitive>False</sensitive>
<label>_Chapter</label>
<right_justify>False</right_justify>
</widget>
<widget>
<class>GtkMenuItem</class>
<name>separator11</name>
<right_justify>False</right_justify>
</widget>
<widget> <widget>
<class>GtkMenuItem</class> <class>GtkMenuItem</class>
<name>menubar_playlist</name> <name>menubar_playlist</name>
...@@ -182,6 +205,36 @@ ...@@ -182,6 +205,36 @@
<class>GtkMenu</class> <class>GtkMenu</class>
<name>menubar_settings_menu</name> <name>menubar_settings_menu</name>
<widget>
<class>GtkMenuItem</class>
<name>separator7</name>
<right_justify>False</right_justify>
</widget>
<widget>
<class>GtkMenuItem</class>
<name>menubar_audio</name>
<sensitive>False</sensitive>
<tooltip>Select audio language</tooltip>
<label>A_udio</label>
<right_justify>False</right_justify>
</widget>
<widget>
<class>GtkMenuItem</class>
<name>menubar_subpictures</name>
<sensitive>False</sensitive>
<tooltip>Select sub-title</tooltip>
<label>Sub _Pictures</label>
<right_justify>False</right_justify>
</widget>
<widget>
<class>GtkMenuItem</class>
<name>separator8</name>
<right_justify>False</right_justify>
</widget>
<widget> <widget>
<class>GtkMenuItem</class> <class>GtkMenuItem</class>
<name>menubar_preferences</name> <name>menubar_preferences</name>
...@@ -585,6 +638,42 @@ ...@@ -585,6 +638,42 @@
<right_justify>False</right_justify> <right_justify>False</right_justify>
</widget> </widget>
<widget>
<class>GtkMenuItem</class>
<name>popup_navigation</name>
<sensitive>False</sensitive>
<label>Navigation</label>
<right_justify>False</right_justify>
</widget>
<widget>
<class>GtkMenuItem</class>
<name>separator10</name>
<right_justify>False</right_justify>
</widget>
<widget>
<class>GtkMenuItem</class>
<name>popup_audio</name>
<sensitive>False</sensitive>
<label>A_udio</label>
<right_justify>False</right_justify>
</widget>
<widget>
<class>GtkMenuItem</class>
<name>popup_subpictures</name>
<sensitive>False</sensitive>
<label>Sub _Pictures</label>
<right_justify>False</right_justify>
</widget>
<widget>
<class>GtkMenuItem</class>
<name>separator9</name>
<right_justify>False</right_justify>
</widget>
<widget> <widget>
<class>GtkMenuItem</class> <class>GtkMenuItem</class>
<name>popup_about</name> <name>popup_about</name>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* decoders. * decoders.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input.c,v 1.90 2001/03/07 01:36:41 sam Exp $ * $Id: input.c,v 1.91 2001/03/07 10:31:10 stef Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -319,6 +319,7 @@ static int InitThread( input_thread_t * p_input ) ...@@ -319,6 +319,7 @@ static int InitThread( input_thread_t * p_input )
p_input->pf_close = f.pf_close; p_input->pf_close = f.pf_close;
p_input->pf_end = f.pf_end; p_input->pf_end = f.pf_end;
p_input->pf_read = f.pf_read; p_input->pf_read = f.pf_read;
p_input->pf_set_area = f.pf_set_area;
p_input->pf_demux = f.pf_demux; p_input->pf_demux = f.pf_demux;
p_input->pf_new_packet = f.pf_new_packet; p_input->pf_new_packet = f.pf_new_packet;
p_input->pf_new_pes = f.pf_new_pes; p_input->pf_new_pes = f.pf_new_pes;
......
...@@ -225,3 +225,69 @@ void input_DumpStream( input_thread_t * p_input ) ...@@ -225,3 +225,69 @@ void input_DumpStream( input_thread_t * p_input )
} }
} }
/*****************************************************************************
* input_ChangeES: answers to a user request with calls to (Un)SelectES
* ---
* Useful since the interface plugins know p_es
*****************************************************************************/
int input_ChangeES( input_thread_t * p_input, es_descriptor_t * p_es,
int i_type )
{
boolean_t b_audio;
boolean_t b_spu;
int i_index;
int i;
i_index = -1;
b_audio = ( i_type == 1 ) ? 1 : 0;
b_spu = ( i_type == 2 ) ? 1 : 0;
vlc_mutex_lock( &p_input->stream.stream_lock );
for( i = 0 ; i < p_input->stream.i_selected_es_number ; i++ )
{
if( ( b_audio && p_input->stream.pp_selected_es[i]->b_audio )
|| ( b_spu && p_input->stream.pp_selected_es[i]->b_spu ) )
{
i_index = i;
break;
}
}
if( p_es != NULL )
{
if( i_index != -1 )
{
if( p_input->stream.pp_selected_es[i_index] != p_es )
{
input_UnselectES( p_input,
p_input->stream.pp_selected_es[i_index] );
input_SelectES( p_input, p_es );
intf_WarnMsg( 1, "dvd info: ES selected -> %s (0x%x)",
p_es->psz_desc, p_es->i_id );
}
}
else
{
input_SelectES( p_input, p_es );
intf_WarnMsg( 1, "dvd info: selected -> %s (0x%x)",
p_es->psz_desc, p_es->i_id );
}
}
else
{
if( i_index != -1 )
{
input_UnselectES( p_input,
p_input->stream.pp_selected_es[i_index] );
}
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
return 0;
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_programs.c: es_descriptor_t, pgrm_descriptor_t management * input_programs.c: es_descriptor_t, pgrm_descriptor_t management
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: input_programs.c,v 1.39 2001/03/02 15:51:22 massiot Exp $ * $Id: input_programs.c,v 1.40 2001/03/07 10:31:10 stef Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -371,6 +371,7 @@ es_descriptor_t * input_AddES( input_thread_t * p_input, ...@@ -371,6 +371,7 @@ es_descriptor_t * input_AddES( input_thread_t * p_input,
p_es->p_pes = NULL; p_es->p_pes = NULL;
p_es->p_decoder_fifo = NULL; p_es->p_decoder_fifo = NULL;
p_es->b_audio = 0; p_es->b_audio = 0;
p_es->b_spu = 0;
if( i_data_len ) if( i_data_len )
{ {
...@@ -508,6 +509,7 @@ static int InitDecConfig( input_thread_t * p_input, es_descriptor_t * p_es, ...@@ -508,6 +509,7 @@ static int InitDecConfig( input_thread_t * p_input, es_descriptor_t * p_es,
p_config->pf_init_bit_stream = InitBitstream; p_config->pf_init_bit_stream = InitBitstream;
p_input->stream.i_selected_es_number++; p_input->stream.i_selected_es_number++;
p_input->stream.pp_selected_es = realloc( p_input->stream.pp_selected_es = realloc(
p_input->stream.pp_selected_es, p_input->stream.pp_selected_es,
p_input->stream.i_selected_es_number p_input->stream.i_selected_es_number
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment