📄 voice.java
字号:
public void listen(Device source) {
if (source != null && source != this)
Dialogic.dx_listen(device, source.getTs());
else
Dialogic.dx_unlisten(device);
}
public void listen(Channel ch, Resource res) {
int ts = res.getTs(ch);
if (ts < 0)
Dialogic.dx_unlisten(device);
else
Dialogic.dx_listen(device, ts);
}
// R2 utility
/*
* Group I Forward Signals
*/
public static final int SIGI_ZERO=100;
public static final int SIGI_1 =101;
public static final int SIGI_2 =102;
public static final int SIGI_3 =103;
public static final int SIGI_4 =104;
public static final int SIGI_5 =105;
public static final int SIGI_6 =106;
public static final int SIGI_7 =107;
public static final int SIGI_8 =108;
public static final int SIGI_9 =109;
public static final int SIGI_10 =110;
public static final int SIGI_11 =111;
public static final int SIGI_12 =112;
public static final int SIGI_13 =113;
public static final int SIGI_14 =114;
public static final int SIGI_15 =115;
/*
* Group II Forward Signals
*/
public static final int SIGII_ZERO=100;
public static final int SIGII_1 =101;
public static final int SIGII_2 =102;
public static final int SIGII_3 =103;
public static final int SIGII_4 =104;
public static final int SIGII_5 =105;
public static final int SIGII_6 =106;
public static final int SIGII_7 =107;
public static final int SIGII_8 =108;
public static final int SIGII_9 =109;
public static final int SIGII_10 =110;
public static final int SIGII_11 =111;
public static final int SIGII_12 =112;
public static final int SIGII_13 =113;
public static final int SIGII_14 =114;
public static final int SIGII_15 =115;
/*
* Group A Backward Signals
*/
public static final int SIGA_ZERO=115;
public static final int SIGA_1 =116;
public static final int SIGA_2 =117;
public static final int SIGA_3 =118;
public static final int SIGA_4 =119;
public static final int SIGA_5 =120;
public static final int SIGA_6 =121;
public static final int SIGA_7 =122;
public static final int SIGA_8 =123;
public static final int SIGA_9 =124;
public static final int SIGA_10 =125;
public static final int SIGA_11 =126;
public static final int SIGA_12 =127;
public static final int SIGA_13 =128;
public static final int SIGA_14 =129;
public static final int SIGA_15 =130;
/*
* Group B Backward Signals
*/
public static final int SIGB_ZERO=115;
public static final int SIGB_1 =116;
public static final int SIGB_2 =117;
public static final int SIGB_3 =118;
public static final int SIGB_4 =119;
public static final int SIGB_5 =120;
public static final int SIGB_6 =121;
public static final int SIGB_7 =122;
public static final int SIGB_8 =123;
public static final int SIGB_9 =124;
public static final int SIGB_10 =125;
public static final int SIGB_11 =126;
public static final int SIGB_12 =127;
public static final int SIGB_13 =128;
public static final int SIGB_14 =129;
public static final int SIGB_15 =130;
private boolean r2Tones = false;
static final int r2fdev = 30;
static final int r2ampl = -10;
static final int[][] forwardSig = { {1380,1500}, {1380,1620}, {1500,1620},
{1380,1740}, {1500,1740}, {1620,1740},
{1380,1860}, {1500,1860}, {1620,1860},
{1740,1860}, {1380,1980}, {1500,1980},
{1620,1980}, {1740,1980}, {1860,1980} };
static final int[][] backwardSig = { {1140,1020}, {1140,900}, {1020,900},
{1140, 780}, {1020,780}, {900, 780},
{1140, 660}, {1020,660}, {900, 660},
{780, 660}, {1140,540}, {1020,540},
{900, 540}, {780, 540}, {660, 540} };
static final TNGEN[] backwardTone = new TNGEN[15];
static final TNGEN[] forwardTone = new TNGEN[15];
static final TPT[] forwardStop = new TPT[15];
static final TPT backwardStop = new TPT();
static final TPT impulseStop = new TPT();
public synchronized void r2_creasig() {
waitIdle();
if (r2Tones)
return;
if (backwardTone[0] == null) {
for (int id = 0; id < 15; id++) {
backwardTone[id] = new TNGEN(backwardSig[id][0], r2ampl,
backwardSig[id][1], r2ampl, 1500);
forwardTone[id] = new TNGEN(forwardSig[id][0], r2ampl,
forwardSig[id][1], r2ampl, 1500);
forwardStop[id] = new TPT(TPT.TONE, SIGI_1+id,
TPT.EDGE|TPT.USE|TPT.CLRBEG, TPT.TONEOFF);
// Dialogic does not support 15 tones in TPT ????
if (id < 10)
backwardStop.add(TPT.TONE, SIGA_1+id,
TPT.EDGE|TPT.USE|TPT.CLRBEG, TPT.TONEON);
}
}
synchronized(toneLock) {
for (int id = 0; id < 15; id++) {
Dialogic.dx_blddt(SIGI_1+id, forwardSig[id][0], r2fdev,
forwardSig[id][1], r2fdev,Dialogic.TN_LEADING);
int ok = Dialogic.dx_addtone(device, 0, 0);
if (ok != 0)
throw new RuntimeException("Addtone failed for " + this);
Dialogic.dx_distone(device, SIGI_1+id, Dialogic.DM_TONEON|Dialogic.DM_TONEOFF);
}
for (int id = 0; id < 15; id++) {
Dialogic.dx_blddt(SIGA_1+id, backwardSig[id][0], r2fdev,
backwardSig[id][1], r2fdev,Dialogic.TN_LEADING);
int ok = Dialogic.dx_addtone(device, 0, 0);
if (ok != 0)
throw new RuntimeException("Addtone failed for " + this);
Dialogic.dx_distone(device, SIGA_1+id, Dialogic.DM_TONEON|Dialogic.DM_TONEOFF);
}
}
r2Tones = true;
}
// Enable forward tones
public void r2_fenable() {
if ((Dialogic.debug & Dialogic.DEBUG_VFNS) != 0)
System.out.println(new java.util.Date().toString().substring(11,20) +
"R2 forward enable (" + device + ")");
if (!r2Tones)
r2_creasig();
for (int id = 0; id < 15; id++)
Dialogic.dx_enbtone(device, SIGI_1+id, Dialogic.DM_TONEON|Dialogic.DM_TONEOFF);
}
// Disable forward tones
public void r2_fdisable() {
if ((Dialogic.debug & Dialogic.DEBUG_VFNS) != 0)
System.out.println(new java.util.Date().toString().substring(11,20) +
"R2 forward disable (" + device + ")");
if (!r2Tones)
r2_creasig();
else
for (int id = 0; id < 15; id++)
Dialogic.dx_distone(device, SIGI_1+id, Dialogic.DM_TONEON|Dialogic.DM_TONEOFF);
}
// Enable backward tones
public void r2_benable() {
if ((Dialogic.debug & Dialogic.DEBUG_VFNS) != 0)
System.out.println(new java.util.Date().toString().substring(11,20) +
"R2 backward enable (" + device + ")");
if (!r2Tones)
r2_creasig();
for (int id = 0; id < 15; id++)
Dialogic.dx_enbtone(device, SIGA_1+id, Dialogic.DM_TONEON|Dialogic.DM_TONEOFF);
}
// Disable backward tones
public void r2_bdisable() {
if ((Dialogic.debug & Dialogic.DEBUG_VFNS) != 0)
System.out.println(new java.util.Date().toString().substring(11,20) +
"R2 backward disable (" + device + ")");
if (!r2Tones)
r2_creasig();
else
for (int id = 0; id < 15; id++)
Dialogic.dx_distone(device, SIGA_1+id, Dialogic.DM_TONEON|Dialogic.DM_TONEOFF);
}
TNGEN tn;
// send a forward tone
public synchronized void r2_sendf(int sig) {
if ((Dialogic.debug & Dialogic.DEBUG_VFNS) != 0)
System.out.println(new java.util.Date().toString().substring(11,20) +
"R2 sendf " + sigName(sig) + " (" + device + ")");
if (sig < SIGI_1 || sig > SIGI_15)
throw new RuntimeException("r2_sendf: invalid R2 sig");
int id = sig - SIGI_1;
waitIdle();
Dialogic.dx_playtone(this, forwardTone[id],
backwardStop, Dialogic.EV_ASYNC);
}
// send a backward tone
public synchronized void r2_sendb(int sig, int sigp) {
if ((Dialogic.debug & Dialogic.DEBUG_VFNS) != 0)
System.out.println(new java.util.Date().toString().substring(11,20) +
"R2 sendb " + sigName(sig) + " (" + device + ")");
if (sig < SIGA_1 || sig > SIGA_15)
throw new RuntimeException("r2_sendb: invalid R2 sig");
if (sigp < SIGI_1 || sigp > SIGI_15)
throw new RuntimeException("r2_sendb: invalid R2 sig present");
int id = sig - SIGA_1;
int idp = sigp - SIGI_1;
waitIdle();
Dialogic.dx_playtone(this, backwardTone[id],
forwardStop[idp], Dialogic.EV_ASYNC);
}
// send a backward impulsive tone
public synchronized void r2_sendbp(int sig) {
if ((Dialogic.debug & Dialogic.DEBUG_VFNS) != 0)
System.out.println(new java.util.Date().toString().substring(11,20) +
"R2 sendbp " + sigName(sig) + " (" + device + ")");
if (sig < SIGA_1 || sig > SIGA_15)
throw new RuntimeException("r2_sendbp: invalid R2 sig");
int id = sig - SIGA_1;
waitIdle();
Dialogic.dx_playtone(this, backwardTone[id],
impulseStop, Dialogic.EV_ASYNC);
}
// Util to print signals for debug
static String sigNames[] = {
"Fwd_1", "Fwd_2", "Fwd_3", "Fwd_4",
"Fwd_5", "Fwd_6", "Fwd_7", "Fwd_8",
"Fwd_9", "Fwd_10", "Fwd_11", "Fwd_12",
"Fwd_13", "Fwd_14", "Fwd_15",
"Bwd_1", "Bwd_2", "Bwd_3", "Bwd_4",
"Bwd_5", "Bwd_6", "Bwd_7", "Bwd_8",
"Bwd_9", "Bwd_10", "Bwd_11", "Bwd_12",
"Bwd_13", "Bwd_14", "Bwd_15"};
private String sigName(int sig) {
if (sig < 101 || sig > 130)
return "Invalid SIG";
else
return sigNames[sig-101];
}
// IOTT/TPT/digbuf tables...
// We keep a block to keep it in scope for the length of the play()/rec()
// that should be freed...
public void finalize() throws Throwable {
close();
super.finalize();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -