Package javax.media

Examples of javax.media.IncompatibleSourceException


    public void setSource(DataSource source)
        throws IOException, IncompatibleSourceException {

        if (!(source instanceof PullDataSource)) {
            throw new IncompatibleSourceException("DataSource not supported: " + source);
        } else {
            streams = ((PullDataSource) source).getStreams();
        }

        if ( streams == null) {
            throw new IOException("Got a null stream from the DataSource");
        }

        if (streams.length == 0) {
            throw new IOException("Got a empty stream array from the DataSource");
        }
        this.source = source;
       
        positionable =  (streams[0] instanceof Seekable);
        seekable =  positionable && ((Seekable)
                   streams[0]).isRandomAccess();

        if (!supports(streams))
            throw new IncompatibleSourceException("DataSource not supported: " + source);
    }
View Full Code Here


  {
      if (TRACE) logger.fine("DataSource: " + source);
   
    
      if (!source.getLocator().getProtocol().equals("file"))
        throw new IncompatibleSourceException("Only file URLs supported: " + source);
     
    // TODO: only handling file URLs right now.
    String path = URLUtils.extractValidPathFromFileUrl(source.getLocator().toExternalForm());
    if (path == null)
      throw new IncompatibleSourceException("Unable to extract valid file path from URL: " + source.getLocator().toExternalForm());
 
    try
    {
      // because Java thinks that /C: is a valid way to start a path on Windows, we have to turn it
      // into something more normal.
      path = new File(path).getCanonicalPath();
    }
    catch (IOException e1)
    {
      final String msg = "Unable to get canonical path from " + path + ": " + e1;
      logger.log(Level.WARNING, msg, e1);
      throw new IncompatibleSourceException(msg);
    }
   
   
    logger.info("Path: " + path);
   
    try
    {
      System.loadLibrary("jdshow");
    }
    catch (Throwable e)
    {  logger.log(Level.WARNING, "" + e, e);
      throw new IncompatibleSourceException();
    }
   
    // TODO: check if media has visual
    visualComponent = new MyCanvas();
   
    visualComponent.addComponentListener(new MyComponentListener());
   
    try
    {
         Com.CoInitialize();
       
         int hr;
        
      long[] p = new long[1];
      hr = Com.CoCreateInstance(Com.CLSID_FilterGraph, 0L, Com.CLSCTX_ALL, Com.IID_IGraphBuilder, p);
      if (Com.FAILED(hr))
        throw new ComException(hr);
     
      graphBuilder = new IGraphBuilder(p[0]);
     

       
      hr = graphBuilder.RenderFile(path, "");
      if (Com.FAILED(hr))
        throw new ComException(hr);
 
      hr = graphBuilder.QueryInterface(Com.IID_IMediaControl, p);
      if (Com.FAILED(hr))
        throw new ComException(hr);
      mediaControl = new IMediaControl(p[0]);
     
      hr = graphBuilder.QueryInterface(Com.IID_IMediaSeeking, p);
      if (Com.FAILED(hr))
        throw new ComException(hr);
      mediaSeeking = new IMediaSeeking(p[0]);
     
 
      hr = graphBuilder.QueryInterface(Com.IID_IVideoWindow, p);
      if (Com.FAILED(hr))
        throw new ComException(hr);
     
      // determine video size:
      final IVideoWindow videoWindow = new IVideoWindow(p[0]);

      {
        long[] width = new long[1];
        hr = videoWindow.get_Width(width);
        if (Com.FAILED(hr))
          throw new ComException(hr);
        //logger.fine("width: " + width[0]);
       
        long[] height = new long[1];
        hr = videoWindow.get_Height(height);
        if (Com.FAILED(hr))
          throw new ComException(hr);
        //logger.fine("height: " + height[0]);
       
        videoSize = new Dimension((int) width[0], (int) height[0]);
      }
     
      videoWindow.Release();
     
     
    }
    catch (ComException e)
    {
      logger.log(Level.WARNING, "" + e, e);
      throw new IncompatibleSourceException(e.getMessage());
    }
      
      super.setSource(source);
     
  }
View Full Code Here

    public void setSource(DataSource source)
        throws IncompatibleSourceException
    {
        //  Make sure the DataSource has only been set once
        if( this.source != null ) {
            throw new IncompatibleSourceException(
                "Datasource already set in MediaHandler " +
                    getClass().getName() );
        }

        this.source = source;
View Full Code Here

  //@Override
  public void setSource(DataSource source) throws IOException, IncompatibleSourceException
  {
    if (!(source instanceof PullDataSource))
      throw new IncompatibleSourceException();
    this.source = (PullDataSource) source;
  }
View Full Code Here

    final String protocol = source.getLocator().getProtocol();
   
    if (USE_DATASOURCE_URL_ONLY)
    {
      if (!(protocol.equals("file")))
        throw new IncompatibleSourceException();

    }
    else
    {

   
    if (!(source instanceof PullDataSource))
      throw new IncompatibleSourceException();
    }
   
    this.source = (PullDataSource) source;
   
  }
View Full Code Here

  {
       if (TRACE) logger.fine("DataSource: " + source);

       initGstreamer();
       if (!gstInitialized)
         throw new IncompatibleSourceException("Unable to initialize gstreamer");

    if (source.getLocator() == null)
         throw new IncompatibleSourceException("null source locator");
     
      super.setSource(source);
     
  }
View Full Code Here

  private JavaSoundCodec codec;
 
    public void setSource(DataSource source) throws IncompatibleSourceException
  {
      if (!(source instanceof PullDataSource))
        throw new IncompatibleSourceException();
         if (!(source instanceof SourceCloneable))
        throw new IncompatibleSourceException();

     
      final PullDataSource pds = (PullDataSource) source;
     
     
     
      if (TRACE) logger.fine("DataSource: " + source);
 
        // TODO: do this in prefetch or realize?
       
      parser = new JavaSoundParser();
     
      try
    {
        parser.open();
      parser.setSource(pds);
      parser.start();
      final Track[] tracks = parser.getTracks();
      if (tracks.length != 1)
        throw new IncompatibleSourceException("Expected exactly 1 track: " + tracks.length);
      track = parser.getTracks()[0]// TODO: what if multiple tracks?
      logger.fine("Format: " + track.getFormat());
     
      codec = new JavaSoundCodec();
     
     
     

     
    } catch (IncompatibleSourceException e)
    {
      logger.log(Level.WARNING, "" + e, e);
      throw e;
    } catch (IOException e)
    {
      logger.log(Level.WARNING, "" + e, e);
      throw new IncompatibleSourceException(e.getMessage());
    } catch (ResourceUnavailableException e)
    {
      logger.log(Level.WARNING, "" + e, e);
      throw new IncompatibleSourceException(e.getMessage());
    } catch (BadHeaderException e)
    {
      logger.log(Level.WARNING, "" + e, e);
      throw new IncompatibleSourceException(e.getMessage());
    }
     
   
    renderer = new JavaSoundRenderer();
   
View Full Code Here

    public void setSource(DataSource source)
        throws IncompatibleSourceException
    {
        //  Make sure the DataSource has only been set once
        if( this.source != null ) {
            throw new IncompatibleSourceException(
                "Datasource already set in MediaHandler " +
                    getClass().getName() );
        }

        this.source = source;
View Full Code Here

    }

      } else {

    // This handler only handles push or pull buffer datasource.
    throw new IncompatibleSourceException();

      }

      this.source = source;
      readBuffer = new Buffer();
View Full Code Here

    final String protocol = source.getLocator().getProtocol();
   
    if (USE_DATASOURCE_URL_ONLY)
    {
      if (!(protocol.equals("file")) && !(protocol.equals("http")))
        throw new IncompatibleSourceException();

    }
    else
    {

   
    if (!(source instanceof PullDataSource))
      throw new IncompatibleSourceException();
    }
   
    this.source = (PullDataSource) source;
   
  }
View Full Code Here

TOP

Related Classes of javax.media.IncompatibleSourceException

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.