2012-04-12 2 views
2

이전에는 JMF로 작업했지만 JMF를 설치해야하지만이 오버 헤드를 추가하고 싶지 않습니다. 그래서 FMJ로 옮기고 싶습니다. 그리고 FMJ는 opensource입니다. :)FMJ에 캡처 장치가 없습니다.

FMJ 소스와 함께 제공되는 샘플 예제가 있습니다. 그리고 마이크에서 캡처 한 RTP 오디오를 실행하고 전송할 수있는 FMJStudio가 있습니다.

그러나 아래 소스를 사용하여 RTP를 전송하려고 할 때 캡처 장치를 찾을 수 없습니다. fmj-20070928-0938_2.zip FMJ에서 그리고이 소스 클래스의 클래스 이름 SimpleVoiceTransmiter입니다 :

완전한 소스

는에서 찾을 수 있습니다. 나는이 소스를 실행하면

//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); 
     } 
    } 

, 출력은 없습니다 : 문제가 될 수 있습니다 무엇 없음 캡처 장치

? :-(

편집 :. 내 시스템에서 JMF을 제거

답변

1

이 좋아, 두 반 일 후, 갑자기 중간에 붙어, 나 자신을 문제를 지적

. 나는 그것이 CLASSPATH 사용자 변수에서 제거되지 않은 JMF을 제거 할 때 문제는 것처럼이 somethinng되었다.

"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;" 

과 내가 그들을 제거하고 컴퓨터를 다시 시작했을 때. 그럼 빙고. 문제없이 코드가 실행됩니다. :)