[MPlayer-dev-eng] [PATCH] GUI: add cheap subtitle switching for non-DVD

Stanislav Maslovski stanislav.maslovski at gmail.com
Wed Apr 12 13:50:12 CEST 2006


Hello,

This patch adds "cheap" subtitle switching for non-DVD playouts
(for ex. OGG or MKV). This patch should apply okay even without my
previos patches that correct audio/video switching in gtk/menu.c

--
Stanislav
-------------- next part --------------
diff -urN mplayer-cvs20060411/Gui/app.h mplayer-cvs20060412/Gui/app.h
--- mplayer-cvs20060411/Gui/app.h	2006-04-12 14:55:58.000000000 +0400
+++ mplayer-cvs20060412/Gui/app.h	2006-04-12 15:12:08.000000000 +0400
@@ -60,7 +60,8 @@
 #define evSetAspect         44
 #define evSetAudio	    45
 #define evSetVideo	    46
-// 47 ...
+#define evSetSubtitle       47
+// 48 ...
 
 #define evExit              1000
 
diff -urN mplayer-cvs20060411/Gui/mplayer/gtk/menu.c mplayer-cvs20060412/Gui/mplayer/gtk/menu.c
--- mplayer-cvs20060411/Gui/mplayer/gtk/menu.c	2006-04-12 15:01:45.000000000 +0400
+++ mplayer-cvs20060412/Gui/mplayer/gtk/menu.c	2006-04-12 15:17:02.000000000 +0400
@@ -378,6 +378,8 @@
  return NULL;
 }
 
+extern int global_sub_size;
+
 GtkWidget * DVDSubMenu;
 GtkWidget * DVDTitleMenu;
 GtkWidget * DVDChapterMenu;
@@ -576,6 +578,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 );
diff -urN mplayer-cvs20060411/Gui/mplayer/mw.c mplayer-cvs20060412/Gui/mplayer/mw.c
--- mplayer-cvs20060411/Gui/mplayer/mw.c	2006-04-12 14:55:58.000000000 +0400
+++ mplayer-cvs20060412/Gui/mplayer/mw.c	2006-04-12 15:22:35.000000000 +0400
@@ -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;
diff -urN mplayer-cvs20060411/help/help_mp-en.h mplayer-cvs20060412/help/help_mp-en.h
--- mplayer-cvs20060411/help/help_mp-en.h	2006-04-12 14:55:58.000000000 +0400
+++ mplayer-cvs20060412/help/help_mp-en.h	2006-04-12 15:12:08.000000000 +0400
@@ -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
diff -urN mplayer-cvs20060411/help/help_mp-ru.h mplayer-cvs20060412/help/help_mp-ru.h
--- mplayer-cvs20060411/help/help_mp-ru.h	2006-04-12 14:55:58.000000000 +0400
+++ mplayer-cvs20060412/help/help_mp-ru.h	2006-04-12 15:12:08.000000000 +0400
@@ -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 "?????"


More information about the MPlayer-dev-eng mailing list