📄 main.cxx
字号:
aec = args.GetOptionString("aec").AsUnsigned();
lidDevice->SetAEC(0, (OpalLineInterfaceDevice::AECLevels)aec);
if (verbose >= 3)
cout << "AEC set to " << AECLevelNames[aec] << endl;
} else {
lidDevice->SetAEC(0, OpalLineInterfaceDevice::AECMedium);
if (verbose >= 3)
cout << "AEC set to default" << endl;
}
PString volStr;
if ((OpalLineInterfaceDevice::AECLevels)aec != OpalLineInterfaceDevice::AECAGC) {
if (args.HasOption("quicknet-recvol"))
volStr = args.GetOptionString("quicknet-recvol");
else if (args.HasOption("recvol"))
volStr = args.GetOptionString("recvol");
unsigned recvol;
if (!volStr.IsEmpty()) {
recvol = volStr.AsInteger();
lidDevice->SetRecordVolume(0, recvol);
} else {
lidDevice->GetRecordVolume(0, recvol);
}
if (verbose >= 3) {
cout << "Recording volume set to " << recvol << endl;
}
}
if (args.HasOption("quicknet-playvol"))
volStr = args.GetOptionString("quicknet-playvol");
else if (args.HasOption("playvol"))
volStr = args.GetOptionString("playvol");
unsigned playvol;
if (!volStr.IsEmpty()) {
playvol = volStr.AsInteger();
lidDevice->SetPlayVolume(0, playvol);
} 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-in", "record-driver", PSoundChannel::Recorder) &&
!SetSoundDevice(args, "sound", "record-driver", PSoundChannel::Recorder, true)
)
return FALSE;
if (
!SetSoundDevice(args, "sound", "play-driver", PSoundChannel::Player) &&
!SetSoundDevice(args, "sound-out", "play-driver", PSoundChannel::Player, true)
)
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) {
AddAllCapabilities(0, 0, "*");
}
#ifdef HAS_T38
SetCapability(0, 1, new H323_T38Capability(H323_T38Capability::e_UDP));
#endif
// set frames per packet if requested by user
if (args.HasOption("fpp")) {
PStringArray lines = args.GetOptionString("fpp").Lines();
for (PINDEX i = 0; i < lines.GetSize(); i++) {
PStringArray tokens = lines[i].Tokenise('=');
if (tokens.GetSize() != 2) {
cerr << "error: --fpp option requires argument in the form 'codec=count'" << endl;
return FALSE;
}
PString fmt = tokens[0];
SetCodecFrames(tokens[0], tokens[1].AsInteger());
}
}
// backwards compatible options
if (args.HasOption("gsmframes"))
SetCodecFrames(OpalGSM0610, args.GetOptionString("gsmframes").AsInteger());
if (args.HasOption("g711frames")) {
// note that G.711 "frames" are really 1/8 millisecond
int frames = 8 * args.GetOptionString("g711frames").AsInteger();
SetCodecFrames(OpalG711uLaw64k, frames);
SetCodecFrames(OpalG711ALaw64k, frames);
}
#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
OpalMediaFormat::List mediaFormats = H323PluginCodecManager::GetMediaFormats();
//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)); \
} \
} \
#ifndef NO_H323_VIDEO
#ifdef H323_AVCODEC
ADD_VIDEO_CAPAB (H323_FFH263Capability);
#endif
#ifdef H323_VICH263
ADD_VIDEO_CAPAB (H323_H263Capability);
#endif
#ifdef H323_RFC2190_AVCODEC
if (mediaFormats.GetValuesIndex(OpalMediaFormat("RFC2190 H.263")) != P_MAX_INDEX) {
int maxbps = videoBitRate/100;
if (!videoReceiveDevice.IsEmpty()) {
if (videoSize == 1) {
SetCapability(0, 1, new H323_RFC2190_H263Capability(0, 0, 2, 0, 0, maxbps));
SetCapability(0, 1, new H323_RFC2190_H263Capability(0, 1, 0, 0, 0, maxbps));
} else {
SetCapability(0, 1, new H323_RFC2190_H263Capability(0, 1, 0, 0, 0, maxbps));
SetCapability(0, 1, new H323_RFC2190_H263Capability(0, 0, 2, 0, 0, maxbps));
}
} else if (autoStartTransmitVideo) {
if (videoSize == 1) {
AddCapability(new H323_RFC2190_H263Capability(0, 0, 2, 0, 0, maxbps));
AddCapability(new H323_RFC2190_H263Capability(0, 1, 0, 0, 0, maxbps));
} else {
AddCapability(new H323_RFC2190_H263Capability(0, 1, 0, 0, 0, maxbps));
AddCapability(new H323_RFC2190_H263Capability(0, 0, 2, 0, 0, maxbps));
}
}
}
#endif
if (mediaFormats.GetValuesIndex(OpalMediaFormat("H.261")) != P_MAX_INDEX) {
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
}
}
}
#endif // NO_H323_VIDEO
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", "ilbc", "h261", "h263"
};
static const char * const capName[] = {
"G.723.1", "G.729", "G.728", "GSM", "G.711-uLaw", "G.711-ALaw", "G.726", "Speex", "ilbc", "H.261", "H.263"
};
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;
/* Use IPv6 address family by default if available. */
#ifdef P_HAS_IPV6
if (PIPSocket::IsIpAddressFamilyV6Supported())
PIPSocket::SetDefaultIpAddressFamilyV6();
#endif
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(PIPSocket::GetDefaultIpAny());
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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -