Skip to content

Commit

Permalink
Revert "feat(react-native): detect speaking while muted from stats (#…
Browse files Browse the repository at this point in the history
…1200)"

This reverts commit c5fc1f5.
  • Loading branch information
santhoshvai committed Nov 29, 2023
1 parent 6a156fa commit 21f7c55
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 148 deletions.
27 changes: 10 additions & 17 deletions packages/client/src/devices/MicrophoneManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { createSoundDetector } from '../helpers/sound-detector';
import { isReactNative } from '../helpers/platforms';
import { OwnCapability } from '../gen/coordinator';
import { CallingState } from '../store';
import { detectAudioLevels } from '../helpers/detect-audio-levels';

export class MicrophoneManager extends InputMediaDeviceManager<MicrophoneManagerState> {
private soundDetectorCleanup?: Function;
Expand Down Expand Up @@ -59,27 +58,21 @@ export class MicrophoneManager extends InputMediaDeviceManager<MicrophoneManager
}

private async startSpeakingWhileMutedDetection(deviceId?: string) {
await this.stopSpeakingWhileMutedDetection();
if (isReactNative()) {
this.soundDetectorCleanup = detectAudioLevels(
this.call.state.callStatsReport$,
(event) => {
this.state.setSpeakingWhileMuted(event.isSoundDetected);
},
);
} else {
// Need to start a new stream that's not connected to publisher
const stream = await this.getStream({
deviceId,
});
this.soundDetectorCleanup = createSoundDetector(stream, (event) => {
this.state.setSpeakingWhileMuted(event.isSoundDetected);
});
return;
}
await this.stopSpeakingWhileMutedDetection();
// Need to start a new stream that's not connected to publisher
const stream = await this.getStream({
deviceId,
});
this.soundDetectorCleanup = createSoundDetector(stream, (event) => {
this.state.setSpeakingWhileMuted(event.isSoundDetected);
});
}

private async stopSpeakingWhileMutedDetection() {
if (!this.soundDetectorCleanup) {
if (isReactNative() || !this.soundDetectorCleanup) {
return;
}
this.state.setSpeakingWhileMuted(false);
Expand Down
65 changes: 0 additions & 65 deletions packages/client/src/helpers/detect-audio-levels.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/client/src/stats/state-store-stats-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ const transform = (
}

return {
audioLevel: rtcStreamStats.audioLevel,
bytesSent: rtcStreamStats.bytesSent,
bytesReceived: rtcStreamStats.bytesReceived,
codec: codec?.mimeType,
Expand Down
1 change: 0 additions & 1 deletion packages/client/src/stats/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export type BaseStats = {
audioLevel?: number;
bytesSent?: number;
bytesReceived?: number;
codec?: string;
Expand Down

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import {
ToggleCameraFaceButton,
ToggleVideoPublishingButton,
ScreenShareButton,
useCallStateHooks,
} from '@stream-io/video-react-native-sdk';
import React from 'react';
import { StyleSheet, Text, View, ViewStyle } from 'react-native';
import { StyleSheet, View, ViewStyle } from 'react-native';
import { appTheme } from '../theme';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { Z_INDEX } from '../constants';
Expand All @@ -31,8 +30,6 @@ export const CallControlsComponent = ({
unreadCountIndicator,
landscape,
}: CallControlsComponentProps) => {
const { useMicrophoneState } = useCallStateHooks();
const { isSpeakingWhileMuted } = useMicrophoneState();
const { bottom } = useSafeAreaInsets();
const landscapeStyles: ViewStyle = {
flexDirection: landscape ? 'column-reverse' : 'row',
Expand All @@ -42,38 +39,22 @@ export const CallControlsComponent = ({
};

return (
<View>
{isSpeakingWhileMuted && (
<View style={styles.speakingLabelContainer}>
<Text style={styles.label}>You are muted. Unmute to speak.</Text>
</View>
)}
<View style={[styles.callControlsWrapper, landscapeStyles]}>
<ReactionsButton />
<ChatButton
onPressHandler={onChatOpenHandler}
unreadBadgeCount={unreadCountIndicator}
/>
<ScreenShareButton />
<ToggleVideoPublishingButton />
<ToggleAudioPublishingButton />
<ToggleCameraFaceButton />
<HangUpCallButton onPressHandler={onHangupCallHandler} />
</View>
<View style={[styles.callControlsWrapper, landscapeStyles]}>
<ReactionsButton />
<ChatButton
onPressHandler={onChatOpenHandler}
unreadBadgeCount={unreadCountIndicator}
/>
<ScreenShareButton />
<ToggleVideoPublishingButton />
<ToggleAudioPublishingButton />
<ToggleCameraFaceButton />
<HangUpCallButton onPressHandler={onHangupCallHandler} />
</View>
);
};

const styles = StyleSheet.create({
speakingLabelContainer: {
backgroundColor: appTheme.colors.static_overlay,
paddingVertical: 10,
width: '100%',
},
label: {
textAlign: 'center',
color: appTheme.colors.static_white,
},
callControlsWrapper: {
justifyContent: 'space-evenly',
zIndex: Z_INDEX.IN_FRONT,
Expand Down
7 changes: 0 additions & 7 deletions sample-apps/react-native/dogfood/src/theme.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
const opacityToHex = (opacity: number) => {
return Math.round(opacity * 255)
.toString(16)
.padStart(2, '0');
};

export const appTheme = {
colors: {
static_grey: '#272A30',
static_white: '#ffffff',
static_overlay: '#080707' + opacityToHex(0.85),
primary: '#005FFF',
light_gray: '#979797',
light_blue: '#669FFF',
Expand Down

0 comments on commit 21f7c55

Please sign in to comment.