public void run(String local, String remote, InputStream pin, OutputStream pout) { try { microphone = SoundMixerEnumerator.getInputLine(pcmformat, DefaultPhonePCMBlockSize); } catch (LineUnavailableException lue) { System.out.println( "\3b" + getClass().getName() + ".<init>:\n\tCould not create microphone input stream.\n\t" + lue); } try { speaker = SoundMixerEnumerator.getOutputLine(pcmformat, DefaultPhonePCMBlockSize); } catch (LineUnavailableException lue) { microphone.close(); System.out.println( "\3b" + getClass().getName() + ".<init>:\n\tCould not create speaker output stream.\n\t" + lue); } if ((speaker == null) || (microphone == null)) { super.run(local, remote, pin, pout); return; } try { recorder = new Recorder(pout); recorder.start(); gui = openMonitorGUI("Remote " + remote + " Local " + local); pin.skip(pin.available()); // waste whatever we couldn't process in time super.run(local, remote, new PhoneCallMonitorInputStream(pin), pout); recorder.interrupt(); gui.dispose(); } catch (Exception e) { System.out.println("3\b" + getClass().getName() + ".run:\n\t" + e); e.printStackTrace(); } finally { deactivate(); microphone.close(); speaker.close(); if (gui != null) { gui.dispose(); } } }
public String toString() { Mixer.Info info = mixer.getMixerInfo(); String s = "\nMixer [" + id + "]"; s += "\n\t Name: " + info.getName(); s += "\n\t Desc: " + info.getDescription(); s += "\n\t Ven : " + info.getVendor(); s += "\n\t Ver : " + info.getVersion(); s += "\n\t Str : " + info.toString(); Line.Info[] infos = mixer.getSourceLineInfo(); s += "\n\nSourceLine count : " + infos.length; for (int i = 0; i < infos.length; i++) { if (infos[i] instanceof DataLine.Info) { s += "\n\t\tData Line Source [" + i + "]"; s += "\n\t\t\t Str : " + infos[i].toString(); } else if (infos[i] instanceof Port.Info) { s += "\n\t\tPort Source [" + i + "]"; s += "\n\t\t\t Name: " + ((Port.Info) infos[i]).getName(); s += "\n\t\t\t is Src: " + ((Port.Info) infos[i]).isSource(); s += "\n\t\t\t Str : " + infos[i].toString(); } else /*if(infos[i]!=null)*/ { s += "\n\t\tSource [" + i + "]"; s += "\n\t\t\t Str : " + infos[i].toString(); } } s += "\n\nOUTPUT\n"; for (int i = 0; i < formats.length; i++) { try { SourceDataLine out = getOutputLine(formats[i]); out.close(); s += "\n" + formats[i].toString(); } catch (Exception e) { // s+="\n"+e.getMessage(); } } infos = mixer.getTargetLineInfo(); s += "\n\nTargetLine count : " + infos.length; for (int i = 0; i < infos.length; i++) { if (infos[i] instanceof DataLine.Info) { s += "\n\t\tData Line Target [" + i + "]"; s += "\n\t\t\t Str : " + infos[i].toString(); } else if (infos[i] instanceof Port.Info) { s += "\n\t\tPort Target [" + i + "]"; s += "\n\t\t\t Name: " + ((Port.Info) infos[i]).getName(); s += "\n\t\t\t is Src: " + ((Port.Info) infos[i]).isSource(); s += "\n\t\t\t Str : " + infos[i].toString(); } else /*if(infos[i]!=null)*/ { s += "\n\t\tTarget [" + i + "]"; s += "\n\t\t\t Str : " + infos[i].toString(); } } s += "\n\nINPUT\n"; for (int i = 0; i < formats.length; i++) { try { TargetDataLine out = getInputLine(formats[i]); out.close(); s += "\n" + formats[i].toString(); } catch (Exception e) { // s+="\n"+e.getMessage(); } } return s; }