Skip to content

feat(examples): Python バインディングを使った FastAPI 製エコーサーバーを追加する - #350

Open
yuki-uchida wants to merge 2 commits into
feat/python-bindingsfrom
feat/python-echo-example
Open

feat(examples): Python バインディングを使った FastAPI 製エコーサーバーを追加する#350
yuki-uchida wants to merge 2 commits into
feat/python-bindingsfrom
feat/python-echo-example

Conversation

@yuki-uchida

Copy link
Copy Markdown
Collaborator

概要

FastAPI プロセス内で MoQT の DUAL リスナーを動かし、publish された track の object を同名 track の購読者へそのまま書き戻すエコーサーバーの example を追加しました。
#349 の上に積んでいます。

やったこと

  • examples/python/echo-server: lifespan で moqt.listen を起動。PublishRequest は accept して読み取りタスクへ、SubscribeRequest は track ごとの購読者リストへ登録し、object を同名 track の全購読者(セッション横断)へ fan-out
  • 購読者は新しい group の object_id 0 からのみ echo を開始する。購読者がいない間の object は捨てる
  • GET / でセッション数・track ごとの受信/echo 数・購読者数を返す

やらないこと

  • relay 相当のキャッシュ(遅れて来た購読者への過去 group の配信)、group id の保持(サーバー側 TrackWriter が再採番する)

影響範囲

  • example の追加のみ

テスト

  • uvicorn 起動 → moq-cli subscribe → ffmpeg testsrc を moq-cli publish で 6 秒 publish。video 180 object 受信・150 echo(最初の group はスキップ)、受信した H.264 を ffprobe で 150 フレーム 640x360 としてデコード確認

備考

  • 本サーバーが返す PUBLISH_OK(delivery_timeout パラメータなし)のデコード時に、moq-cli publisher 側で delivery timeout: Not enough bytes remaining の ERROR ログが出る。moqt 側のデコードログの問題と見ており、この PR では扱わない

@yuki-uchida
yuki-uchida force-pushed the feat/python-echo-example branch from 9fc37e9 to 5ef46f4 Compare September 8, 2026 01:39
examples/python/echo-server runs a MoQT DUAL listener inside a FastAPI
process. Objects received on a published track are written back to every
session subscribed to the same track name; subscribers join at a group
boundary so the echoed stream starts on a keyframe. GET / reports
session and track counters.

Verified with moq-cli: an ffmpeg test pattern published as demo/video
and subscribed from a second moq-cli decodes 150 frames after the first
group is skipped.
maturin develop installs into whichever virtualenv it detects, which
made the module land in a different .venv than the one running uvicorn.
uv sync builds bindings/python as the declared path dependency into the
example's own .venv.
@yuki-uchida
yuki-uchida force-pushed the feat/python-echo-example branch from 02cc0ec to 916c8a6 Compare September 8, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant