Examples of IPCInterface


Examples of org.gudy.azureus2.plugins.ipc.IPCInterface

  addDynamicXCode(
    final DiskManagerFileInfo    source )
  {
    final TranscodeProfile profile = dynamic_transcode_profile;
   
    IPCInterface      ipc  = upnpav_ipc;
   
    if ( profile == null || ipc == null ){
     
      return;
    }
   
    try{
      TranscodeFileImpl transcode_file = allocateFile( profile, false, source, false );
     
      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;
      }
     
      final DiskManagerFileInfo stream_file =
        new DiskManagerFileInfoStream(
          new DiskManagerFileInfoStream.StreamFactory()
          {
            private List<Object>  current_requests = new ArrayList<Object>();
           
            public StreamDetails
            getStream(
              Object    request )
           
              throws IOException
            {           
              try{
                TranscodeJobImpl job = getManager().getTranscodeManager().getQueue().add(
                    (TranscodeTarget)DeviceUPnPImpl.this,
                    profile,
                    source,
                    false,
                    true,
                    TranscodeTarget.TRANSCODE_UNKNOWN );
                 
                synchronized( this ){
               
                  current_requests.add( request );
                }
               
                while( true ){
                 
                  InputStream is = job.getStream( 1000 );
                 
                  if ( is != null ){
                   
                    return( new StreamWrapper( is, job ));
                  }
                 
                  int  state = job.getState();
                 
                  if ( state == TranscodeJobImpl.ST_FAILED ){
                   
                    throw( new IOException( "Transcode failed: " + job.getError()));
                   
                  }else if ( state == TranscodeJobImpl.ST_CANCELLED ){
                   
                    throw( new IOException( "Transcode failed: job cancelled" ));
 
                  }else if ( state == TranscodeJobImpl.ST_COMPLETE ){
                   
                    throw( new IOException( "Job complete but no stream!" ));
                  }
                 
                  synchronized( this ){
                   
                    if ( !current_requests.contains( request )){
                     
                      break;
                    }
                  }
                 
                  System.out.println( "waiting for stream" );
                 
                }
               
                IOException error = new IOException( "Stream request cancelled" );
               
                job.failed( error );
               
                throw( error );
               
              }catch( IOException e ){
               
                throw( e );
               
              }catch( Throwable e ){
               
                throw( new IOException( "Failed to add transcode job: " + Debug.getNestedExceptionMessage(e)));
               
              }finally{
               
                synchronized( this ){
               
                  current_requests.remove( request );
                }
              }
            }
           
            public void
            destroyed(
              Object request )
            {
              synchronized( this ){
               
                current_requests.remove( request );
              }
            }
          },
          transcode_file.getCacheFile());
                   
      acf =  new AzureusContentFile()
          { 
               public DiskManagerFileInfo
               getFile()
               {
                 return( stream_file );
               }
              
            public Object
            getProperty(
              String    name )
            {
                // TODO: duration etc

              if ( name.equals( MY_ACF_KEY )){
               
                return( new Object[]{ DeviceUPnPImpl.this, tf_key });
               
              }else if ( name.equals( PT_PERCENT_DONE )){
               
                return( new Long(1000));
               
              }else if ( name.equals( PT_ETA )){
               
                return( new Long(0));
              }
             
              return( null );
            }
          };
     
      synchronized( acf_map ){

        acf_map.put( tf_key, acf );
      }
         
      transcode_file.setTransientProperty( UPNPAV_FILE_KEY, acf );

      syncCategories( transcode_file, true );
         
      synchronized( this ){
       
        if ( dynamic_xcode_map == null ){
         
          dynamic_xcode_map = new HashMap<String,AzureusContentFile>();
        }
       
        dynamic_xcode_map.put( tf_key, acf );
      }
     
      ipc.invoke( "addContent", new Object[]{ acf });
     
    }catch( Throwable e ){
     
      Debug.out( e );
    }
View Full Code Here

Examples of org.gudy.azureus2.plugins.ipc.IPCInterface

  removeDynamicXCode(
    final DiskManagerFileInfo    source )
  {
    final TranscodeProfile profile = dynamic_transcode_profile;
   
    IPCInterface      ipc  = upnpav_ipc;
   
    if ( profile == null || ipc == null ){
     
      return;
    }
   
    try{
      TranscodeFileImpl transcode_file = lookupFile( profile, source );

        // if the file completed transcoding then we leave the result around for
        // the user to re-use
     
      if ( transcode_file != null && !transcode_file.isComplete()){
       
        AzureusContentFile acf = null;
       
        synchronized( this ){
 
          if ( dynamic_xcode_map != null ){
         
            acf = dynamic_xcode_map.get( transcode_file.getKey());
          }
        }
       
        transcode_file.delete( true );
       
        if ( acf != null ){
       
          ipc.invoke( "removeContent", new Object[]{ acf });
        }
       
        synchronized( acf_map ){
         
          acf_map.remove( transcode_file.getKey());
View Full Code Here

Examples of org.gudy.azureus2.plugins.ipc.IPCInterface

    if ( acf != null ){
     
      return( true );
    }
   
    IPCInterface      ipc  = upnpav_ipc;

    if ( ipc == null ){
     
      return( false );
    }
   
    if ( transcode_file.getDurationMillis() == 0 ){
     
      return( false );
    }
   
    try{
      final DiskManagerFileInfo stream_file =
        new TranscodeJobOutputLeecher( job, transcode_file );
                   
      acf =  new AzureusContentFile()
          { 
               public DiskManagerFileInfo
               getFile()
               {
                 return( stream_file );
               }
              
            public Object
            getProperty(
              String    name )
            {
                // TODO: duration etc
 
              if ( name.equals( MY_ACF_KEY )){
               
                return( new Object[]{ DeviceUPnPImpl.this, tf_key });
               
              }else if ( name.equals( PT_PERCENT_DONE )){
               
                return( new Long(1000));
               
              }else if ( name.equals( PT_ETA )){
               
                return( new Long(0));
              }
             
              return( null );
            }
          };
     
      synchronized( acf_map ){
 
        acf_map.put( tf_key, acf );
      }
   
      ipc.invoke( "addContent", new Object[]{ acf });

      log( "Set up stream-xcode for " + transcode_file.getName());
     
      return( true );
     
View Full Code Here

Examples of org.gudy.azureus2.plugins.ipc.IPCInterface

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

Examples of org.gudy.azureus2.plugins.ipc.IPCInterface

 
  public void
  fileRemoved(
    TranscodeFile    file )
  {
    IPCInterface ipc = upnp_manager.getUPnPAVIPC();
   
    if ( ipc == null ){
     
      return;
    }

    synchronized( this ){

      AzureusContentFile acf = (AzureusContentFile)file.getTransientProperty( UPNPAV_FILE_KEY );

      if ( acf == null ){
   
        return;
      }
     
      file.setTransientProperty( UPNPAV_FILE_KEY, null );

      try{
        ipc.invoke( "removeContent", new Object[]{ acf });
     
       
      }catch( Throwable e ){
       
        Debug.out( e );
View Full Code Here

Examples of org.gudy.azureus2.plugins.ipc.IPCInterface

  protected URL
  getStreamURL(
    TranscodeFileImpl    file,
    String          host )
  {
    IPCInterface ipc = upnp_manager.getUPnPAVIPC();
   
    if ( ipc != null ){

      try{
        DiskManagerFileInfo f = file.getTargetFile();
       
        String str = (String)ipc.invoke( "getContentURL", new Object[]{ f });
       
        if ( str != null && str.length() > 0 ){
         
          if ( host != null ){
           
View Full Code Here

Examples of org.gudy.azureus2.plugins.ipc.IPCInterface

    if ( getMimeType_fails > 5 ){
     
      return( null );
    }
   
    IPCInterface ipc = upnp_manager.getUPnPAVIPC();
   
    if ( ipc != null ){

      try{
        DiskManagerFileInfo f = file.getTargetFile();
       
        String str = (String)ipc.invoke( "getMimeType", new Object[]{ f });
       
        if ( str != null && str.length() > 0 ){
         
          return( str );
        }
View Full Code Here

Examples of org.gudy.azureus2.plugins.ipc.IPCInterface

              {
                if ( result instanceof Boolean ){
                 
                  PluginInterface pi = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByID( "mlab" );

                  IPCInterface callback =
                    new IPCInterface()
                    {
                      public Object
                      invoke(
                        String     methodName,
                        Object[]  params )
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.