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

fix: ffi initialization #120

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions livekit-rtc/livekit/rtc/_ffi_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ def get_ffi_lib_path():


ffi_lib = ctypes.CDLL(get_ffi_lib_path())
ffi_cb_fnc = ctypes.CFUNCTYPE(None, ctypes.POINTER(ctypes.c_uint8), ctypes.c_size_t)

# C function types
ffi_lib.livekit_ffi_initialize.argtypes = [ffi_cb_fnc, ctypes.c_bool]

ffi_lib.livekit_ffi_request.argtypes = [
ctypes.POINTER(ctypes.c_ubyte),
ctypes.c_size_t,
Expand Down Expand Up @@ -116,7 +119,7 @@ def unsubscribe(self, queue: Queue[T]) -> None:
break


@ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.POINTER(ctypes.c_uint8), ctypes.c_size_t)
@ctypes.CFUNCTYPE(None, ctypes.POINTER(ctypes.c_uint8), ctypes.c_size_t)
def ffi_event_callback(
data_ptr: ctypes.POINTER(ctypes.c_uint8), # type: ignore
data_len: ctypes.c_size_t,
Expand Down Expand Up @@ -162,12 +165,7 @@ def __init__(self) -> None:
self._lock = threading.RLock()
self._queue = FfiQueue[proto_ffi.FfiEvent]()

# initialize request
req = proto_ffi.FfiRequest()
cb_callback = int(ctypes.cast(ffi_event_callback, ctypes.c_void_p).value) # type: ignore
req.initialize.event_callback_ptr = cb_callback
req.initialize.capture_logs = True # capture logs on Python
self.request(req)
ffi_lib.livekit_ffi_initialize(ffi_event_callback, True)

@property
def queue(self) -> FfiQueue[proto_ffi.FfiEvent]:
Expand Down
Loading