Skip to content

Commit

Permalink
Merge branch 'main' into theo/remove-whisper-eg
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom committed Feb 14, 2024
2 parents b287af1 + 818aa98 commit 377964f
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 29 deletions.
1 change: 1 addition & 0 deletions examples/face_landmark/face_landmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def draw_landmarks_on_image(rgb_image, detection_result):


async def frame_loop(video_stream: rtc.VideoStream) -> None:
landmarker = FaceLandmarker.create_from_options(options)
cv2.namedWindow("livekit_video", cv2.WINDOW_AUTOSIZE)
cv2.startWindowThread()
async for frame_event in video_stream:
Expand Down
41 changes: 30 additions & 11 deletions livekit-rtc/livekit/rtc/_ffi_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import signal
import asyncio
from contextlib import ExitStack
import ctypes
Expand Down Expand Up @@ -135,21 +136,36 @@ def ffi_event_callback(
which = event.WhichOneof("message")
if which == "logs":
for record in event.logs.records:
logger.log(
to_python_level(record.level),
"%s:%s:%s - %s",
record.target,
record.line,
record.module_path,
record.message,
)
level = to_python_level(record.level)
rtc_debug = os.environ.get("LIVEKIT_WEBRTC_DEBUG", "").strip()
if (
record.target == "libwebrtc"
and level == logging.DEBUG
and rtc_debug.lower() not in ("true", "1")
):
continue

if level is not None:
logger.log(
level,
"%s:%s:%s - %s",
record.target,
record.line,
record.module_path,
record.message,
)

return # no need to queue the logs
elif which == "panic":
logger.critical("Panic: %s", event.panic.message)
# We are in a unrecoverable state, terminate the process
os.kill(os.getpid(), signal.SIGTERM)
return

FfiClient.instance.queue.put(event)


def to_python_level(level: proto_ffi.LogLevel.ValueType) -> int:
def to_python_level(level: proto_ffi.LogLevel.ValueType) -> Optional[int]:
if level == proto_ffi.LogLevel.LOG_ERROR:
return logging.ERROR
elif level == proto_ffi.LogLevel.LOG_WARN:
Expand All @@ -159,9 +175,12 @@ def to_python_level(level: proto_ffi.LogLevel.ValueType) -> int:
elif level == proto_ffi.LogLevel.LOG_DEBUG:
return logging.DEBUG
elif level == proto_ffi.LogLevel.LOG_TRACE:
return logging.DEBUG
# Don't show TRACE logs inside DEBUG, it is too verbos
# Python's logging doesn't have a TRACE level
# return logging.DEBUG
pass

raise Exception("unreachable")
return None


class FfiClient:
Expand Down
30 changes: 16 additions & 14 deletions livekit-rtc/livekit/rtc/_proto/ffi_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 377964f

Please sign in to comment.