pjsip callbacks in C++

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Klaus,
    The bottom line is that you can not use a C++ instance method as a 
callback method.  The reason is that in C++, the "this" pointer is 
passed as the first argument to each instance method.  The C code in 
pjsip has no way to pass a "this" pointer to your call back.
   
    You have 2 alternatives, both of which are effectively the same thing.

1) in C++, write static methods and pass their addresses as the callback 
methods.
2) write some C code methods and use their addresses as the callback 
methods.

    Note that in C++, a static methods does not use a "this" pointer, so 
it is effectively the same thing as a C method.

    Regards,
    Paul


Klaus Darilion wrote:
> Hi!
>
> I'm trying to add pjsip to a QT C++ application. This gives me headaches 
>   as I have no clue how to make callbacks in C++. There are lots of 
> different approaches (static member function as wrapper, templates ...).
>
> I tried the static member function wrapper with logging callbacks but my 
> application crashes ~50%.
>
> I wonder if someone have practical tips for my how to connect pjsip's 
> callbacks to member functions.
>
> thanks
> klaus
>
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
>
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>
>   



[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux