-
-
Notifications
You must be signed in to change notification settings - Fork 363
refactor(IVideoDevice): add Apply method #5949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideThis pull request adds an Sequence Diagram for Applying Video ConstraintssequenceDiagram
actor User
participant RazorComponent as VideoDevices.razor
participant VideoService as VideoDeviceService
participant MediaJs as media.js
User->>RazorComponent: Click 'Apply Resolution' button (e.g., VGA)
RazorComponent->>VideoService: OnApply(640, 480)
VideoService->>VideoService: Apply(new MediaTrackConstraints { Width = 640, Height = 480 })
Note over VideoService, MediaJs: Service calls JS via Interop
VideoService->>MediaJs: apply({ width: 640, height: 480 })
MediaJs->>MediaJs: Get video track
MediaJs->>MediaJs: Get current settings
MediaJs->>MediaJs: Calculate exact height based on aspect ratio
MediaJs->>MediaJs: Prepare new constraints object
MediaJs->>MediaJs: track.applyConstraints(newSettings)
MediaJs-->>VideoService: return success/failure
VideoService-->>RazorComponent: Task<bool>
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ArgoZhang - I've reviewed your changes - here's some feedback:
- The JavaScript
applyfunction appears to always returnfalse; consider returningtrueupon successful application of constraints. - Using
exactconstraints inapplyConstraintsmight cause errors on some devices; consider usingidealfor better compatibility.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟡 Testing: 1 issue found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| return ret; | ||
| } | ||
|
|
||
| export async function apply(options) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Return value is never updated on success.
ret remains false even on success; update it (or return true) when constraints apply successfully.
Suggested implementation:
ret = true;
}
} catch (ex) {Please verify that inserting ret = true at this position fits the overall logic, meaning that the constraints have been applied by this point. You might need to adjust the placement if additional logic should occur before returning a successful value.
| if (options.width) { | ||
| settings.width = { | ||
| exact: options.width, | ||
| }; | ||
| settings.height = { | ||
| exact: Math.floor(options.width / aspectRatio) | ||
| }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Inconsistency between JS applied constraints and provided parameters.
The function ignores options.height even when passed; either apply options.height to the constraints or update the interface to explicitly reflect that only width is used.
| if (options.width) { | |
| settings.width = { | |
| exact: options.width, | |
| }; | |
| settings.height = { | |
| exact: Math.floor(options.width / aspectRatio) | |
| }; | |
| } | |
| if (options.width) { | |
| settings.width = { | |
| exact: options.width, | |
| }; | |
| if (options.height) { | |
| settings.height = { | |
| exact: options.height, | |
| }; | |
| } else { | |
| settings.height = { | |
| exact: Math.floor(options.width / aspectRatio) | |
| }; | |
| } | |
| } |
| var close = await service.Close(".bb-video"); | ||
| Assert.True(close); | ||
|
|
||
| var apply = await service.Apply(new MediaTrackConstraints() { Width = 640, Height = 480, VideoSelector = ".bb-video" }); | ||
| Assert.True(apply); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Consider testing failure scenarios for the Apply method.
Add tests for when the JS interop call for apply returns false and when it throws an exception.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5949 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 669 669
Lines 30548 30555 +7
Branches 4348 4348
=========================================
+ Hits 30548 30555 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #5948
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add support for applying media track constraints to video devices, allowing dynamic adjustment of video stream properties like width and resolution
New Features:
Enhancements:
Tests: