Examples of DeviceManager


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

        if ( l_duration == null ){
           
          active_edm.prepareForProgressiveMode( true );
         
          try{
            DeviceManager dm = DeviceManagerFactory.getSingleton();
           
            TranscodeManager tm = dm.getTranscodeManager();
           
            DeviceMediaRenderer dmr =
              (DeviceMediaRenderer)dm.addVirtualDevice(
                Device.DT_MEDIA_RENDERER,
                "18a0b53a-a466-6795-1d0f-cf38c830ca0e",
                "generic",
                "Media Analyser" );
 
            dmr.setHidden(true);
 
            TranscodeQueue queue = tm.getQueue();
           
            TranscodeJob[] jobs = queue.getJobs();
           
            for ( TranscodeJob job: jobs ){
             
              if ( job.getTarget() == dmr ){
               
                job.removeForce();
              }
            }
           
            TranscodeProfile[] profiles = dmr.getTranscodeProfiles();
           
            TranscodeProfile profile = null;
           
            for (TranscodeProfile p : profiles) {
             
              if ( p.getName().equals( "Generic MP4" )){
               
                profile = p;
 
                break;
              }
            }
           
            if ( profile == null ){
             
              throw( new Exception( "Analyser transcode profile not found" ));
            }
           
            listener.updateActivity( "Analysing media" );
           
            final Map<String,Object> b_map = new HashMap<String,Object>();
           
            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 ){
           
            throw( new Exception( "Media analysis failed", e ));
           
          }finally{
           
          }
        }else{
           
          duration     = l_duration;
          video_width    = l_video_width==null?0:l_video_width;
          video_height  = l_video_height==null?0:l_video_height;
        }
         
        if ( video_width == 0 || video_height == 0){
         
          throw( new Exception( "Media analysis failed - video stream not found" ));
        }
       
        if ( duration == 0 ){
         
          throw( new Exception( "Media analysis failed - duration unknown" ));
        }
       
        listener.updateActivity( "MetaData read: duration=" + TimeFormatter.formatColon( duration/1000) + ", width=" + video_width + ", height=" + video_height );
       
        Method smd_method = player.getClass().getMethod( "setMetaData", new Class[] { Map.class });
       
        Map<String,Object>  md_map = new HashMap<String,Object>();
       
        md_map.put( "duration", duration );
        md_map.put( "width", video_width );
        md_map.put( "height", video_height );
       
        smd_method.invoke( player, new Object[] { md_map });

        final long  bytes_per_sec = file.getLength() / (duration/1000);
     
        long  dl_lim_max     = COConfigurationManager.getIntParameter( "Plugin.azemp.azemp.config.dl_lim_max" ) * 1024L;
        long  dl_lim_extra   = COConfigurationManager.getIntParameter( "Plugin.azemp.azemp.config.dl_lim_extra" ) * 1024L;

        existing_dl_limit = download.getDownloadRateLimitBytesPerSecond();
       
        long  required_limit = Math.max( dl_lim_max, bytes_per_sec + dl_lim_extra );

        if ( required_limit > 0 ){
       
          download.setDownloadRateLimitBytesPerSecond((int)required_limit );
        }
       
        listener.updateActivity( "Average rate=" + DisplayFormatters.formatByteCountToKiBEtcPerSec( bytes_per_sec ) + ", applied dl limit=" + DisplayFormatters.formatByteCountToKiBEtcPerSec( required_limit ));

        synchronized( StreamManager.this ){
         
          if ( cancelled ){
           
            throw( new Exception( "Cancelled" ));
          }
                                                   
          active_edm.setExplicitProgressive( BUFFER_SECS, bytes_per_sec, file_index );
         
          if ( !active_edm.setProgressiveMode( true )){
           
            throw( new Exception( "Failed to set download as progressive" ));
          }
         
          active_edm_activated = true;
        }
       
        new AEThread2( "streamMon" )
        {
         
          public void
          run()
          { 
            final int TIMER_PERIOD     = 250;
            final int PLAY_STATS_PERIOD  = 5000;
            final int PLAY_STATS_TICKS  = PLAY_STATS_PERIOD / TIMER_PERIOD;
           
            final int DL_STARTUP_PERIOD  = 5000;
            final int DL_STARTUP_TICKS  = DL_STARTUP_PERIOD / TIMER_PERIOD;
     
            boolean playback_started   = false;
            boolean  playback_paused    = false;

            boolean  error_reported = false;
           
            try{
              Method start_method     = player.getClass().getMethod( "startPlayback", new Class[] { URL.class });
              Method pause_method     = player.getClass().getMethod( "pausePlayback", new Class[] {});
              Method resume_method     = player.getClass().getMethod( "resumePlayback", new Class[] {});
              Method buffering_method    = player.getClass().getMethod( "bufferingPlayback", new Class[] { Map.class });
              Method play_stats_method  = player.getClass().getMethod( "playStats", new Class[] { Map.class });

              int tick_count = 0;
             
              while( !cancelled ){
                 
                tick_count++;
               
                int dm_state = dm.getState();
               
                boolean complete = file.getLength() == file.getDownloaded();

                if ( !complete ){
                 
View Full Code Here

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

          List<TranscodeTarget> result = new ArrayList<TranscodeTarget>();
         
          if ( !COConfigurationManager.getStringParameter("ui").equals("az2")){

            try{
              DeviceManager dm = DeviceManagerFactory.getSingleton();
           
              Device[] devices = dm.getDevices();
             
              for ( final Device d: devices ){
               
                if ( d instanceof DeviceMediaRenderer ){
                 
View Full Code Here

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

  protected void deviceSelected(final ISelectedContent[] contents,
      final boolean allow_retry) {
    TranscodeChooser deviceChooser = new TranscodeChooser() {
      public void closed() {
        DeviceManager deviceManager = DeviceManagerFactory.getSingleton();
        if (selectedTranscodeTarget != null && selectedProfile != null) {
          for (int i = 0; i < contents.length; i++) {
            ISelectedContent selectedContent = contents[i];

            DownloadManager dm = selectedContent.getDownloadManager();
            if (dm == null) {
              continue;
            }
            DiskManagerFileInfo[] files = dm.getDiskManagerFileInfo();
            for (DiskManagerFileInfo file : files) {
              try {
                deviceManager.getTranscodeManager().getQueue().add(
                    selectedTranscodeTarget,
                    selectedProfile,
                    (org.gudy.azureus2.plugins.disk.DiskManagerFileInfo) PluginCoreUtils.convert(
                        file, false), false);
              } catch (TranscodeException e) {
View Full Code Here

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

      PlatformDevicesMessenger.qosTurnOn(itunes, isBugFix);
    } catch (Throwable ignore) {
    }
    try {
      // catch any devices we found before installing additional plugins
      DeviceManager device_manager = DeviceManagerFactory.getSingleton();
      Device[] devices = device_manager.getDevices();
      for (Device device : devices) {
        try {
          PlatformDevicesMessenger.qosFoundDevice(device);
        } catch (Throwable ignore) {
        }
View Full Code Here

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

   * @return
   *
   * @since 4.1.0.5
   */
  public static boolean ensureInstalled( final Runnable fire_on_install ) {
    DeviceManager device_manager = DeviceManagerFactory.getSingleton();

    if (device_manager.getTranscodeManager().getProviders().length == 0) {
      Utils.execSWTThread(new AERunnable() {
        public void runSupport() {
          if (instance == null || instance.isDisposed()) {
            instance = new DevicesFTUX();
            instance.open( fire_on_install );
View Full Code Here

Examples of com.android.sdklib.devices.DeviceManager

            String deviceName = properties.get(AVD_INI_DEVICE_NAME);
            String deviceMfctr = properties.get(AVD_INI_DEVICE_MANUFACTURER);
            String hash = properties.get(AVD_INI_DEVICE_HASH);
            if (deviceName != null && deviceMfctr != null && hash != null) {
                int deviceHash = Integer.parseInt(hash);
                DeviceManager devMan = DeviceManager.createInstance(myLocalSdk.getLocation(), log);
                deviceStatus = devMan.getDeviceStatus(deviceName, deviceMfctr, deviceHash);
            }
        }


        // TODO: What about missing sdcard, skins, etc?
View Full Code Here

Examples of es.unizar.cps.tecnodiscap.data.DeviceManager

  }

  private void abrirConexiones() {
    // TODO Pasar lista de nodos.
    if (deviceManager == null) {
      deviceManager = new DeviceManager();
      deviceManager.addListener(this);
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
View Full Code Here

Examples of org.jnode.driver.DeviceManager

    public static void main(String[] args) throws Exception {
        new FdiskCommand().execute(args);
    }

    public void execute() throws Exception {
        final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
        PrintWriter out = getOutput().getPrintWriter();
        PrintWriter err = getError().getPrintWriter();
        if (!ARG_DEVICE.isSet()) {
            // Show all devices.
            listAvailableDevices(dm, out);
View Full Code Here

Examples of org.jnode.driver.DeviceManager

        final String password = PASSWORD_ARG.getValue();
        boolean ok = false;
       
        final FileSystemService fss = InitialNaming.lookup(FileSystemService.NAME);
        FTPFileSystemType type = fss.getFileSystemType(FTPFileSystemType.ID);
        final DeviceManager dm = DeviceUtils.getDeviceManager();
        final FTPFSDevice dev = new FTPFSDevice(host, user, password);
        dev.setDriver(new FTPFSDriver());
        FTPFileSystem fs = null;
        try {
            dm.register(dev);
            fs = type.create(dev, true);
            fss.registerFileSystem(fs);
            fss.mount(mountPoint.getAbsolutePath(), fs, null);
            ok = true;
        } catch (Exception ex) {
            getError().getPrintStream().println("FTP mount failed: " + ex.getLocalizedMessage());
            throw ex;
        } finally {
            if (!ok) {
                try {
                    // If we failed, try to undo the changes that we managed to make
                    if (fs != null) {
                        fss.unregisterFileSystem(dev);
                    }
                    dm.unregister(dev);
                } catch (Exception ex) {
                    Logger log = Logger.getLogger(FTPMountCommand.class);
                    log.fatal("Cannot undo failed mount attempt", ex);
                }
            }
View Full Code Here

Examples of org.jnode.driver.DeviceManager

    public void refresh() {
        super.refresh();
        final TreeMap<String, Device> tm = new TreeMap<String, Device>();
        try {
            final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
            for (Device dev : dm.getDevices()) {
                tm.put(dev.getId(), dev);
            }
        } catch (javax.naming.NameNotFoundException E) {
            System.err.println("could not find DeviceManager");
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.