[Live-devel] problems moving to asynchronous rtsp interface
Jeff Shanab
jshanab at smartwire.com
Sat Nov 26 09:40:27 PST 2011
I just started trying to upgrade our code to use the asynchronous interface and I am a bit perplexed at the mix of C and C++. In other libraries the callbacks generally have a void pointer to clientData or 'instance' or something like that which allows me to pass the 'this' pointer, cast it, to the class and access all the particular instances' members. In the openRTSP and PlayCommon code I see the signatures for the callbacks are hard coded to foo(RTSPClient::responsehandler*,int,char*). One level deep it is ok, but as soon as one of these callbacks chains to the next callback, I have lost any reference to my instance data.
I suspect the architecture of this code is to thready but I still want instances of my objects.
For example. This is what causes the ourRTSPClient in the example to be a Global variable. I need to have this as a class member variable, and perhaps do something like this....
getOptions(RTSPClient::responseHandler* afterFunc, void* clientData) {
myClass * instancePTR = (myClass *) clientData;
instancePTR->ourClient_->sendOptionsCommand(instancePTR, ourAuthenticator, clientData);
}
I guess an ideal way would be to create a callback interface that we just include in our code and fill in the blanks. A pointer to the instance is then all live555 needs as it would dictate the names and signatures of the calls.
What is the best way to use these callbacks in a multi threaded (multiple UsageEnvironments) c++ program.?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20111126/214810c9/attachment.html>
More information about the live-devel
mailing list