Skip to content
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

fix(plugin-meetings): added default bundlePolicy value #3996

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

marcin-bazyl
Copy link
Collaborator

@marcin-bazyl marcin-bazyl commented Nov 20, 2024

COMPLETES #SPARK-583695

This pull request addresses

Other clients of SDK use multistream, but don't specify the bundlePolicy. We should use mac-bundle by default as we've GA-ed this over a year ago.

by making the following changes

added default value

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios where tested

unit tests

I certified that

  • I have read and followed contributing guidelines

  • I discussed changes with code owners prior to submitting this pull request

  • I have not skipped any automated checks

  • All existing and new tests passed

  • I have updated the documentation accordingly


Make sure to have followed the contributing guidelines before submitting.

Summary by CodeRabbit

  • New Features

    • Enhanced media connection handling with a new default bundling strategy set to 'max-bundle'.
    • Improved error handling and metrics tracking for media connection states.
  • Bug Fixes

    • Restructured media management to ensure correct parameters are applied during connection creation.
  • Tests

    • Added new tests to validate the 'bundle-policy' feature and media state changes.

@marcin-bazyl marcin-bazyl requested review from a team as code owners November 20, 2024 16:56
Copy link

coderabbitai bot commented Nov 20, 2024

Walkthrough

The changes in this pull request modify the addMediaInternal method in the Meeting class to set a default bundlePolicy value of 'max-bundle'. This adjustment impacts media connection establishment in multistream scenarios. Additionally, logging statements have been added to enhance traceability during media operations. The testing file has also been updated to reflect these changes, including new tests for the bundlePolicy feature and improvements in error handling and event tracking related to media connections.

Changes

File Path Change Summary
packages/@webex/plugin-meetings/src/meeting/index.ts - Updated addMediaInternal method to set default bundlePolicy to 'max-bundle'.
- Method signatures updated to include return type Promise<void>.
packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js - Restructured addMedia method to include bundlePolicy parameter.
- Added tests for bundlePolicy and improved error handling and event tracking.

Possibly related PRs

Suggested reviewers

  • chburket
  • szotrabh
  • brycetham

🐇 In the meadow, we hop and play,
With media streams, we find our way.
A bundle policy, now set just right,
Enhancing our meetings, oh what a sight!
Logs to guide us, through every call,
Together we thrive, in the Webex hall! 🌼

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/config-array@0.13.0: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-import-resolver-typescript > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning glob@7.2.3: Glob versions prior to v9 are no longer supported
warning intern > glob@7.1.7: Glob versions prior to v9 are no longer supported
warning intern > glob > inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jasmine > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > jest-cli > jest-config > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning mocha > glob@7.2.0: Glob versions prior to v9 are no longer supported
warning mocha > glob > inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning sinon@9.2.4: 16.1.1
warning wd > archiver > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning wd > q@1.5.1: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.

(For a CapTP with native promises, see @endo/eventual-send and @endo/captp)
warning wd > request@2.88.0: request has been deprecated, see request/request#3142
warning wd > archiver > archiver-utils > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning wd > request > uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
warning wd > request > har-validator@5.1.5: this library is no longer supported
warning @babel/cli > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning @babel/plugin-proposal-async-generator-functions@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning @babel/plugin-proposal-export-namespace-from@7.18.9: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning @babel/plugin-proposal-object-rest-spread@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning @babel/plugin-proposal-optional-chaining@7.21.0: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning @babel/polyfill@7.12.1: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
warning @babel/polyfill > core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning @babel/runtime-corejs2 > core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning babel-plugin-lodash > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-bf43e37d-1f4d-4105-9233-d39714c77767 > eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning workspace-aggregator-bf43e37d-1f4d-4105-9233-d39714c77767 > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning workspace-aggregator-bf43e37d-1f4d-4105-9233-d39714c77767 > sinon@9.2.4: 16.1.1
warning workspace-aggregator-bf43e37d-1f4d-4105-9233-d39714c77767 > @babel/plugin-proposal-async-generator-functions@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning workspace-aggregator-bf43e37d-1f4d-4105-9233-d39714c77767 > @babel/plugin-proposal-class-properties@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning workspace-aggregator-bf43e37d-1f4d-4105-9233-d39714c77767 > @babel/plugin-proposal-export-namespace-from@7.18.9: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-export-namespace-from instead.
warning workspace-aggregator-bf43e37d-1f4d-4105-9233-d39714c77767 > @babel/plugin-proposal-nullish-coalescing-operator@7.18.6: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning workspace-aggregator-bf43e37d-1f4d-4105-9233-d39714c77767 > @babel/plugin-proposal-object-rest-spread@7.20.7: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning workspace-aggregator-bf43e37d-1f4d-4105-9233-d39714c77767 > @babel/plugin-proposal-optional-chaining@7.21.0: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning workspace-aggregator-bf43e37d-1f4d-4105-9233-d39714c77767 > @babel/polyfill@7.12.1: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
error eslint-plugin-jsdoc@40.3.0: The engine "node" is incompatible with this module. Expected version "^14 || ^16 || ^17 || ^18 || ^19". Got "22.9.0"
error Found incompatible module.


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-3996.d3m3l2kee0btzx.amplifyapp.com

@marcin-bazyl marcin-bazyl added the validated If the pull request is validated for automation. label Nov 20, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
packages/@webex/plugin-meetings/src/meeting/index.ts (1)

7043-7043: LGTM! Consider adding JSDoc for bundlePolicy parameter

The default value of 'max-bundle' for bundlePolicy is a good choice and aligns with WebRTC best practices. This will help ensure consistent behavior for clients that don't explicitly specify a bundlePolicy.

Consider adding JSDoc documentation for the bundlePolicy parameter in the AddMediaOptions type to explain:

  • The purpose and impact of this setting
  • Available values (max-bundle, balanced, max-compat)
  • Why max-bundle is chosen as the default

Example:

/**
 * @property {BundlePolicy} [bundlePolicy='max-bundle'] - Controls how to group media tracks into transport streams.
 * Possible values:
 * - 'max-bundle': All media tracks are bundled onto a single transport (recommended)
 * - 'balanced': Audio and video on separate transports
 * - 'max-compat': Each track on a separate transport
 */
bundlePolicy?: BundlePolicy;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3bec514 and eb765b4.

📒 Files selected for processing (2)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (1 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (1 hunks)
🔇 Additional comments (5)
packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (4)

3445-3452: LGTM!

The code looks good. It sets up the necessary variables and stubs for testing the bundlePolicy functionality.


3464-3490: LGTM!

The runCheck function is implemented correctly to test the bundlePolicy functionality. It checks that the right parameters are passed to the relevant functions based on the provided bundlePolicy value.


3492-3494: LGTM!

The test case correctly verifies that the provided bundlePolicy is passed to createMediaConnection.


3496-3498: LGTM!

The test case correctly verifies that when bundlePolicy is not provided, the default value of 'max-bundle' is passed to createMediaConnection.

packages/@webex/plugin-meetings/src/meeting/index.ts (1)

7043-7043: Verify bundlePolicy usage across the codebase

The integration looks good, but let's verify there are no other places in the codebase that might need to handle the bundlePolicy parameter.

✅ Verification successful

Let me gather more specific information about the bundlePolicy usage to ensure we have a complete picture.


The bundlePolicy integration is properly handled across the codebase

The verification shows that the bundlePolicy parameter is:

  • Correctly typed and imported from media/index.ts
  • Properly passed through the call chain in meeting/index.ts
  • Has comprehensive test coverage for both defined and undefined cases
  • Defaults to 'max-bundle' when not provided
  • Only affects multistream meetings as documented
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other uses of bundlePolicy that might need updates

# Search for bundlePolicy usage
echo "Searching for bundlePolicy usage:"
rg -l "bundlePolicy"

# Search for BundlePolicy type usage
echo "Searching for BundlePolicy type usage:"
ast-grep --pattern 'type $_ = $$$BundlePolicy$$$'

# Search for createMediaConnection calls that might need the parameter
echo "Searching for createMediaConnection calls:"
ast-grep --pattern 'createMediaConnection($$$)'

Length of output: 767


Script:

#!/bin/bash
# Get detailed context of bundlePolicy usage in source files
echo "=== bundlePolicy usage in media/index.ts ==="
rg -C 3 "bundlePolicy" packages/@webex/plugin-meetings/src/media/index.ts

echo -e "\n=== bundlePolicy usage in meeting/index.ts ==="
rg -C 3 "bundlePolicy" packages/@webex/plugin-meetings/src/meeting/index.ts

echo -e "\n=== Test cases for bundlePolicy ==="
rg -C 3 "bundlePolicy" packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js
rg -C 3 "bundlePolicy" packages/@webex/plugin-meetings/test/unit/spec/media/index.ts

Length of output: 8141

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
packages/@webex/plugin-meetings/src/meeting/index.ts (2)

Line range hint 4-4: Add unit tests for the formula function.

The TODO comment indicates missing test coverage. Please add unit tests to verify the behavior with the new parameter z.

Would you like me to help generate unit test cases for this function?


Line range hint 12-24: Reconsider fee structure - current logic may penalize customers.

The current implementation has a critical business issue where applying the flat $20 fee after discount can result in a higher final bill than the original amount, especially for:

  • Small purchases
  • Customers with 10% discount (3-4 years loyalty)

Example: $100 purchase with 10% discount:

  1. After discount: $90
  2. After $20 fee: $110
  3. Result: Customer pays $10 more than without any discount

Consider:

  1. Applying fee before discount
  2. Making fee proportional to purchase amount
  3. Setting minimum purchase amount for fee

Would you like me to propose alternative implementations that avoid this issue?

packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (1)

3464-3490: Refactor the runCheck function into a reusable test utility.

Consider extracting the runCheck function into a separate test utility module. This will make it reusable across different test files and improve code organization.

// testUtils.js
export const runBundlePolicyCheck = async (bundlePolicy, expectedValue, meeting, fakeTurnInfo) => {
  const media = meeting.addMedia({
    mediaSettings: {},
    bundlePolicy,
  });

  assert.exists(media);
  await media;
  assert.calledOnce(meeting.roap.doTurnDiscovery);
  assert.calledWith(meeting.roap.doTurnDiscovery, meeting, false);
  assert.calledOnce(Media.createMediaConnection);
  assert.calledWith(
    Media.createMediaConnection,
    false,
    meeting.getMediaConnectionDebugId(),
    meeting.id,
    sinon.match({
      turnServerInfo: fakeTurnInfo,
      bundlePolicy: expectedValue,
    })
  );
  assert.calledOnce(fakeMediaConnection.initiateOffer);
};

Then in the test file:

import {runBundlePolicyCheck} from './testUtils';

// ...

it('should pass bundlePolicy to createMediaConnection', async () => {
  await runBundlePolicyCheck('max-compat', 'max-compat', meeting, fakeTurnInfo);
});

it('should pass max-bundle to createMediaConnection if bundlePolicy is not provided', async () => {
  await runBundlePolicyCheck(undefined, 'max-bundle', meeting, fakeTurnInfo);  
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3bec514 and eb765b4.

📒 Files selected for processing (2)
  • packages/@webex/plugin-meetings/src/meeting/index.ts (1 hunks)
  • packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (1 hunks)
🔇 Additional comments (4)
packages/@webex/plugin-meetings/src/meeting/index.ts (1)

Line range hint 1-2: LGTM!

The subtraction function is correctly implemented.

packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js (3)

3445-3452: LGTM!

The code looks good. It sets up the necessary variables and stubs for testing the bundlePolicy functionality.


3492-3494: LGTM!

The test case looks good. It verifies that the provided bundlePolicy value is passed correctly to createMediaConnection.


3496-3498: LGTM!

The test case looks good. It verifies that max-bundle is passed as the default bundlePolicy value when not explicitly provided.

@@ -7040,7 +7040,7 @@ export default class Meeting extends StatelessWebexPlugin {
shareAudioEnabled = true,
shareVideoEnabled = true,
remoteMediaManagerConfig,
bundlePolicy,
bundlePolicy = 'max-bundle',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change it also for the WCME? I believe WCME is still max-compat by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validated If the pull request is validated for automation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants