Package javax.media.protocol

Examples of javax.media.protocol.DataSource


  {
    // init FMJ/JMF logging/classpath
    FmjStartup.init();
   
    // create both data sources:
    final DataSource dsVideo = Manager.createDataSource(new MediaLocator("civil:/0"));
   
    // merge them:
    final DataSource dsCloneable = Manager.createCloneableDataSource(dsVideo);
    final DataSource dsClone = ((SourceCloneable) dsCloneable).createClone();
   
//    if (dsCloneable instanceof CaptureDevice)
//      System.out.println("CAPTURE DEVICE!!!");
//    if (dsClone instanceof CaptureDevice)
//      System.out.println("dsClone CAPTURE DEVICE!!!");
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)
            }
            catch (NoPlayerException e)
            {   // no need to log, will be logged by call to createPlayer.
                continue;
            }
            catch (ClassNotFoundException e)
            {
                logger.warning("createPlayer: "  + e);    // no need for call stack
                continue;
            }          
            catch (IOException e)
            {
                logger.log(Level.WARNING, ""  + e, e);
                continue;
            }
            catch (NoClassDefFoundError e)
            {
                logger.log(Level.WARNING, ""  + e, e);
                continue;
            }
            catch (Exception e)
            {
                logger.log(Level.WARNING, ""  + 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 dataSource;
               
               
            }
            catch (ClassNotFoundException e)
            {
                logger.warning("createDataSource: "  + e);    // no need for call stack
                continue;
            }
            catch (IOException e)
            {
                logger.log(Level.WARNING, ""  + e, e);
                continue;
            }
            catch (NoClassDefFoundError e)
            {
                logger.log(Level.WARNING, ""  + e, e);
                continue;
            }
            catch (Exception e)
            {
                logger.log(Level.WARNING, ""  + 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

     * 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

                m_player.getPlayer().deallocate();
                m_player.getPlayer().close();
        m_player.close();
            }
            //File.toURL() is deprecated in favor of File.toURI().toURL(), but MediaLocator doesn't want a proper URL...
            DataSource ds = Manager.createDataSource(new MediaLocator(m_source.toURL()));
            System.out.println("Content type: " + ds.getContentType());
            m_player.setPlayer(Manager.createRealizedPlayer(ds));
            m_player.saveMediaTime();
            m_player.addControllerListener(this);
        } catch (Exception exc) {
            System.out.println(exc);
View Full Code Here

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

    DataSource ds;

    try
      {
      ds = Manager.createDataSource(locator);
      }
View Full Code Here

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

        DataSource ds;

        try {
            ds = javax.media.Manager.createDataSource(locator);
        }
        catch (Exception e) {
View Full Code Here

        } else if (evt instanceof NewReceiveStreamEvent) {

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

                // Find out the formats.
                RTPControl ctl = (RTPControl) ds.getControl("javax.jmf.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();
                jingleMediaSession.mediaReceived(participant != null ? participant.getCNAME() : "");

                // 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.jmf.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

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

        DataSource ds;

        try {
            ds = javax.media.Manager.createDataSource(locator);
        }
        catch (Exception e) {
View Full Code Here

        }
        else if (evt instanceof NewReceiveStreamEvent) {

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

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

                if (participant == null)
                    LOGGER.error("      The sender of this stream had yet to be identified.");
                else {
                    LOGGER.error("      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();
                jingleMediaSession.mediaReceived(participant != null ? participant.getCNAME() : "");

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

            }
            catch (Exception e) {
                LOGGER.error("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.jmf.rtp.RTPControl");
                LOGGER.error("  - The previously unidentified stream ");
                if (ctl != null)
                    LOGGER.error("      " + ctl.getFormat());
                LOGGER.error("      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.