From a06adc7d853fb6131c1c900a8098b6f235d80751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Monnom?= Date: Wed, 14 Feb 2024 20:12:21 +0100 Subject: [PATCH 1/3] kill process on panic (#164) --- livekit-rtc/livekit/rtc/_ffi_client.py | 6 +++++ livekit-rtc/livekit/rtc/_proto/ffi_pb2.py | 30 ++++++++++++---------- livekit-rtc/livekit/rtc/_proto/ffi_pb2.pyi | 25 +++++++++++++++--- livekit-rtc/rust-sdks | 2 +- 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/livekit-rtc/livekit/rtc/_ffi_client.py b/livekit-rtc/livekit/rtc/_ffi_client.py index a1711d11..f9788b2b 100644 --- a/livekit-rtc/livekit/rtc/_ffi_client.py +++ b/livekit-rtc/livekit/rtc/_ffi_client.py @@ -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 @@ -145,6 +146,11 @@ def ffi_event_callback( ) 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) diff --git a/livekit-rtc/livekit/rtc/_proto/ffi_pb2.py b/livekit-rtc/livekit/rtc/_proto/ffi_pb2.py index 7e96cb78..d7fa774f 100644 --- a/livekit-rtc/livekit/rtc/_proto/ffi_pb2.py +++ b/livekit-rtc/livekit/rtc/_proto/ffi_pb2.py @@ -19,7 +19,7 @@ from . import audio_frame_pb2 as audio__frame__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\tffi.proto\x12\rlivekit.proto\x1a\ne2ee.proto\x1a\x0btrack.proto\x1a\nroom.proto\x1a\x11video_frame.proto\x1a\x11\x61udio_frame.proto\"\xcf\x0b\n\nFfiRequest\x12\x30\n\x07\x64ispose\x18\x02 \x01(\x0b\x32\x1d.livekit.proto.DisposeRequestH\x00\x12\x30\n\x07\x63onnect\x18\x03 \x01(\x0b\x32\x1d.livekit.proto.ConnectRequestH\x00\x12\x36\n\ndisconnect\x18\x04 \x01(\x0b\x32 .livekit.proto.DisconnectRequestH\x00\x12;\n\rpublish_track\x18\x05 \x01(\x0b\x32\".livekit.proto.PublishTrackRequestH\x00\x12?\n\x0funpublish_track\x18\x06 \x01(\x0b\x32$.livekit.proto.UnpublishTrackRequestH\x00\x12\x39\n\x0cpublish_data\x18\x07 \x01(\x0b\x32!.livekit.proto.PublishDataRequestH\x00\x12=\n\x0eset_subscribed\x18\x08 \x01(\x0b\x32#.livekit.proto.SetSubscribedRequestH\x00\x12J\n\x15update_local_metadata\x18\t \x01(\x0b\x32).livekit.proto.UpdateLocalMetadataRequestH\x00\x12\x42\n\x11update_local_name\x18\n \x01(\x0b\x32%.livekit.proto.UpdateLocalNameRequestH\x00\x12\x42\n\x11get_session_stats\x18\x0b \x01(\x0b\x32%.livekit.proto.GetSessionStatsRequestH\x00\x12\x44\n\x12\x63reate_video_track\x18\x0c \x01(\x0b\x32&.livekit.proto.CreateVideoTrackRequestH\x00\x12\x44\n\x12\x63reate_audio_track\x18\r \x01(\x0b\x32&.livekit.proto.CreateAudioTrackRequestH\x00\x12\x33\n\tget_stats\x18\x0e \x01(\x0b\x32\x1e.livekit.proto.GetStatsRequestH\x00\x12@\n\x10new_video_stream\x18\x10 \x01(\x0b\x32$.livekit.proto.NewVideoStreamRequestH\x00\x12@\n\x10new_video_source\x18\x11 \x01(\x0b\x32$.livekit.proto.NewVideoSourceRequestH\x00\x12\x46\n\x13\x63\x61pture_video_frame\x18\x12 \x01(\x0b\x32\'.livekit.proto.CaptureVideoFrameRequestH\x00\x12;\n\rvideo_convert\x18\x13 \x01(\x0b\x32\".livekit.proto.VideoConvertRequestH\x00\x12@\n\x10new_audio_stream\x18\x16 \x01(\x0b\x32$.livekit.proto.NewAudioStreamRequestH\x00\x12@\n\x10new_audio_source\x18\x17 \x01(\x0b\x32$.livekit.proto.NewAudioSourceRequestH\x00\x12\x46\n\x13\x63\x61pture_audio_frame\x18\x18 \x01(\x0b\x32\'.livekit.proto.CaptureAudioFrameRequestH\x00\x12\x46\n\x13new_audio_resampler\x18\x19 \x01(\x0b\x32\'.livekit.proto.NewAudioResamplerRequestH\x00\x12\x44\n\x12remix_and_resample\x18\x1a \x01(\x0b\x32&.livekit.proto.RemixAndResampleRequestH\x00\x12*\n\x04\x65\x32\x65\x65\x18\x1b \x01(\x0b\x32\x1a.livekit.proto.E2eeRequestH\x00\x42\t\n\x07message\"\xe7\x0b\n\x0b\x46\x66iResponse\x12\x31\n\x07\x64ispose\x18\x02 \x01(\x0b\x32\x1e.livekit.proto.DisposeResponseH\x00\x12\x31\n\x07\x63onnect\x18\x03 \x01(\x0b\x32\x1e.livekit.proto.ConnectResponseH\x00\x12\x37\n\ndisconnect\x18\x04 \x01(\x0b\x32!.livekit.proto.DisconnectResponseH\x00\x12<\n\rpublish_track\x18\x05 \x01(\x0b\x32#.livekit.proto.PublishTrackResponseH\x00\x12@\n\x0funpublish_track\x18\x06 \x01(\x0b\x32%.livekit.proto.UnpublishTrackResponseH\x00\x12:\n\x0cpublish_data\x18\x07 \x01(\x0b\x32\".livekit.proto.PublishDataResponseH\x00\x12>\n\x0eset_subscribed\x18\x08 \x01(\x0b\x32$.livekit.proto.SetSubscribedResponseH\x00\x12K\n\x15update_local_metadata\x18\t \x01(\x0b\x32*.livekit.proto.UpdateLocalMetadataResponseH\x00\x12\x43\n\x11update_local_name\x18\n \x01(\x0b\x32&.livekit.proto.UpdateLocalNameResponseH\x00\x12\x43\n\x11get_session_stats\x18\x0b \x01(\x0b\x32&.livekit.proto.GetSessionStatsResponseH\x00\x12\x45\n\x12\x63reate_video_track\x18\x0c \x01(\x0b\x32\'.livekit.proto.CreateVideoTrackResponseH\x00\x12\x45\n\x12\x63reate_audio_track\x18\r \x01(\x0b\x32\'.livekit.proto.CreateAudioTrackResponseH\x00\x12\x34\n\tget_stats\x18\x0e \x01(\x0b\x32\x1f.livekit.proto.GetStatsResponseH\x00\x12\x41\n\x10new_video_stream\x18\x10 \x01(\x0b\x32%.livekit.proto.NewVideoStreamResponseH\x00\x12\x41\n\x10new_video_source\x18\x11 \x01(\x0b\x32%.livekit.proto.NewVideoSourceResponseH\x00\x12G\n\x13\x63\x61pture_video_frame\x18\x12 \x01(\x0b\x32(.livekit.proto.CaptureVideoFrameResponseH\x00\x12<\n\rvideo_convert\x18\x13 \x01(\x0b\x32#.livekit.proto.VideoConvertResponseH\x00\x12\x41\n\x10new_audio_stream\x18\x16 \x01(\x0b\x32%.livekit.proto.NewAudioStreamResponseH\x00\x12\x41\n\x10new_audio_source\x18\x17 \x01(\x0b\x32%.livekit.proto.NewAudioSourceResponseH\x00\x12G\n\x13\x63\x61pture_audio_frame\x18\x18 \x01(\x0b\x32(.livekit.proto.CaptureAudioFrameResponseH\x00\x12G\n\x13new_audio_resampler\x18\x19 \x01(\x0b\x32(.livekit.proto.NewAudioResamplerResponseH\x00\x12\x45\n\x12remix_and_resample\x18\x1a \x01(\x0b\x32\'.livekit.proto.RemixAndResampleResponseH\x00\x12+\n\x04\x65\x32\x65\x65\x18\x1b \x01(\x0b\x32\x1b.livekit.proto.E2eeResponseH\x00\x42\t\n\x07message\"\xcf\x07\n\x08\x46\x66iEvent\x12.\n\nroom_event\x18\x01 \x01(\x0b\x32\x18.livekit.proto.RoomEventH\x00\x12\x30\n\x0btrack_event\x18\x02 \x01(\x0b\x32\x19.livekit.proto.TrackEventH\x00\x12=\n\x12video_stream_event\x18\x03 \x01(\x0b\x32\x1f.livekit.proto.VideoStreamEventH\x00\x12=\n\x12\x61udio_stream_event\x18\x04 \x01(\x0b\x32\x1f.livekit.proto.AudioStreamEventH\x00\x12\x31\n\x07\x63onnect\x18\x05 \x01(\x0b\x32\x1e.livekit.proto.ConnectCallbackH\x00\x12\x37\n\ndisconnect\x18\x06 \x01(\x0b\x32!.livekit.proto.DisconnectCallbackH\x00\x12\x31\n\x07\x64ispose\x18\x07 \x01(\x0b\x32\x1e.livekit.proto.DisposeCallbackH\x00\x12<\n\rpublish_track\x18\x08 \x01(\x0b\x32#.livekit.proto.PublishTrackCallbackH\x00\x12@\n\x0funpublish_track\x18\t \x01(\x0b\x32%.livekit.proto.UnpublishTrackCallbackH\x00\x12:\n\x0cpublish_data\x18\n \x01(\x0b\x32\".livekit.proto.PublishDataCallbackH\x00\x12G\n\x13\x63\x61pture_audio_frame\x18\x0b \x01(\x0b\x32(.livekit.proto.CaptureAudioFrameCallbackH\x00\x12K\n\x15update_local_metadata\x18\x0c \x01(\x0b\x32*.livekit.proto.UpdateLocalMetadataCallbackH\x00\x12\x43\n\x11update_local_name\x18\r \x01(\x0b\x32&.livekit.proto.UpdateLocalNameCallbackH\x00\x12\x34\n\tget_stats\x18\x0e \x01(\x0b\x32\x1f.livekit.proto.GetStatsCallbackH\x00\x12\'\n\x04logs\x18\x0f \x01(\x0b\x32\x17.livekit.proto.LogBatchH\x00\x12\x43\n\x11get_session_stats\x18\x10 \x01(\x0b\x32&.livekit.proto.GetSessionStatsCallbackH\x00\x42\t\n\x07message\"\x1f\n\x0e\x44isposeRequest\x12\r\n\x05\x61sync\x18\x01 \x01(\x08\"5\n\x0f\x44isposeResponse\x12\x15\n\x08\x61sync_id\x18\x01 \x01(\x04H\x00\x88\x01\x01\x42\x0b\n\t_async_id\"#\n\x0f\x44isposeCallback\x12\x10\n\x08\x61sync_id\x18\x01 \x01(\x04\"\xb6\x01\n\tLogRecord\x12&\n\x05level\x18\x01 \x01(\x0e\x32\x17.livekit.proto.LogLevel\x12\x0e\n\x06target\x18\x02 \x01(\t\x12\x18\n\x0bmodule_path\x18\x03 \x01(\tH\x00\x88\x01\x01\x12\x11\n\x04\x66ile\x18\x04 \x01(\tH\x01\x88\x01\x01\x12\x11\n\x04line\x18\x05 \x01(\rH\x02\x88\x01\x01\x12\x0f\n\x07message\x18\x06 \x01(\tB\x0e\n\x0c_module_pathB\x07\n\x05_fileB\x07\n\x05_line\"5\n\x08LogBatch\x12)\n\x07records\x18\x01 \x03(\x0b\x32\x18.livekit.proto.LogRecord*S\n\x08LogLevel\x12\r\n\tLOG_ERROR\x10\x00\x12\x0c\n\x08LOG_WARN\x10\x01\x12\x0c\n\x08LOG_INFO\x10\x02\x12\r\n\tLOG_DEBUG\x10\x03\x12\r\n\tLOG_TRACE\x10\x04\x42\x10\xaa\x02\rLiveKit.Protob\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\tffi.proto\x12\rlivekit.proto\x1a\ne2ee.proto\x1a\x0btrack.proto\x1a\nroom.proto\x1a\x11video_frame.proto\x1a\x11\x61udio_frame.proto\"\xcf\x0b\n\nFfiRequest\x12\x30\n\x07\x64ispose\x18\x02 \x01(\x0b\x32\x1d.livekit.proto.DisposeRequestH\x00\x12\x30\n\x07\x63onnect\x18\x03 \x01(\x0b\x32\x1d.livekit.proto.ConnectRequestH\x00\x12\x36\n\ndisconnect\x18\x04 \x01(\x0b\x32 .livekit.proto.DisconnectRequestH\x00\x12;\n\rpublish_track\x18\x05 \x01(\x0b\x32\".livekit.proto.PublishTrackRequestH\x00\x12?\n\x0funpublish_track\x18\x06 \x01(\x0b\x32$.livekit.proto.UnpublishTrackRequestH\x00\x12\x39\n\x0cpublish_data\x18\x07 \x01(\x0b\x32!.livekit.proto.PublishDataRequestH\x00\x12=\n\x0eset_subscribed\x18\x08 \x01(\x0b\x32#.livekit.proto.SetSubscribedRequestH\x00\x12J\n\x15update_local_metadata\x18\t \x01(\x0b\x32).livekit.proto.UpdateLocalMetadataRequestH\x00\x12\x42\n\x11update_local_name\x18\n \x01(\x0b\x32%.livekit.proto.UpdateLocalNameRequestH\x00\x12\x42\n\x11get_session_stats\x18\x0b \x01(\x0b\x32%.livekit.proto.GetSessionStatsRequestH\x00\x12\x44\n\x12\x63reate_video_track\x18\x0c \x01(\x0b\x32&.livekit.proto.CreateVideoTrackRequestH\x00\x12\x44\n\x12\x63reate_audio_track\x18\r \x01(\x0b\x32&.livekit.proto.CreateAudioTrackRequestH\x00\x12\x33\n\tget_stats\x18\x0e \x01(\x0b\x32\x1e.livekit.proto.GetStatsRequestH\x00\x12@\n\x10new_video_stream\x18\x10 \x01(\x0b\x32$.livekit.proto.NewVideoStreamRequestH\x00\x12@\n\x10new_video_source\x18\x11 \x01(\x0b\x32$.livekit.proto.NewVideoSourceRequestH\x00\x12\x46\n\x13\x63\x61pture_video_frame\x18\x12 \x01(\x0b\x32\'.livekit.proto.CaptureVideoFrameRequestH\x00\x12;\n\rvideo_convert\x18\x13 \x01(\x0b\x32\".livekit.proto.VideoConvertRequestH\x00\x12@\n\x10new_audio_stream\x18\x16 \x01(\x0b\x32$.livekit.proto.NewAudioStreamRequestH\x00\x12@\n\x10new_audio_source\x18\x17 \x01(\x0b\x32$.livekit.proto.NewAudioSourceRequestH\x00\x12\x46\n\x13\x63\x61pture_audio_frame\x18\x18 \x01(\x0b\x32\'.livekit.proto.CaptureAudioFrameRequestH\x00\x12\x46\n\x13new_audio_resampler\x18\x19 \x01(\x0b\x32\'.livekit.proto.NewAudioResamplerRequestH\x00\x12\x44\n\x12remix_and_resample\x18\x1a \x01(\x0b\x32&.livekit.proto.RemixAndResampleRequestH\x00\x12*\n\x04\x65\x32\x65\x65\x18\x1b \x01(\x0b\x32\x1a.livekit.proto.E2eeRequestH\x00\x42\t\n\x07message\"\xe7\x0b\n\x0b\x46\x66iResponse\x12\x31\n\x07\x64ispose\x18\x02 \x01(\x0b\x32\x1e.livekit.proto.DisposeResponseH\x00\x12\x31\n\x07\x63onnect\x18\x03 \x01(\x0b\x32\x1e.livekit.proto.ConnectResponseH\x00\x12\x37\n\ndisconnect\x18\x04 \x01(\x0b\x32!.livekit.proto.DisconnectResponseH\x00\x12<\n\rpublish_track\x18\x05 \x01(\x0b\x32#.livekit.proto.PublishTrackResponseH\x00\x12@\n\x0funpublish_track\x18\x06 \x01(\x0b\x32%.livekit.proto.UnpublishTrackResponseH\x00\x12:\n\x0cpublish_data\x18\x07 \x01(\x0b\x32\".livekit.proto.PublishDataResponseH\x00\x12>\n\x0eset_subscribed\x18\x08 \x01(\x0b\x32$.livekit.proto.SetSubscribedResponseH\x00\x12K\n\x15update_local_metadata\x18\t \x01(\x0b\x32*.livekit.proto.UpdateLocalMetadataResponseH\x00\x12\x43\n\x11update_local_name\x18\n \x01(\x0b\x32&.livekit.proto.UpdateLocalNameResponseH\x00\x12\x43\n\x11get_session_stats\x18\x0b \x01(\x0b\x32&.livekit.proto.GetSessionStatsResponseH\x00\x12\x45\n\x12\x63reate_video_track\x18\x0c \x01(\x0b\x32\'.livekit.proto.CreateVideoTrackResponseH\x00\x12\x45\n\x12\x63reate_audio_track\x18\r \x01(\x0b\x32\'.livekit.proto.CreateAudioTrackResponseH\x00\x12\x34\n\tget_stats\x18\x0e \x01(\x0b\x32\x1f.livekit.proto.GetStatsResponseH\x00\x12\x41\n\x10new_video_stream\x18\x10 \x01(\x0b\x32%.livekit.proto.NewVideoStreamResponseH\x00\x12\x41\n\x10new_video_source\x18\x11 \x01(\x0b\x32%.livekit.proto.NewVideoSourceResponseH\x00\x12G\n\x13\x63\x61pture_video_frame\x18\x12 \x01(\x0b\x32(.livekit.proto.CaptureVideoFrameResponseH\x00\x12<\n\rvideo_convert\x18\x13 \x01(\x0b\x32#.livekit.proto.VideoConvertResponseH\x00\x12\x41\n\x10new_audio_stream\x18\x16 \x01(\x0b\x32%.livekit.proto.NewAudioStreamResponseH\x00\x12\x41\n\x10new_audio_source\x18\x17 \x01(\x0b\x32%.livekit.proto.NewAudioSourceResponseH\x00\x12G\n\x13\x63\x61pture_audio_frame\x18\x18 \x01(\x0b\x32(.livekit.proto.CaptureAudioFrameResponseH\x00\x12G\n\x13new_audio_resampler\x18\x19 \x01(\x0b\x32(.livekit.proto.NewAudioResamplerResponseH\x00\x12\x45\n\x12remix_and_resample\x18\x1a \x01(\x0b\x32\'.livekit.proto.RemixAndResampleResponseH\x00\x12+\n\x04\x65\x32\x65\x65\x18\x1b \x01(\x0b\x32\x1b.livekit.proto.E2eeResponseH\x00\x42\t\n\x07message\"\xf6\x07\n\x08\x46\x66iEvent\x12.\n\nroom_event\x18\x01 \x01(\x0b\x32\x18.livekit.proto.RoomEventH\x00\x12\x30\n\x0btrack_event\x18\x02 \x01(\x0b\x32\x19.livekit.proto.TrackEventH\x00\x12=\n\x12video_stream_event\x18\x03 \x01(\x0b\x32\x1f.livekit.proto.VideoStreamEventH\x00\x12=\n\x12\x61udio_stream_event\x18\x04 \x01(\x0b\x32\x1f.livekit.proto.AudioStreamEventH\x00\x12\x31\n\x07\x63onnect\x18\x05 \x01(\x0b\x32\x1e.livekit.proto.ConnectCallbackH\x00\x12\x37\n\ndisconnect\x18\x06 \x01(\x0b\x32!.livekit.proto.DisconnectCallbackH\x00\x12\x31\n\x07\x64ispose\x18\x07 \x01(\x0b\x32\x1e.livekit.proto.DisposeCallbackH\x00\x12<\n\rpublish_track\x18\x08 \x01(\x0b\x32#.livekit.proto.PublishTrackCallbackH\x00\x12@\n\x0funpublish_track\x18\t \x01(\x0b\x32%.livekit.proto.UnpublishTrackCallbackH\x00\x12:\n\x0cpublish_data\x18\n \x01(\x0b\x32\".livekit.proto.PublishDataCallbackH\x00\x12G\n\x13\x63\x61pture_audio_frame\x18\x0b \x01(\x0b\x32(.livekit.proto.CaptureAudioFrameCallbackH\x00\x12K\n\x15update_local_metadata\x18\x0c \x01(\x0b\x32*.livekit.proto.UpdateLocalMetadataCallbackH\x00\x12\x43\n\x11update_local_name\x18\r \x01(\x0b\x32&.livekit.proto.UpdateLocalNameCallbackH\x00\x12\x34\n\tget_stats\x18\x0e \x01(\x0b\x32\x1f.livekit.proto.GetStatsCallbackH\x00\x12\'\n\x04logs\x18\x0f \x01(\x0b\x32\x17.livekit.proto.LogBatchH\x00\x12\x43\n\x11get_session_stats\x18\x10 \x01(\x0b\x32&.livekit.proto.GetSessionStatsCallbackH\x00\x12%\n\x05panic\x18\x11 \x01(\x0b\x32\x14.livekit.proto.PanicH\x00\x42\t\n\x07message\"\x1f\n\x0e\x44isposeRequest\x12\r\n\x05\x61sync\x18\x01 \x01(\x08\"5\n\x0f\x44isposeResponse\x12\x15\n\x08\x61sync_id\x18\x01 \x01(\x04H\x00\x88\x01\x01\x42\x0b\n\t_async_id\"#\n\x0f\x44isposeCallback\x12\x10\n\x08\x61sync_id\x18\x01 \x01(\x04\"\xb6\x01\n\tLogRecord\x12&\n\x05level\x18\x01 \x01(\x0e\x32\x17.livekit.proto.LogLevel\x12\x0e\n\x06target\x18\x02 \x01(\t\x12\x18\n\x0bmodule_path\x18\x03 \x01(\tH\x00\x88\x01\x01\x12\x11\n\x04\x66ile\x18\x04 \x01(\tH\x01\x88\x01\x01\x12\x11\n\x04line\x18\x05 \x01(\rH\x02\x88\x01\x01\x12\x0f\n\x07message\x18\x06 \x01(\tB\x0e\n\x0c_module_pathB\x07\n\x05_fileB\x07\n\x05_line\"5\n\x08LogBatch\x12)\n\x07records\x18\x01 \x03(\x0b\x32\x18.livekit.proto.LogRecord\"\x18\n\x05Panic\x12\x0f\n\x07message\x18\x01 \x01(\t*S\n\x08LogLevel\x12\r\n\tLOG_ERROR\x10\x00\x12\x0c\n\x08LOG_WARN\x10\x01\x12\x0c\n\x08LOG_INFO\x10\x02\x12\r\n\tLOG_DEBUG\x10\x03\x12\r\n\tLOG_TRACE\x10\x04\x42\x10\xaa\x02\rLiveKit.Protob\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -27,22 +27,24 @@ if _descriptor._USE_C_DESCRIPTORS == False: _globals['DESCRIPTOR']._options = None _globals['DESCRIPTOR']._serialized_options = b'\252\002\rLiveKit.Proto' - _globals['_LOGLEVEL']._serialized_start=4450 - _globals['_LOGLEVEL']._serialized_end=4533 + _globals['_LOGLEVEL']._serialized_start=4515 + _globals['_LOGLEVEL']._serialized_end=4598 _globals['_FFIREQUEST']._serialized_start=104 _globals['_FFIREQUEST']._serialized_end=1591 _globals['_FFIRESPONSE']._serialized_start=1594 _globals['_FFIRESPONSE']._serialized_end=3105 _globals['_FFIEVENT']._serialized_start=3108 - _globals['_FFIEVENT']._serialized_end=4083 - _globals['_DISPOSEREQUEST']._serialized_start=4085 - _globals['_DISPOSEREQUEST']._serialized_end=4116 - _globals['_DISPOSERESPONSE']._serialized_start=4118 - _globals['_DISPOSERESPONSE']._serialized_end=4171 - _globals['_DISPOSECALLBACK']._serialized_start=4173 - _globals['_DISPOSECALLBACK']._serialized_end=4208 - _globals['_LOGRECORD']._serialized_start=4211 - _globals['_LOGRECORD']._serialized_end=4393 - _globals['_LOGBATCH']._serialized_start=4395 - _globals['_LOGBATCH']._serialized_end=4448 + _globals['_FFIEVENT']._serialized_end=4122 + _globals['_DISPOSEREQUEST']._serialized_start=4124 + _globals['_DISPOSEREQUEST']._serialized_end=4155 + _globals['_DISPOSERESPONSE']._serialized_start=4157 + _globals['_DISPOSERESPONSE']._serialized_end=4210 + _globals['_DISPOSECALLBACK']._serialized_start=4212 + _globals['_DISPOSECALLBACK']._serialized_end=4247 + _globals['_LOGRECORD']._serialized_start=4250 + _globals['_LOGRECORD']._serialized_end=4432 + _globals['_LOGBATCH']._serialized_start=4434 + _globals['_LOGBATCH']._serialized_end=4487 + _globals['_PANIC']._serialized_start=4489 + _globals['_PANIC']._serialized_end=4513 # @@protoc_insertion_point(module_scope) diff --git a/livekit-rtc/livekit/rtc/_proto/ffi_pb2.pyi b/livekit-rtc/livekit/rtc/_proto/ffi_pb2.pyi index a06fdd2b..4936bc71 100644 --- a/livekit-rtc/livekit/rtc/_proto/ffi_pb2.pyi +++ b/livekit-rtc/livekit/rtc/_proto/ffi_pb2.pyi @@ -334,6 +334,7 @@ class FfiEvent(google.protobuf.message.Message): GET_STATS_FIELD_NUMBER: builtins.int LOGS_FIELD_NUMBER: builtins.int GET_SESSION_STATS_FIELD_NUMBER: builtins.int + PANIC_FIELD_NUMBER: builtins.int @property def room_event(self) -> room_pb2.RoomEvent: ... @property @@ -366,6 +367,8 @@ class FfiEvent(google.protobuf.message.Message): def logs(self) -> global___LogBatch: ... @property def get_session_stats(self) -> room_pb2.GetSessionStatsCallback: ... + @property + def panic(self) -> global___Panic: ... def __init__( self, *, @@ -385,10 +388,11 @@ class FfiEvent(google.protobuf.message.Message): get_stats: track_pb2.GetStatsCallback | None = ..., logs: global___LogBatch | None = ..., get_session_stats: room_pb2.GetSessionStatsCallback | None = ..., + panic: global___Panic | None = ..., ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["audio_stream_event", b"audio_stream_event", "capture_audio_frame", b"capture_audio_frame", "connect", b"connect", "disconnect", b"disconnect", "dispose", b"dispose", "get_session_stats", b"get_session_stats", "get_stats", b"get_stats", "logs", b"logs", "message", b"message", "publish_data", b"publish_data", "publish_track", b"publish_track", "room_event", b"room_event", "track_event", b"track_event", "unpublish_track", b"unpublish_track", "update_local_metadata", b"update_local_metadata", "update_local_name", b"update_local_name", "video_stream_event", b"video_stream_event"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["audio_stream_event", b"audio_stream_event", "capture_audio_frame", b"capture_audio_frame", "connect", b"connect", "disconnect", b"disconnect", "dispose", b"dispose", "get_session_stats", b"get_session_stats", "get_stats", b"get_stats", "logs", b"logs", "message", b"message", "publish_data", b"publish_data", "publish_track", b"publish_track", "room_event", b"room_event", "track_event", b"track_event", "unpublish_track", b"unpublish_track", "update_local_metadata", b"update_local_metadata", "update_local_name", b"update_local_name", "video_stream_event", b"video_stream_event"]) -> None: ... - def WhichOneof(self, oneof_group: typing_extensions.Literal["message", b"message"]) -> typing_extensions.Literal["room_event", "track_event", "video_stream_event", "audio_stream_event", "connect", "disconnect", "dispose", "publish_track", "unpublish_track", "publish_data", "capture_audio_frame", "update_local_metadata", "update_local_name", "get_stats", "logs", "get_session_stats"] | None: ... + def HasField(self, field_name: typing_extensions.Literal["audio_stream_event", b"audio_stream_event", "capture_audio_frame", b"capture_audio_frame", "connect", b"connect", "disconnect", b"disconnect", "dispose", b"dispose", "get_session_stats", b"get_session_stats", "get_stats", b"get_stats", "logs", b"logs", "message", b"message", "panic", b"panic", "publish_data", b"publish_data", "publish_track", b"publish_track", "room_event", b"room_event", "track_event", b"track_event", "unpublish_track", b"unpublish_track", "update_local_metadata", b"update_local_metadata", "update_local_name", b"update_local_name", "video_stream_event", b"video_stream_event"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["audio_stream_event", b"audio_stream_event", "capture_audio_frame", b"capture_audio_frame", "connect", b"connect", "disconnect", b"disconnect", "dispose", b"dispose", "get_session_stats", b"get_session_stats", "get_stats", b"get_stats", "logs", b"logs", "message", b"message", "panic", b"panic", "publish_data", b"publish_data", "publish_track", b"publish_track", "room_event", b"room_event", "track_event", b"track_event", "unpublish_track", b"unpublish_track", "update_local_metadata", b"update_local_metadata", "update_local_name", b"update_local_name", "video_stream_event", b"video_stream_event"]) -> None: ... + def WhichOneof(self, oneof_group: typing_extensions.Literal["message", b"message"]) -> typing_extensions.Literal["room_event", "track_event", "video_stream_event", "audio_stream_event", "connect", "disconnect", "dispose", "publish_track", "unpublish_track", "publish_data", "capture_audio_frame", "update_local_metadata", "update_local_name", "get_stats", "logs", "get_session_stats", "panic"] | None: ... global___FfiEvent = FfiEvent @@ -495,3 +499,18 @@ class LogBatch(google.protobuf.message.Message): def ClearField(self, field_name: typing_extensions.Literal["records", b"records"]) -> None: ... global___LogBatch = LogBatch + +@typing_extensions.final +class Panic(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + MESSAGE_FIELD_NUMBER: builtins.int + message: builtins.str + def __init__( + self, + *, + message: builtins.str = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["message", b"message"]) -> None: ... + +global___Panic = Panic diff --git a/livekit-rtc/rust-sdks b/livekit-rtc/rust-sdks index 4450c6ca..040d7df2 160000 --- a/livekit-rtc/rust-sdks +++ b/livekit-rtc/rust-sdks @@ -1 +1 @@ -Subproject commit 4450c6ca5cf269873db5debf5fc06115490a44ea +Subproject commit 040d7df24fc589bc2313e086eb9673f50ad12e3c From c6c19a5407bd01fb91b8fc85a33548f6fc0592b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Monnom?= Date: Wed, 14 Feb 2024 20:14:11 +0100 Subject: [PATCH 2/3] remove noisy debug logs (#165) --- examples/face_landmark/face_landmark.py | 1 + livekit-rtc/livekit/rtc/_ffi_client.py | 35 +++++++++++++++++-------- livekit-rtc/rust-sdks | 2 +- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/examples/face_landmark/face_landmark.py b/examples/face_landmark/face_landmark.py index b61d8169..edc20f36 100644 --- a/examples/face_landmark/face_landmark.py +++ b/examples/face_landmark/face_landmark.py @@ -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: diff --git a/livekit-rtc/livekit/rtc/_ffi_client.py b/livekit-rtc/livekit/rtc/_ffi_client.py index f9788b2b..ad3cd6b8 100644 --- a/livekit-rtc/livekit/rtc/_ffi_client.py +++ b/livekit-rtc/livekit/rtc/_ffi_client.py @@ -136,14 +136,24 @@ 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": @@ -155,7 +165,7 @@ def ffi_event_callback( 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: @@ -165,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: diff --git a/livekit-rtc/rust-sdks b/livekit-rtc/rust-sdks index 040d7df2..799e95da 160000 --- a/livekit-rtc/rust-sdks +++ b/livekit-rtc/rust-sdks @@ -1 +1 @@ -Subproject commit 040d7df24fc589bc2313e086eb9673f50ad12e3c +Subproject commit 799e95da8cc30456465ed145403d273018721c28 From 818aa98fe7e8c26f37c4cde4d3af01aa249c2f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Monnom?= Date: Wed, 14 Feb 2024 20:32:17 +0100 Subject: [PATCH 3/3] rtc v0.9.0 (#167) --- livekit-rtc/livekit/rtc/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/livekit-rtc/livekit/rtc/version.py b/livekit-rtc/livekit/rtc/version.py index 3ba5d4d8..3e2f46a3 100644 --- a/livekit-rtc/livekit/rtc/version.py +++ b/livekit-rtc/livekit/rtc/version.py @@ -1 +1 @@ -__version__ = "0.9.0.dev1" +__version__ = "0.9.0"