Beispiel #1
0
  /**
   * ************************************************************** Sample Usage for VideoTransmit
   * class **************************************************************
   */
  public static void main(String[] args) {
    // We need three parameters to do the transmission
    // For example,
    //   java VideoTransmit file:/C:/media/test.mov  129.130.131.132 42050

    if (args.length < 3) {
      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();

    // result will be non-null if there was an error. The return
    // value is a String describing the possible error. Print it.
    if (result != null) {
      System.err.println("Error : " + result);
      System.exit(0);
    }

    System.err.println("Start transmission for 60 seconds...");

    // Transmit for 60 seconds and then close the processor
    // This is a safeguard when using a capture data source
    // so that the capture device will be properly released
    // before quitting.
    // The right thing to do would be to have a GUI with a
    // "Stop" button that would call stop on VideoTransmit
    try {
      Thread.currentThread().sleep(60000);
    } catch (InterruptedException ie) {
    }

    // Stop the transmission
    vt.stop();

    System.err.println("...transmission ended.");

    System.exit(0);
  }
Beispiel #2
0
  public static void main(String[] args) {

    // ---------------- CUT HERE START ----------------- //

    Format formats[] = new Format[2];
    formats[0] = new AudioFormat(AudioFormat.IMA4);
    formats[1] = new VideoFormat(VideoFormat.CINEPAK);
    FileTypeDescriptor outputType = new FileTypeDescriptor(FileTypeDescriptor.QUICKTIME);
    Processor p = null;

    try {
      p = Manager.createRealizedProcessor(new ProcessorModel(formats, outputType));
    } catch (IOException e) {
      System.exit(-1);
    } catch (NoProcessorException e) {
      System.exit(-1);
    } catch (CannotRealizeException e) {
      System.exit(-1);
    }
    // get the output of the processor
    DataSource source = p.getDataOutput();
    // create a File protocol MediaLocator with the location of the file to
    // which bits are to be written
    MediaLocator dest = new MediaLocator("file://foo.mov");
    // create a datasink to do the file writing & open the sink to make sure
    // we can write to it.
    DataSink filewriter = null;
    try {
      filewriter = Manager.createDataSink(source, dest);
      filewriter.open();
    } catch (NoDataSinkException e) {
      System.exit(-1);
    } catch (IOException e) {
      System.exit(-1);
    } catch (SecurityException e) {
      System.exit(-1);
    }
    // now start the filewriter and processor
    try {
      filewriter.start();
    } catch (IOException e) {
      System.exit(-1);
    }
    p.start();
    // stop and close the processor when done capturing...
    // close the datasink when EndOfStream event is received...

    // ----------------- CUT HERE END ---------------- //
    try {
      Thread.currentThread().sleep(4000);
    } catch (InterruptedException ie) {
    }
    p.stop();
    p.close();
    try {
      Thread.currentThread().sleep(1000);
    } catch (InterruptedException ie) {
    }
    filewriter.close();
    try {
      Thread.currentThread().sleep(4000);
    } catch (InterruptedException ie) {
    }

    System.exit(0);
  }