📄 main.cxx
字号:
} else {
lidDevice->GetPlayVolume(0, playvol);
}
if (verbose >= 3) {
cout << "Playing volume set to " << playvol << endl;
}
autoHook = args.HasOption("autohook");
if (autoHook)
lidDevice->StopTone(0);
if (verbose >= 3)
cout << "Autohook set to " << autoHook << endl;
}
else {
cout << "Could not open " << ixjDevice << ": ";
int code = lidDevice->GetErrorNumber();
if (code == EBADF)
cout << "check that the Quicknet driver is installed correctly" << endl;
else if (code == EBUSY)
cout << "check that the Quicknet driver is not in use" << endl;
else {
PString errStr = lidDevice->GetErrorText();
if (errStr.IsEmpty())
errStr = psprintf("error code %i", code);
cout << errStr << endl;
}
return FALSE;
}
}
#endif
if (args.HasOption("ringfile"))
ringFile = args.GetOptionString("ringfile");
if (args.HasOption("ringdelay"))
ringDelay = args.GetOptionString("ringdelay").AsInteger();
else
ringDelay = 5;
#if defined(HAS_LIDDEVICE)
if ((lidDevice == NULL) || !lidDevice->IsOpen()) {
#endif
if (!SetSoundDevice(args, "sound", PSoundChannel::Recorder))
return FALSE;
if (!SetSoundDevice(args, "sound", PSoundChannel::Player))
return FALSE;
if (!SetSoundDevice(args, "sound-in", PSoundChannel::Recorder))
return FALSE;
if (!SetSoundDevice(args, "sound-out", PSoundChannel::Player))
return FALSE;
if (verbose >= 3)
cout << "Sound output device: \"" << GetSoundChannelPlayDevice() << "\"\n"
"Sound input device: \"" << GetSoundChannelRecordDevice() << "\"\n";
#ifdef HAS_OSS
if (!InitialiseMixer(args, verbose))
return FALSE;
#endif
#if defined(HAS_LIDDEVICE)
} // endif
#endif
// by default, assume we can do PCM codec
BOOL canDoPCM = TRUE;
// The order in which capabilities are added to the capability table
// determines which one is selected by default.
#if defined(HAS_LIDDEVICE)
if ((lidDevice != NULL) && lidDevice->IsOpen()) {
H323_LIDCapability::AddAllCapabilities(*lidDevice, capabilities, 0, 0);
canDoPCM = lidDevice->GetMediaFormats().GetValuesIndex(OpalMediaFormat(OPAL_PCM16)) != P_MAX_INDEX;
}
#endif
if (canDoPCM) {
int g711Frames = 30;
if (args.HasOption("g711frames")) {
g711Frames = args.GetOptionString("g711frames").AsInteger();
if (g711Frames <= 10 || g711Frames > 240) {
cout << "error: G.711 frame size must be in range 10 to 240" << endl;
g711Frames = 30;
}
}
int gsmFrames = 4;
if (args.HasOption("gsmframes")) {
gsmFrames = args.GetOptionString("gsmframes").AsInteger();
if (gsmFrames < 1 || gsmFrames > 7) {
cout << "error: GSM frame size must be in range 1 to 7" << endl;
gsmFrames = 4;
}
}
if (verbose >= 3) {
cout <<"G.711 frame size: " << g711Frames << endl;
cout <<"GSM frame size: " << gsmFrames << endl;
}
H323_GSM0610Capability * gsmCap;
SetCapability(0, 0, gsmCap = new H323_GSM0610Capability);
gsmCap->SetTxFramesInPacket(gsmFrames);
MicrosoftGSMAudioCapability * msGsmCap;
SetCapability(0, 0, msGsmCap = new MicrosoftGSMAudioCapability);
msGsmCap->SetTxFramesInPacket(gsmFrames);
H323_G711Capability * g711uCap;
SetCapability(0, 0, g711uCap = new H323_G711Capability(H323_G711Capability::muLaw));
g711uCap->SetTxFramesInPacket(g711Frames);
H323_G711Capability * g711aCap;
SetCapability(0, 0, g711aCap = new H323_G711Capability(H323_G711Capability::ALaw));
g711aCap->SetTxFramesInPacket(g711Frames);
SetCapability(0, 0, new SpeexNarrow3AudioCapability());
SetCapability(0, 0, new SpeexNarrow4AudioCapability());
SetCapability(0, 0, new SpeexNarrow5AudioCapability());
SetCapability(0, 0, new SpeexNarrow6AudioCapability());
SetCapability(0, 0, new SpeexNarrow2AudioCapability());
SetCapability(0, 0, new H323_G726_Capability(*this, H323_G726_Capability::e_16k));
SetCapability(0, 0, new H323_G726_Capability(*this, H323_G726_Capability::e_24k));
SetCapability(0, 0, new H323_G726_Capability(*this, H323_G726_Capability::e_32k));
SetCapability(0, 0, new H323_G726_Capability(*this, H323_G726_Capability::e_40k));
SetCapability(0, 0, new H323_LPC10Capability(*this));
}
//AddCapability puts the codec into the list of codecs we can send
//SetCapability puts the codec into the list of codecs we can send and receive
#ifdef DEPRECATED_CU30
PFilePath fileName= PProcess::Current().GetConfigurationFile();
PString statsDir = fileName.GetDirectory(); //Statistics files ("y" "u" "v" and "mc") have to be here.
INT _width,_height;
_width= 176 << videoSize;
_height= 144 << videoSize;
cout<<"SetVideo size to "<<_width<<" x " <<_height<<endl;
if (args.HasOption("videocu30") || args.HasOption("videocu30stats")) {
if (!videoReceiveDevice.IsEmpty()) SetCapability(0, 1, new H323_Cu30Capability(*this, statsDir, _width, _height, videoCu30Stats));
else
if (autoStartTransmitVideo)
AddCapability(new H323_Cu30Capability(*this, statsDir, _width, _height, videoCu30Stats));
}
#endif
//Make sure the CIF and QCIF capabilities are in the correct order
#define ADD_VIDEO_CAPAB(a) \
if (!videoReceiveDevice.IsEmpty()) { \
if (videoSize == 1) { \
SetCapability(0, 1, new a(0, 0, 1, 0, 0, videoBitRate, videoFramesPS)); \
SetCapability(0, 1, new a(0, 1, 0, 0, 0, videoBitRate, videoFramesPS)); \
} else { \
SetCapability(0, 1, new a(0, 1, 0, 0, 0, videoBitRate, videoFramesPS)); \
SetCapability(0, 1, new a(0, 0, 1, 0, 0, videoBitRate, videoFramesPS)); \
} \
} else if (autoStartTransmitVideo) { \
if (videoSize == 1) { \
AddCapability(new a(0, 0, 1, 0, 0, videoBitRate, videoFramesPS)); \
AddCapability(new a(0, 1, 0, 0, 0, videoBitRate, videoFramesPS)); \
} else { \
AddCapability(new a(0, 1, 0, 0, 0, videoBitRate, videoFramesPS)); \
AddCapability(new a(0, 0, 1, 0, 0, videoBitRate, videoFramesPS)); \
} \
} \
#if H323_AVCODEC
ADD_VIDEO_CAPAB (H323_FFH263Capability);
#endif
#if H323_VICH263
ADD_VIDEO_CAPAB (H323_H263Capability);
#endif
if (!videoReceiveDevice.IsEmpty()) {
if (videoSize == 1) {
SetCapability(0, 1, new H323_H261Capability(0, 4, FALSE, FALSE, 6217));
SetCapability(0, 1, new H323_H261Capability(2, 0, FALSE, FALSE, 6217));
} else {
SetCapability(0, 1, new H323_H261Capability(2, 0, FALSE, FALSE, 6217));
SetCapability(0, 1, new H323_H261Capability(0, 4, FALSE, FALSE, 6217));
}
} else if (autoStartTransmitVideo) {
if (videoSize == 1) {
AddCapability(new H323_H261Capability(0, 4, FALSE, FALSE, 6217)); //CIF
AddCapability(new H323_H261Capability(2, 0, FALSE, FALSE, 6217)); //QCIF
} else {
AddCapability(new H323_H261Capability(2, 0, FALSE, FALSE, 6217)); //QCIF
AddCapability(new H323_H261Capability(0, 4, FALSE, FALSE, 6217)); //CIF
}
}
PStringArray toRemove = args.GetOptionString('D').Lines();
PStringArray toReorder = args.GetOptionString('P').Lines();
static const char * const oldArgName[] = {
"g7231", "g729", "g728", "gsm", "g711-ulaw", "g711-alaw", "g.726", "speex"
};
static const char * const capName[] = {
"G.723.1", "G.729", "G.728", "GSM", "G.711-uLaw", "G.711-ALaw", "G.726", "Speex"
};
for (i = 0; i < PARRAYSIZE(oldArgName); i++) {
if (args.HasOption(PString("no-")+oldArgName[i]))
toRemove[toRemove.GetSize()] = capName[i];
if (args.HasOption(oldArgName[i]))
toReorder[toReorder.GetSize()] = capName[i];
}
capabilities.Remove(toRemove);
capabilities.Reorder(toReorder);
PCaselessString uiMode = args.GetOptionString('I');
if (uiMode == "q931")
SetSendUserInputMode(H323Connection::SendUserInputAsQ931);
else if (uiMode == "signal")
SetSendUserInputMode(H323Connection::SendUserInputAsTone);
else if (uiMode == "rfc2833")
SetSendUserInputMode(H323Connection::SendUserInputAsInlineRFC2833);
else
SetSendUserInputMode(H323Connection::SendUserInputAsString);
PCaselessString uiCap = args.GetOptionString('U');
if (uiCap == "signal")
capabilities.SetCapability(0, P_MAX_INDEX, new H323_UserInputCapability(H323_UserInputCapability::SignalToneH245));
else if (uiCap == "rfc2833")
capabilities.SetCapability(0, P_MAX_INDEX, new H323_UserInputCapability(H323_UserInputCapability::SignalToneRFC2833));
else if (uiCap == "string") {
PINDEX num = capabilities.SetCapability(0, P_MAX_INDEX, new H323_UserInputCapability(H323_UserInputCapability::HookFlashH245));
capabilities.SetCapability(0, num+1, new H323_UserInputCapability(H323_UserInputCapability::BasicString));
} else if (uiCap != "none")
AddAllUserInputCapabilities(0, P_MAX_INDEX);
if (verbose >= 3) {
cout << "User Input Send Mode: as ";
switch (GetSendUserInputMode()) {
case H323Connection::SendUserInputAsQ931 :
cout << "Q.931 Keypad Information Element";
break;
case H323Connection::SendUserInputAsString :
cout << "H.245 string";
break;
case H323Connection::SendUserInputAsTone :
cout << "H.245 tone";
break;
case H323Connection::SendUserInputAsInlineRFC2833 :
cout << "RFC2833";
break;
default :
cout << "Unknown!";
}
cout << '\n';
}
//SetCapability(0, P_MAX_INDEX, new H323_T120Capability);
if (verbose >= 4)
cout << "Codecs (in preference order):\n" << setprecision(2) << capabilities << endl << endl;
if (!args.GetOptionString("listenport").IsEmpty())
listenPort = (WORD)args.GetOptionString("listenport").AsInteger();
PStringArray interfaceList;
if (!args.GetOptionString('i').IsEmpty())
interfaceList = args.GetOptionString('i').Lines();
PString interfacePrintable;
// if no interfaces specified, then bind to all interfaces with a single Listener
// otherwise, bind to specific interfaces
if (interfaceList.GetSize() == 0) {
PIPSocket::Address interfaceAddress(INADDR_ANY);
H323ListenerTCP * listener = new H323ListenerTCP(*this, interfaceAddress, listenPort);
if (!StartListener(listener)) {
cout << "Could not open H.323 listener port on "
<< listener->GetListenerPort() << endl;
delete listener;
return FALSE;
}
interfacePrintable = psprintf("ALL:%i", listenPort);
} else {
for (i = 0; i < interfaceList.GetSize(); i++) {
PString interfaceStr = interfaceList[i];
WORD interfacePort = listenPort;
// Allow for [ipaddr]:port form, especially for IPv6
PINDEX pos = interfaceStr.Find(']');
if (pos == P_MAX_INDEX)
pos = 0;
pos = interfaceStr.Find(':', pos);
if (pos != P_MAX_INDEX) {
interfacePort = (WORD)interfaceStr.Mid(pos+1).AsInteger();
interfaceStr = interfaceStr.Left(pos);
}
interfacePrintable &= interfaceStr + ":" + PString(PString::Unsigned, interfacePort);
PIPSocket::Address interfaceAddress(interfaceStr);
H323ListenerTCP * listener = new H323ListenerTCP(*this, interfaceAddress, interfacePort);
if (!StartListener(listener)) {
cout << "Could not open H.323 listener port on "
<< interfaceAddress << ":" << interfacePort << endl;
delete listener;
return FALSE;
}
}
}
if (verbose >= 3)
cout << "Listening interfaces : " << interfacePrintable << endl;
if (args.HasOption("translate")) {
masqAddressPtr = new PIPSocket::Address(args.GetOptionString("translate"));
behind_masq = TRUE;
cout << "Masquerading as address " << *(masqAddressPtr) << endl;
} else {
behind_masq = FALSE;
}
// Initialise the security info
if (args.HasOption("password")) {
SetGatekeeperPassword(args.GetOptionString("password"));
cout << "Enabling H.235 security access to gatekeeper." << endl;
}
if (args.HasOption('g')) {
PString gkName = args.GetOptionString('g');
H323TransportUDP * rasChannel;
if (args.GetOptionString('i').
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -