0

I'm writing RTSP client and after creating it with

class RtspClientManager
{
private:
    rtsp_client;
    void continueAfterDescribe(RTSPClient* rtspClient, int resultCode, char* resultString);
}

...

rtsp_client = RTSPClient::createNew(*env, szUrl);

i'm sending describe command:

rtsp_client->sendDescribeCommand(continueAfterDescribe);

I would like to have a continueAfterDescribe as RtspClientManager::continueAfterDescribe instance member and have access to all the members.

Of course continueAfterDescribe could be a static member function but then I would only have access to static members. How to pass a pointer to a non-static member function and have access to all instance members within RtspClientManager??

RTSPClient method sendDescribeCommand has such signature:

unsigned RTSPClient::sendDescribeCommand(responseHandler* responseHandler);

typedef void (responseHandler)(RTSPClient* rtspClient,
             int resultCode, char* resultString);
PawelZ
  • 117
  • 3
  • 13
  • possible duplicate of [Passing a qualified non-static member function as a function pointer](http://stackoverflow.com/questions/499153/passing-a-qualified-non-static-member-function-as-a-function-pointer) – DevSolar May 07 '14 at 09:26
  • Is `RTSPClient` your class? or library class? – ikh May 07 '14 at 09:36

1 Answers1

0

You can't. You have to use static function. But in your situation you can pass a RtspClientManager object as a parameter to the function and then use other methods/members of that object. Also your declarations are not correct, they should be like this:

typedef void (*responseHandler)(RTSPClient* rtspClient,
         int resultCode, char* resultString);

unsigned RTSPClient::sendDescribeCommand(responseHandler responseHandler);
Rakib
  • 7,435
  • 7
  • 29
  • 45