Skip to content

Commit

Permalink
Update _ffi_client.py
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom committed Dec 9, 2023
1 parent 87f73a8 commit a16eb38
Showing 1 changed file with 5 additions and 7 deletions.
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

0 comments on commit a16eb38

Please sign in to comment.