Add pixel budget controls for video rendition selection#1411
Conversation
Adds a `pixels` attribute (default `auto`) to <moq-watch>. In auto mode the element observes its own size via ResizeObserver and feeds width * height * devicePixelRatio^2 into the video source's pixel target, so a 360px slot no longer pulls a 1080p stream. A numeric value pins the budget instead. https://claude.ai/code/session_013QzaZSQikeDkEmuV8ZdTJE
Adds dedicated dimension caps on Target alongside the existing pixel-area cap, plus a byDimensions filter, so a widescreen slot doesn't pick a square rendition with the same total area. <moq-watch>'s auto mode now feeds maxWidth/maxHeight (scaled by devicePixelRatio) instead of pixels; the numeric pixels attribute still pins a total-area budget. https://claude.ai/code/session_013QzaZSQikeDkEmuV8ZdTJE
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis pull request adds a 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| pixels?: number; | ||
|
|
||
| // Maximum desired coded width in pixels. | ||
| maxWidth?: number; |
There was a problem hiding this comment.
IMO rename to width. All of these are maximums.
| // Controls the video selection cap. "auto" derives maxWidth/maxHeight from | ||
| // the element's rendered size so we don't download a 1080p stream for a | ||
| // 360p slot. A number pins a total-pixel-area budget instead. | ||
| #pixelsMode = new Signal<PixelsMode>("auto"); |
There was a problem hiding this comment.
I don't understand why you would ever want to change this from auto? It's confusing, can you delete it entirely?
Summary
Adds a new
pixelsattribute and property to the<moq-watch>element that controls how video renditions are selected based on pixel constraints. This enables two modes of operation: automatic sizing based on the element's rendered dimensions, or a fixed pixel-area budget for bandwidth control.Changes
New
PixelsModetype: Union of"auto"(default) or a non-negative number representing total pixel area budget.Element attribute and property: Added
pixelsto the observed attributes list and implemented getter/setter that parse and manage the pixel mode via a Signal.Auto mode with ResizeObserver: When
pixelsis"auto", the element tracks its rendered size using ResizeObserver and feedsmaxWidth/maxHeightconstraints to the video source, scaled bydevicePixelRatiofor high-DPI displays. This prevents downloading unnecessarily high-resolution streams for small viewport slots.Numeric mode: When
pixelsis set to a number, it pins a total pixel-area budget (pixelsfield on the target) and clears dimension constraints so the two don't conflict.New
byDimensionsfilter: Added rendition filtering function that respectsmaxWidthandmaxHeightconstraints independently. Selects the largest rendition within budget, or falls back to the smallest over-budget option if nothing fits.Target type expansion: Extended the
Targettype with optionalmaxWidthandmaxHeightfields to support dimension-based filtering alongside the existingpixelsfield.Implementation Details
parsePixelsModefunction handles null/empty/invalid inputs by defaulting to"auto".byPixelsfilter.https://claude.ai/code/session_013QzaZSQikeDkEmuV8ZdTJE