Using H323Plus in a class library

Discussion related to implementation and use of the H.323 Plus H.323 stack at https://www.h323plus.org.
Post Reply
Alcor2022
Posts: 7
Joined: Mon Dec 20, 2021 3:37 am

Using H323Plus in a class library

Post by Alcor2022 »

Hello,

I am working on a VC++ wrapper for H323Plus (based on compiled H323Plus.lib and ptlibs.lib). There will be a C# executable that references the wrapper DLL to use H323Plus features. Before I go much further I would like to understand the function of the PProcess and PCREATE_PROCESS. There is some internal initialization happening, but this is basically what I have so far:

PCREATE_PROCESS(BaseProcess);

/* This is what PCREATE_PROCESS is doing
int main(int argc, char **argv, char **envp)
{
BaseProcess *pinstance = new BaseProcess();
pinstance->PreInitialise(argc,argv,envp);
int terminationValue = pinstance->InternalMain();
delete pinstance;

return terminationValue;
}
*/

BaseProcess::BaseProcess()
: PProcess("H323Plus", "Wrapper", MAJOR_VERSION, MINOR_VERSION, BUILD_TYPE, BUILD_NUMBER, true)
{

endpointp = NULL;
}

BaseProcess::~BaseProcess()
{}


Notice the last parameter in the PProcess arguments of "true". From what I gather, this is supposed to indicate that the process is used in a library versus an executable. I've made a comment block which shows what the PCREATE_PROCESS expands to. Basically, I am not sure how to use this PProcess object in a class library. What I would like to do is create the process instance as shown in this block, but create it when I instantiate my H323 wrapper class from the C# module. In examples I have seen, the main routine for the Process is setting up a loop or a terminationSync.Wait(). Is it required to have a process with a continually running thread (the main() routine)? I know that a Process instance is needed, as some methods are looking for Process::Current(). Looking for some guidance on how to implement this in a class library vs. directly in an executable.

David
Alcor2022
Posts: 7
Joined: Mon Dec 20, 2021 3:37 am

Re: Using H323Plus in a class library

Post by Alcor2022 »

Hello again!

I believe I have successfully integrated H323 into my wrapper DLL. I am able to create a global Process class, and call the PProcess::Current().getLibVersion() method from one of my reference classes instantiated in my C# application. Next step is to setup an endpoint via the C# app and see if I can get it listening for incoming calls. Then I'll implement a MakeCall method to try and place a call to an Ekiga endpoint.

Basically, in my main wrapper ref class, I placed this:

extern BaseApp _theApp;

Then in the BaseApp class, which includes a class based on PProcess, I created a global instance in the cpp file:

BaseApp _theApp;

My BaseApp class looks like this (in BaseApp.h):

class BaseApp
{
public:
BaseApp();

class BaseProcess : public PProcess
{
PCLASSINFO(BaseProcess, PProcess);

BaseProcess() :PProcess("H323Plus", "Starfish", MAJOR_VERSION, MINOR_VERSION, PProcess::CodeStatus::ReleaseCode, BUILD_NUMBER, true) { }

~BaseProcess() {}

void Main() {}
} _baseProcess;

// Any other stuff we want to do with our base app?
int SomeFunction();
};


David
Alcor2022
Posts: 7
Joined: Mon Dec 20, 2021 3:37 am

Re: Using H323Plus in a class library

Post by Alcor2022 »

Just wanted to update my progress...
I was able to place a call to my C# application using the H323Plus wrapper that I am building (I called my endpoint using the Ekiga softphone). Next step is to place an outbound call and continue developing the wrapper functionality. I am also generating events that can be consumed by the C# application.

David
User avatar
willamowius
Posts: 50
Joined: Tue Sep 01, 2009 7:25 am
Contact:

Re: Using H323Plus in a class library

Post by willamowius »

That's great!

You should really put your C# wrapper into a Github repository for others to look at and contribute.
Jan Willamowius
Founder of the GNU Gatekeeper Project
https://www.gnugk.org
https://www.willamowius.com (H.323 support)
Post Reply