FileDocCategorySizeDatePackage
EnhancedDownloadManagerFile.javaAPI DocAzureus 3.0.3.43308Fri Sep 14 14:07:34 BST 2007com.aelitis.azureus.core.download

EnhancedDownloadManagerFile

public class EnhancedDownloadManagerFile extends Object

Fields Summary
private org.gudy.azureus2.core3.disk.DiskManagerFileInfo
file
private long
offset
private int
header_size
private int[]
speeds
Constructors Summary
protected EnhancedDownloadManagerFile(org.gudy.azureus2.core3.disk.DiskManagerFileInfo _file, long _offset, Map _map)

		file		= _file;
		offset		= _offset;
		
		try{
			if ( _map != null ){
				
				Long	l_header_size = (Long)_map.get( "header_size" );
				
				if ( l_header_size != null ){
					
					header_size = l_header_size.intValue();
				}
				
				List 	stream_info = (List)_map.get( "stream_info" );
				
				if ( stream_info != null ){
					
					speeds = new int[stream_info.size()][];
					
					for (int i=0;i<stream_info.size();i++){
						
						List	entry = (List)stream_info.get(i);
						
						
						int		speed 			= ((Long)entry.get(0)).intValue();
						int		worst_buffer	= ((Long)entry.get(1)).intValue();
						int		init_buffer		= ((Long)entry.get(2)).intValue();
						
						speeds[i] = new int[]{ speed, worst_buffer, init_buffer };
					}
				}
			}
		}catch( Throwable e ){
			
			Debug.printStackTrace(e);
		}
	
Methods Summary
public longgetByteOffestInTorrent()

		return( offset );
	
public org.gudy.azureus2.core3.disk.DiskManagerFileInfogetFile()

		return( file );
	
public intgetHeaderSize()

		return( header_size );
	
public intgetInitialBufferBytes(long rate)

		int	buffer_size = 0;
		
		if ( speeds != null ){
			
			int	k_rate = (int)rate/1024;
					
			for (int i=0;i<speeds.length;i++){
				
				if ( k_rate > speeds[i][0] ){
					
						// use the init buffer rather than the worst one
					
					buffer_size = speeds[i][2] * 1024;
					
					break;
				}
			}
		}
		
		// System.out.println( "getInitialBufferBytes(" + rate + ") -> " + header_size + "/" + buffer_size );
		
		return( header_size + buffer_size );
	
public java.lang.StringgetString()

		String	speeds_str = "";
		
		if ( speeds != null ){
		
			speeds_str = ",speeds=";
			
			for (int i=0;i<speeds.length;i++){
				
				int[]	s = speeds[i];
				
				speeds_str += (i==0?"":",") + "[" + s[0] + "," + s[1] + "," + s[2] + "]"; 
			}
		}
		
		return( file.getFile(true).getName()+ ",header=" + header_size + speeds_str );