Package javax.media.protocol

Examples of javax.media.protocol.DataSource


   {
     final ProcessorModel processorModel = new ProcessorModel(new MediaLocator(urlStr), outputFormat == null ? null : new Format[]{outputFormat}, outputContentDescriptor);
    
    final Processor processor = Manager.createRealizedProcessor(processorModel);
 
    final DataSource ds = processor.getDataOutput();

    final DataSink[] streamDataSinkHolder = new DataSink[] {null};
    // connect the data output of the processor to a StreamDataSink, which will make the data available to PipedInputStream, which we return.
    final PipedInputStream in = new PipedInputStream() {
View Full Code Here


            try
            {
                ReceiveStream stream = ((NewReceiveStreamEvent)event).getReceiveStream();
                System.out.println("### stream=" + stream.getClass().getName());

                DataSource ds = stream.getDataSource();
                System.out.println("### ds=" + ds.getClass().getName());
               
                Object[] controls = ds.getControls();
                for (int i=0; i<controls.length; i++)
                {
                    if ( controls[i] instanceof RTPControl )
                    {
                        Format format = ((RTPControl)controls[i]).getFormat();
View Full Code Here

    {
      String dataSourceClassName = (String) dataSourceList.get(i);
      try
      {
        final Class dataSourceClass = Class.forName(dataSourceClassName);
        final DataSource dataSource = (DataSource) dataSourceClass.newInstance();
        dataSource.setLocator(sourceLocator);
        dataSource.connect();
        return createPlayer(dataSource);
       
        // TODO: JMF seems to disconnect data sources in this method, based on this stack trace:
//        java.lang.NullPointerException
//        at com.sun.media.protocol.rtp.DataSource.disconnect(DataSource.java:207)
//        at javax.media.Manager.createPlayer(Manager.java:425)
//        at net.sf.fmj.ui.application.ContainerPlayer.createNewPlayer(ContainerPlayer.java:357)
       
        // TODO: JMF appears to get the streams from the data source (somewhere near) here.  If the stream is null, we get (from JMF:)
//        javax.media.NoPlayerException: Error instantiating class: com.sun.media.content.unknown.Handler : java.io.IOException: Got a null stream from the DataSource
//        at javax.media.Manager.createPlayerForSource(Manager.java:1502)
//        at javax.media.Manager.createPlayer(Manager.java:500)
        // more specifically, it callse getStreams, and if there are no streams or only a null streams, it throws an exception.
        // it then calls isRandomAccess on the stream (or streams?).
       
        // perhaps calling random access is necessary to determine whether some kind of buffered clone of the source is needed
        // OR whether the datasource needs to be closed and re-opened, for the case when one handler is tried, and rejects
        // the source.  If the source is not random access, then you'd have to throw it a way if a handler opened it, read
        // from it, and rejected it.
        // see comments below with URLDataSource connection, below.
        // this is one of the weaknesses of the JMF architecture, that it potentially needs to open a media data source multiple times
        // in order to figure out what to do with it. 
      }
      catch (NoPlayerException e)
      {  // no need to log, will be logged by call to createPlayer.
        continue;
      }
      catch (ClassNotFoundException e)
      {
        logger.finer("createPlayer: "  + e)// no need for call stack
        continue;
      }     
      catch (IOException e)
      {
        logger.log(Level.FINE, ""  + e, e);
        if (RETHROW_IO_EXCEPTIONS)
          throw e;
        else
          continue;
      }
      catch (NoClassDefFoundError e)
      {
        logger.log(Level.FINE, ""  + e, e);
        continue;
      }
      catch (Exception e)
      {
        logger.log(Level.FINE, ""  + e, e);
        continue;
      }

       
    }
   
    // if none found, try URLDataSource:
    final URL url;
    try
    {
      url = sourceLocator.getURL();
    }
    catch (Exception e)
    {  logger.log(Level.WARNING, ""  + e, e);
      throw new NoPlayerException();
    }
    final URLDataSource dataSource = new URLDataSource(url);
    dataSource.connect()// TODO: there is a problem because we connect to the datasource here, but
                // the following call may try twice or more to use the datasource with a player, once
                // for the right content type, and multiple times for unknown.  The first attempt (for example) may actually
                // read data, in which case the second one will be missing data when it reads.
                // really, the datasource needs to be recreated.
                // The workaround for now is that URLDataSource (and others) allows repeated connect() calls.
View Full Code Here

    {
      String dataSourceClassName = (String) dataSourceList.get(i);
      try
      {
        final Class dataSourceClass = Class.forName(dataSourceClassName);
        final DataSource dataSource = (DataSource) dataSourceClass.newInstance();
        dataSource.setLocator(sourceLocator);
        dataSource.connect();
        return createProcessor(dataSource);
       
       
      }
      catch (ClassNotFoundException e)
      {
        logger.finer("createProcessor: "  + e)// no need for call stack
        continue;
      }
      catch (IOException e)
      {
        logger.log(Level.FINE, ""  + e, e);
        if (RETHROW_IO_EXCEPTIONS)
          throw e;
        else
          continue;
      }
      catch (NoProcessorException e)
      {  continue// no need to log, will be logged by call to createProcessor.
      }
      catch (NoClassDefFoundError e)
      {
        logger.log(Level.FINE, ""  + e, e);
        continue;
      }
      catch (Exception e)
      {
        logger.log(Level.FINE, ""  + e, e);
        continue;
      }

       
    }
   
    // if none found, try URLDataSource:
    final URL url;
    try
    {
      url = sourceLocator.getURL();
    }
    catch (Exception e)
    {  logger.log(Level.WARNING, ""  + e, e);
      throw new NoProcessorException();
    }
    final URLDataSource dataSource = new URLDataSource(url);
    dataSource.connect();
    return createProcessor(dataSource);
  }
View Full Code Here

    {
      String dataSourceClassName = (String) dataSourceList.get(i);
      try
      {
        final Class dataSourceClass = Class.forName(dataSourceClassName);
        final DataSource dataSource = (DataSource) dataSourceClass.newInstance();
        dataSource.setLocator(sourceLocator);
        dataSource.connect();
        return dataSource;
       
       
      }
      catch (ClassNotFoundException e)
      {
        logger.finer("createDataSource: "  + e)// no need for call stack
        continue;
      }
      catch (IOException e)
      {
        logger.log(Level.FINE, ""  + e, e);
        if (RETHROW_IO_EXCEPTIONS)
          throw e;
        else
          continue;
      }
      catch (NoClassDefFoundError e)
      {
        logger.log(Level.FINE, ""  + e, e);
        continue;
      }
      catch (Exception e)
      {
        logger.log(Level.FINE, ""  + e, e);
        continue;
      }

       
    }
   
    // if none found, try URLDataSource:
    final URL url;
    try
    {
      url = sourceLocator.getURL();
    }
    catch (Exception e)
    {  logger.log(Level.WARNING, ""  + e, e);
      throw new NoDataSourceException();
    }
    final URLDataSource dataSource = new URLDataSource(url);
    dataSource.connect();
    return dataSource;
  }
View Full Code Here

    private String createProcessor() {
  if (locator == null)
      return "Locator is null";

  DataSource ds;
  DataSource clone;

  try {
      ds = javax.media.Manager.createDataSource(locator);
  } catch (Exception e) {
      return "Couldn't create DataSource";
View Full Code Here

    /**
     * Create the DataSink.
     */
    DataSink createDataSink(Processor p, MediaLocator outML) {

  DataSource ds;

  if ((ds = p.getDataOutput()) == null) {
      System.err.println("Something is really wrong: the processor does not have an output DataSource");
      return null;
  }
View Full Code Here

  /**
   * Create the DataSink.
   */
  DataSink createDataSink(Processor p, MediaLocator outML) {

      DataSource ds;

      if ((ds = p.getDataOutput()) == null) {
    System.err.println("Something is really wrong: the processor does not have an output DataSource");
    return null;
      }
View Full Code Here

    private String createProcessor() {
  if (locator == null)
      return "Locator is null";

  DataSource ds;
  DataSource clone;

  try {
      ds = javax.media.Manager.createDataSource(locator);
  } catch (Exception e) {
      return "Couldn't create DataSource";
View Full Code Here

   
  else if (evt instanceof NewReceiveStreamEvent) {

      try {
    stream = ((NewReceiveStreamEvent)evt).getReceiveStream();
    DataSource ds = stream.getDataSource();

    // Find out the formats.
    RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
    if (ctl != null){
        System.err.println("  - Recevied new RTP stream: " + ctl.getFormat());
    } else
        System.err.println("  - Recevied new RTP stream");

    if (participant == null)
        System.err.println("      The sender of this stream had yet to be identified.");
    else {
        System.err.println("      The stream comes from: " + participant.getCNAME());
    }

    // create a player by passing datasource to the Media Manager
    Player p = javax.media.Manager.createPlayer(ds);
    if (p == null)
        return;

    p.addControllerListener(this);
    p.realize();
    PlayerWindow pw = new PlayerWindow(p, stream);
    playerWindows.addElement(pw);

    // Notify intialize() that a new stream had arrived.
    synchronized (dataSync) {
        dataReceived = true;
        dataSync.notifyAll();
    }

      } catch (Exception e) {
    System.err.println("NewReceiveStreamEvent exception " + e.getMessage());
    return;
      }
       
  }

  else if (evt instanceof StreamMappedEvent) {

       if (stream != null && stream.getDataSource() != null) {
    DataSource ds = stream.getDataSource();
    // Find out the formats.
    RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
    System.err.println("  - The previously unidentified stream ");
    if (ctl != null)
        System.err.println("      " + ctl.getFormat());
    System.err.println("      had now been identified as sent by: " + participant.getCNAME());
       }
View Full Code Here

TOP

Related Classes of javax.media.protocol.DataSource

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.