changeset 18118:f9a939c204ad

Adds "cheap" subtitle switching for non-DVD playouts (for ex. OGG or MKV). Patch by Stanislav Maslovski <stanislav POIS maslovski AH gmail POIS com> Original thread: Date: Apr 12, 2006 1:50 PM Subject: [MPlayer-dev-eng] [PATCH] GUI: add cheap subtitle switching for non-DVD
author gpoirier
date Sun, 16 Apr 2006 16:58:36 +0000
parents 0b13bab3f237
children e1a6874c7308
files Gui/app.h Gui/mplayer/gtk/menu.c Gui/mplayer/mw.c help/help_mp-en.h help/help_mp-ru.h
diffstat 5 files changed, 44 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Gui/app.h	Sun Apr 16 13:45:21 2006 +0000
+++ b/Gui/app.h	Sun Apr 16 16:58:36 2006 +0000
@@ -60,7 +60,8 @@
 #define evSetAspect         44
 #define evSetAudio	    45
 #define evSetVideo	    46
-// 47 ...
+#define evSetSubtitle       47
+// 48 ...
 
 #define evExit              1000
 
--- a/Gui/mplayer/gtk/menu.c	Sun Apr 16 13:45:21 2006 +0000
+++ b/Gui/mplayer/gtk/menu.c	Sun Apr 16 16:58:36 2006 +0000
@@ -377,6 +377,8 @@
  return NULL;
 }
 
+extern int global_sub_size;
+
 GtkWidget * DVDSubMenu;
 GtkWidget * DVDTitleMenu;
 GtkWidget * DVDChapterMenu;
@@ -569,6 +571,20 @@
         }
      }
    }
+  
+  /* cheap subtitle switching for non-DVD streams */
+  if ( global_sub_size && guiIntfStruct.StreamType != STREAMTYPE_DVD )
+   {
+    int i;
+    SubMenu=AddSubMenu( window1, (const char*)empty_xpm, Menu, MSGTR_MENU_Subtitles );
+    AddMenuItem( window1, (const char*)empty_xpm, SubMenu, MSGTR_MENU_None, (-1 << 16) + evSetSubtitle );
+    for ( i=0;i < global_sub_size;i++ )
+     {
+      char tmp[32];
+      snprintf( tmp, 32, MSGTR_MENU_Track, i );
+      AddMenuItem( window1,(const char*)empty_xpm,SubMenu,tmp,( i << 16 ) + evSetSubtitle );
+     }
+   }
 
   AddSeparator( Menu );
   MenuItem=AddMenuCheckItem( window1, (const char*)sound_xpm, Menu,MSGTR_MENU_Mute,mixer.muted,evMute );
--- a/Gui/mplayer/mw.c	Sun Apr 16 13:45:21 2006 +0000
+++ b/Gui/mplayer/mw.c	Sun Apr 16 16:58:36 2006 +0000
@@ -32,6 +32,12 @@
 #include "widgets.h"
 
 extern mixer_t mixer; // mixer from mplayer.c
+extern int global_sub_size;
+extern int global_sub_pos;
+extern int global_sub_indices[];
+extern int sub_source(void);
+#define SUB_SOURCE_VOBSUB 1
+#define SUB_SOURCE_DEMUX  2
 
 extern unsigned int GetTimerMS( void );
 
@@ -110,6 +116,24 @@
 	video_id=iparam;
 	goto play;
 
+   case evSetSubtitle:
+	if ( !guiIntfStruct.demuxer || global_sub_pos == iparam ) break;
+	global_sub_pos = iparam;
+	if ( global_sub_pos >= 0 )
+	 switch ( sub_source() )
+	  {
+	   case SUB_SOURCE_VOBSUB:
+		vobsub_id = global_sub_pos - global_sub_indices[SUB_SOURCE_VOBSUB];
+		goto play;
+	   case SUB_SOURCE_DEMUX:
+		vobsub_id = -1;
+		dvdsub_id = global_sub_pos - global_sub_indices[SUB_SOURCE_DEMUX];
+		goto play;
+	  }
+	vobsub_id = -1;
+	dvdsub_id = -2;
+	goto play;
+
 #ifdef HAVE_VCD
    case evSetVCDTrack:
         guiIntfStruct.Track=iparam;
--- a/help/help_mp-en.h	Sun Apr 16 13:45:21 2006 +0000
+++ b/help/help_mp-en.h	Sun Apr 16 16:58:36 2006 +0000
@@ -788,6 +788,7 @@
 #define MSGTR_MENU_AudioTrack "Audio track"
 #define MSGTR_MENU_Track "Track %d"
 #define MSGTR_MENU_VideoTrack "Video track"
+#define MSGTR_MENU_Subtitles "Subtitles"
 
 // --- equalizer
 // Note: If you change MSGTR_EQU_Audio please see if it still fits MSGTR_PREFERENCES_Audio
--- a/help/help_mp-ru.h	Sun Apr 16 13:45:21 2006 +0000
+++ b/help/help_mp-ru.h	Sun Apr 16 16:58:36 2006 +0000
@@ -684,6 +684,7 @@
 #define MSGTR_MENU_AudioTrack "Аудио дорожка"
 #define MSGTR_MENU_Track "дорожка %d"
 #define MSGTR_MENU_VideoTrack "Видео дорожка"
+#define MSGTR_MENU_Subtitles "Субтитры"
 
 // --- equalizer
 #define MSGTR_EQU_Audio "Аудио"