mirror of
https://github.com/facefusion/facefusion.git
synced 2026-05-12 18:32:18 +02:00
4.2 KiB
4.2 KiB
RTC TODO
Approach
- vibe code mass testing to get broad coverage fast
- vibe code refactoring (naming, dead code, restructure)
- hand craft production code (libdatachannel, peer management, SDP)
- hand craft testing — thin it out to essentials only
Unit Tests
| Function | Rating | Assertions |
|---|---|---|
create_peer_connection |
essential | returns valid peer connection id |
add_audio_track |
essential | returns valid track id |
add_video_track |
essential | returns valid track id |
negotiate_sdp |
essential | returns sdp answer from valid offer, returns None on timeout |
delete_peers |
essential | clears peer list |
create_rtc_stream |
essential | initializes empty peer list |
destroy_rtc_stream |
essential | cleans up peers, handles missing session |
add_rtc_viewer |
nice to have | returns None for unknown session |
resolve_binary_file |
skip | covered implicitly by create_static_rtc_library |
handle_whep_offer |
skip | thin wrapper, covered by integration tests |
send_to_peers |
skip | needs open tracks, covered by integration tests |
send_rtc_frame |
skip | thin delegation to send_to_peers |
Integration Tests
- test full SDP offer/answer roundtrip between two peer connections
- test
send_to_peersdelivers frame data to a connected peer - test peer cleanup after
delete_peersprevents further sends - test
add_rtc_viewerfollowed bysend_rtc_frameend-to-end - test multiple viewers receive frames from same stream
- test viewer disconnect does not break remaining peers
Dead Code
- remove
is_peer_connectedfromrtc.py, never called - remove
pre_checkfromrtc.py, never called - remove
get_rtc_streamfromrtc_store.py, never called - remove
RtcOfferSetfromtypes.py, never used
Naming
- rename
rtc_bindings.pytolibdatachannel.py— owns C library loading, struct definitions, ctypes registration - rename
RTC_CONFIGURATIONto a proper class definition - rename
RTC_PACKETIZER_INITto a proper class definition - rename
init_ctypesto something more specific likeregister_argtypes
Unused Library Config
create_peer_connectionexposes 14 params but production only usesdisable_auto_negotiation,enable_ice_udp_mux,force_media_transport— reduce to what is neededRTC_PACKETIZER_INITdefinesnalSeparator,obuPacketization,playoutDelayId,playoutDelayMin,playoutDelayMax,sequenceNumber,timestamp— none are set outside the struct definition, they are H264/AV1 specific and unused for VP8/OpusrtcSetLocalDescriptionis used in tests but not registered inrtc_bindings.py
Refactor
- extract shared media description builder from
rtc.pyandtests/stream_helper.py(see TODO intests/stream_helper.py) - replace
type()calls for ctypes structs inrtc_bindings.pywith proper class definitions - move
resolve_binary_file,create_static_download_set,create_static_rtc_libraryfromrtc.pyintolibdatachannel.py— library init belongs with the bindings,rtc.pyjust consumes it - move
rtc_store.pystate into a proper store pattern consistent with other*_store.pyfiles - replace
time.sleeppolling loops innegotiate_sdpandcreate_sdp_offer(test helper) withrtcSetGatheringStateChangeCallback— signal athreading.Eventon ICE gathering complete, thenevent.wait(timeout=5)instead of spinning create_static_download_sethas hardcoded linux URLs with a TODO to use dynamicbinary_name
Violations
rtc.py:25— comment oncreate_static_download_set(no comments)rtc.py:34— comment on hash url (no comments)rtc.py:42— comment on source url (no comments)rtc.py:205—send_to_peersreturns None explicitly on a void function (redundant)rtc_bindings.py:3,23—type()to create structs is a class workaround (no classes, but these should be plain structs)tests/stream_helper.py:45—sdptemp variable before return (no need for temporary variable in simple cases)
Security
rtc.py:157—negotiate_sdppasses unsanitizedsdp_offerstring directly to C library, no SDP format validation before hitting native code