Hi
@Artyom Degtyarev [JB], I want C++ code invoke a callback that is implemented in Kotlin, and that callback need to return a string, is that possible?
Currently I declare the callback in C header like this:
typedef const char* (*PCClientOnPreferCodecs)(void*, const char*, const char*);
And my Kotlin code implementing it is:
private fun PCClientCallbackOnPreferCodecs(opaque: COpaquePointer?, peerUidPtr: CPointer<ByteVar>?, sdpPtr: CPointer<ByteVar>?): CPointer<ByteVar>? {
initRuntimeIfNeeded()
if (opaque == null) {
return null
}
memScoped {
return opaque.asStableRef<PeerConnectionClientCallback>().get().onPreferCodecs(peerUid, sdp).cstr.ptr
}
}
I pass it into C++ with
staticCFunction(::PCClientCallbackOnPreferCodecs)
, and pass
opaque
with
StableRef.create(callback).asCPointer()
.
It could be compiled and linked, but at runtime the string I get at C++ is scrambled code.