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