2012-04-12 11 views
2

Zuvor arbeitete ich mit JMF, aber JMF muss installiert werden, aber ich möchte diesen Overhead nicht hinzufügen. Deshalb möchte ich nach FMJ verlegt werden. Und FMJ ist Opensource. :)Keine Erfassungsgeräte in FMJ gefunden

Es gibt ein Beispiel mit einer FMJ-Quelle. Und es gibt ein FMJStudio, von wo aus ich RTP-Audio vom Mikrofon abspielen und übertragen kann.

Aber wenn ich RTP über die unten angegebene Quelle übertragen möchte, konnte es kein Aufnahmegerät finden. fmj-20070928-0938_2.zip in FMJ Und der Name der Klasse dieser Quellenklasse ist SimpleVoiceTransmiter:

Die komplette Quelle kann gefunden werden.

//final String urlStr = URLUtils.createUrlStr(new File("samplemedia/gulp2.wav"));//"file://samplemedia/gulp2.wav"; 
    Format format; 

    format = new AudioFormat(AudioFormat.ULAW_RTP, 8000, 8, 1); 
    //format = new AudioFormat(AudioFormat.ULAW_RTP, 8000.0, 8, 1, AudioFormat.LITTLE_ENDIAN, AudioFormat.SIGNED); 
    //format = new AudioFormat(BonusAudioFormatEncodings.ALAW_RTP, 8000, 8, 1); 
    //format = new AudioFormat(BonusAudioFormatEncodings.SPEEX_RTP, 8000, 8, 1, -1, AudioFormat.SIGNED); 
    //format = new AudioFormat(BonusAudioFormatEncodings.ILBC_RTP, 8000.0, 16, 1, AudioFormat.LITTLE_ENDIAN, AudioFormat.SIGNED); 

    CaptureDeviceInfo di = null; 
      //Set to true if you want to transmit audio from capture device, like microphone. 
    if (true) 
    { 
     // First find a capture device that will capture linear audio 
     // data at 8bit 8Khz 
     AudioFormat captureFormat = new AudioFormat(AudioFormat.LINEAR, 8000, 8, 1); 

     Vector devices = CaptureDeviceManager.getDeviceList(captureFormat); 



     if (devices.size() > 0) 
     { 
      di = (CaptureDeviceInfo) devices.elementAt(0); 
     } else 
     { 
      System.err.println("No capture devices"); 
      // exit if we could not find the relevant capturedevice. 
      System.exit(-1); 

     } 
    } 

    // Create a processor for this capturedevice & exit if we 
    // cannot create it 
    Processor processor = null; 
    try 
    { 
     //processor = Manager.createProcessor(new MediaLocator(urlStr)); 
        processor = Manager.createProcessor(di.getLocator()); 
    } 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(10); 
     } 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 g.711 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 g.711, so disable it 
      track[i].setEnabled(false); 
     } 
    } 

    // At this point, we have determined where we can send out 
    // g.711 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; 
     } 

     // 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.99:49150/audio/1"; 

      MediaLocator m = new MediaLocator(url); 

      DataSink d = Manager.createDataSink(ds, m); 
      d.open(); 
      d.start(); 

      System.out.println("Starting processor"); 
      processor.start(); 
      Thread.sleep(30000); 
     } catch (Exception e) 
     { 
      e.printStackTrace(); 
      System.exit(-1); 
     } 
    } 

Wenn ich diese Quelle laufen, Der Ausgang ist: Keine Aufnahmegeräte

Was kann das Problem sein? :-(

Edit:. Ich deinstallierte die JMF von meinem System

Antwort

1

Ok, nach zweieinhalb Tagen, aus dem Nichts in der Mitte stecken, zeigte ich mich, das Problem

Die. Problem war, als ich JMF deinstalliert es nicht von der CLASSPATH Benutzervariablen entfernt es wurde somethinng wie:.

"C:\PROGRA~1\JMF21~1.1E\lib\sound.jar;C:\PROGRA~1\JMF21~1.1E\lib\jmf.jar;C:\PROGRA~1\JMF21~1.1E\lib;" 

und als ich sie entfernte und meinen Computer neu startete. Dann Bingo. Der Code läuft ohne Probleme. :)

Verwandte Themen