Skip to content

Commit 1c63f54

Browse files
committed
fmt.
1 parent 6ee7394 commit 1c63f54

2 files changed

Lines changed: 15 additions & 22 deletions

File tree

livekit-rtc/tests/test_audio.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ def _band_energies(
121121
freqs, magnitudes = _fft_spectrum(frame)
122122
power = magnitudes**2
123123
return {
124-
center: float(np.sum(power[(freqs >= center - bandwidth_hz) & (freqs <= center + bandwidth_hz)]))
124+
center: float(
125+
np.sum(power[(freqs >= center - bandwidth_hz) & (freqs <= center + bandwidth_hz)])
126+
)
125127
for center in centers
126128
}
127129

@@ -195,18 +197,12 @@ async def collect_samples() -> np.ndarray:
195197
buffers: list[np.ndarray] = []
196198
total = 0
197199
async for event in audio_stream:
198-
chunk = np.frombuffer(
199-
bytes(event.frame.data.cast("B")), dtype=np.int16
200-
)
200+
chunk = np.frombuffer(bytes(event.frame.data.cast("B")), dtype=np.int16)
201201
buffers.append(chunk)
202202
total += len(chunk)
203203
if total >= collect_samples_target:
204204
break
205-
return (
206-
np.concatenate(buffers)
207-
if buffers
208-
else np.array([], dtype=np.int16)
209-
)
205+
return np.concatenate(buffers) if buffers else np.array([], dtype=np.int16)
210206

211207
publish_task = asyncio.create_task(publish_tones())
212208
received = await asyncio.wait_for(collect_samples(), timeout=20.0)

livekit-rtc/tests/test_video.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ def create_token(identity: str, room_name: str) -> str:
6767
def unique_room_name(base: str) -> str:
6868
return f"{base}-{uuid.uuid4().hex[:8]}"
6969

70-
def _solid_color_rgba_frame(
71-
width: int, height: int, rgb: tuple[int, int, int]
72-
) -> rtc.VideoFrame:
70+
71+
def _solid_color_rgba_frame(width: int, height: int, rgb: tuple[int, int, int]) -> rtc.VideoFrame:
7372
"""Build a solid-color 640x480 RGBA `VideoFrame` for the given RGB triple."""
7473
pixels = np.empty((height, width, 4), dtype=np.uint8)
7574
pixels[:, :, 0] = rgb[0]
@@ -169,9 +168,7 @@ def on_track_subscribed(
169168
assert subscribed_track is not None
170169

171170
# Request RGBA frames from the SFU so we don't have to convert per frame.
172-
video_stream = rtc.VideoStream(
173-
subscribed_track, format=rtc.VideoBufferType.RGBA
174-
)
171+
video_stream = rtc.VideoStream(subscribed_track, format=rtc.VideoBufferType.RGBA)
175172

176173
received_frames: list[np.ndarray] = []
177174
stop_collecting = asyncio.Event()
@@ -197,9 +194,11 @@ async def collect_frames() -> None:
197194
vf = event.frame
198195
if vf.type != rtc.VideoBufferType.RGBA:
199196
vf = vf.convert(rtc.VideoBufferType.RGBA)
200-
arr = np.frombuffer(
201-
bytes(vf.data.cast("B")), dtype=np.uint8
202-
).reshape(vf.height, vf.width, 4).copy()
197+
arr = (
198+
np.frombuffer(bytes(vf.data.cast("B")), dtype=np.uint8)
199+
.reshape(vf.height, vf.width, 4)
200+
.copy()
201+
)
203202
received_frames.append(arr)
204203
if stop_collecting.is_set():
205204
break
@@ -228,8 +227,7 @@ async def collect_frames() -> None:
228227

229228
# Classify each received frame against the 5-color palette.
230229
classified = [
231-
_classify_frame_color(f, VIDEO_COLOR_SEQUENCE)[0]
232-
for f in received_frames
230+
_classify_frame_color(f, VIDEO_COLOR_SEQUENCE)[0] for f in received_frames
233231
]
234232

235233
# Reduce to stable runs: ignore single-frame transitions at color boundaries.
@@ -271,8 +269,7 @@ async def collect_frames() -> None:
271269
expected_names = {name for name, _ in VIDEO_COLOR_SEQUENCE}
272270
missing = expected_names - saved.keys()
273271
assert not missing, (
274-
f"Did not capture a frame for colors: {missing}. "
275-
f"Classified stream: {classified}"
272+
f"Did not capture a frame for colors: {missing}. Classified stream: {classified}"
276273
)
277274
finally:
278275
await publisher_room.disconnect()

0 commit comments

Comments
 (0)