How to obtain the Microphone volume controller in JMF?
this is what I have:
I tried this implementation concept of yours, but I keep getting a null from the first volume processor when I try to get the stream, here is how I do it:
// 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 th开发者_开发问答e 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);
this is the output It generates:
volumeProcessorState: Configured format set to track control - com.sun.media.ProcessEngine$ProcTControl@1627c16: LINEAR, 48000.0 Hz, 16-bit, Stereo, LittleEndian, Signed volumeProcessorState: Realized
and the data output from the processor is Null.
I should make clear that when the content descriptor != null I do get an output stream but not the volume controller, and the when it is null I get the controller, but no stream.
I try to connect to an audio microphone device
Adam.
The Microphone does not have a Volume component! Must implement one yourself.
精彩评论