[Enhancement]Extend SimulcastEncoderAdapter to support adaptive strming#75
Open
ipavlidakis wants to merge 1 commit intodevelopfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes a runtime
SimulcastEncoderAdapteredge case where SEA has multipleencoder contexts, but only one spatial layer is actually active.
In that state, SEA was returning aggregated simulcast
EncoderInfoinstead ofthe active encoder's runtime adaptation hints. The result is that a
single-active-layer call can behave differently from true single-layer
publishing, especially for quality scaling and other adaptation decisions.
Problem
SimulcastEncoderAdapter::GetEncoderInfo()only had a passthrough behaviorwhen
stream_contexts_.size() == 1.In practice, SEA can still have multiple stream contexts after init while
runtime bitrate allocation pauses all but one layer.
When that happened, SEA continued to report aggregated simulcast info and
explicitly disabled
scaling_settings.That means downstream components do not see the active encoder's real runtime
capabilities and hints, including:
min_pixels_per_frameis_qp_trustedresolution_bitrate_limitsmin_qpsupports_native_handlepreferred_pixel_formatsRoot Cause
The bug is in
SimulcastEncoderAdapter::GetEncoderInfo().The old logic treated "single stream context" as equivalent to "single active
layer", but those are not the same thing at runtime.
Once SEA enters multi-encoder mode, the number of stream contexts may stay
greater than one even if only one layer is currently unpaused.
Fix
In multi-encoder mode, SEA still aggregates the simulcast-specific fields as it
did before.
If exactly one stream is unpaused, SEA now forwards the active encoder's
runtime-sensitive fields:
scaling_settingssupports_native_handlehas_trusted_rate_controlleris_hardware_acceleratedis_qp_trustedresolution_bitrate_limitsmin_qppreferred_pixel_formatsSEA still preserves its aggregated simulcast fields:
implementation_namefps_allocationrequested_resolution_alignmentapply_alignment_to_all_simulcast_layersIf more layers become active again later in the call, SEA goes back to the
existing aggregated behavior without needing re-init.
Why This Is Safe
This is a narrow behavior change.
It does not change:
GetEncoderInfo()pathIt only changes the runtime case where SEA is effectively behaving like
single-layer publishing but was still reporting multi-layer aggregated info.
Tests
Added regression coverage in
simulcast_encoder_adapter_unittest.ccfor:The tests verify forwarding of:
min_pixels_per_framemin_qpThe tests also verify that
fps_allocationstill preserves SEA's spatial-slotlayout.
Validation
Validated by compiling the two edited translation units with the generated
build commands:
media/engine/simulcast_encoder_adapter.ccmedia/engine/simulcast_encoder_adapter_unittest.ccI did not complete:
rtc_media_unittestsrunReviewer Notes
Please pay special attention to:
supports_native_handlein the single-unpaused case isthe right runtime behavior
is_hardware_acceleratedorhas_trusted_rate_controllerthat should remain aggregated even in thesingle-unpaused state
VideoStreamEncoderre-reading
EncoderInfoafter runtime pause/unpause transitions