Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why are only ten callbacks allocated? #648

Open
zhuker opened this issue Jan 11, 2023 · 4 comments
Open

Why are only ten callbacks allocated? #648

zhuker opened this issue Jan 11, 2023 · 4 comments

Comments

@zhuker
Copy link

zhuker commented Jan 11, 2023

I am trying to create a wrapper around https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c/
The client code uses callbacks heavily
How do i use more than 10 at the same time?
eg
C:

/**
 * @brief RtcOnConnectionStateChange is fired to report a change in peer connection state.
 *
 * Reference: https://www.w3.org/TR/webrtc/#event-iceconnectionstatechange
 */
typedef VOID (*RtcOnConnectionStateChange)(UINT64, RTC_PEER_CONNECTION_STATE);

jni wrapper

static void (*JavaCPP_video_zhuker_kinesis_KinesisWebrtc_00024RtcOnConnectionStateChange_allocate_callbacks[10])(UINT64 arg0, RTC_PEER_CONNECTION_STATE arg1) = {
        JavaCPP_video_zhuker_kinesis_KinesisWebrtc_00024RtcOnConnectionStateChange_allocate_callback,
        JavaCPP_video_zhuker_kinesis_KinesisWebrtc_00024RtcOnConnectionStateChange_allocate_callback1,
        JavaCPP_video_zhuker_kinesis_KinesisWebrtc_00024RtcOnConnectionStateChange_allocate_callback2,
        JavaCPP_video_zhuker_kinesis_KinesisWebrtc_00024RtcOnConnectionStateChange_allocate_callback3,
        JavaCPP_video_zhuker_kinesis_KinesisWebrtc_00024RtcOnConnectionStateChange_allocate_callback4,
        JavaCPP_video_zhuker_kinesis_KinesisWebrtc_00024RtcOnConnectionStateChange_allocate_callback5,
        JavaCPP_video_zhuker_kinesis_KinesisWebrtc_00024RtcOnConnectionStateChange_allocate_callback6,
        JavaCPP_video_zhuker_kinesis_KinesisWebrtc_00024RtcOnConnectionStateChange_allocate_callback7,
        JavaCPP_video_zhuker_kinesis_KinesisWebrtc_00024RtcOnConnectionStateChange_allocate_callback8,
        JavaCPP_video_zhuker_kinesis_KinesisWebrtc_00024RtcOnConnectionStateChange_allocate_callback9 };
        ```
@saudet
Copy link
Member

saudet commented Jan 11, 2023

We can set that amount with the @Allocator(max=... annotation value:
http://bytedeco.org/javacpp/apidocs/org/bytedeco/javacpp/annotation/Allocator.html#max--

@saudet
Copy link
Member

saudet commented Jan 12, 2023

We can also create trampolines dynamically using libffi:
https://github.com/bytedeco/javacpp-presets/tree/master/libffi
It's slower though, and it's not as easy to use as the wrappers in JNA...

@DemonJun
Copy link

We can set that amount with the @Allocator(max=... annotation value: http://bytedeco.org/javacpp/apidocs/org/bytedeco/javacpp/annotation/Allocator.html#max--

where is @Allocator should i use?

@saudet
Copy link
Member

saudet commented Aug 18, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants