Migrate to WHIP (#1120)

* migrate to whip part1

* migrate to whip part2

* migrate to whip part3

* migrate to whip part4

* migrate to whip/whep with bidirectional

* migrate to whip/whep with bidirectional

* use next library

* add _next to lid datachannel files

* cleanup and add todos

* use internal helper rtcGetPayloadTypesForCodec

* fix lint

* refactor decode()

* move logic to codecs

* move logic to codecs

* break encoders and decoders into multiple files

* break encoders and decoders into multiple files

* cleanup more

* drop action for stream endpoints, keep type for self documentation

* restore the v4 store

* fix: align frame_width and frame_height to even in both collect() and read_resolution() in both decoders.

---------

Co-authored-by: harisreedhar <h4harisreedhar.s.s@gmail.com>
This commit is contained in:
Henry Ruhs
2026-05-18 16:16:06 +02:00
committed by GitHub
co-authored by harisreedhar
parent c48c238f88
commit c00ea92f35
25 changed files with 969 additions and 633 deletions
+82
View File
@@ -0,0 +1,82 @@
import ctypes
from typing import Optional
from facefusion.libraries import aom as aom_module
from facefusion.types import AomDecoder, Resolution
def create() -> Optional[AomDecoder]:
aom_library = aom_module.create_static_library()
if aom_library:
aom_decoder = ctypes.create_string_buffer(128)
aom_codec = ctypes.c_void_p.in_dll(aom_library, 'aom_codec_av1_dx_algo')
if aom_library.aom_codec_dec_init_ver(aom_decoder, ctypes.byref(aom_codec), None, 0, 22) == 0:
return aom_decoder
return None
#TODO: needs review
def decode(aom_decoder : AomDecoder, input_buffer : bytes) -> bytes:
aom_library = aom_module.create_static_library()
output_buffer = bytes()
if aom_library and input_buffer:
input_total = len(input_buffer)
temp_buffer = (ctypes.c_uint8 * input_total).from_buffer_copy(input_buffer)
if aom_library.aom_codec_decode(aom_decoder, temp_buffer, input_total, None) == 0:
frame_pointer = aom_library.aom_codec_get_frame(aom_decoder, ctypes.byref(ctypes.c_void_p(0)))
if frame_pointer:
output_buffer = collect(frame_pointer)
return output_buffer
#TODO: needs review
def collect(frame_pointer : int) -> bytes:
frame_width = ctypes.c_uint.from_address(frame_pointer + 28).value & ~1
frame_height = ctypes.c_uint.from_address(frame_pointer + 32).value & ~1
planes_offset = frame_pointer + 64
strides_offset = frame_pointer + 88
output_buffer = bytes()
for index in range(3):
plane_pointer = ctypes.c_void_p.from_address(planes_offset + index * 8).value
stride = ctypes.c_int.from_address(strides_offset + index * 4).value
plane_width = frame_width >> (index > 0)
plane_height = frame_height >> (index > 0)
for row in range(plane_height):
output_buffer += ctypes.string_at(plane_pointer + row * stride, plane_width)
return output_buffer
#TODO: needs review
def read_resolution(aom_decoder : AomDecoder, input_buffer : bytes) -> Optional[Resolution]:
aom_library = aom_module.create_static_library()
if aom_library and input_buffer:
input_total = len(input_buffer)
temp_buffer = (ctypes.c_uint8 * input_total).from_buffer_copy(input_buffer)
if aom_library.aom_codec_decode(aom_decoder, temp_buffer, input_total, None) == 0:
frame_pointer = aom_library.aom_codec_get_frame(aom_decoder, ctypes.byref(ctypes.c_void_p(0)))
if frame_pointer:
frame_width = ctypes.c_uint.from_address(frame_pointer + 28).value & ~1
frame_height = ctypes.c_uint.from_address(frame_pointer + 32).value & ~1
return frame_width, frame_height
return None
def destroy(aom_decoder : AomDecoder) -> None:
aom_library = aom_module.create_static_library()
if aom_library:
aom_library.aom_codec_destroy(aom_decoder)