TranscodeFile _transcode_file,
boolean _new_file )
{
TranscodeFileImpl transcode_file = (TranscodeFileImpl)_transcode_file;
IPCInterface ipc = upnpav_ipc;
synchronized( this ){
if ( ipc == null ){
return;
}
if ( !transcode_file.isComplete()){
syncCategories( transcode_file, _new_file );
return;
}
AzureusContentFile acf = (AzureusContentFile)transcode_file.getTransientProperty( UPNPAV_FILE_KEY );
if ( acf != null ){
return;
}
final String tf_key = transcode_file.getKey();
synchronized( acf_map ){
acf = acf_map.get( tf_key );
}
if ( acf != null ){
return;
}
try{
final DiskManagerFileInfo f = transcode_file.getTargetFile();
acf =
new AzureusContentFile()
{
public DiskManagerFileInfo
getFile()
{
return( f );
}
public Object
getProperty(
String name )
{
if( name.equals( MY_ACF_KEY )){
return( new Object[]{ DeviceUPnPImpl.this, tf_key });
}else if ( name.equals( PT_CATEGORIES )){
TranscodeFileImpl tf = getTranscodeFile( tf_key );
if ( tf != null ){
return( tf.getCategories());
}
return( new String[0] );
}else{
TranscodeFileImpl tf = getTranscodeFile( tf_key );
if ( tf != null ){
long res = 0;
if ( name.equals( PT_DURATION )){
res = tf.getDurationMillis();
}else if ( name.equals( PT_VIDEO_WIDTH )){
res = tf.getVideoWidth();
}else if ( name.equals( PT_VIDEO_HEIGHT )){
res = tf.getVideoHeight();
}else if ( name.equals( PT_DATE )){
res = tf.getCreationDateMillis();
}else if ( name.equals( PT_PERCENT_DONE )){
if ( tf.isComplete()){
res = 1000;
}else{
TranscodeJob job = tf.getJob();
if ( job == null ){
res = 0;
}else{
res = 10*job.getPercentComplete();
}
}
return( res );
}else if ( name.equals( PT_ETA )){
if ( tf.isComplete()){
res = 0;
}else{
TranscodeJob job = tf.getJob();
if ( job == null ){
res = Long.MAX_VALUE;
}else{
res = job.getETASecs();
}
}
return( res );
}
if ( res > 0 ){
return( new Long( res ));
}
}
}
return( null );
}
};
transcode_file.setTransientProperty( UPNPAV_FILE_KEY, acf );
synchronized( acf_map ){
acf_map.put( tf_key, acf );
}
syncCategories( transcode_file, _new_file );
try{
ipc.invoke( "addContent", new Object[]{ acf });
}catch( Throwable e ){
Debug.out( e );
}