Streams: offer the H.264 level the encoder makes, at most 5.2
The app's streams always offered H.264 at level 3.1: its peer configuration is made before a share starts, and only voelinctl set the real level. A 4K or high-frame-rate stream then declared far less in its offer than in its SPS, which a viewer that sizes its decoder from the offer may refuse. Each layer's encoder now tells its sink what it makes (`MediaSink::layer_format`: size, frame rate, bitrate, whether the bitrate is automatic), when the sink is attached (from the size captured so far, so a viewer that joins before the first frame is encoded is covered), with the layer's first frame and on every change. The engine's stream task offers new viewers the level of the largest layer (its bitrate at `max_bitrate` if that is higher) in both profiles, and puts an automatic bitrate into the layer as before; this one hook replaces `auto_bitrate`. Offering 6.0 broke the stream: str0m 0.23 knows no H.264 level above 5.2, nor does libwebrtc (`H264Level` on its main branch), and a `profile-level-id` they cannot parse matches nothing, so a viewer answered without video (`m=video 0`). The offer is now capped at 5.2 (`h264::MAX_OFFER_LEVEL`); a stream that needs 6.x (4K above 60 fps, 8K) is offered as 5.2 and keeps its real level in the SPS. Tests: through two stream tasks, an encoder's 3840x2160@60 reaches the next offer as 640c34 and 42e034 (and without the update it stays 3.1); the largest layer counts, at its max bitrate; an automatic bitrate still moves the layer once, not per frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
df4f534022
commit
500d41e5d2
4 files changed
+266
-78
No files matched your search
+11
-2
@@ -145,7 +145,7 @@ viewer: Engine::subscribe_frames ─ VideoPipeline (thread) ─ VideoDecoder
|
||||
the encoder thread works it out from each picture's size and the layer's
|
||||
frame rate, so a resolution or frame-rate change moves it at once. The
|
||||
sink is told with the first frame and whenever it changes
|
||||
(`MediaSink::auto_bitrate`); the engine's `StreamSink` puts it into the
|
||||
(`MediaSink::layer_format`); the engine's `StreamSink` puts it into the
|
||||
live stream's layer, so new connections start their bandwidth estimate at
|
||||
it and all of them probe for it. `Streamer::bitrate_kbps()` is what to
|
||||
announce in `setupstream` (the share dialog and the studio do, up to the
|
||||
@@ -216,7 +216,16 @@ viewer: Engine::subscribe_frames ─ VideoPipeline (thread) ─ VideoDecoder
|
||||
at the level the stream needs (`PeerConfig::h264_profile_level_ids`,
|
||||
`set_h264_format(width, height, fps, bitrate)`: macroblocks per second
|
||||
and per frame, and bitrate, per H.264 Table A-1; never below 3.1, the
|
||||
level offered before). A viewer that takes both answers High (the
|
||||
level offered before, and never above 5.2, the highest libwebrtc and
|
||||
str0m parse: a viewer answered an offer of 6.0 without video). The app's
|
||||
streams set it from what the encoder makes: every layer's encoder tells
|
||||
its size, frame rate and bitrate (`MediaSink::layer_format`, from the
|
||||
size captured so far when the sink is attached, then with the layer's
|
||||
first frame and every change), and the stream task offers new viewers
|
||||
the level of the largest (a layer's bitrate at its `max_bitrate` if
|
||||
higher), in both profiles. Before, an app stream always offered 3.1,
|
||||
also for 4K and high frame rates. A stream that needs 6.x is offered as
|
||||
5.2 and carries its real level in the SPS. A viewer that takes both answers High (the
|
||||
streamer writes the first of its own order the answer lists); one that
|
||||
takes only Baseline gets frames from an encoder in Constrained Baseline
|
||||
(above). str0m's other H.264 variants are only accepted, never offered,
|
||||
|
||||
Reference in new issue
Block a user