Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Engine.StreamBase


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
//==============================================================================
//	Created on: 10/13/2003
//	Base class for streaming music related classes
//  Organizational purposes only
//
//	Written by Ron Prestenback
//	© 2003, Epic Games, Inc.  All Rights Reserved
//==============================================================================
class StreamBase extends Object
	Abstract
	Native;

enum EFileType
{
	FILE_None,
	FILE_Directory,
	FILE_Log,
	FILE_Ini,
	FILE_Stream,
	FILE_Playlist,
	FILE_Music,
	FILE_Map,
	FILE_Texture,
	FILE_Animation,
	FILE_Static,
	FILE_XML,
	FILE_HTML,
	FILE_Sound,
	FILE_Demo,
	FILE_DivX,
};

enum EStreamPlaylistType
{
	SPT_None,
	SPT_M3U,
	SPT_PLS,
	SPT_B4S,
};

struct FilePath
{
	var string FullPath,
               Directory,	// Always contains trailing path-separator
	           Filename,	// Only contains name (no dots)
			   Extension;   // Only contains extension (no dots)

	var array<string> DirectoryParts;
};

struct ID3Field
{
	var pointer           Reference;
	var string            FieldName;
	var string           FieldValue;
	var byte     		    FieldID;
	var byte                Code[4];
};

// "StringA" * "StringB" = "StringA\StringB" or "StringA/StringB"
native static final operator(40) string *  ( coerce string A, coerce string B );
native static final operator(44) string *= ( out	string A, coerce string B );


// OS-specific hooks
native static final function string GetPathSeparator();
native static final function bool   IsCaseSensitive();

// seperates a file path into a ParsedFilePath struct
static final event string GetPathRoot( out string InPath )
{
	local int i;
	local string root;

	i = InStr(InPath, GetPathSeparator() $ GetPathSeparator()); // would look like:   '//blah/blah/'
	if ( i == -1 )
		i = InStr(InPath, ":" $ GetPathSeparator()); 	// would look like 'c:\blah\blah'

	if ( i != -1 )
	{
		root = Left(InPath, i + 1);
		InPath = Mid(InPath, i + 2);
		// so root should now be either '/' or 'c:'
	}

	return root;
}

static final event bool HasExtension( string Test )
{
	return ParseExtension(Test) != "";
}

static final event bool ParsePath( string InPath, out FilePath ParsedPath )
{
	local int i;

	if ( InPath == "" )
		return false;

	ParsedPath.FullPath = InPath;

	i = RevInStr(InPath, GetPathSeparator());
	if ( i != -1 )
		ParsedPath.Directory = Left(InPath, i+1);

	ParsedPath.DirectoryParts = ParseDirectories(InPath);
	ParsedPath.Extension = ParseExtension(InPath);
	ParsedPath.FileName = InPath;

	return ParsedPath.DirectoryParts.Length > 0 || (ParsedPath.Extension != "" && ParsedPath.FileName != "");
}

static final event string ParseExtension( out string FileNameWithExtension )
{
	local int i;
	local string Ext;

	if ( FileNameWithExtension == "" )
		return "";

	i = RevInStr(FileNameWithExtension, ".");
	if ( i >= 0 )
		Ext = Mid(FileNameWithExtension, i + 1);

	if ( ConvertToFileType(Ext) != FILE_None )
	{
		FileNameWithExtension = Left(FileNameWithExtension,i);
		return Locs(Ext);
	}

	return "";
}

static final event array<string> ParseDirectories( out string InPath )
{
	local array<string> Directories;
	local string root;

	root = GetPathRoot(InPath);
	Split(InPath, GetPathSeparator(), Directories);
	InPath = "";

	// Re-insert the root directory at the beginning of the array
	if ( root != "" )
	{
		Directories.Insert(0,1);
		Directories[0] = root;
	}

	// If the last item was actually a file, remove it from the array and store in the out string
	if ( HasExtension(Directories[Directories.Length - 1]) )
	{
		InPath = Directories[Directories.Length - 1];
		Directories.Length = Directories.Length - 1;
	}

	return Directories;
}

static final function int RevInStr( string src, string match )
{
	local int pos, i;
	local string s;

	if ( src == "" || match == "" )
		return -1;

	s = src;
	i = InStr(s, match);

	do
	{
		pos += i;
		s = Mid(src, pos+1);
		i = InStr(s, match) + 1;
	} until ( i == 0 );

	return pos;
}

static final function string FormatTimeDisplay( coerce float Seconds )
{
	local int i;
	local string TimeString;

	// Get hours
	i = Seconds / 3600;
	if ( i > 0 )
		TimeString = i $ ":";

	i = Seconds / 60;
	if ( TimeString != "" && i < 10 )
		TimeString $= "0";

	TimeString $= i $ ":";

	i = Seconds % 60;
	if ( i < 10 )
		TimeString $= "0";

	TimeString $= i;

	return TimeString;
}

static final event string ConvertToFileExtension( EFileType Type )
{
	switch ( Type )
	{
	case FILE_Log:       return ".log";
	case FILE_Ini:       return ".ini";
	case FILE_Playlist:  return ".m3u;.pls;.b4s";
	case FILE_Music:     return ".umx";
	case FILE_Map:       return ".ut2";
	case FILE_Texture:   return ".utx";
	case FILE_Animation: return ".ukx";
	case FILE_Static:    return ".usx";
	case FILE_XML:       return ".xml";
	case FILE_HTML:      return ".html;.htm";
	case FILE_Sound:     return ".uax";
	case FILE_Demo:      return ".DEMO4";
	case FILE_DivX:      return ".avi";
	case FILE_Stream:
//			return ".ogg";
		return ".mp3;.ogg";
	}

	return "";
}

static final event EFileType ConvertToFileType( string Extension )
{
	local string Ext;

	if ( Extension == "" )
		return FILE_None;

	Ext = ParseExtension(Extension);
	if ( Ext == "" )
		Ext = Extension;

	Ext = Locs(Ext);
	switch ( Ext )
	{
		case "mp3":// return FILE_None;
		case "ogg":	return FILE_Stream;
		case "wav":
		case "umx":	return FILE_Music;
		case "ut2": return FILE_Map;
		case "ukx": return FILE_Animation;
		case "uax": return FILE_Sound;
		case "utx": return FILE_Texture;
		case "dem": return FILE_Demo;
		case "usx": return FILE_Static;
		case "ini": return FILE_Ini;
		case "log": return FILE_Log;
		case "avi": return FILE_DivX;
		case "xml": return FILE_XML;
		case "html":
		case "htm": return FILE_HTML;
		case "m3u":
		case "b4s":
		case "pls": return FILE_Playlist;
	}

	return FILE_None;
}

static function bool CompareNames( string NameA, string NameB )
{
	if ( IsCaseSensitive() )
		return NameA == NameB;

	return NameA ~= NameB;
}

function bool HandleDebugExec( string Command, string Param )
{
//	log(Class.Name$"::HandleDebugExec  Command:"$Command@"Param:"$Param);
	return false;
}

defaultproperties
{
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: pr 5-2-2018 12:35:48.000 - Creation time: sk 18-3-2018 09:50:19.363 - Created with UnCodeX