Page 1 of 1

Using H323Plus in a class library

Posted: Thu Dec 23, 2021 12:38 am
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

Re: Using H323Plus in a class library

Posted: Tue Dec 28, 2021 5:47 am
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

Re: Using H323Plus in a class library

Posted: Wed Dec 29, 2021 5:51 pm
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

Re: Using H323Plus in a class library

Posted: Wed Dec 29, 2021 6:16 pm
by willamowius
That's great!

You should really put your C# wrapper into a Github repository for others to look at and contribute.