Package javax.media

Examples of javax.media.MediaLocator


    // Create a processor for this capturedevice & exit if we
    // cannot create it
    Processor processor = null;
    try
    {
      processor = Manager.createProcessor(new MediaLocator(urlStr));
    } catch (IOException e)
    {
      e.printStackTrace();
      System.exit(-1);
    } catch (NoProcessorException e)
    {
      e.printStackTrace();
      System.exit(-1);
    }

    // configure the processor
    processor.configure();

    while (processor.getState() != Processor.Configured)
    {
      try
      {
        Thread.sleep(100);
      } catch (InterruptedException e)
      {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    processor.setContentDescriptor(new ContentDescriptor(ContentDescriptor.RAW_RTP));

    TrackControl track[] = processor.getTrackControls();

    boolean encodingOk = false;

    // Go through the tracks and try to program one of them to
    // output gsm data.

    for (int i = 0; i < track.length; i++)
    {
      if (!encodingOk && track[i] instanceof FormatControl)
      {
        if (((FormatControl) track[i]).setFormat(format) == null)
        {

          track[i].setEnabled(false);
        } else
        {
          encodingOk = true;
        }
      } else
      {
        // we could not set this track to gsm, so disable it
        track[i].setEnabled(false);
      }
    }

    // At this point, we have determined where we can send out
    // gsm data or not.
    // realize the processor
    if (encodingOk)
    {
      if (!new net.sf.fmj.ejmf.toolkit.util.StateWaiter(processor).blockingRealize())
      {
        System.err.println("Failed to realize");
        return;
      }
   
//      while (processor.getState() != Processor.Realized)
//      {
//        try
//        {
//          Thread.sleep(100);
//        } catch (InterruptedException e)
//        {
//          // TODO Auto-generated catch block
//          e.printStackTrace();
//        }
//      }
      // get the output datasource of the processor and exit
      // if we fail
      DataSource ds = null;

      try
      {
        ds = processor.getDataOutput();
      } catch (NotRealizedError e)
      {
        e.printStackTrace();
        System.exit(-1);
      }

      // hand this datasource to manager for creating an RTP
      // datasink our RTP datasink will multicast the audio
      try
      {
        String url = "rtp://192.168.1.4:8000/audio/16";

        MediaLocator m = new MediaLocator(url);

        DataSink d = Manager.createDataSink(ds, m);
        d.open();
        d.start();
       
View Full Code Here


   */
  public static void main(String[] args)
  {
    String url = "rtp://192.168.1.1:22224/audio/16";

    MediaLocator mrl = new MediaLocator(url);

    // Create a player for this rtp session
    Player player = null;
    try
    {
View Full Code Here

  if (inputURL == null) {
      System.err.println("No input url is specified");
      prUsage();
  }

  MediaLocator ml;

  if ((ml = new MediaLocator(inputURL)) == null) {
      System.err.println("Cannot build media locator from: " + inputURL);
      prUsage();
      System.exit(0);
  }
View Full Code Here

  if (mlStr == null) {
      prUsage();
      System.exit(0);
   }

  MediaLocator ml;

  if ((ml = new MediaLocator(mlStr)) == null) {
      System.err.println("Cannot build media locator from: " + mlStr);
      prUsage();
      System.exit(0);
  }
View Full Code Here

  if (args.length == 0) {
      prUsage();
      System.exit(0);
   }

  MediaLocator ml;

  if ((ml = new MediaLocator(args[0])) == null) {
      System.err.println("Cannot build media locator from: " + args[0]);
      prUsage();
      System.exit(0);
  }
View Full Code Here

  // Check the frame rate.
  if (frameRate < 1)
      frameRate = 1;

  // Generate the output media locators.
  MediaLocator oml;

  if ((oml = createMediaLocator(outputURL)) == null) {
      System.err.println("Cannot build media locator from: " + outputURL);
      System.exit(0);
  }
View Full Code Here

    /**
     * Create a media locator from the given string.
     */
    static MediaLocator createMediaLocator(String url) {

  MediaLocator ml;

  if (url.indexOf(":") > 0 && (ml = new MediaLocator(url)) != null)
      return ml;

  if (url.startsWith(File.separator)) {
      if ((ml = new MediaLocator("file:" + url)) != null)
    return ml;
  } else {
      String file = "file:" + System.getProperty("user.dir") + File.separator + url;
      if ((ml = new MediaLocator(file)) != null)
    return ml;
  }

  return null;
    }
View Full Code Here

    private String createTransmitter() {
  // Create a media locator for the RTP data sink.
  // For example:
  //    rtp://129.130.131.132:42050/video
  String rtpURL = "rtp://" + ipAddress + ":" + port + "/video";
  MediaLocator outputLocator = new MediaLocator(rtpURL);

  // Create a data sink, open it and start transmission. It will wait
  // for the processor to start sending data. So we need to start the
  // output data source of the processor. We also need to start the
  // processor itself, which is done after this method returns.
View Full Code Here

  if (args.length == 0) {
      prUsage();
      System.exit(0);
   }

  MediaLocator ml;
  int copies = 1;

  if ((ml = new MediaLocator(args[0])) == null) {
      System.err.println("Cannot build media locator from: " + args[0]);
      prUsage();
      System.exit(0);
  }
View Full Code Here

      System.err.println("Usage: VideoTransmit <sourceURL> <destIP> <destPort>");
      System.exit(-1);
  }
 
  // Create a video transmit object with the specified params.
  VideoTransmit vt = new VideoTransmit(new MediaLocator(args[0]),
               args[1],
               args[2]);
  // Start the transmission
  String result = vt.start();
View Full Code Here

TOP

Related Classes of javax.media.MediaLocator

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.