reactor-runtime 3.10.0__tar.gz → 3.10.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/PKG-INFO +1 -1
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/pyproject.toml +1 -1
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/pyproject.toml.orig +1 -1
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/core/__init__.py +2 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/core/transport.py +13 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/core/values.py +19 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/message_gateway.py +11 -1
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/protocol/frames.py +10 -1
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/runner/runner.py +54 -7
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/livekit/media_in.py +53 -22
- reactor_runtime-3.10.2/src/reactor_runtime/transport/step_frames.py +526 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/acceptor.py +17 -1
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/connection.py +30 -4
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/router.py +6 -1
- reactor_runtime-3.10.0/src/reactor_runtime/transport/step_frames.py +0 -304
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/LICENSE +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/NOTICE +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/README.md +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/codes.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/core/fields.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/core/model.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/core/naming.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/core/service.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/core/session.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/core/stages.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/core/stats.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/core/typespec.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/distributed/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/distributed/errors.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/distributed/ipc.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/distributed/protocol.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/distributed/rank.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/distributed/runner.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/distributed/worker.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/event_stream.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/http/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/http/events.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/http/routes.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/http/server.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/http/spec.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/http/step_usage.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/app/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/app/input_state.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/app/outcome.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/app/reactor_app.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/app/step_completed.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/client.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/events/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/events/decorators.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/events/errors.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/events/messages.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/internal/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/internal/aliases.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/internal/bridge.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/internal/input_buffer.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/internal/reactor_core.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/model/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/model/contract.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/model/reactor_model.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/model/schema.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/pipeline/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/pipeline/idle.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/pipeline/input_state.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/pipeline/reactor_pipeline.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/tracks/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/tracks/descriptors.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/tracks/input.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/interface/tracks/output.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/log.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/manifest.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/metrics/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/metrics/command.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/metrics/model.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/metrics/registry.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/metrics/session.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/paths.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/protocol/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/protocol/base.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/protocol/common.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/protocol/v0/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/protocol/v0/codec.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/protocol/v1/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/protocol/v1/codec.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/py.typed +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/recording/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/recording/chunk_encoder.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/recording/markers.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/recording/recorder.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/runner/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/runner/client_stats.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/runner/connection_manager.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/runner/offer_epochs.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/runner/runtime_stats.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/runner/session_start.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/runner/stages.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/runner/state_machine.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/runner/system_client.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/runner/upload_resolution.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/schema.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/serve.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/service.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/step_results/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/step_results/mp4.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/step_results/store.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/step_results/usage.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/acceptor.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/livekit/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/livekit/connection.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/livekit/pacer.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/livekit/participant.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/livekit/room.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/livekit/router.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/livekit/signals.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/livekit/version.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/router.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/__init__.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/client_stats.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/config.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/frame_stages.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/frames.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/message_stages.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/metrics.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/pacer.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/peer.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/reading.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/sdp.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/signaling.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/stats.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/webrtc/version.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/upload_store.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_wire/v1/common_pb2.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_wire/v1/common_pb2.pyi +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_wire/v1/control_pb2.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_wire/v1/control_pb2.pyi +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_wire/v1/data_pb2.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_wire/v1/data_pb2.pyi +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_wire/v1/model_pb2.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_wire/v1/model_pb2.pyi +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_wire/v1/platform_pb2.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_wire/v1/platform_pb2.pyi +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_wire/v1/step_pb2.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_wire/v1/step_pb2.pyi +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_wire/v1/track_pb2.py +0 -0
- {reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_wire/v1/track_pb2.pyi +0 -0
|
@@ -60,6 +60,7 @@ from reactor_runtime.core.values import (
|
|
|
60
60
|
ConnectionCapabilities,
|
|
61
61
|
ConnectionOrigin,
|
|
62
62
|
ConnId,
|
|
63
|
+
DecodedStep,
|
|
63
64
|
FrameStage,
|
|
64
65
|
Health,
|
|
65
66
|
HealthStatus,
|
|
@@ -96,6 +97,7 @@ __all__ = [
|
|
|
96
97
|
"ConnectionOrigin",
|
|
97
98
|
"ConnectionOriginSource",
|
|
98
99
|
"ConnectionSink",
|
|
100
|
+
"DecodedStep",
|
|
99
101
|
"EndReason",
|
|
100
102
|
"FieldInfo",
|
|
101
103
|
"FileUploaded",
|
|
@@ -23,6 +23,7 @@ from reactor_runtime.core.values import (
|
|
|
23
23
|
ConnectionCapabilities,
|
|
24
24
|
ConnectionOrigin,
|
|
25
25
|
ConnId,
|
|
26
|
+
DecodedStep,
|
|
26
27
|
FrameStage,
|
|
27
28
|
InputFrame,
|
|
28
29
|
MediaChunk,
|
|
@@ -328,6 +329,18 @@ class ConnectionSink(Protocol):
|
|
|
328
329
|
message family rather than guessing.
|
|
329
330
|
"""
|
|
330
331
|
|
|
332
|
+
def decoded_step_received(
|
|
333
|
+
self, conn_id: ConnId, step: DecodedStep, version: ProtocolVersion
|
|
334
|
+
) -> None:
|
|
335
|
+
"""Hand up a step request whose encoded frames the transport decoded.
|
|
336
|
+
|
|
337
|
+
Takes the place of :meth:`message_received` for that request: it is
|
|
338
|
+
decoded and dispatched as the same request arriving on the data
|
|
339
|
+
channel, with each encoded frame read as its picture in
|
|
340
|
+
``step.pictures``. A transport delivers it in the order the request
|
|
341
|
+
arrived among the connection's other messages.
|
|
342
|
+
"""
|
|
343
|
+
|
|
331
344
|
def command_received(
|
|
332
345
|
self,
|
|
333
346
|
conn_id: ConnId,
|
|
@@ -533,6 +533,25 @@ class MediaChunk:
|
|
|
533
533
|
return split_batch(self.bundle)
|
|
534
534
|
|
|
535
535
|
|
|
536
|
+
@dataclass(frozen=True, eq=False)
|
|
537
|
+
class DecodedStep:
|
|
538
|
+
"""A client's step request whose encoded frames its transport already decoded.
|
|
539
|
+
|
|
540
|
+
The request goes up as it arrived, its encoded frames still in it, with the
|
|
541
|
+
picture each one decodes to beside it, so the runner reads the pictures
|
|
542
|
+
without the request being rewritten and serialized again.
|
|
543
|
+
|
|
544
|
+
Attributes:
|
|
545
|
+
payload: The request's wire frame, as the client sent it.
|
|
546
|
+
pictures: The ``(H, W, 3)`` ``uint8`` RGB picture each encoded frame
|
|
547
|
+
decodes to, keyed by ``(entry, position)``: the index of its
|
|
548
|
+
``media_input`` entry, and its position among that entry's frames.
|
|
549
|
+
"""
|
|
550
|
+
|
|
551
|
+
payload: bytes
|
|
552
|
+
pictures: Mapping[tuple[int, int], npt.NDArray[np.uint8]]
|
|
553
|
+
|
|
554
|
+
|
|
536
555
|
@dataclass(frozen=True)
|
|
537
556
|
class RequestedStep:
|
|
538
557
|
"""A client's request for one step of a stepped session, once accepted.
|
|
@@ -18,9 +18,11 @@ from __future__ import annotations
|
|
|
18
18
|
import logging
|
|
19
19
|
import uuid
|
|
20
20
|
from collections.abc import Awaitable, Callable, Mapping
|
|
21
|
-
from dataclasses import dataclass
|
|
21
|
+
from dataclasses import dataclass, field
|
|
22
22
|
from typing import Any
|
|
23
23
|
|
|
24
|
+
import numpy as np
|
|
25
|
+
import numpy.typing as npt
|
|
24
26
|
from google.protobuf.message import DecodeError
|
|
25
27
|
|
|
26
28
|
from reactor_runtime.core import ConnectionSink, ConnId
|
|
@@ -91,6 +93,8 @@ class InboundStep:
|
|
|
91
93
|
and minted here when absent.
|
|
92
94
|
received_at: When the frame carrying the request reached the runtime,
|
|
93
95
|
on a monotonic clock.
|
|
96
|
+
pictures: The picture the transport decoded each encoded frame to, by
|
|
97
|
+
``(entry, position)`` in *media_input*; empty when it decoded none.
|
|
94
98
|
"""
|
|
95
99
|
|
|
96
100
|
state: Mapping[str, Any]
|
|
@@ -99,6 +103,7 @@ class InboundStep:
|
|
|
99
103
|
conn_id: ConnId
|
|
100
104
|
request_id: str
|
|
101
105
|
received_at: float
|
|
106
|
+
pictures: Mapping[tuple[int, int], npt.NDArray[np.uint8]] = field(default_factory=dict)
|
|
102
107
|
|
|
103
108
|
|
|
104
109
|
StepHandler = Callable[[InboundStep], Awaitable[None]]
|
|
@@ -154,6 +159,7 @@ class MessageGateway:
|
|
|
154
159
|
version: ProtocolVersion,
|
|
155
160
|
*,
|
|
156
161
|
received_at: float,
|
|
162
|
+
pictures: Mapping[tuple[int, int], npt.NDArray[np.uint8]] | None = None,
|
|
157
163
|
) -> None:
|
|
158
164
|
"""Decode one inbound frame and route it.
|
|
159
165
|
|
|
@@ -169,6 +175,9 @@ class MessageGateway:
|
|
|
169
175
|
The caller stamps it at the transport edge and it rides the decoded
|
|
170
176
|
command, because the gateway runs as a task and cannot see how long the
|
|
171
177
|
frame waited for the event loop.
|
|
178
|
+
|
|
179
|
+
*pictures* are what the transport decoded a step request's encoded
|
|
180
|
+
frames to, and ride the :class:`InboundStep` the frame carries.
|
|
172
181
|
"""
|
|
173
182
|
try:
|
|
174
183
|
message = self._codec_for(version).decode_inbound(payload, channel)
|
|
@@ -219,6 +228,7 @@ class MessageGateway:
|
|
|
219
228
|
conn_id=conn_id,
|
|
220
229
|
request_id=message.request_id or _new_request_id(),
|
|
221
230
|
received_at=received_at,
|
|
231
|
+
pictures=pictures or {},
|
|
222
232
|
)
|
|
223
233
|
)
|
|
224
234
|
return
|
|
@@ -189,8 +189,17 @@ def decode_frame(frame: step_pb2.Frame, kind: TrackKind) -> InputFrame:
|
|
|
189
189
|
FrameEncodingError: The encoding is unspecified or unknown, or the
|
|
190
190
|
frame does not fit it.
|
|
191
191
|
"""
|
|
192
|
+
return decoded_frame(frame, _codec(frame).decode(frame, kind))
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def decoded_frame(frame: step_pb2.Frame, data: npt.NDArray[Any]) -> InputFrame:
|
|
196
|
+
"""Return *data*, the samples a transport decoded *frame* to, as the frame a model reads.
|
|
197
|
+
|
|
198
|
+
The frame's metadata and capture time ride along unchanged, as they do
|
|
199
|
+
through :func:`decode_frame`.
|
|
200
|
+
"""
|
|
192
201
|
return InputFrame(
|
|
193
|
-
data=
|
|
202
|
+
data=data,
|
|
194
203
|
metadata=frame.metadata if frame.HasField("metadata") else None,
|
|
195
204
|
capture_time_us=frame.capture_time_us if frame.HasField("capture_time_us") else None,
|
|
196
205
|
)
|
|
@@ -28,6 +28,9 @@ from collections.abc import AsyncIterator, Callable, Coroutine, Mapping
|
|
|
28
28
|
from dataclasses import dataclass
|
|
29
29
|
from typing import Any, Protocol
|
|
30
30
|
|
|
31
|
+
import numpy as np
|
|
32
|
+
import numpy.typing as npt
|
|
33
|
+
|
|
31
34
|
from reactor_runtime.codes import INVALID_COMMAND, UNRESOLVED_UPLOAD
|
|
32
35
|
from reactor_runtime.core import (
|
|
33
36
|
JOURNAL_EVENTS,
|
|
@@ -39,6 +42,7 @@ from reactor_runtime.core import (
|
|
|
39
42
|
Connection,
|
|
40
43
|
ConnectionSink,
|
|
41
44
|
ConnId,
|
|
45
|
+
DecodedStep,
|
|
42
46
|
EndReason,
|
|
43
47
|
FileUploaded,
|
|
44
48
|
Health,
|
|
@@ -85,6 +89,7 @@ from reactor_runtime.protocol.frames import (
|
|
|
85
89
|
FrameEncodingError,
|
|
86
90
|
check_frame,
|
|
87
91
|
decode_frame,
|
|
92
|
+
decoded_frame,
|
|
88
93
|
media_size,
|
|
89
94
|
track_frames,
|
|
90
95
|
)
|
|
@@ -676,12 +681,40 @@ class Runner(ServiceComponent, ConnectionSink):
|
|
|
676
681
|
loop is busy waits before the gateway reads it, and the wait belongs to
|
|
677
682
|
the command's ingress rather than being invisible.
|
|
678
683
|
"""
|
|
684
|
+
self._dispatch_inbound(
|
|
685
|
+
lambda received_at: self._gateway.handle(
|
|
686
|
+
conn_id, payload, channel, version, received_at=received_at
|
|
687
|
+
)
|
|
688
|
+
)
|
|
689
|
+
|
|
690
|
+
def decoded_step_received(
|
|
691
|
+
self, conn_id: ConnId, step: DecodedStep, version: ProtocolVersion
|
|
692
|
+
) -> None:
|
|
693
|
+
"""Hand a step request whose encoded frames the transport decoded to the gateway.
|
|
694
|
+
|
|
695
|
+
Scheduled and stamped as :meth:`message_received` does a frame, so the
|
|
696
|
+
request keeps its place among the connection's messages.
|
|
697
|
+
"""
|
|
698
|
+
self._dispatch_inbound(
|
|
699
|
+
lambda received_at: self._gateway.handle(
|
|
700
|
+
conn_id,
|
|
701
|
+
step.payload,
|
|
702
|
+
Channel.DATA,
|
|
703
|
+
version,
|
|
704
|
+
received_at=received_at,
|
|
705
|
+
pictures=step.pictures,
|
|
706
|
+
)
|
|
707
|
+
)
|
|
708
|
+
|
|
709
|
+
def _dispatch_inbound(self, handle: Callable[[float], Coroutine[Any, Any, None]]) -> None:
|
|
710
|
+
"""Stamp an inbound frame's arrival and schedule *handle* with it on the runtime loop.
|
|
711
|
+
|
|
712
|
+
Both kinds of inbound frame go through here, so they keep the order
|
|
713
|
+
they arrived in. The task is tracked until it completes.
|
|
714
|
+
"""
|
|
679
715
|
if self._loop is None:
|
|
680
716
|
return
|
|
681
|
-
|
|
682
|
-
task = self._loop.create_task(
|
|
683
|
-
self._gateway.handle(conn_id, payload, channel, version, received_at=received_at)
|
|
684
|
-
)
|
|
717
|
+
task = self._loop.create_task(handle(time.monotonic()))
|
|
685
718
|
self._inbound.add(task)
|
|
686
719
|
task.add_done_callback(self._inbound.discard)
|
|
687
720
|
|
|
@@ -1870,7 +1903,7 @@ class Runner(ServiceComponent, ConnectionSink):
|
|
|
1870
1903
|
return
|
|
1871
1904
|
calls.append((key, name, resolved))
|
|
1872
1905
|
try:
|
|
1873
|
-
media_input = self._check_media_input(step.media_input)
|
|
1906
|
+
media_input = self._check_media_input(step.media_input, step.pictures)
|
|
1874
1907
|
except _StepInputError as error:
|
|
1875
1908
|
refuse(error.entry, str(error))
|
|
1876
1909
|
return
|
|
@@ -1896,12 +1929,16 @@ class Runner(ServiceComponent, ConnectionSink):
|
|
|
1896
1929
|
self._sm.send(SessionEvent.COMMAND, name=name, args=args, conn_id=step.conn_id)
|
|
1897
1930
|
|
|
1898
1931
|
def _check_media_input(
|
|
1899
|
-
self,
|
|
1932
|
+
self,
|
|
1933
|
+
media_input: tuple[step_pb2.TrackFrames, ...],
|
|
1934
|
+
pictures: Mapping[tuple[int, int], npt.NDArray[np.uint8]],
|
|
1900
1935
|
) -> dict[str, list[FrameSource]]:
|
|
1901
1936
|
"""Check a step request's media input, by the input track each entry belongs to.
|
|
1902
1937
|
|
|
1903
1938
|
Every frame is checked without copying its samples; the copy happens
|
|
1904
|
-
when the model's thread calls the source this returns for it.
|
|
1939
|
+
when the model's thread calls the source this returns for it. A frame
|
|
1940
|
+
the transport already decoded is read as its picture in *pictures*,
|
|
1941
|
+
keyed by ``(entry, position)``, which only a video track takes.
|
|
1905
1942
|
|
|
1906
1943
|
Raises:
|
|
1907
1944
|
_StepInputError: An entry names a track the model does not take, a
|
|
@@ -1933,6 +1970,16 @@ class Runner(ServiceComponent, ConnectionSink):
|
|
|
1933
1970
|
frames: list[FrameSource] = []
|
|
1934
1971
|
samples = 0
|
|
1935
1972
|
for position, frame in enumerate(entry.frames):
|
|
1973
|
+
picture = pictures.get((index, position))
|
|
1974
|
+
if picture is not None:
|
|
1975
|
+
if info.kind is not TrackKind.VIDEO:
|
|
1976
|
+
raise _StepInputError(
|
|
1977
|
+
where,
|
|
1978
|
+
f"{where}.frames[{position}]: an encoded video frame cannot go "
|
|
1979
|
+
f"to {info.kind} track {entry.track!r}",
|
|
1980
|
+
)
|
|
1981
|
+
frames.append(functools.partial(decoded_frame, frame, picture))
|
|
1982
|
+
continue
|
|
1936
1983
|
try:
|
|
1937
1984
|
shape = check_frame(frame, info.kind)
|
|
1938
1985
|
except FrameEncodingError as error:
|
{reactor_runtime-3.10.0 → reactor_runtime-3.10.2}/src/reactor_runtime/transport/livekit/media_in.py
RENAMED
|
@@ -18,11 +18,16 @@ names the stream, as JSON::
|
|
|
18
18
|
|
|
19
19
|
and after its last frame comes one with no samples, ``data`` of shape
|
|
20
20
|
``(1, 0)``, and ``{"stream_id": "AUDIO_x7Kq", "ended": true}``. A stream ends when
|
|
21
|
-
it closes
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
it closes or when its sender leaves. A new stream on the topic never ends one
|
|
22
|
+
that is still open: up to :data:`MAX_OPEN_INPUT_STREAMS` feed the track at
|
|
23
|
+
once, each to its own end, and their frames interleave in the order they
|
|
24
|
+
arrive. A model that plays streams one after another, such as one utterance
|
|
25
|
+
each, tells them apart by ``stream_id``. A stream past the bound is refused.
|
|
26
|
+
|
|
27
|
+
A stream without the attributes is taken to be at the track's rate, in mono;
|
|
28
|
+
one whose ``sample_rate`` is not between :data:`MIN_STREAM_RATE` and
|
|
29
|
+
:data:`MAX_STREAM_RATE`, or whose ``num_channels`` is not between 1 and
|
|
30
|
+
:data:`MAX_STREAM_CHANNELS`, is refused.
|
|
26
31
|
|
|
27
32
|
Each input track has one owner across the session, whatever its transport: the
|
|
28
33
|
first client to feed it holds it, as a WebRTC client's publish request does,
|
|
@@ -63,6 +68,15 @@ MAX_STREAM_RATE = 192_000
|
|
|
63
68
|
MAX_STREAM_CHANNELS = 8
|
|
64
69
|
"""The most ``num_channels`` a byte stream may declare."""
|
|
65
70
|
|
|
71
|
+
MAX_OPEN_INPUT_STREAMS = 4
|
|
72
|
+
"""How many byte streams may feed one topic at once.
|
|
73
|
+
|
|
74
|
+
A sender that closes each stream before it opens the next can still have two
|
|
75
|
+
open here: the next stream's header may arrive before the runtime has read the
|
|
76
|
+
end of the one before. A stream past the bound is refused, so a stream already
|
|
77
|
+
feeding the track is never cut.
|
|
78
|
+
"""
|
|
79
|
+
|
|
66
80
|
VIDEO_QUEUE_FRAMES = 4
|
|
67
81
|
"""How many decoded frames a remote video track may queue; past it, the oldest is dropped.
|
|
68
82
|
|
|
@@ -191,7 +205,7 @@ class StreamFramer:
|
|
|
191
205
|
|
|
192
206
|
@dataclass
|
|
193
207
|
class _Stream:
|
|
194
|
-
"""
|
|
208
|
+
"""A byte stream that feeds a topic's input track."""
|
|
195
209
|
|
|
196
210
|
stream_id: str
|
|
197
211
|
sender: str
|
|
@@ -241,8 +255,8 @@ class RoomInputs:
|
|
|
241
255
|
# track id, in arrival order: its sender gets no word that it was
|
|
242
256
|
# refused, so the room starts it once a participant frees the input.
|
|
243
257
|
self._waiting: dict[str, _WaitingTrack] = {}
|
|
244
|
-
# Each byte stream topic, and the
|
|
245
|
-
self._streams: dict[str, _Stream] = {}
|
|
258
|
+
# Each byte stream topic, and the streams open on it, by stream id.
|
|
259
|
+
self._streams: dict[str, dict[str, _Stream]] = {}
|
|
246
260
|
# The readers each participant's media runs on, so its leaving stops them.
|
|
247
261
|
self._readers: dict[str, set[asyncio.Task[None]]] = {}
|
|
248
262
|
|
|
@@ -252,7 +266,11 @@ class RoomInputs:
|
|
|
252
266
|
return list(self._mapped)
|
|
253
267
|
|
|
254
268
|
def on_byte_stream(self, reader: rtc.ByteStreamReader, sender: str, conn_id: ConnId) -> None:
|
|
255
|
-
"""Start feeding an input track from a byte stream a client opened.
|
|
269
|
+
"""Start feeding an input track from a byte stream a client opened.
|
|
270
|
+
|
|
271
|
+
Streams already open on the topic go on feeding the track. The
|
|
272
|
+
stream is refused when :data:`MAX_OPEN_INPUT_STREAMS` are open there.
|
|
273
|
+
"""
|
|
256
274
|
topic = reader.info.topic
|
|
257
275
|
track = self._mapped.get(topic)
|
|
258
276
|
info = self._inputs.get(track or "")
|
|
@@ -273,13 +291,19 @@ class RoomInputs:
|
|
|
273
291
|
)
|
|
274
292
|
reader.close()
|
|
275
293
|
return
|
|
294
|
+
open_count = len(self._streams.get(topic, {}))
|
|
295
|
+
if open_count >= MAX_OPEN_INPUT_STREAMS:
|
|
296
|
+
logger.warning(
|
|
297
|
+
"refused an input byte stream: too many open on its topic",
|
|
298
|
+
topic=topic,
|
|
299
|
+
open_streams=open_count,
|
|
300
|
+
)
|
|
301
|
+
reader.close()
|
|
302
|
+
return
|
|
276
303
|
if not self._claim(track, conn_id, streamed=True):
|
|
277
304
|
logger.debug("dropped a stream for an input track another client holds")
|
|
278
305
|
reader.close()
|
|
279
306
|
return
|
|
280
|
-
previous = self._streams.get(topic)
|
|
281
|
-
if previous is not None:
|
|
282
|
-
self._end(topic, previous)
|
|
283
307
|
stream = _Stream(
|
|
284
308
|
stream_id=reader.info.stream_id,
|
|
285
309
|
sender=sender,
|
|
@@ -291,7 +315,7 @@ class RoomInputs:
|
|
|
291
315
|
).encode(),
|
|
292
316
|
reader=reader,
|
|
293
317
|
)
|
|
294
|
-
self._streams[
|
|
318
|
+
self._streams.setdefault(topic, {})[stream.stream_id] = stream
|
|
295
319
|
self._spawn(sender, self._feed(topic, stream, reader))
|
|
296
320
|
|
|
297
321
|
def on_track(self, track: rtc.Track, sender: str, conn_id: ConnId) -> None:
|
|
@@ -345,7 +369,7 @@ class RoomInputs:
|
|
|
345
369
|
|
|
346
370
|
A track waiting for one of those inputs then starts feeding it.
|
|
347
371
|
"""
|
|
348
|
-
for topic, stream in
|
|
372
|
+
for topic, stream in self._open_streams():
|
|
349
373
|
if stream.sender == sender:
|
|
350
374
|
self._end(topic, stream)
|
|
351
375
|
for task in self._readers.pop(sender, set()):
|
|
@@ -367,7 +391,7 @@ class RoomInputs:
|
|
|
367
391
|
Each stream's reader is closed directly: a reader task cancelled
|
|
368
392
|
before it first runs never reaches its own cleanup.
|
|
369
393
|
"""
|
|
370
|
-
for topic, stream in
|
|
394
|
+
for topic, stream in self._open_streams():
|
|
371
395
|
self._end(topic, stream)
|
|
372
396
|
for tasks in self._readers.values():
|
|
373
397
|
for task in tasks:
|
|
@@ -420,9 +444,6 @@ class RoomInputs:
|
|
|
420
444
|
async def _feed(self, topic: str, stream: _Stream, reader: rtc.ByteStreamReader) -> None:
|
|
421
445
|
try:
|
|
422
446
|
async for chunk in reader:
|
|
423
|
-
if self._streams.get(topic) is not stream:
|
|
424
|
-
# Superseded by a newer stream on the topic, which ended this one.
|
|
425
|
-
return
|
|
426
447
|
for samples in stream.framer.push(chunk):
|
|
427
448
|
self._push(stream, samples)
|
|
428
449
|
except asyncio.CancelledError:
|
|
@@ -431,12 +452,22 @@ class RoomInputs:
|
|
|
431
452
|
logger.warning("reading an input byte stream failed", topic=topic, exc_info=True)
|
|
432
453
|
finally:
|
|
433
454
|
reader.close()
|
|
434
|
-
|
|
435
|
-
|
|
455
|
+
self._end(topic, stream)
|
|
456
|
+
|
|
457
|
+
def _open_streams(self) -> list[tuple[str, _Stream]]:
|
|
458
|
+
"""Every open stream with its topic, in the order each topic's streams opened."""
|
|
459
|
+
return [(topic, s) for topic, streams in self._streams.items() for s in streams.values()]
|
|
436
460
|
|
|
437
461
|
def _end(self, topic: str, stream: _Stream) -> None:
|
|
438
|
-
"""Send what the stream left, then its end frame, and stop it feeding the track.
|
|
439
|
-
|
|
462
|
+
"""Send what the stream left, then its end frame, and stop it feeding the track.
|
|
463
|
+
|
|
464
|
+
A stream ends once: ending one that has already ended does nothing.
|
|
465
|
+
"""
|
|
466
|
+
streams = self._streams.get(topic)
|
|
467
|
+
if streams is None or streams.get(stream.stream_id) is not stream:
|
|
468
|
+
return
|
|
469
|
+
del streams[stream.stream_id]
|
|
470
|
+
if not streams:
|
|
440
471
|
del self._streams[topic]
|
|
441
472
|
stream.reader.close()
|
|
442
473
|
for samples in stream.framer.flush():
|