"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "samples/simple/main.cxx" between
h323plus-1_27_0.tar.gz and h323plus-1_27_1.tar.gz

About: H.323 Plus offers libraries for voice (VoIP) and videoconferencing using H.323.

main.cxx  (h323plus-1_27_0):main.cxx  (h323plus-1_27_1)
skipping to change at line 55 skipping to change at line 55
#define defVideoDriver "*" #define defVideoDriver "*"
#endif #endif
#define new PNEW #define new PNEW
PCREATE_PROCESS(SimpleH323Process); PCREATE_PROCESS(SimpleH323Process);
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
SimpleH323Process::SimpleH323Process() SimpleH323Process::SimpleH323Process()
: PProcess("H323Plus", "simple", : PProcess("H323Plus", "simple", MAJOR_VERSION, MINOR_VERSION, BUILD_TYPE, BUI
MAJOR_VERSION, MINOR_VERSION, BUILD_TYPE, BUILD_NUMBER) LD_NUMBER)
{ {
endpoint = NULL; endpoint = NULL;
} }
SimpleH323Process::~SimpleH323Process() SimpleH323Process::~SimpleH323Process()
{ {
delete endpoint; delete endpoint;
} }
void SimpleH323Process::Main() void SimpleH323Process::Main()
skipping to change at line 220 skipping to change at line 219
<< endl; << endl;
return; return;
} }
#if PTRACING #if PTRACING
PTrace::Initialise(args.GetOptionCount('t'), PTrace::Initialise(args.GetOptionCount('t'),
args.HasOption('o') ? (const char *)args.GetOptionString('o ') : NULL, args.HasOption('o') ? (const char *)args.GetOptionString('o ') : NULL,
PTrace::DateAndTime | PTrace::TraceLevel | PTrace::FileAndL ine); PTrace::DateAndTime | PTrace::TraceLevel | PTrace::FileAndL ine);
#endif #endif
// Create the H.323 endpoint and initialise it // Create the H.323 endpoint and initialize it
endpoint = new SimpleH323EndPoint; endpoint = new SimpleH323EndPoint;
if (!endpoint->Initialise(args)) if (!endpoint->Initialise(args))
return; return;
// See if making a call or just listening. // See if making a call or just listening.
if (args.HasOption('l')) if (args.HasOption('l'))
cout << "Waiting for incoming calls for \"" << endpoint->GetLocalUserName() << "\"\n"; cout << "Waiting for incoming calls for \"" << endpoint->GetLocalUserName() << "\"\n";
else { else {
cout << "Initiating call to \"" << args[0] << "\"\n"; cout << "Initiating call to \"" << args[0] << "\"\n";
endpoint->MakeCall(args[0], endpoint->currentCallToken); endpoint->MakeCall(args[0], endpoint->currentCallToken);
} }
if (args.HasOption('S')) { if (args.HasOption('S')) {
// sleep infinitely, usefull for testing purposes // sleep infinitely, useful for testing purposes
for (;;) { for (;;) {
PThread::Sleep(1000); PThread::Sleep(1000);
} }
} }
cout << "Press X to exit." << endl; cout << "Press X to exit." << endl;
// Simplest possible user interface // Simplest possible user interface
for (;;) { for (;;) {
cout << "H323> " << flush; cout << "H323> " << flush;
skipping to change at line 272 skipping to change at line 271
if (connection != NULL) { if (connection != NULL) {
if (cmd == "H") if (cmd == "H")
connection->ClearCall(); connection->ClearCall();
else if (cmd == "Y") else if (cmd == "Y")
connection->AnsweringCall(H323Connection::AnswerCallNow); connection->AnsweringCall(H323Connection::AnswerCallNow);
else if (cmd == "N") else if (cmd == "N")
connection->AnsweringCall(H323Connection::AnswerCallDenied); connection->AnsweringCall(H323Connection::AnswerCallDenied);
#ifdef H323_H239 #ifdef H323_H239
else if (cmd == "S") { else if (cmd == "S") {
if (connection->OpenH239Channel()) if (connection->OpenH239Channel())
cout << "Application Session Open.." << endl; cout << "H.239 session open.." << endl;
else else
cout << "Application Open Error: Remote may not support Feature!" << endl; cout << "H.239 open error: Remote may not support feature!" << end l;
} else if (cmd == "E") { } else if (cmd == "E") {
if (connection->CloseH239Channel()) if (connection->CloseH239Channel())
cout << "Application Session Closed.." << endl; cout << "H.239 session closed.." << endl;
} }
#endif #endif
else else
connection->SendUserInput(cmd); connection->SendUserInput(cmd);
connection->Unlock(); connection->Unlock();
} }
} }
} }
cout << "Exiting " << GetName() << endl; cout << "Exiting " << GetName() << endl;
skipping to change at line 418 skipping to change at line 417
H323Capability::CapabilityFrameSize MaxVideoFrame = H323Capability::cifMPI; H323Capability::CapabilityFrameSize MaxVideoFrame = H323Capability::cifMPI;
PString inputDriverName = videoDriver; PString inputDriverName = videoDriver;
PStringList devices = PVideoInputDevice::GetDriversDeviceNames(inputDriverName ); PStringList devices = PVideoInputDevice::GetDriversDeviceNames(inputDriverName );
if (devices.GetSize() == 0) { if (devices.GetSize() == 0) {
cout << "No Video Grabber available Disabling Video Support!" << endl; cout << "No Video Grabber available Disabling Video Support!" << endl;
hasVideo = FALSE; hasVideo = FALSE;
#if PTLIB_VER >= 2110 #if PTLIB_VER >= 2110
} else { } else {
PVideoInputDevice::Capabilities caps; PVideoInputDevice::Capabilities caps;
if (PVideoInputDevice::GetDeviceCapabilities(devices[0],inputDriverName,&cap s)) { if (PVideoInputDevice::GetDeviceCapabilities(devices[0], inputDriverName, &c aps)) {
cout << "Video Device " << devices[0] << " capabilities." << endl; cout << "Video Device " << devices[0] << " capabilities." << endl;
cout << " Grabber capabilities." << endl; cout << " Grabber capabilities." << endl;
for (std::list<PVideoFrameInfo>::const_iterator r = caps.framesizes.begin( ); r != caps.framesizes.end(); ++r) { for (std::list<PVideoFrameInfo>::const_iterator r = caps.framesizes.begin( ); r != caps.framesizes.end(); ++r) {
cout << " w: " << r->GetFrameWidth() << " h: " << r->GetFrameHe ight() << " fmt: " cout << " w: " << r->GetFrameWidth() << " h: " << r->GetFrameHe ight() << " fmt: "
<< r->GetColourFormat() << " fps: " << r->GetFrameRate() << endl; << r->GetColourFormat() << " fps: " << r->GetFrameRate() << endl;
if ((r->GetFrameWidth() >= 1280) && (r->GetFrameHeight() >= 720)) { if ((r->GetFrameWidth() >= 1280) && (r->GetFrameHeight() >= 720)) {
MaxVideoFrame = H323Capability::p720MPI; MaxVideoFrame = H323Capability::p720MPI;
} }
} }
} else { } else {
cout << "InputDevice " << devices[0] << " capabilities not Available." << endl; cout << "InputDevice " << devices[0] << " capabilities not Available." << endl;
} }
#endif #endif
} }
if (MaxVideoFrame == H323Capability::p720MPI) if (MaxVideoFrame == H323Capability::p720MPI)
cout << "High Definition Webcam detected." << endl << endl; cout << "High Definition Webcam detected." << endl << endl;
#else #else
hasVideo = FALSE; hasVideo = FALSE;
#endif #endif
// Set the default codecs available on sound cards. // Set the default codecs available on sound cards.
AddAllCapabilities(0, P_MAX_INDEX, "*"); AddAllCapabilities(0, P_MAX_INDEX, "*");
if (!hasVideo) if (!hasVideo)
RemoveCapability(H323Capability::e_Video); RemoveCapability(H323Capability::e_Video);
#ifdef H323_VIDEO #ifdef H323_VIDEO
else else
skipping to change at line 603 skipping to change at line 603
H323ListenerTCP * listener = new H323ListenerTCP(*this, interfaceAddress, inte rfacePort); H323ListenerTCP * listener = new H323ListenerTCP(*this, interfaceAddress, inte rfacePort);
if (iface.IsEmpty()) if (iface.IsEmpty())
iface = "*"; iface = "*";
if (!StartListener(listener)) { if (!StartListener(listener)) {
cerr << "Could not open H.323 listener port on \"" << iface << '"' << endl; cerr << "Could not open H.323 listener port on \"" << iface << '"' << endl;
return FALSE; return FALSE;
} }
#ifdef H323_TLS // Initialise TLS #ifdef H323_TLS // Initialize TLS
bool useTLS = args.HasOption("tls"); bool useTLS = args.HasOption("tls");
if (useTLS) { if (useTLS) {
DisableH245Tunneling(false); // Tunneling must be used with TLS DisableH245Tunneling(false); // Tunneling must be used with TLS
if (args.HasOption("tls-cafile")) if (args.HasOption("tls-cafile"))
useTLS = TLS_SetCAFile(args.GetOptionString("tls-cafile")); useTLS = TLS_SetCAFile(args.GetOptionString("tls-cafile"));
if (useTLS && args.HasOption("tls-cert")) if (useTLS && args.HasOption("tls-cert"))
useTLS = TLS_SetCertificate(args.GetOptionString("tls-cert")); useTLS = TLS_SetCertificate(args.GetOptionString("tls-cert"));
if (useTLS && args.HasOption("tls-privkey")) { if (useTLS && args.HasOption("tls-privkey")) {
PString passphrase = PString(); PString passphrase = PString();
if (args.HasOption("tls-passphrase")) if (args.HasOption("tls-passphrase"))
skipping to change at line 632 skipping to change at line 632
cerr << "Could not enable TLS signal security." << endl; cerr << "Could not enable TLS signal security." << endl;
} }
} }
#endif #endif
// Initialise the security info // Initialise the security info
if (args.HasOption('p')) { if (args.HasOption('p')) {
SetGatekeeperPassword(args.GetOptionString('p')); SetGatekeeperPassword(args.GetOptionString('p'));
cout << "Enabling H.235 security access to gatekeeper." << endl; cout << "Enabling H.235 security access to gatekeeper." << endl;
// also set password for H.235.1 on Q.931 messages // also set password for H.235.1 on Q.931 messages
SetEPCredentials(GetLocalUserName(), args.GetOptionString('p')); // locsl us er name should probably be replaced by endpointID by framework SetEPCredentials(GetLocalUserName(), args.GetOptionString('p')); // local us er name should probably be replaced by endpointID by framework
} }
#ifdef H323_H46017 #ifdef H323_H46017
if (args.HasOption('k')) { if (args.HasOption('k')) {
PString gk17 = args.GetOptionString('k'); PString gk17 = args.GetOptionString('k');
if (H46017CreateConnection(gk17, false)) { if (H46017CreateConnection(gk17, false)) {
cout << "Using H.460.17 Gatekeeper Tunneling." << endl; cout << "Using H.460.17 Gatekeeper Tunneling." << endl;
SetInitialBandwidth(384000); SetInitialBandwidth(384000);
return true; return true;
} }
skipping to change at line 886 skipping to change at line 886
break; break;
} }
} }
if (deviceName.IsEmpty()) if (deviceName.IsEmpty())
deviceName = isEncoding ? "fake" : "NULL"; deviceName = isEncoding ? "fake" : "NULL";
PVideoDevice * device = isEncoding ? (PVideoDevice *)PVideoInputDevice::Create DeviceByName(deviceName) PVideoDevice * device = isEncoding ? (PVideoDevice *)PVideoInputDevice::Create DeviceByName(deviceName)
: (PVideoDevice *)PVideoOutputDevice::Creat eDeviceByName(deviceName); : (PVideoDevice *)PVideoOutputDevice::Creat eDeviceByName(deviceName);
// codec needs a list of possible formats, otherwise the frame size isn't nego tiated properly // codec needs a list of possible formats, otherwise the frame size isn't nego tiated properly
#if PTLIB_VER >= 2110
if (isEncoding) { if (isEncoding) {
#if PTLIB_VER >= 2110
PVideoInputDevice::Capabilities videoCaps; PVideoInputDevice::Capabilities videoCaps;
if (((PVideoInputDevice *)device)->GetDeviceCapabilities(deviceName,device Driver,&videoCaps)) { if (((PVideoInputDevice *)device)->GetDeviceCapabilities(deviceName, devic eDriver, &videoCaps)) {
codec.SetSupportedFormats(videoCaps.framesizes); codec.SetSupportedFormats(videoCaps.framesizes);
} else { } else
// set fixed list of resolutions for drivers that don't provide a list #endif // PTLIB_VER
PVideoInputDevice::Capabilities caps; {
PVideoFrameInfo cap; // set fixed list of resolutions for PTLib < 2.11 and for drivers that don
cap.SetColourFormat("YUV420P"); 't provide a a list
cap.SetFrameRate(30); PVideoInputDevice::Capabilities caps;
// sizes must be from largest to smallest PVideoFrameInfo cap;
cap.SetFrameSize(1280, 720); cap.SetColourFormat("YUV420P");
caps.framesizes.push_back(cap); cap.SetFrameRate(30);
cap.SetFrameSize(704, 576); // sizes must be from largest to smallest
caps.framesizes.push_back(cap); cap.SetFrameSize(1280, 720);
cap.SetFrameSize(352, 288); caps.framesizes.push_back(cap);
caps.framesizes.push_back(cap); cap.SetFrameSize(704, 576);
codec.SetSupportedFormats(caps.framesizes); caps.framesizes.push_back(cap);
} cap.SetFrameSize(640, 400);
} caps.framesizes.push_back(cap);
#else cap.SetFrameSize(352, 288);
if (isEncoding) { caps.framesizes.push_back(cap);
PVideoInputDevice::Capabilities caps; codec.SetSupportedFormats(caps.framesizes);
PVideoFrameInfo cap; }
cap.SetColourFormat("YUV420P");
cap.SetFrameRate(30);
// sizes must be from largest to smallest
cap.SetFrameSize(1280, 720);
caps.framesizes.push_back(cap);
cap.SetFrameSize(704, 576);
caps.framesizes.push_back(cap);
cap.SetFrameSize(640, 400);
caps.framesizes.push_back(cap);
cap.SetFrameSize(352, 288);
caps.framesizes.push_back(cap);
codec.SetSupportedFormats(caps.framesizes);
} }
#endif
if (!device->SetFrameSize(codec.GetWidth(), codec.GetHeight()) || if (!device->SetFrameSize(codec.GetWidth(), codec.GetHeight()) ||
!device->SetFrameRate(codec.GetFrameRate()) || !device->SetFrameRate(codec.GetFrameRate()) ||
!device->SetColourFormatConverter("YUV420P")) { !device->SetColourFormatConverter("YUV420P")) {
PTRACE(1, "Failed to configure the video device \"" << deviceName << '"') ; PTRACE(1, "Failed to configure the video device \"" << deviceName << '"') ;
return FALSE; return FALSE;
} }
if (!device->Open(deviceName, TRUE)) { if (!device->Open(deviceName, TRUE)) {
PTRACE(1, "Failed to open the video device \"" << deviceName << '"'); PTRACE(1, "Failed to open the video device \"" << deviceName << '"');
skipping to change at line 950 skipping to change at line 936
if (isEncoding) if (isEncoding)
channel->AttachVideoReader((PVideoInputDevice *)device); channel->AttachVideoReader((PVideoInputDevice *)device);
else else
channel->AttachVideoPlayer((PVideoOutputDevice *)device); channel->AttachVideoPlayer((PVideoOutputDevice *)device);
return codec.AttachChannel(channel,TRUE); return codec.AttachChannel(channel,TRUE);
} }
#ifdef H323_H239 #ifdef H323_H239
PBoolean SimpleH323EndPoint::OpenExtendedVideoChannel(H323Connection & connectio n, PBoolean SimpleH323EndPoint::OpenExtendedVideoChannel(H323Connection & connectio n,
PBoolean PTRACE_PARAM(isEncoding), PBoolean isEncoding,
H323VideoCodec & codec) H323VideoCodec & codec)
{ {
#ifdef P_APPSHARE #ifdef P_APPSHARE
PString deviceDriver = "Application"; PString deviceDriver = "Application";
#else #else
PString deviceDriver = "*"; PString deviceDriver = "*";
#endif #endif
PStringList devices = isEncoding ? PVideoInputDevice::GetDriversDeviceNames(de viceDriver) PStringList devices = isEncoding ? PVideoInputDevice::GetDriversDeviceNames(de viceDriver)
: PVideoOutputDevice::GetDriversDeviceNames("* "); : PVideoOutputDevice::GetDriversDeviceNames("* ");
// Look for a useful device // Look for a useful device
PString deviceName; PString deviceName;
skipping to change at line 975 skipping to change at line 960
PTRACE(4, devices[i]); PTRACE(4, devices[i]);
PCaselessString devName = devices[i]; PCaselessString devName = devices[i];
if (devName != "*.yuv" && devName != "NULL") { if (devName != "*.yuv" && devName != "NULL") {
deviceName = devName; deviceName = devName;
break; break;
} }
} }
if (deviceName.IsEmpty()) if (deviceName.IsEmpty())
deviceName = isEncoding ? "fake" : "NULL"; deviceName = isEncoding ? "fake" : "NULL";
PVideoDevice * device = isEncoding ? (PVideoDevice *)PVideoInputDevice::Create PVideoDevice * device = isEncoding ? (PVideoDevice *)PVideoInputDevice::Create
OpenedDevice(deviceDriver,deviceName) OpenedDevice(deviceDriver, deviceName)
: (PVideoDevice *)PVideoOutputDevice::Creat : (PVideoDevice *)PVideoOutputDevice::Creat
eOpenedDevice(deviceDriver,deviceName); eOpenedDevice(deviceDriver, deviceName);
// codec needs a list of possible formats, otherwise the frame size isn't nego
tiated properly
if (isEncoding) { if (isEncoding) {
#if PTLIB_VER >= 2110
PVideoInputDevice::Capabilities videoCaps; PVideoInputDevice::Capabilities videoCaps;
if (((PVideoInputDevice *)device)->GetDeviceCapabilities(deviceName,device Driver,&videoCaps)) if (((PVideoInputDevice *)device)->GetDeviceCapabilities(deviceName, devic eDriver, &videoCaps)) {
codec.SetSupportedFormats(videoCaps.framesizes); codec.SetSupportedFormats(videoCaps.framesizes);
} else
#endif // PTLIB_VER
{
// set fixed list of resolutions for PTLib < 2.11 and for drivers that don
't provide a a list
PVideoInputDevice::Capabilities caps;
PVideoFrameInfo cap;
cap.SetColourFormat("YUV420P");
cap.SetFrameRate(30);
// sizes must be from largest to smallest
cap.SetFrameSize(1280, 720);
caps.framesizes.push_back(cap);
cap.SetFrameSize(704, 576);
caps.framesizes.push_back(cap);
cap.SetFrameSize(640, 400);
caps.framesizes.push_back(cap);
cap.SetFrameSize(352, 288);
caps.framesizes.push_back(cap);
codec.SetSupportedFormats(caps.framesizes);
}
}
if (!device->SetFrameSize(codec.GetWidth(), codec.GetHeight()) ||
!device->SetFrameRate(codec.GetFrameRate()) ||
!device->SetColourFormatConverter("YUV420P")) {
PTRACE(1, "Failed to configure the video device \"" << deviceName << '"')
;
return FALSE;
} }
if (!device->SetColourFormatConverter("YUV420P") || if (!device->Open(deviceName, TRUE)) {
!device->SetFrameSizeConverter(codec.GetWidth(), codec.GetHeight(),PVideoF PTRACE(1, "Failed to open the video device \"" << deviceName << '"');
rameInfo::eScale)) {
PTRACE(1, "Failed to open or configure the video device \"" << deviceName <<
'"');
return FALSE; return FALSE;
} }
PVideoChannel * channel = new PVideoChannel; PVideoChannel * channel = new PVideoChannel;
if (isEncoding) if (isEncoding)
channel->AttachVideoReader((PVideoInputDevice *)device); channel->AttachVideoReader((PVideoInputDevice *)device);
else else
channel->AttachVideoPlayer((PVideoOutputDevice *)device); channel->AttachVideoPlayer((PVideoOutputDevice *)device);
skipping to change at line 1031 skipping to change at line 1042
#ifdef H323_H235 #ifdef H323_H235
void SimpleH323EndPoint::OnMediaEncryption(unsigned session, H323Channel::Direct ions dir, const PString & cipher) void SimpleH323EndPoint::OnMediaEncryption(unsigned session, H323Channel::Direct ions dir, const PString & cipher)
{ {
cout << "Media Encryption " << session << " " << dir << " " << cipher << end l; cout << "Media Encryption " << session << " " << dir << " " << cipher << end l;
} }
#endif #endif
#ifdef H323_TLS #ifdef H323_TLS
void SimpleH323EndPoint::OnSecureSignallingChannel(bool isSecured) void SimpleH323EndPoint::OnSecureSignallingChannel(bool isSecured)
{ {
// at this point an endpoint could refuse a call with non-secured signall ing connection // at this point an endpoint could refuse a call with non-secured signali ng connection
cout << "TLS " << (isSecured ? "" : "NOT") << " enabled for call." << endl; cout << "TLS " << (isSecured ? "" : "NOT") << " enabled for call." << endl;
} }
#endif #endif
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
SimpleH323Connection::SimpleH323Connection(SimpleH323EndPoint & ep, unsigned ref ) SimpleH323Connection::SimpleH323Connection(SimpleH323EndPoint & ep, unsigned ref )
: H323Connection(ep, ref) : H323Connection(ep, ref)
{ {
#ifdef H323_H4609 #ifdef H323_H4609
H4609EnableStats(); H4609EnableStats();
skipping to change at line 1074 skipping to change at line 1085
cout << channel.GetCapability() << endl; cout << channel.GetCapability() << endl;
return TRUE; return TRUE;
} }
void SimpleH323Connection::OnUserInputString(const PString & value) void SimpleH323Connection::OnUserInputString(const PString & value)
{ {
cout << "User input received: \"" << value << '"' << endl; cout << "User input received: \"" << value << '"' << endl;
} }
// End of File ///////////////////////////////////////////////////////////////
 End of changes. 24 change blocks. 
59 lines changed or deleted 73 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)