示例#1
0
bool_t SetFileExt(tchar_t* URL, size_t URLLen, const tchar_t* Ext)
{
	tchar_t *p,*q,*p2;
	bool_t HasHost;

	p = (tchar_t*) GetProtocol(URL,NULL,0,&HasHost);
	q = p;
	
	p = tcsrchr(q,'\\');
    p2 = tcsrchr(q,'/');
    if (!p || (p2 && p2>p))
		p=p2;
	if (p)
		q = p+1;
	else
	if (HasHost) // only hostname
		return 0;
	
	if (!q[0]) // no filename at all?
		return 0;

	p = tcsrchr(q,'.');
	if (p)
		*p = 0;

	tcscat_s(URL,URLLen,T("."));
	tcscat_s(URL,URLLen,Ext);
	return 1;
}
示例#2
0
static void Remove(const tchar_t* InstallDir,const tchar_t* Name)
{
	tchar_t Path[MAXPATH];
	tcscpy_s(Path,MAXPATH,InstallDir);
	tcscat_s(Path,MAXPATH,T("\\"));
	tcscat_s(Path,MAXPATH,Name);
	DeleteFile(Path);
}
示例#3
0
static void OutputArrayValues(parsercontext *p, const tchar_t *name, tchar_t *values[], size_t size)
{
	tchar_t Path[MAXPATH];
	tchar_t Value[MAXPATH];
	textwriter Output, StringOutput;
	size_t i;

	stprintf_s(Value, TSIZEOF(Value), T("res_%s"), name);

	for (i=0; i<size; ++i)
	{
		stprintf_s(Path, TSIZEOF(Path), T("values-%s"), values[i]);

		FolderCreate((nodecontext*)p, Path);
		if (PathIsFolder((nodecontext*)p, Path))
		{
			tcscat_s(Path, TSIZEOF(Path), T("/resinfo.xml"));
			memset(&Output,0,sizeof(Output));
			Output.Stream = StreamOpen(p, Path, SFLAG_WRONLY|SFLAG_CREATE);

			TextElementXML(p, &Output, T("resources"));

			TextElementBegin(&StringOutput, &Output, T("string"));
			TextAttrib(&StringOutput, T("name"), Value, TYPE_STRING);
			TcsToUpper(Path, TSIZEOF(Path), values[i]);
			TextElementEndData(&StringOutput, Path);

			TextElementEnd(&Output);

			StreamClose(Output.Stream);
		}
	}
}
示例#4
0
void FindFiles(nodecontext *p,const tchar_t* Path, const tchar_t* Mask,void(*Process)(const tchar_t*,void*),void* Param)
{
    DIR* Directory;
    struct dirent* DirectoryInfo;
    tchar_t TPathToFile[MAXPATH];
    
    Directory = opendir(Path);
    if (Directory)
    {
        while ( (DirectoryInfo = readdir(Directory)) != NULL )
        {
            char* FileExtension = 0;
            FileExtension = strrchr(DirectoryInfo->d_name, '.');
            if(FileExtension)
            {
                if (strcmp(Mask, FileExtension ) == 0 )
                {
                    tcscpy_s(TPathToFile, TSIZEOF(TPathToFile), Path);
                    tcscat_s(TPathToFile, TSIZEOF(TPathToFile), DirectoryInfo->d_name);
                    Process(TPathToFile, Param);
                }
            }
        }
        
        closedir(Directory);
    }
    
}
示例#5
0
static NOINLINE void AddFieldStr(pin* Pin,int Id,const tchar_t* Value)
{
	if (Value[0])
	{
		tchar_t s[512];
		GetFrameName(Id,s,TSIZEOF(s));
		tcscat_s(s,TSIZEOF(s),Value);
		AddField(Pin,Id,s);
	}
}
示例#6
0
void AddPathDelimiter(tchar_t* Path,size_t PathLen)
{
    size_t n = tcslen(Path);
#if defined(TARGET_WIN) || defined(TARGET_SYMBIAN)
    bool_t HasProtocol = GetProtocol(Path,NULL,0,NULL)==Path;
	if (!n || (n>0 && (HasProtocol || Path[n-1] != '/') && (!HasProtocol || Path[n-1] != '\\')))
	{
        if (HasProtocol)
            tcscat_s(Path,PathLen,T("\\"));
        else
	    	tcscat_s(Path,PathLen,T("/"));
	}
#elif defined(TARGET_PS2SDK)
	if (!n || (n>0 && Path[n-1] != '/' && Path[n-1] != '\\' && Path[n-1] != ':'))
		tcscat_s(Path,PathLen,T("/"));
#else
	if (!n || (n>0 && Path[n-1] != '/'))
		tcscat_s(Path,PathLen,T("/"));
#endif
}
示例#7
0
DLLEXPORT int WINAPI Uninstall_Exit(HWND hwndParent)
{
	tchar_t Base[MAXPATH];
	tchar_t Base2[MAXPATH];
	HKEY Key;
	DWORD RegSize;
	int n;

	if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, T("SOFTWARE"), 0, KEY_READ|KEY_WRITE, &Key) == ERROR_SUCCESS)
	{
		RegDeleteKey(Key,T("TCPMP"));
		RegCloseKey(Key);
	}

	RegSize = sizeof(Base);
	for (n=0;RegEnumKeyEx(HKEY_CLASSES_ROOT,n,Base,&RegSize,NULL,NULL,NULL,NULL)==ERROR_SUCCESS;++n)
	{
		if (Base[0] == '.')
		{
			tcscpy_s(Base2,TSIZEOF(Base2),Base+1);
			tcscat_s(Base2,TSIZEOF(Base2),T("%sFile"));
			tcsupr(Base2);
			RegistryRestore(Base,Base2);
		}
		else
		{
			tcscpy_s(Base2,TSIZEOF(Base2),Base);
			tcscat_s(Base2,TSIZEOF(Base2),T("\\DefaultIcon"));
			RegistryRestore(Base2,T("\\PLAYER.EXE"));
			tcscpy_s(Base2,TSIZEOF(Base2),Base);
			tcscat_s(Base2,TSIZEOF(Base2),T("\\shell\\open\\command"));
			RegistryRestore(Base2,T("\\PLAYER.EXE"));
		}
		RegSize = sizeof(Base);
	}

	return 0;
}
示例#8
0
void AbsPath(tchar_t* Abs, int AbsLen, const tchar_t* Path, const tchar_t* Base)
{
	if (Base && GetProtocol(Base,NULL,0,NULL)!=Base && (Path[0] == '/' || Path[0] == '\\') &&
        (Path[1] != '/' && Path[1] != '\\'))
	{
		tchar_t* s;
		bool_t HasHost;

		tcscpy_s(Abs,AbsLen,Base);
		s = (tchar_t*)GetProtocol(Abs,NULL,0,&HasHost);
		if (!HasHost)
		{
			// keep "mime://" from Base
			++Path;
			*s = 0;
		}
		else
		{
			// keep "mime://host" from Base
			tchar_t *a,*b;
			a = tcschr(s,'\\');
			b = tcschr(s,'/');
			if (!a || (b && b<a))
				a=b;
			if (a)
				*a=0;
		}
	}
	else
	if (Base && GetProtocol(Path,NULL,0,NULL)==Path && Path[0] != '/' && Path[0] != '\\' &&
		!(Path[0] && Path[1]==':' && (Path[2]=='\\' || Path[2]=='\0')))
	{	
		// doesn't have mime or drive letter or pathdelimiter at the start
		const tchar_t* MimeEnd = GetProtocol(Base,NULL,0,NULL);
		tcscpy_s(Abs,AbsLen,Base);

#if defined(TARGET_WIN) || defined(TARGET_SYMBIAN)
		if (MimeEnd==Base)
			AddPathDelimiter(Abs,AbsLen);
		else
#endif
		if (MimeEnd[0])
			AddPathDelimiter(Abs,AbsLen);
	}
	else
		Abs[0] = 0;

	tcscat_s(Abs,AbsLen,Path);
    AbsPathNormalize(Abs,AbsLen);
}
示例#9
0
static err_t EnumDir(filestream* p,const tchar_t* Exts,bool_t ExtFilter,streamdir* Item)
{
	struct dirent *Dirent;

	if (!p->FindDir)
		return ERR_END_OF_FILE;

	Item->FileName[0] = 0;
    Item->Size = INVALID_FILEPOS_T;

	while (!Item->FileName[0] && (Dirent = readdir(p->FindDir)) != NULL)
	{
	    tchar_t FilePath[MAXPATH];
	    struct stat file_stats;
        
        if (Dirent->d_name[0]=='.') // skip hidden files and current directory
            continue;

	    tcscpy_s(FilePath, TSIZEOF(FilePath), p->DirPath);
	    tcscat_s(FilePath, TSIZEOF(FilePath), Dirent->d_name);
	    tcscpy_s(Item->FileName,TSIZEOF(Item->FileName), Dirent->d_name);

	    stat(FilePath, &file_stats);

	    Item->ModifiedDate = LinuxToDateTime(file_stats.st_mtime);
	    if (S_ISDIR(file_stats.st_mode))
        {
            Item->Type = FTYPE_DIR;
		    Item->Size = INVALID_FILEPOS_T;
        }
	    else
	    {
		    Item->Size = file_stats.st_size;
		    Item->Type = CheckExts(Item->FileName,Exts);

			if (!Item->Type && ExtFilter)
				Item->FileName[0] = 0; // skip
	    }
	}

	if (!Item->FileName[0])
	{
		closedir(p->FindDir);
		p->FindDir = NULL;
		return ERR_END_OF_FILE;
	}

	return ERR_NONE;
}
示例#10
0
文件: urlpart.c 项目: ViFork/ResInfo
err_t CreateUrlPart(nodecontext *Context, tchar_t *Out, size_t OutLen, const tchar_t *URL, filepos_t Offset, size_t Length, const tchar_t *Mime)
{
    datetime_t FileDate;
    if (!URL || !URL[0])
        return ERR_INVALID_DATA;

    stprintf_s(Out,OutLen,T("urlpart://%s"),URL);
    tcsreplace(Out,OutLen,URLPART_SEPARATOR,URLPART_SEP_ESCAPE);
    tcscat_s(Out,OutLen,URLPART_SEPARATOR);
    if (Offset > 0)
        stcatprintf_s(Out,OutLen,T("ofs=%d#"),(int)Offset); // TODO: support 64 bits offset
    if (Length > 0)
        stcatprintf_s(Out,OutLen,T("len=%d#"),(int)Length);
    if (Mime)
        stcatprintf_s(Out,OutLen,T("mime=%s#"),Mime);
    FileDate = FileDateTime(Context,URL);
    if (FileDate != INVALID_DATETIME_T)
        stcatprintf_s(Out,OutLen,T("date=%d#"),(int)FileDate);
    return ERR_NONE;
}
示例#11
0
文件: mediainfo.c 项目: Erikhht/TCPMP
static void Info(win* Win,node* Node,winunit* y,int Name)
{
	int No;
	datadef DataDef;

	if (Name)
		WinPropLabel(Win,y,LangStr(MEDIAINFO_ID,Name),LangStr(Node->Class,NODE_NAME));

	for (No=0;NodeEnum(Node,No,&DataDef)==ERR_NONE;++No)
		if (!(DataDef.Flags & (DF_OUTPUT|DF_HIDDEN)))
		{
			tchar_t s[256];
			tick_t Tick;
			int i;
			bool_t Ok = 0;

			switch (DataDef.Type)
			{
			case TYPE_TICK:
				Ok = Node->Get(Node,DataDef.No,&Tick,sizeof(Tick))==ERR_NONE;
				TickToString(s,TSIZEOF(s),Tick,0,1,0);
				break;

			case TYPE_INT:
				Ok = Node->Get(Node,DataDef.No,&i,sizeof(i))==ERR_NONE;
				IntToString(s,TSIZEOF(s),i,(DataDef.Flags & DF_HEX)!=0);
				if (DataDef.Flags & DF_KBYTE)
					tcscat_s(s,TSIZEOF(s),T(" KB"));
				break;

			case TYPE_STRING:
				Ok = Node->Get(Node,DataDef.No,s,sizeof(s))==ERR_NONE;
				break;					
			}

			if (Ok)
				WinPropLabel(Win,y,DataDef.Name,s);
		}
}
示例#12
0
static void UpdatePage(settings* p)
{
	datadef DataDef;
	node* Node;
	bool_t Found = 0;
	int Class = Context()->SettingsPage;
	int No,i;
	winunit y;
	bool_t CheckList;
	tchar_t Data[MAXDATA/sizeof(tchar_t)];

#ifndef REGISTRY_GLOBAL
	if (p->Win.Flags & WIN_PROP_CHANGED)
	{
		p->Win.Flags &= ~WIN_PROP_CHANGED;
		if (p->Current)
			NodeRegSave(p->Current);
	}
#endif

	WinBeginUpdate(&p->Win);

	for (No=0;No<p->Count;++No)
	{
		if (p->Node[No]==Class)
			Found = 1;
		WinMenuCheck(&p->Win,p->Menu,SETTINGS_PAGES+No,p->Node[No]==Class);
	}

	if (!Found && p->Count>0)
		Class = p->Node[0];
	
	NodeDelete(p->Current);
	p->Current = Node = NodeCreate(Class);
	
	if (Node)
	{
		WinTitle(&p->Win,LangStr(Class,NODE_NAME));

		p->Win.LabelWidth = 
			(Class == PLATFORM_ID) ? 60:
			(p->Win.ScreenWidth < 130) ? 80:
			(Class == PLAYER_ID || Class == ADVANCED_ID) ? 120:90;

		CheckList = Class == ASSOCIATION_ID;
		y = 2;

		// if the menu is in bottom of screen. print a hint before platform settings (first page shown)
		if (Class == PLATFORM_ID && (p->Win.Flags & WIN_BOTTOMTOOLBAR) && !(p->Win.Flags & WIN_2BUTTON))
		{
			WinLabel(&p->Win,&y,-1,-1,LangStr(SETTINGS_ID,SETTINGS_HINT),PROPSIZE,0,NULL);
			y += 10;
		}

		for (No=0;NodeEnum(Node,No,&DataDef)==ERR_NONE;++No)
			if ((DataDef.Flags & DF_SETUP) && !(DataDef.Flags & DF_HIDDEN))
			{
				if (DataDef.Flags & DF_GAP)
					y += 7;

				if (!(DataDef.Flags & DF_RDONLY))
					WinPropValue(&p->Win,&y,Node,DataDef.No);
				else
				if (Node->Get(Node,DataDef.No,Data,DataDef.Size)==ERR_NONE)
				{
					switch (DataDef.Type)
					{
					case TYPE_LABEL:
						WinLabel(&p->Win,&y,-1,-1,DataDef.Name,PROPSIZE,0,NULL);
						break;

					case TYPE_TICK:
						TickToString(Data,TSIZEOF(Data),*(tick_t*)Data,0,1,0);
						WinPropLabel(&p->Win,&y,DataDef.Name,Data);
						break;

					case TYPE_INT:
						i = *(int*)Data;

						if (DataDef.Flags & DF_ENUMCLASS)
							tcscpy_s(Data,TSIZEOF(Data),LangStr(i,NODE_NAME));
						else
						if (DataDef.Flags & DF_ENUMSTRING)
							tcscpy_s(Data,TSIZEOF(Data),LangStr(DataDef.Format1,i));
						else
							Data[0] = 0;

						if (!Data[0])
							IntToString(Data,TSIZEOF(Data),i,(DataDef.Flags & DF_HEX)!=0);
						if (DataDef.Flags & DF_KBYTE)
							tcscat_s(Data,TSIZEOF(Data),T(" KB"));
						if (DataDef.Flags & DF_MHZ)
							tcscat_s(Data,TSIZEOF(Data),T(" Mhz"));
						WinPropLabel(&p->Win,&y,DataDef.Name,Data);
						break;

					case TYPE_STRING:
						WinPropLabel(&p->Win,&y,DataDef.Name,Data);
						break;
						
					case TYPE_HOTKEY:
						HotKeyToString(Data,TSIZEOF(Data),*(int*)Data);
						WinPropLabel(&p->Win,&y,DataDef.Name,Data);
						break;
						
					case TYPE_BOOL:
						WinPropLabel(&p->Win,&y,DataDef.Name,
							LangStr(PLATFORM_ID,*(bool_t*)Data ? PLATFORM_YES:PLATFORM_NO));
						break;

					default:
						WinPropLabel(&p->Win,&y,DataDef.Name,NULL);
						break;
					}
				}
			}
	}

	WinEndUpdate(&p->Win);
}
示例#13
0
static int Init(benchresult* p)
{
	node* Player = Context()->Player;
	node* Platform = Context()->Platform;
	node* Format;
	node* Input;
	node* VOutput;
	node* AOutput;
	winunit y;
	int i;
	int Frames;
	int Samples;
	int Bytes;
	tick_t Tick;
	tick_t OrigTick;
	point SizeSrc;
	point SizeDst;
	packetformat Video;
	packetformat Audio;
	tchar_t Buffer[256];
	fraction f;

	p->TimeDate = GetTimeDate();

	Player->Get(Player,PLAYER_FORMAT,&Format,sizeof(Format));
	Player->Get(Player,PLAYER_INPUT,&Input,sizeof(Input));

	VOutput = NULL;
	AOutput = NULL;
	OrigTick = 0;
	Frames = 0;
	Samples = 0;
	Bytes = 0;
	memset(&Video,0,sizeof(Video));
	memset(&Audio,0,sizeof(Audio));

	stprintf_s(p->Log,TSIZEOF(p->Log),LangStrDef(BENCHRESULT_ID,BENCHRESULT_LOG),Context()->ProgramName,Context()->ProgramVersion);
	tcscat_s(p->Log,TSIZEOF(p->Log),T("\n\n"));

	if (Format)
	{
		int No;
		pin Pin;
		packetformat PacketFormat;

		Format->Get(Format,FORMAT_FILEPOS,&Bytes,sizeof(Bytes));

		for (No=0;Format->Get(Format,FORMAT_STREAM+No,&Pin,sizeof(Pin))==ERR_NONE;++No)
			if (Pin.Node && Format->Get(Format,(FORMAT_STREAM+No)|PIN_FORMAT,&PacketFormat,sizeof(PacketFormat))==ERR_NONE)
			{
				if (PacketFormat.Type == PACKET_VIDEO) 
				{
					Video = PacketFormat;
					Player->Get(Player,PLAYER_VOUTPUT,&VOutput,sizeof(VOutput));
					if (VOutput)
						VOutput->Get(VOutput,OUT_TOTAL,&Frames,sizeof(Frames));
				}
				if (PacketFormat.Type == PACKET_AUDIO) 
				{
					Audio = PacketFormat;
					Player->Get(Player,PLAYER_AOUTPUT,&AOutput,sizeof(AOutput));
					if (AOutput)
					{
						packetformat Format;
						AOutput->Get(AOutput,OUT_TOTAL,&Samples,sizeof(Samples));
						if (AOutput->Get(AOutput,OUT_INPUT|PIN_FORMAT,&Format,sizeof(Format))==ERR_NONE &&
							Format.Type == PACKET_AUDIO)
						{
							if (Format.Format.Audio.Bits>=8)
								Samples /= Format.Format.Audio.Bits/8;
							if (!(Format.Format.Audio.Flags & PCM_PLANES) && Format.Format.Audio.Channels)
								Samples /= Format.Format.Audio.Channels;
						}
					}
				}
			}
	}

	y = 4;

	Player->Get(Player,PLAYER_BENCHMARK,&Tick,sizeof(Tick));

	if (Frames && Video.PacketRate.Num)
		OrigTick = Scale64(Frames,(int64_t)Video.PacketRate.Den*TICKSPERSEC,Video.PacketRate.Num);
	else
	if (Samples && Audio.Format.Audio.SampleRate)
		OrigTick = Scale(Samples,TICKSPERSEC,Audio.Format.Audio.SampleRate);

	if (Tick && OrigTick)
	{
		f.Num = OrigTick;
		f.Den = Tick;

		FractionToString(Buffer,TSIZEOF(Buffer),&f,1,2);
		AddItem(p,&y,BENCHRESULT_SPEED,Buffer);
	}

	if (Frames)
	{
		IntToString(Buffer,TSIZEOF(Buffer),Frames,0);
		AddItem(p,&y,BENCHRESULT_FRAMES,Buffer);
	}

	if (Samples)
	{
		IntToString(Buffer,TSIZEOF(Buffer),Samples,0);
		AddItem(p,&y,BENCHRESULT_SAMPLES,Buffer);
	}

	if (Bytes)
	{
		IntToString(Buffer,TSIZEOF(Buffer),Bytes/1024,0);
		tcscat_s(Buffer,TSIZEOF(Buffer),T(" KB"));
		AddItem(p,&y,BENCHRESULT_BYTES,Buffer);
	}

	y += 6;
	tcscat_s(p->Log,TSIZEOF(p->Log),T("\n"));

	TickToString(Buffer,TSIZEOF(Buffer),Tick,0,1,0);
	AddItem(p,&y,BENCHRESULT_TIME,Buffer);

	if (Frames && Tick)
	{
		f.Num = Frames;
		f.Den = Tick;
		Simplify(&f,MAX_INT/TICKSPERSEC,MAX_INT);
		f.Num *= TICKSPERSEC;
		FractionToString(Buffer,TSIZEOF(Buffer),&f,0,2);
		AddItem(p,&y,BENCHRESULT_FPS,Buffer);
	}

	if (Samples && Tick)
	{
		f.Num = Samples;
		f.Den = Tick;
		Simplify(&f,MAX_INT/TICKSPERSEC,MAX_INT);
		f.Num *= TICKSPERSEC;
		FractionToString(Buffer,TSIZEOF(Buffer),&f,0,0);
		AddItem(p,&y,BENCHRESULT_SRATE,Buffer);
	}

	if (Bytes && Tick)
	{
		f.Num = Scale(Bytes,8,1000);
		f.Den = Tick;
		Simplify(&f,MAX_INT/TICKSPERSEC,MAX_INT);
		f.Num *= TICKSPERSEC;
		if (f.Den && (f.Num/f.Den) > 1000)
		{
			Simplify(&f,MAX_INT,MAX_INT/1024);
			f.Den *= 1000;
			FractionToString(Buffer,TSIZEOF(Buffer),&f,0,1);
			tcscat_s(Buffer,TSIZEOF(Buffer),T(" Mbit/s"));
		}
		else
		{
			FractionToString(Buffer,TSIZEOF(Buffer),&f,0,0);
			tcscat_s(Buffer,TSIZEOF(Buffer),T(" kbit/s"));
		}
		AddItem(p,&y,BENCHRESULT_BANDWIDTH,Buffer);
	}

	y += 6;
	tcscat_s(p->Log,TSIZEOF(p->Log),T("\n"));

	if (OrigTick)
	{
		TickToString(Buffer,TSIZEOF(Buffer),OrigTick,0,1,0);
		AddItem(p,&y,BENCHRESULT_ORIG_TIME,Buffer);
	}

	if (Video.PacketRate.Num)
	{
		FractionToString(Buffer,TSIZEOF(Buffer),&Video.PacketRate,0,2);
		AddItem(p,&y,BENCHRESULT_ORIG_FPS,Buffer);
	}

	if (Audio.Format.Audio.SampleRate)
	{
		IntToString(Buffer,TSIZEOF(Buffer),Audio.Format.Audio.SampleRate,0);
		AddItem(p,&y,BENCHRESULT_ORIG_SRATE,Buffer);
	}

	if (Bytes && OrigTick)
	{
		f.Num = Scale(Bytes,8,1000);
		f.Den = OrigTick;
		Simplify(&f,MAX_INT/TICKSPERSEC,MAX_INT);
		f.Num *= TICKSPERSEC;
		if (f.Den && (f.Num/f.Den) > 1000)
		{
			f.Den *= 1000;
			FractionToString(Buffer,TSIZEOF(Buffer),&f,0,1);
			tcscat_s(Buffer,TSIZEOF(Buffer),T(" Mbit/s"));
		}
		else
		{
			FractionToString(Buffer,TSIZEOF(Buffer),&f,0,0);
			tcscat_s(Buffer,TSIZEOF(Buffer),T(" kbit/s"));
		}
		AddItem(p,&y,BENCHRESULT_ORIG_BANDWIDTH,Buffer);
	}

	if (Frames && Samples)
	{
		y += 9;
		WinLabel(&p->Win,&y,-1,-1,LangStr(BENCHRESULT_ID,BENCHRESULT_MSG),11,0,NULL);
	}

	tcscat_s(p->Log,TSIZEOF(p->Log),T("\n"));

	if (Input && Input->Get(Input,STREAM_URL,Buffer,sizeof(Buffer))==ERR_NONE)
		AddLog(p,BENCHRESULT_ID,BENCHRESULT_URL,Buffer);

	if (Input && Input->Get(Input,STREAM_LENGTH,&i,sizeof(i))==ERR_NONE)
	{
		IntToString(Buffer,TSIZEOF(Buffer),i,0);
		AddLog(p,BENCHRESULT_ID,BENCHRESULT_FILESIZE,Buffer);
	}

	if (Platform)
	{
		if (Platform->Get(Platform,PLATFORM_TYPE,Buffer,sizeof(Buffer))==ERR_NONE)
			AddLog(p,PLATFORM_ID,PLATFORM_TYPE,Buffer);

		if (Platform->Get(Platform,PLATFORM_VERSION,Buffer,sizeof(Buffer))==ERR_NONE)
			AddLog(p,PLATFORM_ID,PLATFORM_VERSION,Buffer);

		if (Platform->Get(Platform,PLATFORM_OEMINFO,Buffer,sizeof(Buffer))==ERR_NONE)
			AddLog(p,PLATFORM_ID,PLATFORM_OEMINFO,Buffer);

		ThreadSleep(GetTimeFreq()/10);

		if (Platform->Get(Platform,PLATFORM_CPUMHZ,&i,sizeof(i))==ERR_NONE)
		{
			IntToString(Buffer,TSIZEOF(Buffer),i,0);
			tcscat_s(Buffer,TSIZEOF(Buffer),T(" Mhz"));
			AddLog(p,PLATFORM_ID,PLATFORM_CPUMHZ,Buffer);
		}
	}

	if (VOutput)
	{
		tcscpy_s(Buffer,TSIZEOF(Buffer),LangStrDef(VOutput->Class,NODE_NAME));
		if (VOutput->Get(VOutput,OUT_OUTPUT|PIN_FORMAT,&Video,sizeof(Video))==ERR_NONE)
		{
			if (Video.Format.Video.Direction & DIR_SWAPXY)
				SwapInt(&Video.Format.Video.Width,&Video.Format.Video.Height);
			stcatprintf_s(Buffer,TSIZEOF(Buffer),T(" %dx%d %dbits"),Video.Format.Video.Width,Video.Format.Video.Height,Video.Format.Video.Pixel.BitCount);
		}

		if (QueryAdvanced(ADVANCED_SLOW_VIDEO))
			tcscat_s(Buffer,TSIZEOF(Buffer),T(" Slow"));
		if (QueryAdvanced(ADVANCED_COLOR_LOOKUP))
			tcscat_s(Buffer,TSIZEOF(Buffer),T(" Lookup"));

		AddLog(p,PLAYER_ID,PLAYER_VOUTPUT,Buffer);
	}

	if (Player->Get(Player,PLAYER_BENCHMARK_SRC,&SizeSrc,sizeof(point))==ERR_NONE &&
		Player->Get(Player,PLAYER_BENCHMARK_DST,&SizeDst,sizeof(point))==ERR_NONE && 
		SizeSrc.x>0 && SizeSrc.y>0)
		{
			stprintf_s(Buffer,TSIZEOF(Buffer),T("%dx%d -> %dx%d"),SizeSrc.x,SizeSrc.y,SizeDst.x,SizeDst.y);
			AddLog(p,BENCHRESULT_ID,BENCHRESULT_ZOOM,Buffer);
		}

	if (AOutput)
	{
		tcscpy_s(Buffer,TSIZEOF(Buffer),LangStrDef(AOutput->Class,NODE_NAME));
		if (AOutput->Get(AOutput,OUT_OUTPUT|PIN_FORMAT,&Audio,sizeof(Audio))==ERR_NONE)
			stcatprintf_s(Buffer,TSIZEOF(Buffer),T(" %dHz %dBits %dCh."),Audio.Format.Audio.SampleRate,Audio.Format.Audio.Bits,Audio.Format.Audio.Channels);
		AddLog(p,PLAYER_ID,PLAYER_AOUTPUT,Buffer);
	}

	return ERR_NONE;
}
示例#14
0
文件: mediainfo.c 项目: Erikhht/TCPMP
static int Init(win* p)
{
	tchar_t s[256];
	packetformat Format;
	int No;
	node* VOutput = NULL;
	node* Reader = NULL;
	node* Input = NULL;
	node* Player = Context()->Player;
	winunit y;

	Player->Get(Player,PLAYER_FORMAT,&Reader,sizeof(Reader));
	Player->Get(Player,PLAYER_INPUT,&Input,sizeof(Input));
	Player->Get(Player,PLAYER_VOUTPUT,&VOutput,sizeof(VOutput));

	y = 4;

	if (Input)
		Info(p,Input,&y,0);

	if (Reader)
	{
		pin Pin;

		Info(p,Reader,&y,MEDIAINFO_FORMAT);
		Comment(p,(player*)Player,&y,-1);

		for (No=0;Reader->Get(Reader,FORMAT_STREAM+No,&Pin,sizeof(Pin))==ERR_NONE;++No)
			if (PlayerGetStream((player*)Player,No,&Format,NULL,0,NULL))
			{
				y += 6;

				if (Format.Type != PACKET_NONE)
				{
					if (!PacketFormatName(&Format,s,TSIZEOF(s))) s[0] =0;
					WinPropLabel(p,&y,LangStr(PLAYER_ID,STREAM_NAME+Format.Type),s);
				}

				switch (Format.Type)
				{
				case PACKET_NONE:
					break;

				case PACKET_VIDEO:
					if (Pin.Node && Compressed(&Format.Format.Video.Pixel))
						Info(p,Pin.Node,&y,MEDIAINFO_CODEC);

					if (Format.Format.Video.Width && Format.Format.Video.Height)
					{
						stprintf_s(s,TSIZEOF(s),T("%d x %d"),Format.Format.Video.Width,Format.Format.Video.Height);
						WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_SIZE),s);
					}
					if (Format.PacketRate.Num)
					{
						FractionToString(s,TSIZEOF(s),&Format.PacketRate,0,3);
						WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_FPS),s);
					}
					if (Format.ByteRate)
					{
						IntToString(s,TSIZEOF(s),(Format.ByteRate+62)/125,0);
						tcscat_s(s,TSIZEOF(s),T(" kbit/s")); // 1000byte/sec
						WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_BITRATE),s);
					}

					break;

				case PACKET_AUDIO:

					if (Pin.Node && Format.Format.Audio.Format != AUDIOFMT_PCM)
						Info(p,Pin.Node,&y,MEDIAINFO_CODEC);

					s[0] = 0;
					if (Format.Format.Audio.SampleRate)
					{
						IntToString(s+tcslen(s),TSIZEOF(s)-tcslen(s),Format.Format.Audio.SampleRate,0);
						tcscat_s(s,TSIZEOF(s),T(" Hz "));
					}
					switch (Format.Format.Audio.Channels)
					{
					case 0: break;
					case 1: tcscat_s(s,TSIZEOF(s),LangStr(MEDIAINFO_ID,MEDIAINFO_AUDIO_MONO)); break;
					case 2: tcscat_s(s,TSIZEOF(s),LangStr(MEDIAINFO_ID,MEDIAINFO_AUDIO_STEREO)); break;
					default: stcatprintf_s(s,TSIZEOF(s),T("%d Ch"),Format.Format.Audio.Channels); break;
					}
					if (s[0])
						WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_FORMAT),s);

					if (Format.ByteRate)
					{
						IntToString(s,TSIZEOF(s),(Format.ByteRate+62)/125,0);
						tcscat_s(s,TSIZEOF(s),T(" kbit/s")); // 1000bit/sec
						WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_BITRATE),s);
					}

					break;

				case PACKET_SUBTITLE:
					if (Pin.Node)
						Info(p,Pin.Node,&y,MEDIAINFO_CODEC);
					break;
				}

				Comment(p,(player*)Player,&y,No);
			}

		if (VOutput)
		{
			int Total = 0;
			int Dropped = 0;

			VOutput->Get(VOutput,OUT_TOTAL,&Total,sizeof(int));
			VOutput->Get(VOutput,OUT_DROPPED,&Dropped,sizeof(int));

			Total += Dropped;
			if (Total)
			{
				y += 6;

				IntToString(s,TSIZEOF(s),Total,0);
				WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_VIDEO_TOTAL),s);

				IntToString(s,TSIZEOF(s),Dropped,0);
				WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_VIDEO_DROPPED),s);

				Player->Get(Player,PLAYER_VSTREAM,&No,sizeof(No));
				if (No>=0 && Reader->Get(Reader,(FORMAT_STREAM+No)|PIN_FORMAT,&Format,sizeof(Format))==ERR_NONE &&
					Format.Type == PACKET_VIDEO && Format.PacketRate.Num)
				{
					Simplify(&Format.PacketRate,(1<<30)/Total,(1<<30)/Total);
					Format.PacketRate.Num *= Total - Dropped;
					Format.PacketRate.Den *= Total;
					FractionToString(s,TSIZEOF(s),&Format.PacketRate,0,3);
					WinPropLabel(p,&y,LangStr(MEDIAINFO_ID,MEDIAINFO_AVG_FPS),s);
				}
			}
		}
	}

	return ERR_NONE;
}
示例#15
0
static void OutputValues(parsercontext *p, size_t size, size_t night, size_t density, size_t touchscreen, size_t keyboard, size_t textinput, size_t navstate, size_t navmethod)
{
	tchar_t Path[MAXPATH];
	textwriter Output, StringOutput;

	stprintf_s(Path, TSIZEOF(Path), T("values")
		T("-%s")
//		T("-%s")
		T("-%s")
//		T("-%s")
//		T("-%s")
//		T("-%s")
//		T("-%s")
//		T("-%s")
		,Size[size]
//		,Night[night]
		,Density[density]
//		,TouchScreen[touchscreen]
//		,Keyboard[keyboard]
//		,TextInput[textinput]
//		,NavigationState[navstate]
//		,NavigationMethod[navmethod]
		);

	FolderCreate((nodecontext*)p, Path);
	if (PathIsFolder((nodecontext*)p, Path))
	{
		tcscat_s(Path, TSIZEOF(Path), T("/resinfo.xml"));
		memset(&Output,0,sizeof(Output));
		Output.Stream = StreamOpen(p, Path, SFLAG_WRONLY|SFLAG_CREATE);

		TextElementXML(p, &Output, T("resources"));

		TextElementBegin(&StringOutput, &Output, T("string"));
		TextAttrib(&StringOutput, T("name"), T("res_size"), TYPE_STRING);
		TcsToUpper(Path, TSIZEOF(Path), Size[size]);
		TextElementEndData(&StringOutput, Path);

		TextElementBegin(&StringOutput, &Output, T("string"));
		TextAttrib(&StringOutput, T("name"), T("res_night"), TYPE_STRING);
		TcsToUpper(Path, TSIZEOF(Path), Night[night]);
		TextElementEndData(&StringOutput, Path);

		TextElementBegin(&StringOutput, &Output, T("string"));
		TextAttrib(&StringOutput, T("name"), T("res_density"), TYPE_STRING);
		TcsToUpper(Path, TSIZEOF(Path), Density[density]);
		TextElementEndData(&StringOutput, Path);

		TextElementBegin(&StringOutput, &Output, T("string"));
		TextAttrib(&StringOutput, T("name"), T("res_touchscreen"), TYPE_STRING);
		TcsToUpper(Path, TSIZEOF(Path), TouchScreen[touchscreen]);
		TextElementEndData(&StringOutput, Path);

		TextElementBegin(&StringOutput, &Output, T("string"));
		TextAttrib(&StringOutput, T("name"), T("res_keyboard"), TYPE_STRING);
		TcsToUpper(Path, TSIZEOF(Path), Keyboard[keyboard]);
		TextElementEndData(&StringOutput, Path);

		TextElementBegin(&StringOutput, &Output, T("string"));
		TextAttrib(&StringOutput, T("name"), T("res_textinput"), TYPE_STRING);
		TcsToUpper(Path, TSIZEOF(Path), TextInput[textinput]);
		TextElementEndData(&StringOutput, Path);

		TextElementBegin(&StringOutput, &Output, T("string"));
		TextAttrib(&StringOutput, T("name"), T("res_navstate"), TYPE_STRING);
		TcsToUpper(Path, TSIZEOF(Path), NavigationState[navstate]);
		TextElementEndData(&StringOutput, Path);

		TextElementBegin(&StringOutput, &Output, T("string"));
		TextAttrib(&StringOutput, T("name"), T("res_navmethod"), TYPE_STRING);
		TcsToUpper(Path, TSIZEOF(Path), NavigationMethod[navmethod]);
		TextElementEndData(&StringOutput, Path);

		TextElementEnd(&Output);

		StreamClose(Output.Stream);
	}
}
示例#16
0
DLLEXPORT int WINAPI Install_Exit(HWND Parent, LPCTSTR InstallDir, WORD FailedDirs,WORD FailedFiles,WORD FailedRegKeys,WORD FailedRegVals,WORD FailedShortcuts)
{
	HMODULE GAPI;
	HMODULE CoreDLL;
	tchar_t LocalPath[MAXPATH];
	tchar_t WinPath[MAXPATH];
	int32_t Slow = -1;

	DWORD Disp;
	HKEY Key;

	tchar_t* AdvBase = T("SOFTWARE\\TCPMP\\ADVP");

#ifdef ARM
	tchar_t* Base = T("System\\GDI\\Drivers\\ATI");
	tchar_t* Name = T("DisableDeviceBitmap");
	HANDLE Handle;
#endif

	//-------------------------------------
	// Remove possible old files

	Remove(InstallDir,T("lang_en.plg"));
	Remove(InstallDir,T("asf.plg"));
	Remove(InstallDir,T("avi.plg"));
	Remove(InstallDir,T("a52.plg"));
	Remove(InstallDir,T("mjpeg.plg"));
	Remove(InstallDir,T("mpeg4aac.plg"));
	Remove(InstallDir,T("mpegaudio.plg"));
	Remove(InstallDir,T("mpegvideo.plg"));
	Remove(InstallDir,T("overlay.plg"));
	Remove(InstallDir,T("vorbis.plg"));

	//-------------------------------------
	// GAPI's gx.dll keep it or not?

	WinPath[0] = 0;
	CoreDLL = LoadLibrary(T("coredll.dll"));
	if (CoreDLL)
	{
		BOOL (WINAPI* FuncSHGetSpecialFolderPath)(HWND,LPTSTR,int,BOOL);

		*(FARPROC*)&FuncSHGetSpecialFolderPath = GetProcAddress(CoreDLL,T("SHGetSpecialFolderPath"));

		if (FuncSHGetSpecialFolderPath)
			FuncSHGetSpecialFolderPath(NULL,WinPath,0x24/*CSIDL_WINDOWS*/,FALSE);

		FreeLibrary(CoreDLL);
	}
	if (!WinPath[0])
		tcscpy_s(WinPath,MAXPATH,T("\\Windows"));

	tcscat_s(WinPath,MAXPATH,T("\\gx.dll")); //Mod2010
	tcscpy_s(LocalPath,MAXPATH,InstallDir);
	tcscat_s(LocalPath,MAXPATH,T("\\gx.dll")); //Mod2010

	GAPI = LoadLibrary(WinPath);
	if (GAPI)
	{
		DeleteFile(LocalPath);
	}
	else
	{
		GAPI = LoadLibrary(LocalPath); // can we load our gx.dll? aygshell.dll available?
		if (GAPI)
		{
			// check new HPC device with aygshell support, but no GXINFO

			OSVERSIONINFO Ver;
			Ver.dwOSVersionInfoSize = sizeof(Ver);
			GetVersionEx(&Ver);

			if (Ver.dwMajorVersion >= 4)
			{
				HDC DC = GetDC(NULL);
				DWORD Code = GETGXINFO;
				GXDeviceInfo Info;
				memset(&Info,0,sizeof(Info));
				Info.Version = 100;

				if (ExtEscape(DC, ESC_QUERYESCSUPPORT, sizeof(DWORD), (char*)&Code, 0, NULL) > 0)
					ExtEscape(DC, GETGXINFO, 0, NULL, sizeof(Info), (char*)&Info);

				if (Info.cxWidth==0 || Info.cyHeight==0)
				{
					// release and remove our gx.dll
					FreeLibrary(GAPI);
					GAPI = NULL;
				}

				ReleaseDC(NULL,DC);
			}
		}

		if (!GAPI)
		{
			DeleteFile(LocalPath);
			GAPI = LoadLibrary(T("gx.dll")); // try load on path
		}
	}

	//-------------------------------------
	// Benchmark video memory

	SlowVideoRAW(&Slow);

	if (GAPI)
	{
		if (Slow == -1)
			SlowVideoGAPI(GAPI,Parent,&Slow);
		FreeLibrary(GAPI);
	}

	// EPSON display drive in NEXIO
	if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, T("Drivers\\Display\\S1D13806"), 0, KEY_READ, &Key) == ERROR_SUCCESS)
	{
		Slow = 1;
		RegCloseKey(Key);
	}

	if (Slow != -1)
	{
		if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, AdvBase, 0, NULL, 0, 0, NULL, &Key, &Disp) == ERROR_SUCCESS)
		{
			tchar_t Name[32];
			IntToString(Name,TSIZEOF(Name),ADVANCED_SLOW_VIDEO,0);
			RegSetValueEx(Key, Name, 0, REG_DWORD, (LPBYTE)&Slow, sizeof(Slow));
			RegCloseKey(Key);
		}
	}

#ifdef ARM

	//-------------------------------------
	// ATI Imageon 3200 registry settings

	Handle = LoadLibrary(T("ACE_DDI.DLL"));
	if (Handle)
	{
		FreeLibrary(Handle);

		if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, Base, 0, NULL, 0, KEY_READ|KEY_WRITE, NULL, &Key, &Disp) == ERROR_SUCCESS)
		{
			DWORD Value;
			DWORD RegType;
			DWORD RegSize;

			RegSize=sizeof(Value);
			if (RegQueryValueEx(Key, Name, 0, &RegType, (LPBYTE)&Value, &RegSize) != ERROR_SUCCESS || !Value)
			{
				Value = 1;
				RegSetValueEx(Key, Name, 0, REG_DWORD, (LPBYTE)&Value, sizeof(Value));

				MessageBox(Parent,
					T("TCPMP installer disabled ATI IMAGEON device bitmap caching for better video playback. ") 
					T("After install please warm boot the device for changes to take effect! ")
					T("You can change this setting later in the player."),T("Setup"),MB_OK|MB_SETFOREGROUND);
			}
			RegCloseKey(Key);
		}
	}
	else
	{
		tcscpy_s(LocalPath,MAXPATH,InstallDir);
		tcscat_s(LocalPath,MAXPATH,T("\\ati3200.plg"));
		DeleteFile(LocalPath);
	}

	//-------------------------------------
	// Intel 2700G 

	Handle = LoadLibrary(T("PVRVADD.DLL"));
	if (Handle)
	{
		FreeLibrary(Handle);
	}
	else
	{
		tcscpy_s(LocalPath,MAXPATH,InstallDir);
		tcscat_s(LocalPath,MAXPATH,T("\\intel2700g.plg"));
		DeleteFile(LocalPath);
	}

#endif

	return 0;
}
示例#17
0
void String_Init()
{
	void* Buffer;

	StringAlloc();

	Buffer = malloc(MAXTEXT);
	if (Buffer)
	{
#ifdef NO_PLUGINS
		{
			int n;
			HANDLE Module = GetModuleHandle(NULL);
			HRSRC Rsrc = FindResource(Module,MAKEINTRESOURCE(2000),T("LANGTAR"));
			if (Rsrc)
			{
				int Size = SizeofResource(Module,Rsrc);
				HGLOBAL Global = LoadResource(Module,Rsrc);
				if (Global)
				{
					void* p = LockResource(Global);
					if (p)
					{
						stream* Stream = StreamOpenMem(p,Size);
						if (Stream)
						{
							LoadTGZ(Stream,Buffer);
							StreamCloseMem(Stream);
						}
					}
				}
			}
			for (n=2000;(Rsrc = FindResource(Module,MAKEINTRESOURCE(n),T("LANG")))!=NULL;++n)
			{
				int Size = SizeofResource(Module,Rsrc);
				HGLOBAL Global = LoadResource(Module,Rsrc);
				if (Global)
				{
					void* p = LockResource(Global);
					if (p)
						StringAddText(p,Size);
				}
			}
		}

#endif
#ifndef NO_LANG
		{
			tchar_t Path[MAXPATH];
			stream* p;

			GetModulePath(Path,T("common.dll"));
			tcscat_s(Path,TSIZEOF(Path),T("language.tgz"));
			p = StreamOpen(Path,0);
			if (p)
			{
				LoadTGZ(p,Buffer);
				StreamClose(p);
			}

			GetModulePath(Path,T("common.dll"));
			FindFiles(Path,T("*.txt"),LoadTXT,Buffer);
		}
#endif
		free(Buffer);
	}
}
示例#18
0
static NOINLINE void GetFrameName(int Id,tchar_t* Out,int OutLen)
{
	tcscpy_s(Out,OutLen,PlayerComment(Id));
	tcscat_s(Out,OutLen,T("="));
}