8973
|
1
|
|
2 // main window
|
|
3
|
|
4 #include <stdlib.h>
|
|
5 #include <stdio.h>
|
|
6 #include <inttypes.h>
|
|
7 #include <sys/stat.h>
|
|
8 #include <unistd.h>
|
|
9
|
|
10 #include "../app.h"
|
|
11 #include "../skin/font.h"
|
|
12 #include "../skin/skin.h"
|
|
13 #include "../wm/ws.h"
|
|
14
|
|
15 #include "../../config.h"
|
|
16 #include "../../help_mp.h"
|
|
17 #include "../../libvo/x11_common.h"
|
|
18
|
|
19 #include "../../libmpdemux/stream.h"
|
|
20 #include "../../mixer.h"
|
|
21 #include "../../libvo/sub.h"
|
|
22 #include "../../mplayer.h"
|
|
23
|
|
24 #include "../../libmpdemux/demuxer.h"
|
|
25 #include "../../libmpdemux/stheader.h"
|
|
26 #include "../../codec-cfg.h"
|
|
27
|
|
28
|
|
29 #include "play.h"
|
|
30 #include "widgets.h"
|
|
31
|
|
32 extern unsigned int GetTimerMS( void );
|
|
33
|
|
34 inline void TranslateFilename( int c,char * tmp )
|
|
35 {
|
|
36 int i;
|
|
37 switch ( guiIntfStruct.StreamType )
|
|
38 {
|
|
39 case STREAMTYPE_STREAM:
|
|
40 strcpy( tmp,guiIntfStruct.Filename );
|
|
41 break;
|
|
42 case STREAMTYPE_FILE:
|
|
43 if ( ( guiIntfStruct.Filename )&&( guiIntfStruct.Filename[0] ) )
|
|
44 {
|
|
45 if ( strrchr( guiIntfStruct.Filename,'/' ) ) strcpy( tmp,strrchr( guiIntfStruct.Filename,'/' ) + 1 );
|
|
46 else strcpy( tmp,guiIntfStruct.Filename );
|
|
47 if ( tmp[strlen( tmp ) - 4] == '.' ) tmp[strlen( tmp ) - 4]=0;
|
|
48 if ( tmp[strlen( tmp ) - 5] == '.' ) tmp[strlen( tmp ) - 5]=0;
|
|
49 } else strcpy( tmp,MSGTR_NoFileLoaded );
|
|
50 break;
|
|
51 #ifdef USE_DVDREAD
|
|
52 case STREAMTYPE_DVD:
|
|
53 if ( guiIntfStruct.DVD.current_chapter ) sprintf( tmp,MSGTR_Chapter,guiIntfStruct.DVD.current_chapter );
|
|
54 else strcat( tmp,MSGTR_NoChapter );
|
|
55 break;
|
|
56 #endif
|
|
57 #ifdef HAVE_VCD
|
|
58 case STREAMTYPE_VCD:
|
|
59 sprintf( tmp,MSGTR_VCDTrack,guiIntfStruct.Track );
|
|
60 break;
|
|
61 #endif
|
|
62 default: strcpy( tmp,MSGTR_NoMediaOpened );
|
|
63 }
|
|
64 if ( c )
|
|
65 {
|
|
66 for ( i=0;i < (int)strlen( tmp );i++ )
|
|
67 {
|
|
68 int t=0;
|
|
69 if ( c == 1 ) { if ( ( tmp[i] >= 'A' )&&( tmp[i] <= 'Z' ) ) t=32; }
|
|
70 if ( c == 2 ) { if ( ( tmp[i] >= 'a' )&&( tmp[i] <= 'z' ) ) t=-32; }
|
|
71 tmp[i]=(char)( tmp[i] + t );
|
|
72 }
|
|
73 }
|
|
74 }
|
|
75
|
|
76 char * Translate( char * str )
|
|
77 {
|
|
78 static char trbuf[512];
|
|
79 char tmp[512];
|
|
80 int i,c;
|
|
81 int t;
|
|
82 memset( trbuf,0,512 );
|
|
83 memset( tmp,0,128 );
|
|
84 for ( c=0,i=0;i < (int)strlen( str );i++ )
|
|
85 {
|
|
86 if ( str[i] != '$' ) { trbuf[c++]=str[i]; trbuf[c]=0; }
|
|
87 else
|
|
88 {
|
|
89 switch ( str[++i] )
|
|
90 {
|
|
91 case 't': sprintf( tmp,"%02d",guiIntfStruct.Track ); strcat( trbuf,tmp ); break;
|
|
92 case 'o': TranslateFilename( 0,tmp ); strcat( trbuf,tmp ); break;
|
|
93 case 'f': TranslateFilename( 1,tmp ); strcat( trbuf,tmp ); break;
|
|
94 case 'F': TranslateFilename( 2,tmp ); strcat( trbuf,tmp ); break;
|
|
95 case '6': t=guiIntfStruct.LengthInSec; goto calclengthhhmmss;
|
|
96 case '1': t=guiIntfStruct.TimeSec;
|
|
97 calclengthhhmmss:
|
|
98 sprintf( tmp,"%02d:%02d:%02d",t/3600,t/60%60,t%60 ); strcat( trbuf,tmp );
|
|
99 break;
|
|
100 case '7': t=guiIntfStruct.LengthInSec; goto calclengthmmmmss;
|
|
101 case '2': t=guiIntfStruct.TimeSec;
|
|
102 calclengthmmmmss:
|
|
103 sprintf( tmp,"%04d:%02d",t/60,t%60 ); strcat( trbuf,tmp );
|
|
104 break;
|
|
105 case '3': sprintf( tmp,"%02d",guiIntfStruct.TimeSec / 3600 ); strcat( trbuf,tmp ); break;
|
|
106 case '4': sprintf( tmp,"%02d",( ( guiIntfStruct.TimeSec / 60 ) % 60 ) ); strcat( trbuf,tmp ); break;
|
|
107 case '5': sprintf( tmp,"%02d",guiIntfStruct.TimeSec % 60 ); strcat( trbuf,tmp ); break;
|
|
108 case '8': sprintf( tmp,"%01d:%02d:%02d",guiIntfStruct.TimeSec / 3600,( guiIntfStruct.TimeSec / 60 ) % 60,guiIntfStruct.TimeSec % 60 ); strcat( trbuf,tmp ); break;
|
|
109 case 'v': sprintf( tmp,"%3.2f%%",guiIntfStruct.Volume ); strcat( trbuf,tmp ); break;
|
|
110 case 'V': sprintf( tmp,"%3.1f",guiIntfStruct.Volume ); strcat( trbuf,tmp ); break;
|
|
111 case 'b': sprintf( tmp,"%3.2f%%",guiIntfStruct.Balance ); strcat( trbuf,tmp ); break;
|
|
112 case 'B': sprintf( tmp,"%3.1f",guiIntfStruct.Balance ); strcat( trbuf,tmp ); break;
|
|
113 case 'd': sprintf( tmp,"%d",guiIntfStruct.FrameDrop ); strcat( trbuf,tmp ); break;
|
|
114 case 'x': sprintf( tmp,"%d",guiIntfStruct.MovieWidth ); strcat( trbuf,tmp ); break;
|
|
115 case 'y': sprintf( tmp,"%d",guiIntfStruct.MovieHeight ); strcat( trbuf,tmp ); break;
|
|
116 case 'C': sprintf( tmp,"%s", guiIntfStruct.sh_video? ((sh_video_t *)guiIntfStruct.sh_video)->codec->name : "");
|
|
117 strcat( trbuf,tmp ); break;
|
|
118 case 's': if ( guiIntfStruct.Playing == 0 ) strcat( trbuf,"s" ); break;
|
|
119 case 'l': if ( guiIntfStruct.Playing == 1 ) strcat( trbuf,"p" ); break;
|
|
120 case 'e': if ( guiIntfStruct.Playing == 2 ) strcat( trbuf,"e" ); break;
|
|
121 case 'a':
|
|
122 if ( muted ) { strcat( trbuf,"n" ); break; }
|
|
123 switch ( guiIntfStruct.AudioType )
|
|
124 {
|
|
125 case 0: strcat( trbuf,"n" ); break;
|
|
126 case 1: strcat( trbuf,"m" ); break;
|
|
127 case 2: strcat( trbuf,"t" ); break;
|
|
128 }
|
|
129 break;
|
|
130 case 'T':
|
|
131 switch ( guiIntfStruct.StreamType )
|
|
132 {
|
|
133 case STREAMTYPE_FILE: strcat( trbuf,"f" ); break;
|
|
134 #ifdef HAVE_VCD
|
|
135 case STREAMTYPE_VCD: strcat( trbuf,"v" ); break;
|
|
136 #endif
|
|
137 case STREAMTYPE_STREAM: strcat( trbuf,"u" ); break;
|
|
138 #ifdef USE_DVDREAD
|
|
139 case STREAMTYPE_DVD: strcat( trbuf,"d" ); break;
|
|
140 #endif
|
|
141 default: strcat( trbuf," " ); break;
|
|
142 }
|
|
143 break;
|
|
144 case '$': strcat( trbuf,"$" ); break;
|
|
145 default: continue;
|
|
146 }
|
|
147 c=strlen( trbuf );
|
|
148 }
|
|
149 }
|
|
150 return trbuf;
|
|
151 }
|
|
152
|
|
153 static char * image_buffer = NULL;
|
|
154 static int image_width = 0;
|
|
155
|
|
156 void PutImage( txSample * bf,int x,int y,int max,int ofs )
|
|
157 {
|
|
158 int i=0,ix,iy;
|
|
159 uint32_t * buf = NULL;
|
|
160 uint32_t * drw = NULL;
|
|
161 register uint32_t tmp;
|
|
162 register uint32_t yc;
|
|
163
|
|
164 if ( ( !bf )||( bf->Image == NULL ) ) return;
|
|
165
|
|
166 i=( bf->Width * ( bf->Height / max ) ) * ofs;
|
|
167 buf=(uint32_t *)image_buffer;
|
|
168 drw=(uint32_t *)bf->Image;
|
|
169
|
|
170 #if 0
|
|
171 for ( iy=y;iy < (int)(y+bf->Height / max);iy++ )
|
|
172 for ( ix=x;ix < (int)(x+bf->Width);ix++ )
|
|
173 {
|
|
174 tmp=drw[i++];
|
|
175 if ( tmp != 0x00ff00ff ) buf[iy * image_width + ix]=tmp;
|
|
176 }
|
|
177 #else
|
|
178 yc=y * image_width;
|
|
179 for ( iy=y;iy < (int)(y+bf->Height / max);iy++ )
|
|
180 {
|
|
181 for ( ix=x;ix < (int)(x+bf->Width);ix++ )
|
|
182 {
|
|
183 tmp=drw[i++];
|
|
184 if ( tmp != 0x00ff00ff ) buf[yc + ix]=tmp;
|
|
185 }
|
|
186 yc+=image_width;
|
|
187 }
|
|
188 #endif
|
|
189 }
|
|
190
|
|
191 void Render( wsTWindow * window,wItem * Items,int nrItems,char * db,int size )
|
|
192 {
|
|
193 wItem * item;
|
|
194 txSample * image = NULL;
|
|
195 int i, type;
|
|
196
|
|
197 image_buffer=db;
|
|
198 image_width=window->Width;
|
|
199
|
|
200 for( i=0;i < nrItems + 1;i++ )
|
|
201 {
|
|
202 item=&Items[i];
|
|
203 switch( item->type )
|
|
204 {
|
|
205 case itButton:
|
|
206 PutImage( &item->Bitmap,item->x,item->y,3,item->pressed );
|
|
207 break;
|
|
208 case itPotmeter:
|
|
209 PutImage( &item->Bitmap,item->x,item->y,item->phases,( item->phases - 1 ) * ( item->value / 100.0f ) );
|
|
210 break;
|
|
211 case itHPotmeter:
|
|
212 PutImage( &item->Bitmap,item->x,item->y,item->phases,item->phases * ( item->value / 100.0f ) );
|
|
213 PutImage( &item->Mask,item->x + (int)( ( item->width - item->psx ) * item->value / 100.0f ),item->y,3,item->pressed );
|
|
214 break;
|
|
215 case itVPotmeter:
|
|
216 PutImage( &item->Bitmap,
|
|
217 item->x,item->y,
|
|
218 item->phases,
|
|
219 item->phases * ( item->value / 100.0f ) );
|
|
220 PutImage( &item->Mask,
|
|
221 item->x,item->y + (int)( ( item->height - item->psy ) * item->value / 100.0f ),
|
|
222 3,item->pressed );
|
|
223 break;
|
|
224 case itSLabel:
|
|
225 image=fntRender( item,0,"%s",item->label );
|
|
226 if ( image ) PutImage( image,item->x,item->y,1,0 );
|
|
227 case itDLabel:
|
|
228 {
|
|
229 char * t = Translate( item->label );
|
|
230 int l = fntTextWidth( item->fontid,t );
|
|
231 image=fntRender( item,(GetTimerMS() / 20)%(l?l:item->width),"%s",t );
|
|
232 }
|
|
233 if ( image ) PutImage( image,item->x,item->y,1,0 );
|
|
234 break;
|
|
235 }
|
|
236 }
|
|
237 wsConvert( window,db,size );
|
|
238 }
|