Package com.aelitis.azureus.core.devices

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


      try
        final IPCInterface  ipc = plugin_interface.getIPC();

        final Object context;
       
        final TranscodeProviderAdapter  adapter;
       
        if ( output.getProtocol().equals( "tcp" )){
         
          adapter = _adapter;
         
          context =
            ipc.invoke(
              "transcodeToTCP",
              new Object[]{
                ((TranscodeProviderAnalysisImpl)analysis).getResult(),
                source_url,
                profile.getName(),
                output.getPort() });
        }else{
         
          final File file = new File( output.toURI());
           
          adapter =
            new TranscodeProviderAdapter()
            {
              public void
              updateProgress(
                int    percent,
                int    eta_secs,
                int    width,
                int    height )
              {
                _adapter.updateProgress( percent, eta_secs, width, height );
              }
             
              public void
              streamStats(
                long          connect_rate,
                long          write_speed )
              {
                _adapter.streamStats(connect_rate, write_speed);
              }
             
              public void
              failed(
                TranscodeException    error )
              {
                try{
                  file.delete();
                 
                }finally{
                 
                  _adapter.failed( error );
                }
              }
             
              public void
              complete()
              {
                _adapter.complete();
              }
            };
           
          context =
            ipc.invoke(
              "transcodeToFile",
              new Object[]{
                ((TranscodeProviderAnalysisImpl)analysis).getResult(),
                source_url,
                profile.getName(),
                file });
        }
 
        new AEThread2( "xcodeStatus", true )
          {
            public void
            run()
            {
              try{
                boolean  in_progress = true;
               
                while( in_progress ){
                 
                  in_progress = false;
                 
                  if ( f_pipe != null ){
                   
                    adapter.streamStats( f_pipe.getConnectionRate(), f_pipe.getWriteSpeed());                   
                  }
                 
                  try{
                    Map status = (Map)ipc.invoke( "getTranscodeStatus", new Object[]{ context });
                   
                    long  state = (Long)status.get( "state" );
                   
                    if ( state == 0 ){
                     
                      int  percent = (Integer)status.get( "percent" );
                     
                      Integer  i_eta  = (Integer)status.get( "eta_secs" );
                     
                      int eta = i_eta==null?-1:i_eta;
                     
                      Integer  i_width  = (Integer)status.get( "new_width" );
                     
                      int width = i_width==null?0:i_width;
                     
                      Integer  i_height  = (Integer)status.get( "new_height" );
                     
                      int height = i_height==null?0:i_height;
                     
                      adapter.updateProgress( percent, eta, width, height );
                     
                      if ( percent == 100 ){
                       
                        adapter.complete();
   
                      }else{
                       
                        in_progress = true;
                     
                        Thread.sleep(1000);
                      }
                    }else if ( state == 1 ){
                     
                      adapter.failed( new TranscodeException( "Transcode cancelled" ));
                     
                    }else{
                     
                      adapter.failed( new TranscodeException( "Transcode failed", (Throwable)status.get( "error" )));
                    }
                  }catch( Throwable e ){
                   
                    adapter.failed( new TranscodeException( "Failed to get status", e ));
                  }
                }
              }finally{
               
                if ( f_pipe != null ){
View Full Code Here

TOP

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

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.