代码之家  ›  专栏  ›  技术社区  ›  TacB0sS

JMF麦克风音量控制器

  •  0
  • TacB0sS  · 技术社区  · 14 年前

    如何在JMF中获得麦克风音量控制器?

    // the device is the media device specifically audio
    Processor processorForVolume = Manager.createProcessor(device.getLocator());
    
    // wait until configured
    ProcessorStates newState = new ProcessorStateListener(Processor.Configured).waitForProcessorState(processorForVolume);
    System.out.println("volumeProcessorState: "+newState);
    
    // setting the content descriptor to null - read in another thread this allows to get the gain control
    processorForVolume.setContentDescriptor(null);
    
    // set the track control format to one supported by the device and the track control.
    // I didn't match it to an RTP allowed format, but I don't think this has anything to do with it...
    TrackControl[] trackControls = processorForVolume.getTrackControls();
    if (trackControls.length == 0)
        throw new MC_Exception("No track controls where found for this device:", new Object[]{device});
    for (TrackControl control : trackControls)
        trackManipulator.manipulateTrackControls(control);
    
    // wait until the processor is realized
    newState = new ProcessorStateListener(Controller.Realized).waitForProcessorState(processorForVolume);
    System.out.println("volumeProcessorState: "+newState);
    
    // receives the gain control
    micVolumeController = processorForVolume.getGainControl();
    
    // cannot get the output stream to process further... any suggestions?
    processor = Manager.createProcessor(processorForVolume.getDataOutput());
    new ProcessorStateListener(Processor.Configured).waitForProcessorState(processor);
    processor.setContentDescriptor(DeviceCapturingManager.RAW_RTP);
    new ProcessorStateListener(Controller.Realized).waitForProcessorState(processor);
    

    这是它生成的输出:

    volumeProcessorState:已配置 设置为跟踪控制的格式- com.sun.media。ProcessEngine$ProcTControl@1627c16: 线性,48000.0 Hz,16位,立体声, LittleEndian,签名 volumeProcessorState:已实现

    我应该弄清楚,当内容描述符!=null我得到一个输出流,但不是卷控制器,当它为null时,我得到控制器,但没有流。

    我尝试连接到音频麦克风设备

    亚当。

    1 回复  |  直到 14 年前
        1
  •  0
  •   TacB0sS    13 年前

    麦克风没有音量组件!必须自己实施。