Package com.aelitis.azureus.core.devices

Examples of com.aelitis.azureus.core.devices.TranscodeJob


                     
                      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 );
                  }
View Full Code Here


            b_map.put( "state", new Integer( 1 ));
            b_map.put( "msg", MessageText.getString( "stream.analysing.media" ));
           
            buffering_method.invoke(player, new Object[] { b_map });

            final TranscodeJob tj = queue.add( dmr, profile, file, true );
                     
            try{
              final AESemaphore sem = new AESemaphore( "analyserWait" );

              synchronized( StreamManager.this ){
               
                if ( cancelled ){
                 
                  throw( new Exception( "Cancelled" ));
                }
               
                active_sem  = sem;
                active_job   = tj;
              }
               
              final long[] properties = new long[3];
             
              final Throwable[] error = { null };
             
              tj.analyseNow(
                new TranscodeAnalysisListener()
                {
                  public void
                  analysisComplete(
                    TranscodeJob          file,
                    TranscodeProviderAnalysis    analysis )
                  {
                    try{                     
                      properties[0] = analysis.getLongProperty( TranscodeProviderAnalysis.PT_DURATION_MILLIS );
                      properties[1] = analysis.getLongProperty( TranscodeProviderAnalysis.PT_VIDEO_WIDTH );
                      properties[2] = analysis.getLongProperty( TranscodeProviderAnalysis.PT_VIDEO_HEIGHT );
                     
                      tj.removeForce();
                     
                    }finally{
                     
                      sem.releaseForever();
                    }
                  }
                 
                  public void
                  analysisFailed(
                    TranscodeJob    file,
                    TranscodeException  e )
                  {
                    try{
                      error[0] = e;
                   
                      tj.removeForce();
                     
                    }finally{
                     
                      sem.releaseForever();
                    }
                  }
                });
             
              new AEThread2( "SM:anmon" )
                {
                  public void
                  run()
                  {
                    boolean  last_preview_mode = preview_mode;
                   
                    while( !sem.isReleasedForever() && !cancelled ){
                     
                      if ( !sem.reserve( 250 )){
                     
                        if ( cancelled ){
                         
                          return;
                        }
                         
                        try{
                          Boolean b = (Boolean)is_active_method.invoke( player, new Object[0] );
                         
                          if ( !b ){
                           
                            cancel();
                           
                            break;
                          }
                        }catch( Throwable e ){ 
                        }
                       
                        if ( last_preview_mode != preview_mode ){
                         
                          last_preview_mode = preview_mode;
                         
                          b_map.put( "msg", MessageText.getString( last_preview_mode?"stream.analysing.media.preview":"stream.analysing.media" ));

                        }
                        DownloadStats stats = download.getStats();
                       
                        b_map.put( "dl_rate", stats.getDownloadAverage());
                        b_map.put( "dl_size", stats.getDownloaded());
                        b_map.put( "dl_time", SystemTime.getMonotonousTime() - stream_start );
                       
                        try{
                          buffering_method.invoke(player, new Object[] { b_map });

                        }catch( Throwable e ){
                         
                        }
                      }
                    }
                  }
                }.start();
               
              sem.reserve();
             
              synchronized( StreamManager.this ){
               
                if ( cancelled ){
                   
                  throw( new Exception( "Cancelled" ));
                }
               
                active_job   = null;
                active_sem  = null;
              }
             
              if ( error[0] != null ){
               
                throw( error[0] );
              }
             
              duration     = properties[0];
              video_width    = properties[1];
              video_height  = properties[2];
             
              if ( duration > 0 ){
               
                if ( map == null ){
                 
                  map = new HashMap<String, Map<String,Object>>();
                 
                }else{
                 
                  map = new HashMap<String, Map<String,Object>>( map );
                }
               
                Map<String,Object> file_map = map.get( String.valueOf( file_index ));
               
                if ( file_map == null ){
               
                  file_map = new HashMap<String, Object>();
                 
                  map.put( String.valueOf( file_index ), file_map );
                }
               
                file_map.put( "duration", duration );
                file_map.put( "video_width", video_width );
                file_map.put( "video_height", video_height );
               
                download.setMapAttribute( mi_ta, map );
              }
             
            }catch( Throwable e ){
             
              tj.removeForce();
             
              throw( e );
            }
           
          }catch( Throwable e ){
View Full Code Here

    }
   
    public void
    cancel()
    {
      TranscodeJob  job;
     
      EnhancedDownloadManager  edm;
      boolean          edm_activated;
     
      synchronized( StreamManager.this ){
       
        cancelled = true;
     
        job = active_job;
       
        if ( active_sem != null ){
         
          active_sem.releaseForever();
        }
       
        edm       = active_edm;
        edm_activated  = active_edm_activated;
       
        streamers.remove( this );
      }
     
      if ( job != null ){
       
        job.removeForce();
      }
     
      if ( edm != null ){
       
        if ( edm_activated ){
View Full Code Here

  }
 
  public String
  getName()
  {
    TranscodeJob job = getJob();

    String text;
   
    if ( job == null){
     
      try{
        DiskManagerFileInfo sourceFile = getSourceFile();
       
        try {
          Download download = sourceFile.getDownload();
         
          if ( download == null ){
           
            text = sourceFile.getFile().getName();
           
          }else{
           
            text = download.getName();
           
            DiskManagerFileInfo[] fileInfo = download.getDiskManagerFileInfo();
           
            if (fileInfo.length > 1) {
             
              text += ": " + sourceFile.getFile().getName();
            }
          }
        }catch (DownloadException e ){
         
          text = sourceFile.getFile().getName();
        }
     
      }catch( Throwable e ){

        text = "";
      }
    }else{
     
      text = job.getName();
    }
   
    return( text );
  }
View Full Code Here

  public void refresh(TableCell cell) {
    TranscodeFile tf = (TranscodeFile) cell.getDataSource();
    if (tf == null) {
      return;
    }
    TranscodeJob job = tf.getJob();
   
    String   tooltip = null;
    String  text  = null;
    boolean  error  = false;
   
    if ( job == null ){
     
      try{
        if ( tf.isComplete() && !tf.getTargetFile().getFile().exists()){
         
          tooltip = "File '" + tf.getTargetFile().getFile().getAbsolutePath() + "' not found";
         
          text = js_resources[5] + ": File not found";
         
          error = true;
        }
      }catch( Throwable e ){     
      }
     
      if ( text == null ){

        if ( tf.isCopyingToDevice() ) {

          text = js_resources[11];

        } else if ( tf.getCopyToDeviceFails() > 0 ){
     
          text = js_resources[7];
         
          error = true;
         
        }else if ( tf.isTemplate() && !tf.isComplete()){
         
          text = js_resources[8];
         
        }else{
         
          text = js_resources[9];
        }
      }
    }else{
     
      int state = job.getState();

      text = js_resources[state];

      if ( state == TranscodeJob.ST_QUEUED ){
       
        long eta = job.getDownloadETA();
     
        if ( eta > 0 ){
       
          text = js_resources[10] + ": " + eta_text + " " + ( eta==Long.MAX_VALUE?Constants.INFINITY_STRING:TimeFormatter.format( eta ));
        }
      }else{
       
        text = js_resources[state];
 
        if ( state == TranscodeJob.ST_FAILED ) {
           
          String  error_msg = job.getError();
         
          if ( error_msg != null ){
           
              // error message can be very large and technical as it includes output
              // from ffmpeg error etc. So trim it back for user consumption.
View Full Code Here

        ISelectedContent sc = (ISelectedContent) ds;
        int idx = sc.getFileIndex();
        DownloadManager dm = sc.getDownloadManager();
        return dm.getDiskManagerFileInfoSet().getFiles()[idx];
      } else if (ds instanceof TranscodeJob) {
        TranscodeJob tj = (TranscodeJob) ds;
        try {
          return PluginCoreUtils.unwrap(tj.getFile());
        } catch (DownloadException e) {
        }
      } else if (ds instanceof TranscodeFile) {
        TranscodeFile tf = (TranscodeFile) ds;
        try {
View Full Code Here

        GlobalManager gm = AzureusCoreFactory.getSingleton().getGlobalManager();
        return gm.getDownloadManager((TOTorrent) ds);
      } else if (ds instanceof ISelectedContent) {
        return getDM(((ISelectedContent)ds).getDownloadManager());
      } else   if (ds instanceof TranscodeJob) {
        TranscodeJob tj = (TranscodeJob) ds;
        try {
          DiskManagerFileInfo file = tj.getFile();
          if (file != null) {
            Download download = tj.getFile().getDownload();
            if (download != null) {
              return PluginCoreUtils.unwrap(download);
            }
          }
        } catch (DownloadException e) {
View Full Code Here

      } catch (Throwable e) {
      }
    }

    if (ds instanceof TranscodeJob) {
      TranscodeJob tj = (TranscodeJob) ds;
      try {
        DiskManagerFileInfo file = tj.getFile();
        if (file != null) {
          Download download = tj.getFile().getDownload();
         
          if (download != null) {
            Torrent torrent = download.getTorrent();
            if (torrent != null) {
              return PluginCoreUtils.unwrap(torrent);
View Full Code Here

        return getContentNetwork(((ISelectedContent)ds).getDownloadManager());
      } else if ((ds instanceof String) && ((String)ds).length() == 32) {
        // assume 32 byte string is a hash and that it belongs to the def. network
        id = ConstantsVuze.getDefaultContentNetwork().getID();
      } else   if (ds instanceof TranscodeJob) {
        TranscodeJob tj = (TranscodeJob) ds;
        try {
          DiskManagerFileInfo file = tj.getFile();
          if (file != null) {
            Download download = tj.getFile().getDownload();
            if (download != null) {
              DownloadManager dm = PluginCoreUtils.unwrap(download);
              return getContentNetwork(dm);
            }
          }
View Full Code Here

  public void refresh(TableCell cell) {
    TranscodeFile tf = (TranscodeFile) cell.getDataSource();
    if (tf == null) {
      return;
    }
    TranscodeJob job = tf.getJob();

    long value;
    if (job == null) {
      try {
        value = Integer.MAX_VALUE + tf.getCreationDateMillis() + 1;
      } catch (Throwable t) {
        value = Integer.MAX_VALUE + 1L;
      }
    } else {
      value = job.getIndex();
    }
    if (cell.setSortValue(value) || !cell.isValid()) {
      if (value > Integer.MAX_VALUE) {
        cell.setText("");
      } else {
View Full Code Here

TOP

Related Classes of com.aelitis.azureus.core.devices.TranscodeJob

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.