2003-01-17 22:39:43 +00:00
|
|
|
|
|
|
|
// main window
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
2007-05-16 21:45:46 +00:00
|
|
|
#include <string.h>
|
2003-01-17 22:39:43 +00:00
|
|
|
|
2005-12-08 22:12:57 +00:00
|
|
|
#include "app.h"
|
|
|
|
#include "skin/font.h"
|
|
|
|
#include "skin/skin.h"
|
|
|
|
#include "wm/ws.h"
|
|
|
|
|
|
|
|
#include "../config.h"
|
|
|
|
#include "../help_mp.h"
|
|
|
|
#include "../libvo/x11_common.h"
|
|
|
|
|
2006-07-31 17:39:17 +00:00
|
|
|
#include "../stream/stream.h"
|
2005-12-08 22:12:57 +00:00
|
|
|
#include "../mixer.h"
|
|
|
|
#include "../libvo/sub.h"
|
|
|
|
|
|
|
|
#include "../libmpdemux/demuxer.h"
|
|
|
|
#include "../libmpdemux/stheader.h"
|
|
|
|
#include "../codec-cfg.h"
|
2007-04-29 12:44:34 +00:00
|
|
|
#include "../access_mpcontext.h"
|
2007-07-05 22:01:07 +00:00
|
|
|
#include "../libavutil/avstring.h"
|
2003-01-17 22:39:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "play.h"
|
|
|
|
#include "widgets.h"
|
|
|
|
|
|
|
|
extern unsigned int GetTimerMS( void );
|
|
|
|
|
2004-06-25 16:49:53 +00:00
|
|
|
inline void TranslateFilename( int c,char * tmp,size_t tmplen )
|
2003-01-17 22:39:43 +00:00
|
|
|
{
|
|
|
|
int i;
|
2004-06-25 16:49:53 +00:00
|
|
|
char * p;
|
|
|
|
|
2003-01-17 22:39:43 +00:00
|
|
|
switch ( guiIntfStruct.StreamType )
|
|
|
|
{
|
|
|
|
case STREAMTYPE_STREAM:
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcpy(tmp, guiIntfStruct.Filename, tmplen);
|
2003-01-17 22:39:43 +00:00
|
|
|
break;
|
|
|
|
case STREAMTYPE_FILE:
|
|
|
|
if ( ( guiIntfStruct.Filename )&&( guiIntfStruct.Filename[0] ) )
|
|
|
|
{
|
2004-08-28 20:20:40 +00:00
|
|
|
if ( (p = strrchr(guiIntfStruct.Filename, '/')) )
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcpy(tmp, p + 1, tmplen);
|
2004-06-25 16:49:53 +00:00
|
|
|
else
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcpy(tmp, guiIntfStruct.Filename, tmplen);
|
2003-01-17 22:39:43 +00:00
|
|
|
if ( tmp[strlen( tmp ) - 4] == '.' ) tmp[strlen( tmp ) - 4]=0;
|
|
|
|
if ( tmp[strlen( tmp ) - 5] == '.' ) tmp[strlen( tmp ) - 5]=0;
|
2007-07-05 22:01:07 +00:00
|
|
|
} else av_strlcpy( tmp,MSGTR_NoFileLoaded,tmplen );
|
2003-01-17 22:39:43 +00:00
|
|
|
break;
|
|
|
|
#ifdef USE_DVDREAD
|
|
|
|
case STREAMTYPE_DVD:
|
2004-06-25 16:49:53 +00:00
|
|
|
if ( guiIntfStruct.DVD.current_chapter ) snprintf(tmp,tmplen,MSGTR_Chapter,guiIntfStruct.DVD.current_chapter );
|
2007-07-05 22:01:07 +00:00
|
|
|
else av_strlcat( tmp,MSGTR_NoChapter,tmplen );
|
2003-01-17 22:39:43 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_VCD
|
|
|
|
case STREAMTYPE_VCD:
|
2004-06-25 16:49:53 +00:00
|
|
|
snprintf( tmp,tmplen,MSGTR_VCDTrack,guiIntfStruct.Track );
|
2003-01-17 22:39:43 +00:00
|
|
|
break;
|
|
|
|
#endif
|
2007-07-05 22:01:07 +00:00
|
|
|
default: av_strlcpy( tmp,MSGTR_NoMediaOpened,tmplen );
|
2003-01-17 22:39:43 +00:00
|
|
|
}
|
|
|
|
if ( c )
|
|
|
|
{
|
|
|
|
for ( i=0;i < (int)strlen( tmp );i++ )
|
|
|
|
{
|
|
|
|
int t=0;
|
|
|
|
if ( c == 1 ) { if ( ( tmp[i] >= 'A' )&&( tmp[i] <= 'Z' ) ) t=32; }
|
|
|
|
if ( c == 2 ) { if ( ( tmp[i] >= 'a' )&&( tmp[i] <= 'z' ) ) t=-32; }
|
|
|
|
tmp[i]=(char)( tmp[i] + t );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-25 16:49:53 +00:00
|
|
|
/* Unsafe! Pass only null-terminated strings as (char *)str. */
|
2003-01-17 22:39:43 +00:00
|
|
|
char * Translate( char * str )
|
|
|
|
{
|
2007-02-21 19:14:49 +00:00
|
|
|
mixer_t *mixer = mpctx_get_mixer(guiIntfStruct.mpcontext);
|
2003-01-17 22:39:43 +00:00
|
|
|
static char trbuf[512];
|
|
|
|
char tmp[512];
|
|
|
|
int i,c;
|
|
|
|
int t;
|
2004-06-25 16:49:53 +00:00
|
|
|
int strsize = 0;
|
2003-01-17 22:39:43 +00:00
|
|
|
memset( trbuf,0,512 );
|
|
|
|
memset( tmp,0,128 );
|
2004-06-25 16:49:53 +00:00
|
|
|
strsize = strlen(str);
|
|
|
|
for ( c=0,i=0;i < strsize;i++ )
|
2003-01-17 22:39:43 +00:00
|
|
|
{
|
|
|
|
if ( str[i] != '$' ) { trbuf[c++]=str[i]; trbuf[c]=0; }
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch ( str[++i] )
|
|
|
|
{
|
2004-06-25 16:49:53 +00:00
|
|
|
case 't': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.Track );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
2004-06-25 16:49:53 +00:00
|
|
|
case 'o': TranslateFilename( 0,tmp,sizeof( tmp ) );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
2004-06-25 16:49:53 +00:00
|
|
|
case 'f': TranslateFilename( 1,tmp,sizeof( tmp ) );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
2004-06-25 16:49:53 +00:00
|
|
|
case 'F': TranslateFilename( 2,tmp,sizeof( tmp ) );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
2003-01-17 22:39:43 +00:00
|
|
|
case '6': t=guiIntfStruct.LengthInSec; goto calclengthhhmmss;
|
|
|
|
case '1': t=guiIntfStruct.TimeSec;
|
|
|
|
calclengthhhmmss:
|
2004-06-25 16:49:53 +00:00
|
|
|
snprintf( tmp,sizeof( tmp ),"%02d:%02d:%02d",t/3600,t/60%60,t%60 );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) );
|
2003-01-17 22:39:43 +00:00
|
|
|
break;
|
|
|
|
case '7': t=guiIntfStruct.LengthInSec; goto calclengthmmmmss;
|
|
|
|
case '2': t=guiIntfStruct.TimeSec;
|
|
|
|
calclengthmmmmss:
|
2004-06-25 16:49:53 +00:00
|
|
|
snprintf( tmp,sizeof( tmp ),"%04d:%02d",t/60,t%60 );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) );
|
2003-01-17 22:39:43 +00:00
|
|
|
break;
|
2004-06-25 16:49:53 +00:00
|
|
|
case '3': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.TimeSec / 3600 );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
2004-06-25 16:49:53 +00:00
|
|
|
case '4': snprintf( tmp,sizeof( tmp ),"%02d",( ( guiIntfStruct.TimeSec / 60 ) % 60 ) );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
2004-06-25 16:49:53 +00:00
|
|
|
case '5': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.TimeSec % 60 );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
|
|
|
case '8': snprintf( tmp,sizeof( tmp ),"%01d:%02d:%02d",guiIntfStruct.TimeSec / 3600,( guiIntfStruct.TimeSec / 60 ) % 60,guiIntfStruct.TimeSec % 60 ); av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
2004-06-25 16:49:53 +00:00
|
|
|
case 'v': snprintf( tmp,sizeof( tmp ),"%3.2f%%",guiIntfStruct.Volume );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
2004-06-25 16:49:53 +00:00
|
|
|
case 'V': snprintf( tmp,sizeof( tmp ),"%3.1f",guiIntfStruct.Volume );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
2004-06-25 16:49:53 +00:00
|
|
|
case 'b': snprintf( tmp,sizeof( tmp ),"%3.2f%%",guiIntfStruct.Balance );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
2004-06-25 16:49:53 +00:00
|
|
|
case 'B': snprintf( tmp,sizeof( tmp ),"%3.1f",guiIntfStruct.Balance );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
2004-06-25 16:49:53 +00:00
|
|
|
case 'd': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.FrameDrop );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
2004-06-25 16:49:53 +00:00
|
|
|
case 'x': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.MovieWidth );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
2004-06-25 16:49:53 +00:00
|
|
|
case 'y': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.MovieHeight );
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
2004-06-25 16:49:53 +00:00
|
|
|
case 'C': snprintf( tmp,sizeof( tmp ),"%s", guiIntfStruct.sh_video? ((sh_video_t *)guiIntfStruct.sh_video)->codec->name : "");
|
2007-07-05 22:01:07 +00:00
|
|
|
av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
|
|
|
|
case 's': if ( guiIntfStruct.Playing == 0 ) av_strlcat( trbuf,"s",sizeof( trbuf ) ); break;
|
|
|
|
case 'l': if ( guiIntfStruct.Playing == 1 ) av_strlcat( trbuf,"p",sizeof( trbuf ) ); break;
|
|
|
|
case 'e': if ( guiIntfStruct.Playing == 2 ) av_strlcat( trbuf,"e",sizeof( trbuf ) ); break;
|
2003-01-17 22:39:43 +00:00
|
|
|
case 'a':
|
2007-07-05 22:01:07 +00:00
|
|
|
if ( mixer->muted ) { av_strlcat( trbuf,"n",sizeof( trbuf ) ); break; }
|
2003-01-17 22:39:43 +00:00
|
|
|
switch ( guiIntfStruct.AudioType )
|
|
|
|
{
|
2007-07-05 22:01:07 +00:00
|
|
|
case 0: av_strlcat( trbuf,"n",sizeof( trbuf ) ); break;
|
|
|
|
case 1: av_strlcat( trbuf,"m",sizeof( trbuf ) ); break;
|
|
|
|
case 2: av_strlcat( trbuf,"t",sizeof( trbuf ) ); break;
|
2003-01-17 22:39:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'T':
|
|
|
|
switch ( guiIntfStruct.StreamType )
|
|
|
|
{
|
2007-07-05 22:01:07 +00:00
|
|
|
case STREAMTYPE_FILE: av_strlcat( trbuf,"f",sizeof( trbuf ) ); break;
|
2003-01-17 22:39:43 +00:00
|
|
|
#ifdef HAVE_VCD
|
2007-07-05 22:01:07 +00:00
|
|
|
case STREAMTYPE_VCD: av_strlcat( trbuf,"v",sizeof( trbuf ) ); break;
|
2003-01-17 22:39:43 +00:00
|
|
|
#endif
|
2007-07-05 22:01:07 +00:00
|
|
|
case STREAMTYPE_STREAM: av_strlcat( trbuf,"u",sizeof( trbuf ) ); break;
|
2003-01-17 22:39:43 +00:00
|
|
|
#ifdef USE_DVDREAD
|
2007-07-05 22:01:07 +00:00
|
|
|
case STREAMTYPE_DVD: av_strlcat( trbuf,"d",sizeof( trbuf ) ); break;
|
2003-01-17 22:39:43 +00:00
|
|
|
#endif
|
2007-07-05 22:01:07 +00:00
|
|
|
default: av_strlcat( trbuf," ",sizeof( trbuf ) ); break;
|
2003-01-17 22:39:43 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-07-05 22:01:07 +00:00
|
|
|
case '$': av_strlcat( trbuf,"$",sizeof( trbuf ) ); break;
|
2003-01-17 22:39:43 +00:00
|
|
|
default: continue;
|
|
|
|
}
|
|
|
|
c=strlen( trbuf );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return trbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char * image_buffer = NULL;
|
|
|
|
static int image_width = 0;
|
|
|
|
|
|
|
|
void PutImage( txSample * bf,int x,int y,int max,int ofs )
|
|
|
|
{
|
|
|
|
int i=0,ix,iy;
|
|
|
|
uint32_t * buf = NULL;
|
|
|
|
uint32_t * drw = NULL;
|
|
|
|
register uint32_t tmp;
|
2007-08-28 10:48:53 +00:00
|
|
|
/* register uint32_t yc; */
|
2003-01-17 22:39:43 +00:00
|
|
|
|
|
|
|
if ( ( !bf )||( bf->Image == NULL ) ) return;
|
|
|
|
|
|
|
|
i=( bf->Width * ( bf->Height / max ) ) * ofs;
|
|
|
|
buf=(uint32_t *)image_buffer;
|
|
|
|
drw=(uint32_t *)bf->Image;
|
|
|
|
|
2003-02-01 08:46:17 +00:00
|
|
|
#if 1
|
2003-01-17 22:39:43 +00:00
|
|
|
for ( iy=y;iy < (int)(y+bf->Height / max);iy++ )
|
|
|
|
for ( ix=x;ix < (int)(x+bf->Width);ix++ )
|
|
|
|
{
|
|
|
|
tmp=drw[i++];
|
|
|
|
if ( tmp != 0x00ff00ff ) buf[iy * image_width + ix]=tmp;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
yc=y * image_width;
|
|
|
|
for ( iy=y;iy < (int)(y+bf->Height / max);iy++ )
|
|
|
|
{
|
|
|
|
for ( ix=x;ix < (int)(x+bf->Width);ix++ )
|
|
|
|
{
|
|
|
|
tmp=drw[i++];
|
|
|
|
if ( tmp != 0x00ff00ff ) buf[yc + ix]=tmp;
|
|
|
|
}
|
|
|
|
yc+=image_width;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2004-06-26 13:54:20 +00:00
|
|
|
void SimplePotmeterPutImage( txSample * bf,int x,int y,float frac )
|
|
|
|
{
|
|
|
|
int i=0,w,r,ix,iy;
|
|
|
|
uint32_t * buf = NULL;
|
|
|
|
uint32_t * drw = NULL;
|
|
|
|
register uint32_t tmp;
|
|
|
|
|
|
|
|
if ( ( !bf )||( bf->Image == NULL ) ) return;
|
|
|
|
|
|
|
|
buf=(uint32_t *)image_buffer;
|
|
|
|
drw=(uint32_t *)bf->Image;
|
|
|
|
w=bf->Width*frac;
|
|
|
|
r=bf->Width-w;
|
|
|
|
for ( iy=y;iy < (int)(y+bf->Height);iy++ )
|
|
|
|
{
|
|
|
|
for ( ix=x;ix < (int)(x+w);ix++ )
|
|
|
|
{
|
|
|
|
tmp=drw[i++];
|
|
|
|
if ( tmp != 0x00ff00ff ) buf[iy * image_width + ix]=tmp;
|
|
|
|
}
|
|
|
|
i+=r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-17 22:39:43 +00:00
|
|
|
void Render( wsTWindow * window,wItem * Items,int nrItems,char * db,int size )
|
|
|
|
{
|
|
|
|
wItem * item;
|
|
|
|
txSample * image = NULL;
|
2006-07-09 16:01:36 +00:00
|
|
|
int i;
|
2003-01-17 22:39:43 +00:00
|
|
|
|
|
|
|
image_buffer=db;
|
|
|
|
image_width=window->Width;
|
|
|
|
|
|
|
|
for( i=0;i < nrItems + 1;i++ )
|
|
|
|
{
|
|
|
|
item=&Items[i];
|
|
|
|
switch( item->type )
|
|
|
|
{
|
|
|
|
case itButton:
|
|
|
|
PutImage( &item->Bitmap,item->x,item->y,3,item->pressed );
|
|
|
|
break;
|
|
|
|
case itPotmeter:
|
2004-06-26 13:54:20 +00:00
|
|
|
if (item->phases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f );
|
|
|
|
else PutImage( &item->Bitmap,item->x,item->y,item->phases,( item->phases - 1 ) * ( item->value / 100.0f ) );
|
2003-01-17 22:39:43 +00:00
|
|
|
break;
|
|
|
|
case itHPotmeter:
|
2004-06-26 13:54:20 +00:00
|
|
|
if (item->phases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f );
|
|
|
|
else PutImage( &item->Bitmap,item->x,item->y,item->phases,( item->phases - 1 ) * ( item->value / 100.0f ) );
|
2003-01-17 22:39:43 +00:00
|
|
|
PutImage( &item->Mask,item->x + (int)( ( item->width - item->psx ) * item->value / 100.0f ),item->y,3,item->pressed );
|
|
|
|
break;
|
|
|
|
case itVPotmeter:
|
|
|
|
PutImage( &item->Bitmap,
|
|
|
|
item->x,item->y,
|
|
|
|
item->phases,
|
2005-12-27 19:21:04 +00:00
|
|
|
item->phases * ( 1. - item->value / 100.0f ) );
|
2003-01-17 22:39:43 +00:00
|
|
|
PutImage( &item->Mask,
|
2005-12-27 19:21:04 +00:00
|
|
|
item->x,item->y + (int)( ( item->height - item->psy ) * ( 1. - item->value / 100.0f ) ),
|
2003-01-17 22:39:43 +00:00
|
|
|
3,item->pressed );
|
|
|
|
break;
|
|
|
|
case itSLabel:
|
|
|
|
image=fntRender( item,0,"%s",item->label );
|
|
|
|
if ( image ) PutImage( image,item->x,item->y,1,0 );
|
|
|
|
case itDLabel:
|
|
|
|
{
|
|
|
|
char * t = Translate( item->label );
|
|
|
|
int l = fntTextWidth( item->fontid,t );
|
2004-06-26 12:22:48 +00:00
|
|
|
l=(l?l:item->width);
|
|
|
|
image=fntRender( item,l-(GetTimerMS() / 20)%l,"%s",t );
|
2003-01-17 22:39:43 +00:00
|
|
|
}
|
|
|
|
if ( image ) PutImage( image,item->x,item->y,1,0 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wsConvert( window,db,size );
|
|
|
|
}
|