-
Notifications
You must be signed in to change notification settings - Fork 2
FCE-2591: Apply default audio filters #459
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
Changes from all commits
68f6cb3
695141f
7819b31
b509047
7cc49bc
d4a8baf
0675c20
7059d84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,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, | ||
| }; | ||
| } | ||
|
Comment on lines
+1
to
+52
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,7 +12,10 @@ import { | |||||||||||||||||||||
| } from '@fishjam-cloud/react-client'; | ||||||||||||||||||||||
| import { FishjamClient } from '@fishjam-cloud/ts-client'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import { mergeMobileAudioConstraints } from './constraints'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export { RTCView, RTCPIPView, type RTCVideoViewProps, type RTCPIPViewProps } from './overrides/RTCView'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export { | ||||||||||||||||||||||
| ScreenCapturePickerView, | ||||||||||||||||||||||
| startPIP, | ||||||||||||||||||||||
|
|
@@ -90,8 +93,17 @@ export type { | |||||||||||||||||||||
| export type FishjamProviderProps = Omit<ReactClientFishjamProviderProps, 'persistLastDevice' | 'fishjamClient'>; | ||||||||||||||||||||||
| export function FishjamProvider(props: FishjamProviderProps) { | ||||||||||||||||||||||
| const fishjamClient = new FishjamClient({ reconnect: props.reconnect, debug: props.debug, clientType: 'mobile' }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const mergedConstraints = React.useMemo(() => { | ||||||||||||||||||||||
| return { | ||||||||||||||||||||||
| ...props.constraints, | ||||||||||||||||||||||
| audio: mergeMobileAudioConstraints(props.constraints?.audio), | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
| }, [props.constraints]); | ||||||||||||||||||||||
|
Comment on lines
+97
to
+102
|
||||||||||||||||||||||
| const mergedConstraints = React.useMemo(() => { | |
| return { | |
| ...props.constraints, | |
| audio: mergeMobileAudioConstraints(props.constraints?.audio), | |
| }; | |
| }, [props.constraints]); | |
| const mergedConstraints = { | |
| ...props.constraints, | |
| audio: mergeMobileAudioConstraints(props.constraints?.audio), | |
| }; |
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.
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 totrue). 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.