[vlc-devel] [PATCH] Add hotkey to cycle through program SIDs.
Zoran Turalija
zoran.turalija at gmail.com
Mon Aug 13 07:54:04 CEST 2012
Allow far more easier cycling through program Service IDs in multi-program
stream eg. DVB streams.
---
include/vlc_keys.h | 2 ++
modules/control/hotkeys.c | 40 ++++++++++++++++++++++++++++++++++++++++
src/config/keys.c | 1 +
src/libvlc-module.c | 5 +++++
4 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/include/vlc_keys.h b/include/vlc_keys.h
index c46b19c..a04847c 100644
--- a/include/vlc_keys.h
+++ b/include/vlc_keys.h
@@ -200,6 +200,8 @@ typedef enum vlc_action {
ACTIONID_RATE_NORMAL,
ACTIONID_RATE_SLOWER_FINE,
ACTIONID_RATE_FASTER_FINE,
+ /* Cycle Through Program Service IDs */
+ ACTIONID_PROGRAM_SID,
} vlc_action_t;
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index dcbef28..25af282 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -501,6 +501,46 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
list2.p_list->p_values[i].psz_string );
var_FreeList( &list, &list2 );
}
+ else if( i_action == ACTIONID_PROGRAM_SID )
+ {
+ vlc_value_t val, list, list2;
+ int i_count, i;
+ var_Get( p_input, "program", &val );
+
+ var_Change( p_input, "program", VLC_VAR_GETCHOICES,
+ &list, &list2 );
+ i_count = list.p_list->i_count;
+ if( i_count <= 1 )
+ {
+ DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL,
+ _("Program Service ID: %s"), _("N/A") );
+ var_FreeList( &list, &list2 );
+ goto cleanup_and_continue;
+ }
+ for( i = 0; i < i_count; i++ )
+ {
+ if( val.i_int == list.p_list->p_values[i].i_int )
+ {
+ break;
+ }
+ }
+ /* value of program was not in choices list */
+ if( i == i_count )
+ {
+ msg_Warn( p_input,
+ "invalid current program SID, selecting 0" );
+ i = 0;
+ }
+ else if( i == i_count - 1 )
+ i = 0;
+ else
+ i++;
+ var_Set( p_input, "program", list.p_list->p_values[i] );
+ DisplayMessage( p_vout, SPU_DEFAULT_CHANNEL,
+ _("Program Service ID: %s"),
+ list2.p_list->p_values[i].psz_string );
+ var_FreeList( &list, &list2 );
+ }
else if( i_action == ACTIONID_ASPECT_RATIO && p_vout )
{
vlc_value_t val={0}, val_list, text_list;
diff --git a/src/config/keys.c b/src/config/keys.c
index 24c3061..2588295 100644
--- a/src/config/keys.c
+++ b/src/config/keys.c
@@ -307,6 +307,7 @@ static const struct action actions[] =
{ "play-pause", ACTIONID_PLAY_PAUSE, },
{ "position", ACTIONID_POSITION, },
{ "prev", ACTIONID_PREV, },
+ { "program-sid", ACTIONID_PROGRAM_SID, },
{ "quit", ACTIONID_QUIT, },
{ "random", ACTIONID_RANDOM, },
{ "rate-faster-fine", ACTIONID_RATE_FASTER_FINE, },
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index a330d31..fe95a21 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1365,6 +1365,8 @@ static const char *const ppsz_albumart_descriptions[] =
#define AUDIO_TRACK_KEY_LONGTEXT N_("Cycle through the available audio tracks(languages).")
#define SUBTITLE_TRACK_KEY_TEXT N_("Cycle subtitle track")
#define SUBTITLE_TRACK_KEY_LONGTEXT N_("Cycle through the available subtitle tracks.")
+#define PROGRAM_SID_KEY_TEXT N_("Cycle program Service ID")
+#define PROGRAM_SID_KEY_LONGTEXT N_("Cycle through the available program Service IDs (SIDs).")
#define ASPECT_RATIO_KEY_TEXT N_("Cycle source aspect ratio")
#define ASPECT_RATIO_KEY_LONGTEXT N_("Cycle through a predefined list of source aspect ratios.")
#define CROP_KEY_TEXT N_("Cycle video crop")
@@ -2319,6 +2321,7 @@ vlc_module_begin ()
# define KEY_AUDIO_TRACK "b"
# define KEY_SUBTITLE_TRACK "v"
+# define KEY_PROGRAM_SID "x"
# define KEY_ASPECT_RATIO "a"
# define KEY_CROP "c"
# define KEY_TOGGLE_AUTOSCALE "o"
@@ -2483,6 +2486,8 @@ vlc_module_begin ()
AUDI_DEVICE_CYCLE_KEY_LONGTEXT, false )
add_key( "key-subtitle-track", KEY_SUBTITLE_TRACK,
SUBTITLE_TRACK_KEY_TEXT, SUBTITLE_TRACK_KEY_LONGTEXT, false )
+ add_key( "key-program-sid", KEY_PROGRAM_SID,
+ PROGRAM_SID_KEY_TEXT, PROGRAM_SID_KEY_LONGTEXT, false )
add_key( "key-aspect-ratio", KEY_ASPECT_RATIO,
ASPECT_RATIO_KEY_TEXT, ASPECT_RATIO_KEY_LONGTEXT, false )
add_key( "key-crop", KEY_CROP,
--
1.7.5.4
More information about the vlc-devel
mailing list