private void init( int payloadType, AudioSource src, AudioSender snd, AudioDestination dst, AudioReceiver rcv, int fs) { Logger.debug("AudioProcessor.init:"); Logger.debug(" destination=" + dst.getClass()); if (src != null) Logger.debug(" source=" + src.getClass()); else Logger.debug(" source=null"); if (snd != null) Logger.debug(" sender=" + snd.getClass()); else Logger.debug(" sender=null"); if (rcv != null) Logger.debug(" receiver=" + rcv.getClass()); else Logger.debug(" receiver=null"); this.payloadType = payloadType; frameSize = fs; { Logger.debug(""); switch (this.payloadType) { case 0: encoder = new PCMUCodec4(this); decoder = new PCMUCodec4(this); break; case 8: encoder = new PCMACodec(this); decoder = new PCMACodec(this); break; default: encoder = null; decoder = null; break; } if (encoder != null) Logger.debug("encoder=" + encoder.getClass()); if (decoder != null) Logger.debug("decoder=" + decoder.getClass()); if (encoder != null) encoder.init(); if (decoder != null) decoder.init(); } source = src; sender = snd; destination = dst; // Logger.debug("AudioProcessor constructor: destination="+destination); receiver = rcv; if (sender != null) sender.init(this.payloadType); AudioFormat format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 8000, 16, 1, 2, 8000, bigEndian); // AudioFormat format=new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,22050,8,1,1,22050,false); if (source != null) source.init(this, format, frameSize); if (destination != null) destination.init(this, format, frameSize); else Logger.error("AudioProcessor: destination=null"); if (receiver != null) receiver.init(this); }
public void stop() { Logger.info("AudioProcessor.stop: closing all inputs and outputs"); if (source != null) source.close(); if (sender != null) sender.close(); if (destination != null) destination.close(); if (receiver != null) receiver.close(); return; }
public boolean start() { boolean ok = false; if (source != null) source.go(); if (sender != null) sender.go(); if (destination != null) destination.go(); if (receiver != null) receiver.go(); ok = true; return ok; }