Skip to content

FCE-2591: Apply default audio filters#459

Closed
anna1901 wants to merge 8 commits intomainfrom
FCE-2591/apply-audio-filters
Closed

FCE-2591: Apply default audio filters#459
anna1901 wants to merge 8 commits intomainfrom
FCE-2591/apply-audio-filters

Conversation

@anna1901
Copy link
Contributor

Description

Apply default audio filters that can be overwritten by the user.

Documentation impact

  • Documentation update required
  • Documentation updated in another PR
  • No documentation update required

Types of changes

  • 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
    not work as expected)

@linear
Copy link

linear bot commented Jan 22, 2026

@anna1901 anna1901 requested a review from Copilot January 22, 2026 13:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements default audio filters for mobile clients by introducing Google-specific audio processing constraints. These defaults can be overridden by users through custom audio constraints.

Changes:

  • Added new constraints.ts module with default mobile audio constraints and merge logic
  • Modified FishjamProvider to automatically apply default audio constraints
  • Exported DEFAULT_MOBILE_AUDIO_CONSTRAINTS for user reference

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/mobile-client/src/constraints.ts New file defining default Google audio processing constraints and merge function
packages/mobile-client/src/index.ts Updated to import and apply default audio constraints in FishjamProvider

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +97 to +102
const mergedConstraints = React.useMemo(() => {
return {
...props.constraints,
audio: mergeMobileAudioConstraints(props.constraints?.audio),
};
}, [props.constraints]);
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The useMemo dependency array includes props.constraints which is an object reference. This will cause the memo to recompute on every render if the parent component doesn't memoize the constraints object, defeating the purpose of using useMemo. Consider using individual properties as dependencies (e.g., props.constraints?.audio, props.constraints?.video) or document that users should memoize their constraints object. Alternatively, follow the pattern used in react-client's FishjamProvider which directly passes props.constraints without wrapping in useMemo.

Suggested change
const mergedConstraints = React.useMemo(() => {
return {
...props.constraints,
audio: mergeMobileAudioConstraints(props.constraints?.audio),
};
}, [props.constraints]);
const mergedConstraints = {
...props.constraints,
audio: mergeMobileAudioConstraints(props.constraints?.audio),
};

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +52
/**
* Google-specific audio processing constraints (legacy Chrome constraints).
* These are not part of the standard MediaTrackConstraints type but are supported by WebRTC implementations.
*/
interface GoogleAudioConstraints {
googEchoCancellation?: string | boolean;
googAutoGainControl?: string | boolean;
googNoiseSuppression?: string | boolean;
googTypingNoiseDetection?: string | boolean;
googHighpassFilter?: string | boolean;
}

/**
* Extended MediaTrackConstraints that includes Google-specific audio processing properties.
*/
export type ExtendedMediaTrackConstraints = MediaTrackConstraints & GoogleAudioConstraints;

/**
* Default audio constraints for mobile-client with Google audio processing features enabled.
* These constraints can be overridden by passing custom audio constraints to FishjamProvider.
*/
export const DEFAULT_MOBILE_AUDIO_CONSTRAINTS: ExtendedMediaTrackConstraints = {
googEchoCancellation: true,
googAutoGainControl: true,
googNoiseSuppression: true,
googTypingNoiseDetection: true,
googHighpassFilter: true,
};

/**
* Merges default mobile audio constraints with user-provided constraints.
* User-provided constraints take precedence over defaults.
*
* @param userConstraints - User-provided audio constraints (can be boolean or MediaTrackConstraints)
* @returns Merged audio constraints
*/
export function mergeMobileAudioConstraints(
userConstraints?: ExtendedMediaTrackConstraints | boolean,
): ExtendedMediaTrackConstraints | boolean {
if (userConstraints === false) {
return false;
}

if (userConstraints === true || userConstraints === undefined) {
return DEFAULT_MOBILE_AUDIO_CONSTRAINTS;
}

return {
...DEFAULT_MOBILE_AUDIO_CONSTRAINTS,
...userConstraints,
};
}
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The ExtendedMediaTrackConstraints type and DEFAULT_MOBILE_AUDIO_CONSTRAINTS constant are not exported from the module. Users who want to reference these defaults or understand the type structure for their custom constraints cannot access them. Consider exporting these to improve developer experience and API discoverability. For example, add these exports to index.ts:
export type { ExtendedMediaTrackConstraints } from './constraints';
export { DEFAULT_MOBILE_AUDIO_CONSTRAINTS } from './constraints';

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +11
interface GoogleAudioConstraints {
googEchoCancellation?: string | boolean;
googAutoGainControl?: string | boolean;
googNoiseSuppression?: string | boolean;
googTypingNoiseDetection?: string | boolean;
googHighpassFilter?: string | boolean;
}
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The GoogleAudioConstraints interface allows both string and boolean values (e.g., googEchoCancellation?: string | boolean), but the DEFAULT_MOBILE_AUDIO_CONSTRAINTS only uses boolean values (all set to true). If string values are not needed or supported, consider simplifying the interface to only accept boolean values for clarity. If string values are needed, the comment should explain when and why string values would be used instead of boolean.

Copilot uses AI. Check for mistakes.
@MiloszFilimowski
Copy link
Collaborator

Turns out these filters are enabled natively in react-native-webrtc and will be ignored anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments