Repository navigation
gql-server: Allow all users to share screens (not only presenter) (backend portion) - #21303
Conversation
Add fields: contentType: to identify whether is camera or screenshare hasAudio: useful for screenshare focused: indicates if this screenshare will be shown in presentation area
|
Caution Review failedThe pull request is closed. WalkthroughThe changes involve enhancements to the webcam broadcasting functionality within the application. Key modifications include updates to method signatures to incorporate new parameters such as Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Outside diff range and nitpick comments (13)
bigbluebutton-html5/imports/ui/components/video-provider/mutations.ts (1)
4-4: Consider renaming the mutation for clarity.Now that this mutation is used for both camera broadcasts and screen sharing, the name
CameraBroadcastStartmight be misleading. Consider renaming it to something more generic, such asStreamBroadcastStart, to better reflect its expanded functionality.bbb-graphql-actions/src/actions/cameraSetFocused.ts (1)
13-32: Use lowercase 'string' type and consider adding a comment for clarity.
- Replace
Stringwithstringin the routing object for consistency and to address the static analysis hint:const routing = { meetingId: sessionVariables['x-hasura-meetingid'] as string, userId: sessionVariables['x-hasura-userid'] as string };
- Consider adding a brief comment explaining the purpose of the
SetCamFocusStateReqMsgevent for better code documentation:// Event to set the focus state of a camera/screen share stream const eventName = `SetCamFocusStateReqMsg`;These changes will improve code consistency and clarity.
🧰 Tools
🪛 Biome
[error] 15-15: Don't use 'String' as a type.
Use lowercase primitives for consistency.
Safe fix: Use 'string' instead(lint/complexity/noBannedTypes)
[error] 16-16: Don't use 'String' as a type.
Use lowercase primitives for consistency.
Safe fix: Use 'string' instead(lint/complexity/noBannedTypes)
bbb-graphql-server/metadata/databases/BigBlueButton/tables/public_v_user_camera.yaml (1)
32-34: LGTM! Consider future renaming for clarity.The addition of
contentType,focused, andhasAudiocolumns to theselect_permissionsfor thebbb_clientrole aligns well with the PR objectives. These changes effectively support the new functionality of allowing all users to share screens.As mentioned in the PR objectives, there's a plan to rename the
user_cameracollection touser_streamin the future. When implementing this change, consider updating the following:
- The
custom_namefield in this file (currently set touser_camera).- Any references to
user_camerain other parts of the codebase.- Documentation and comments referencing this collection.
This renaming will improve clarity and better represent the expanded functionality of this collection.
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Webcams.scala (1)
Line range hint
1-108: Summary of changes and next stepsThe changes to the
WebcamStreamcase class successfully implement the new fields required for supporting screen sharing for all users. However, there are a few areas that require attention:
- Verify that all usages of
WebcamStreamin the codebase are updated to accommodate the new fields.- Review and update the methods in the
Webcamsobject and class to ensure they handle the new fields correctly.- Consider updating the
isPublishermethod to account for the newcontentTypefield when differentiating between camera streams and screen shares.Please address these points to ensure a smooth integration of the new features.
As mentioned in the PR objectives, there's a plan to rename the
user_cameracollection touser_stream. Consider whether this renaming should be part of this PR or if it should be done in a separate PR. If it's part of this PR, update the relevant parts of the code (including comments and documentation) to reflect this change.bigbluebutton-html5/imports/ui/components/video-provider/container.tsx (2)
47-47: Approve addition ofcontentType, but consider screen sharing implementationThe addition of
contentType: 'camera'to thecameraBroadcastStartmutation aligns with the PR objectives. However, there are a few points to consider:
- This change doesn't fully implement the "Allow all users to share screens" objective mentioned in the PR summary.
- The hardcoded 'camera' value suggests this function is specific to camera broadcasts.
Consider the following suggestions:
- Implement a separate function for initiating screen shares, or
- Modify
sendUserShareWebcamto accept acontentTypeparameter, making it more flexible:const sendUserShareMedia = (mediaId: string, contentType: 'camera' | 'screen') => { return cameraBroadcastStart({ variables: { cameraId: mediaId, contentType } }); };This approach would allow the function to handle both camera and screen sharing, aligning better with the PR objectives.
Expand Screen Sharing Implementation in
VideoProviderContainerThe current changes introduce the
contentTypeparameter but do not fully integrate screen sharing functionality as intended by the PR objective "Allow all users to share screens". To ensure comprehensive screen sharing capabilities:
Add Dedicated Screen Sharing Functions:
- Implement functions to initiate and manage screen sharing, similar to
sendUserShareWebcam.Update
VideoProviderProps:
- Extend the
VideoProvidercomponent to accept and handle screen sharing-related props.Integrate with Existing Screen Sharing Logic:
- Ensure that screen share streams are properly managed and displayed by leveraging the existing screen sharing implementations identified in the codebase.
🔗 Analysis chain
Line range hint
1-180: Consider expanding implementation for screen sharing functionalityWhile the addition of the
contentTypeparameter is a step towards implementing screen sharing, the current changes don't fully reflect the PR objective of "Allow all users to share screens". Consider the following points:
- No new functions or components have been added to handle screen sharing specifically.
- The
VideoProvidercomponent props haven't been updated to include screen sharing capabilities.To fully implement screen sharing:
- Add a new function to initiate screen sharing, similar to
sendUserShareWebcam.- Update the
VideoProvidercomponent to include props for screen sharing.- Modify the
usersVideofiltering logic to accommodate screen share streams.- Update the
VideoProviderrender method to display screen shares appropriately.To ensure consistency across the codebase, let's check for any related changes:
This will help identify if screen sharing functionality is implemented elsewhere or if additional changes are needed.
To accurately search for screen sharing related changes in TypeScript files, let's adjust the file type specification:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for screen sharing related changes rg --type typescript -i "screen.?shar(e|ing)"Length of output: 82
Script:
#!/bin/bash # Search for screen sharing related changes in TypeScript files using the correct type or extension rg --type ts -i "screen.?shar(e|ing)"Length of output: 10961
bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/WebcamsMsgs.scala (2)
21-25: LGTM: Consistent changes to UserBroadcastCamStartMsgBody.The addition of
contentTypeandhasAudiofields toUserBroadcastCamStartMsgBodyis consistent with the earlier changes and aligns with the PR objectives.Consider grouping related message classes together in the file for better organization. For example, you could move
UserBroadcastCamStartMsgandUserBroadcastCamStartMsgBodycloser toUserBroadcastCamStartedEvtMsgandUserBroadcastCamStartedEvtMsgBody.
188-194: LGTM: New SetCamFocusStateReqMsg adds useful functionality.The addition of
SetCamFocusStateReqMsgandSetCamFocusStateReqMsgBodyintroduces the ability to change the video focus state, which aligns with the PR objective of enhancing screen sharing capabilities.Consider adding a brief comment to explain the purpose of the
setByfield inSetCamFocusStateReqMsgBody. This would improve code clarity and maintainability.akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/testdata/FakeUserGenerator.scala (1)
118-118: Approve changes with suggestions for improvementThe modifications to the
WebcamStreaminstantiation align with the PR objectives by introducing thecontentTypefield andhasAudioparameter. However, I have a few suggestions to enhance the implementation:
Consider making the
contentTypeparameter dynamic instead of hardcoding "camera". This would allow the method to create both camera and screen share streams, aligning better with the PR's goal of enabling screen sharing for all users.The method name
createFakeWebcamStreamFormight be misleading now that it can potentially represent screen shares as well. Consider renaming it to something likecreateFakeUserStreamForto better reflect its expanded functionality.Could you please clarify the purpose of the
focusedparameter? It's not mentioned in the PR objectives, and its intended use is not immediately clear.Here's a suggested refactor to address points 1 and 2:
-def createFakeWebcamStreamFor(userId: String, subscribers: Set[String]): WebcamStream = { +def createFakeUserStreamFor(userId: String, contentType: String, subscribers: Set[String]): WebcamStream = { val streamId = RandomStringGenerator.randomAlphanumericString(10) - WebcamStream(streamId, userId, "camera", hasAudio = false, focused = false, subscribers) + WebcamStream(streamId, userId, contentType, hasAudio = false, focused = false, subscribers) }This change allows the method to create both camera and screen share streams, providing more flexibility and better aligning with the PR objectives.
bbb-graphql-server/bbb_schema.sql (3)
640-642: LGTM! Consider adding a check constraint forcontentType.The additions to the
user_cameratable align well with the PR objectives. ThecontentTypecolumn allows differentiation between camera and screen share streams,hasAudiois relevant for screen sharing with audio, andfocusedcould be used to highlight a specific stream.Consider adding a check constraint to ensure
contentTypeonly accepts valid values:ALTER TABLE "user_camera" ADD CONSTRAINT "check_content_type" CHECK ("contentType" IN ('camera', 'screenshare'));
1531-1531: LGTM! Consider aligning constraints withuser_cameratable.The addition of the
contentTypecolumn to thescreensharetable is consistent with the changes made to theuser_cameratable and supports the PR objectives.For consistency, consider adding a check constraint similar to the one suggested for the
user_cameratable:ALTER TABLE "screenshare" ADD CONSTRAINT "check_content_type" CHECK ("contentType" IN ('camera', 'screenshare'));This will ensure data integrity and consistency across both tables.
Line range hint
1-1647: Overall, the changes effectively support screen sharing for all users.The modifications to the
user_cameraandscreensharetables, along with the new index, provide a solid foundation for implementing screen sharing functionality for all users. The changes align well with the PR objectives and maintain consistency across the schema.Consider the following architectural advice:
- Ensure that the application logic properly handles the new
contentTypefield when managing streams.- Update any existing queries or views that rely on the modified tables to take advantage of the new structure.
- If not already planned, consider adding appropriate access control mechanisms to manage who can initiate screen sharing based on meeting settings or user roles.
bbb-graphql-actions/src/actions/cameraBroadcastStart.ts (1)
14-20: Consider adding unit tests forcontentTypevalidationTo ensure the new validation logic for
contentTypeworks as expected, consider adding unit tests that cover both valid and invalid values. This will help prevent future regressions and ensure robust input handling.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (11)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/webcam/UserBroadcastCamStartMsgHdlr.scala (3 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/UserCameraDAO.scala (2 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Webcams.scala (1 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/testdata/FakeUserGenerator.scala (1 hunks)
- bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/WebcamsMsgs.scala (2 hunks)
- bbb-graphql-actions/src/actions/cameraBroadcastStart.ts (2 hunks)
- bbb-graphql-actions/src/actions/cameraSetFocused.ts (1 hunks)
- bbb-graphql-server/bbb_schema.sql (2 hunks)
- bbb-graphql-server/metadata/databases/BigBlueButton/tables/public_v_user_camera.yaml (1 hunks)
- bigbluebutton-html5/imports/ui/components/video-provider/container.tsx (1 hunks)
- bigbluebutton-html5/imports/ui/components/video-provider/mutations.ts (1 hunks)
🧰 Additional context used
🪛 Biome
bbb-graphql-actions/src/actions/cameraSetFocused.ts
[error] 15-15: Don't use 'String' as a type.
Use lowercase primitives for consistency.
Safe fix: Use 'string' instead(lint/complexity/noBannedTypes)
[error] 16-16: Don't use 'String' as a type.
Use lowercase primitives for consistency.
Safe fix: Use 'string' instead(lint/complexity/noBannedTypes)
🔇 Additional comments (11)
bigbluebutton-html5/imports/ui/components/video-provider/mutations.ts (2)
4-4: LGTM! The changes align with the PR objectives.The addition of the
contentTypeparameter to theCameraBroadcastStartmutation is correct and aligns with the PR objectives of introducing a newcontentTypefield to differentiate between camera and screen share streams.Also applies to: 7-7
Line range hint
12-18: Verify if CAMERA_BROADCAST_STOP needs updating.The
CAMERA_BROADCAST_STOPmutation hasn't been updated to include thecontentTypeparameter. Please verify if this is intentional or if it should be updated to match the changes made toCAMERA_BROADCAST_START.✅ Verification successful
Verification Complete: The
CAMERA_BROADCAST_STOPmutation does not require thecontentTypeparameter and is correctly implemented as is. No updates are necessary.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check if CAMERA_BROADCAST_STOP is used differently for camera and screen sharing # Test: Search for usages of CAMERA_BROADCAST_STOP rg --type typescript -A 5 'CAMERA_BROADCAST_STOP'Length of output: 84
Script:
#!/bin/bash # Description: Search for usages of CAMERA_BROADCAST_STOP in .ts and .tsx files rg --glob '*.ts' --glob '*.tsx' -A 5 'CAMERA_BROADCAST_STOP'Length of output: 2774
Script:
#!/bin/bash # Description: Retrieve the definition of CAMERA_BROADCAST_START in .ts and .tsx files rg --glob '*.ts' --glob '*.tsx' -A 10 'export const CAMERA_BROADCAST_START'Length of output: 1158
bbb-graphql-actions/src/actions/cameraSetFocused.ts (1)
1-2: LGTM: Import statements are appropriate.The import statements correctly bring in the necessary types and validation functions for the
buildRedisMessagefunction.akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Webcams.scala (1)
Line range hint
7-98: Consider updatingWebcamsobject and class methods to handle newWebcamStreamfields.While the
WebcamStreamcase class has been updated with new fields (contentType,hasAudio, andfocused), the methods in theWebcamsobject and class haven't been modified to handle these new fields. Please review the following methods and update them if necessary:
addWebcamStreamremoveWebcamStreamaddSubscriberremoveSubscriberisPublisherParticularly, the
isPublishermethod might need to consider thecontentTypefield to differentiate between camera streams and screen shares.To help identify which methods might need updating, please run the following script:
#!/bin/bash # Description: Analyze Webcams object and class methods # Search for method definitions in Webcams object and class echo "Searching for method definitions in Webcams object and class:" ast-grep --lang scala --pattern $'(object|class) Webcams { $$$ def $METHODNAME($$$) { $$$ } $$$ }' # Search for usages of WebcamStream fields within these methods echo "Searching for usages of WebcamStream fields within Webcams methods:" rg --type scala -A 5 'def\s+\w+.*WebcamStream.*\{[\s\S]*?(streamId|userId|contentType|hasAudio|focused|subscribers)'Please review the output of this script to determine which methods need to be updated to handle the new
WebcamStreamfields.bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/WebcamsMsgs.scala (2)
Line range hint
1-194: Summary: Changes successfully implement PR objectives.The modifications to
UserBroadcastCamStartedEvtMsgBodyandUserBroadcastCamStartMsgBody, along with the addition ofSetCamFocusStateReqMsg, successfully implement the PR objectives of enabling screen sharing for all users. The newcontentTypefield allows differentiation between camera and screen share streams, while thehasAudiofield provides important metadata about the stream's audio capabilities.The introduction of the focus state functionality enhances control over shared screens, which is particularly useful in a multi-user screen sharing environment.
These changes lay a solid foundation for the planned future renaming of the
user_cameracollection touser_stream, as mentioned in the PR summary.
10-13: LGTM: Changes align with PR objectives.The addition of
contentTypeandhasAudiofields toUserBroadcastCamStartedEvtMsgBodyis consistent with the PR objectives. These changes support differentiating between camera and screen share streams, and provide information about audio presence in the stream.To ensure these changes are consistently applied throughout the codebase, let's verify the usage:
✅ Verification successful
****: The
contentTypeandhasAudiofields inUserBroadcastCamStartedEvtMsgBodyare consistently used across the codebase, aligning with the PR objectives.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify usage of UserBroadcastCamStartedEvtMsgBody with new fields # Test: Search for UserBroadcastCamStartedEvtMsgBody usage rg --type scala -A 5 "UserBroadcastCamStartedEvtMsgBody"Length of output: 1804
bbb-graphql-server/bbb_schema.sql (1)
647-647: LGTM! Efficient index for querying streams.The new index on
user_cameratable is well-designed. It will improve query performance when filtering streams by meeting, content type, and focus status, which aligns with the new table structure and the PR objectives.akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/UserCameraDAO.scala (3)
17-17: Confirm that the projection mapping includes all fieldsThe projection in the
*method correctly includes the new fieldscontentType,hasAudio, andfocused. This ensures proper mapping between the table columns and theUserCameraDbModel.
21-23: New columns are correctly added to the table schemaThe new columns
contentType,hasAudio, andfocusedare properly defined in the table schema, matching the corresponding fields inUserCameraDbModel.
35-37: Verify thatWebcamStreamincludes the new fieldsThe
insertmethod now accesseswebcam.contentType,webcam.hasAudio, andwebcam.focused. Please ensure that theWebcamStreamclass has these fields defined to prevent potential runtime errors.To confirm, you can run the following script:
✅ Verification successful
Verification Successful
The
WebcamStreamclass includes the fieldscontentType,hasAudio, andfocusedas required.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that WebcamStream includes the new fields # Test: Search for the definition of WebcamStream with the new fields. ast-grep --lang scala --pattern $'case class WebcamStream( streamId: $_, userId: $_, contentType: $_, hasAudio: $_, focused: $_, $$$ )'Length of output: 947
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/webcam/UserBroadcastCamStartMsgHdlr.scala (1)
Line range hint
20-54: Changes are acceptable and align with PR objectivesThe additions of
contentTypeandhasAudioparameters in thebroadcastEventmethod and theWebcamStreamconstructor are correctly implemented. The logic forstartFocusedaccurately determines whether the stream should be focused based on the content type and user role.
…m/UserBroadcastCamStartMsgHdlr.scala Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
Automated tests Summary✅ All the CI tests have passed! |


We are enabling screen sharing for all users, not just the presenter.
Implementation:
user_cameracollection.user_camerastreams.contentTypefield to indicate if a stream is from a camera or a screen share.user_cameratouser_stream.GraphQL Schema Updates:
Subscription
user_camera:Mutation
cameraBroadcastStart:contentTypehasAudioMutation
cameraSetFocused: (only presenter can call)streamIdfocused