From 7735c3740fc7bc7228a981d6fb578e6fd84d7db6 Mon Sep 17 00:00:00 2001 From: harisreedhar Date: Mon, 1 Jun 2026 15:19:28 +0530 Subject: [PATCH] bring back todos --- facefusion/apis/stream_helper.py | 4 +++- tests/test_api_stream_helper.py | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/facefusion/apis/stream_helper.py b/facefusion/apis/stream_helper.py index bc62669c..11c3b8ae 100644 --- a/facefusion/apis/stream_helper.py +++ b/facefusion/apis/stream_helper.py @@ -15,7 +15,7 @@ from facefusion import rtc, rtc_store, state_manager, streamer from facefusion.audio import create_empty_audio_frame from facefusion.codecs import aom_decoder, aom_encoder, opus_decoder, opus_encoder, vpx_decoder, vpx_encoder from facefusion.libraries import datachannel as datachannel_module -from facefusion.types import AomDecoder, AomEncoder, AudioCodec, AudioPack, BitRate, PeerConnection, Resolution, RtcPeer, RtcPeerAudio, SdpAnswer, SdpOffer, SessionId, VideoCodec, VisionFrame, VideoPack, VpxDecoder, VpxEncoder +from facefusion.types import AomDecoder, AomEncoder, AudioCodec, AudioPack, BitRate, PeerConnection, Resolution, RtcPeer, RtcPeerAudio, SdpAnswer, SdpOffer, SessionId, VideoCodec, VideoPack, VisionFrame, VpxDecoder, VpxEncoder #TODO: remove source_paths guard, process_image should work independent of source_paths since processors decide if they need sources @@ -231,12 +231,14 @@ def receive_video_frames(video_track : int, video_codec : VideoCodec, video_dequ available_event.wait() available_event.clear() + # TODO: extract numpy.empty(0) into an empty_vision_frame variable so the sentinel intent is clear video_deque.append((numpy.empty(0), 0.0)) video_event.set() destroy_video_decoder(video_codec, video_decoder) # TODO: audio_codec is not used but has to, even if there is just one +# TODO: audio_codec is passed but never checked — decoder should be selected based on codec the same way video does for av1 vs vp8 # TODO: method is too complex def receive_audio_frames(audio_track : int, audio_codec : AudioCodec, audio_deque : deque[AudioPack]) -> None: datachannel_library = datachannel_module.create_static_library() diff --git a/tests/test_api_stream_helper.py b/tests/test_api_stream_helper.py index 3ed5d4c6..fdde23e7 100644 --- a/tests/test_api_stream_helper.py +++ b/tests/test_api_stream_helper.py @@ -201,6 +201,7 @@ def test_run_encode_loop(video_codec : VideoCodec, payload_type : int) -> None: thread = threading.Thread(target = run_encode_loop, args = (rtc_peer, video_codec, video_deque, audio_deque, video_event), daemon = True) thread.start() time.sleep(0.1) + # TODO: extract numpy.empty(0) into an empty_vision_frame variable so the sentinel intent is clear video_deque.append((numpy.empty(0), 0.0)) video_event.set() thread.join(timeout = 5.0) @@ -248,6 +249,7 @@ def test_run_peer_loop_send_order(video_codec : VideoCodec, payload_type : int) thread = threading.Thread(target = run_encode_loop, args = (rtc_peer, video_codec, video_deque, audio_deque, video_event), daemon = True) thread.start() time.sleep(0.1) + # TODO: extract numpy.empty(0) into an empty_vision_frame variable so the sentinel intent is clear video_deque.append((numpy.empty(0), 0.0)) video_event.set() thread.join(timeout = 5.0) @@ -271,6 +273,7 @@ def test_receive_video_frames() -> None: receiver_thread.start() receiver_thread.join(timeout = 2.0) + # TODO: avoid [0][0] tuple indexing — use named access once VideoPack becomes a TypedDict if is_linux() or is_windows(): assert create_hash(video_deque[0][0].tobytes()) == 'a17439db' @@ -278,9 +281,11 @@ def test_receive_video_frames() -> None: assert create_hash(video_deque[0][0].tobytes()) == '38d00e2a' +# TODO: refine test def test_receive_audio_frames() -> None: datachannel_library_mock = MagicMock() datachannel_library_mock.rtcReceiveMessage.side_effect = [ 0, -1 ] + # TODO: rename audio_data — not a recognised naming convention audio_data = numpy.zeros(960 * 2, dtype = numpy.float32) audio_deque : deque[AudioPack] = deque() @@ -290,6 +295,7 @@ def test_receive_audio_frames() -> None: receiver_thread.start() receiver_thread.join(timeout = 2.0) + # TODO: assertions do not verify meaningful audio content — dtype/size/len would pass for an empty silent frame assert audio_deque[0][0].dtype == numpy.float32 assert audio_deque[0][0].size == 960 * 2 assert len(audio_deque) == 1