Skip to content

Commit

Permalink
Remove media access conditional compile - part 1 (#5587)
Browse files Browse the repository at this point in the history
* Remove media access condition compile

* Change files

* update

* update

* address pr comment

* update
  • Loading branch information
fuyan2024 authored Jan 28, 2025
1 parent b0f2c1f commit 167e634
Show file tree
Hide file tree
Showing 13 changed files with 4,950 additions and 4,971 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "patch",
"area": "improvement",
"workstream": "Hard mute",
"comment": "Remove conditional compile media access part 1",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "patch",
"area": "improvement",
"workstream": "Hard mute",
"comment": "Remove conditional compile media access part 1",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
25 changes: 9 additions & 16 deletions packages/calling-stateful-client/src/CallClientState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ export interface VideoStreamRendererViewState {
target: HTMLElement;
}

/* @conditional-compile-remove(media-access) */
/**
* Media access state
* @public
Expand Down Expand Up @@ -562,7 +561,6 @@ export interface RemoteParticipantState {
* Proxy of {@link @azure/communication-calling#SpotlightCallFeature.spotlightedParticipants}.
*/
spotlight?: SpotlightState;
/* @conditional-compile-remove(media-access) */
/**
* Proxy of {@link @azure/communication-calling#Call.MediaAccessCallFeature.MediaAccess}.
*/
Expand Down Expand Up @@ -759,7 +757,6 @@ export interface CallState {
*/
breakoutRooms?: BreakoutRoomsState;

/* @conditional-compile-remove(media-access) */
/**
* Proxy of {@link @azure/communication-calling#MediaAccessFeature}.
*/
Expand Down Expand Up @@ -1001,7 +998,6 @@ export interface CallClientState {
* See documentation of {@Link CallErrors} for details.
*/
latestErrors: CallErrors;
/* @conditional-compile-remove(breakout-rooms) */ /* @conditional-compile-remove(media-access) */
/**
* Stores the latest notifications.
*
Expand Down Expand Up @@ -1124,15 +1120,13 @@ export type CallErrorTarget =
| 'Call.muteAllRemoteParticipants'
| 'Call.setConstraints';

/* @conditional-compile-remove(breakout-rooms) */ /* @conditional-compile-remove(media-access) */
/**
* @public
*/
export type CallNotifications = {
[target in NotificationTarget]: CallNotification;
};

/* @conditional-compile-remove(breakout-rooms) */ /* @conditional-compile-remove(media-access) */
/**
* @public
*/
Expand All @@ -1142,18 +1136,17 @@ export interface CallNotification {
timestamp: Date;
}

/* @conditional-compile-remove(breakout-rooms) */ /* @conditional-compile-remove(media-access) */
/** @public */
export type NotificationTarget =
| 'assignedBreakoutRoomOpened'
| 'assignedBreakoutRoomOpenedPromptJoin'
| 'assignedBreakoutRoomChanged'
| 'breakoutRoomJoined'
| 'breakoutRoomClosingSoon'
| /* @conditional-compile-remove(media-access) */ 'capabilityTurnVideoOnPresent'
| /* @conditional-compile-remove(media-access) */ 'capabilityTurnVideoOnAbsent'
| /* @conditional-compile-remove(media-access) */ 'capabilityUnmuteMicPresent'
| /* @conditional-compile-remove(media-access) */ 'capabilityUnmuteMicAbsent'
| /* @conditional-compile-remove(breakout-rooms) */ 'assignedBreakoutRoomOpened'
| /* @conditional-compile-remove(breakout-rooms) */ 'assignedBreakoutRoomOpenedPromptJoin'
| /* @conditional-compile-remove(breakout-rooms) */ 'assignedBreakoutRoomChanged'
| /* @conditional-compile-remove(breakout-rooms) */ 'breakoutRoomJoined'
| /* @conditional-compile-remove(breakout-rooms) */ 'breakoutRoomClosingSoon'
| 'capabilityTurnVideoOnPresent'
| 'capabilityTurnVideoOnAbsent'
| 'capabilityUnmuteMicPresent'
| 'capabilityUnmuteMicAbsent'
| /* @conditional-compile-remove(together-mode) */ 'togetherModeStarted'
| /* @conditional-compile-remove(together-mode) */ 'togetherModeEnded';

Expand Down
13 changes: 2 additions & 11 deletions packages/calling-stateful-client/src/CallContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import {
ScalingMode,
VideoDeviceInfo
} from '@azure/communication-calling';
/* @conditional-compile-remove(media-access) */
import { MediaAccess, MeetingMediaAccess } from '@azure/communication-calling';
import { RaisedHand } from '@azure/communication-calling';
import { RaisedHand, MediaAccess, MeetingMediaAccess } from '@azure/communication-calling';
/* @conditional-compile-remove(breakout-rooms) */
import { BreakoutRoom, BreakoutRoomsSettings } from '@azure/communication-calling';

Expand Down Expand Up @@ -48,7 +46,6 @@ import {
CallErrorTarget,
CallError
} from './CallClientState';
/* @conditional-compile-remove(breakout-rooms) */ /* @conditional-compile-remove(media-access) */
import { NotificationTarget, CallNotifications, CallNotification } from './CallClientState';
import { TeamsIncomingCallState } from './CallClientState';
import { CaptionsInfo } from './CallClientState';
Expand Down Expand Up @@ -94,7 +91,6 @@ export class CallContext {
private _atomicId: number;
private _callIdHistory: CallIdHistory = new CallIdHistory();
private _timeOutId: { [key: string]: ReturnType<typeof setTimeout> } = {};
/* @conditional-compile-remove(breakout-rooms) */ /* @conditional-compile-remove(media-access) */
private _latestCallIdsThatPushedNotifications: Partial<Record<NotificationTarget, string>> = {};

constructor(userId: CommunicationIdentifierKind, maxListeners = 50) {
Expand All @@ -115,8 +111,7 @@ export class CallContext {
userId: userId,
environmentInfo: undefined,
latestErrors: {} as CallErrors,
/* @conditional-compile-remove(breakout-rooms) */ /* @conditional-compile-remove(media-access) */ latestNotifications:
{} as CallNotifications
latestNotifications: {} as CallNotifications
};
this._emitter = new EventEmitter();
this._emitter.setMaxListeners(maxListeners);
Expand Down Expand Up @@ -1396,15 +1391,13 @@ export class CallContext {
});
}

/* @conditional-compile-remove(breakout-rooms) */ /* @conditional-compile-remove(media-access) */
public setLatestNotification(callId: string, notification: CallNotification): void {
this._latestCallIdsThatPushedNotifications[notification.target] = callId;
this.modifyState((draft: CallClientState) => {
draft.latestNotifications[notification.target] = notification;
});
}

/* @conditional-compile-remove(breakout-rooms) */ /* @conditional-compile-remove(media-access) */
public deleteLatestNotification(callId: string, notificationTarget: NotificationTarget): void {
let callIdToPushLatestNotification = this._latestCallIdsThatPushedNotifications[notificationTarget];
callIdToPushLatestNotification = callIdToPushLatestNotification
Expand All @@ -1421,7 +1414,6 @@ export class CallContext {
});
}

/* @conditional-compile-remove(media-access) */
public setMediaAccesses(callId: string, mediaAccesses: MediaAccess[]): void {
this.modifyState((draft: CallClientState) => {
const call = draft.calls[this._callIdHistory.latestCallId(callId)];
Expand All @@ -1441,7 +1433,6 @@ export class CallContext {
});
}

/* @conditional-compile-remove(media-access) */
public setMeetingMediaAccess(callId: string, meetingMediaAccess: MeetingMediaAccess): void {
this.modifyState((draft: CallClientState) => {
const call = draft.calls[this._callIdHistory.latestCallId(callId)];
Expand Down
4 changes: 0 additions & 4 deletions packages/calling-stateful-client/src/CallSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { LocalRecordingSubscriber } from './LocalRecordingSubscriber';
import { BreakoutRoomsSubscriber } from './BreakoutRoomsSubscriber';
/* @conditional-compile-remove(together-mode) */
import { TogetherModeSubscriber } from './TogetherModeSubscriber';
/* @conditional-compile-remove(media-access) */
import { MediaAccessSubscriber } from './MediaAccessSubscriber';
import { _isTeamsMeeting } from './TypeGuards';

Expand Down Expand Up @@ -67,7 +66,6 @@ export class CallSubscriber {
private _breakoutRoomsSubscriber: BreakoutRoomsSubscriber;
/* @conditional-compile-remove(together-mode) */
private _togetherModeSubscriber: TogetherModeSubscriber;
/* @conditional-compile-remove(media-access) */
private _mediaAccessSubscriber: MediaAccessSubscriber;

constructor(call: CallCommon, context: CallContext, internalContext: InternalCallContext) {
Expand Down Expand Up @@ -136,7 +134,6 @@ export class CallSubscriber {
this._call.feature(Features.TogetherMode)
);

/* @conditional-compile-remove(media-access) */
this._mediaAccessSubscriber = new MediaAccessSubscriber(
this._callIdRef,
this._context,
Expand Down Expand Up @@ -251,7 +248,6 @@ export class CallSubscriber {
this._breakoutRoomsSubscriber.unsubscribe();
/* @conditional-compile-remove(together-mode) */
this._togetherModeSubscriber.unsubscribe();
/* @conditional-compile-remove(media-access) */
this._mediaAccessSubscriber.unsubscribe();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export class CapabilitiesSubscriber {
private _callIdRef: CallIdRef;
private _context: CallContext;
private _capabilitiesFeature: CapabilitiesFeature;
/* @conditional-compile-remove(media-access) */
private _capabilitiesInitialized: boolean = false;

constructor(callIdRef: CallIdRef, context: CallContext, capabilities: CapabilitiesFeature) {
Expand All @@ -38,14 +37,11 @@ export class CapabilitiesSubscriber {
if (data.oldValue.viewAttendeeNames !== data.newValue.viewAttendeeNames) {
this._context.setHideAttendeeNames(this._callIdRef.callId, data);
}
/* @conditional-compile-remove(media-access) */
this.setUnmuteMicAndTurnVideoOnNotification(data);

/* @conditional-compile-remove(media-access) */
this.setUnmuteMicAndTurnVideoOnNotification(data);
this._capabilitiesInitialized = true;
};

/* @conditional-compile-remove(media-access) */
private setUnmuteMicAndTurnVideoOnNotification = (data: CapabilitiesChangeInfo): void => {
if (data.oldValue.turnVideoOn?.isPresent !== data.newValue.turnVideoOn?.isPresent) {
if (
Expand Down
2 changes: 1 addition & 1 deletion packages/calling-stateful-client/src/Converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function convertSdkParticipantToDeclarativeParticipant(
raisedHand: undefined,
role: participant.role,
spotlight: undefined,
/* @conditional-compile-remove(media-access) */ mediaAccess: undefined
mediaAccess: undefined
};
}

Expand Down
4 changes: 0 additions & 4 deletions packages/calling-stateful-client/src/MediaAccessSubscriber.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

/* @conditional-compile-remove(media-access) */
import {
MediaAccessCallFeature,
MediaAccessChangedEvent,
MeetingMediaAccessChangedEvent
} from '@azure/communication-calling';
/* @conditional-compile-remove(media-access) */
import { CallContext } from './CallContext';
/* @conditional-compile-remove(media-access) */
import { CallIdRef } from './CallIdRef';

/* @conditional-compile-remove(media-access) */
/**
* @private
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,7 @@ describe('Stateful call client', () => {
agent.testHelperPushCall(createMockCall());
expect(await waitWithBreakCondition(() => Object.keys(client.getState().calls).length === 1)).toBe(true);
expect(await waitWithBreakCondition(() => Object.keys(client.getState().callsEnded).length === 0)).toBe(true);
// Expecting different results for different flavors, 1 for stable and 2 for beta.
/* @conditional-compile-remove(breakout-rooms) */ /* @conditional-compile-remove(media-access) */
expect(listener.onChangeCalledCount).toBe(2);
/* @conditional-compile-remove(breakout-rooms) */ /* @conditional-compile-remove(media-access) */
return;
expect(listener.onChangeCalledCount).toBe(1);
}
{
const listener = new StateChangeListener(client);
Expand Down
4 changes: 0 additions & 4 deletions packages/calling-stateful-client/src/TestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
CallFeature
} from '@azure/communication-calling';
import { RaiseHandCallFeature, RaisedHandListener, RaisedHand } from '@azure/communication-calling';
/* @conditional-compile-remove(media-access) */
import {
MediaAccessCallFeature,
MediaAccessChangedListener,
Expand Down Expand Up @@ -183,7 +182,6 @@ export class MockRaiseHandCallFeatureImpl implements RaiseHandCallFeature {
/* No state to clean up */
}
}
/* @conditional-compile-remove(media-access) */
/**
* @private
*/
Expand Down Expand Up @@ -496,9 +494,7 @@ export function createMockApiFeatures(
name: 'Default',
isRecordingActive: false,
isTranscriptionActive: false,
/* @conditional-compile-remove(media-access) */
getAllOthersMediaAccess: () => [],
/* @conditional-compile-remove(media-access) */
getMeetingMediaAccess: () => ({ isAudioPermitted: true, isVideoPermitted: true })
});
return generic;
Expand Down
2 changes: 0 additions & 2 deletions packages/calling-stateful-client/src/index-public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export type {
VideoStreamRendererViewState,
CallInfoState
} from './CallClientState';
/* @conditional-compile-remove(breakout-rooms) */ /* @conditional-compile-remove(media-access) */
export type { CallNotification, CallNotifications, NotificationTarget } from './CallClientState';
export type { TeamsIncomingCallState } from './CallClientState';
/* @conditional-compile-remove(remote-ufd) */
Expand Down Expand Up @@ -58,5 +57,4 @@ export type { LocalRecordingCallFeatureState } from './CallClientState';
export type { ConferencePhoneInfo } from './CallClientState';
/* @conditional-compile-remove(breakout-rooms) */
export type { BreakoutRoomsState } from './CallClientState';
/* @conditional-compile-remove(media-access) */
export type { MediaAccessState } from './CallClientState';
Original file line number Diff line number Diff line change
Expand Up @@ -4246,7 +4246,7 @@ export interface NotificationStyles {
}

// @public (undocumented)
export type NotificationTarget = 'assignedBreakoutRoomOpened' | 'assignedBreakoutRoomOpenedPromptJoin' | 'assignedBreakoutRoomChanged' | 'breakoutRoomJoined' | 'breakoutRoomClosingSoon' | /* @conditional-compile-remove(media-access) */ 'capabilityTurnVideoOnPresent' | /* @conditional-compile-remove(media-access) */ 'capabilityTurnVideoOnAbsent' | /* @conditional-compile-remove(media-access) */ 'capabilityUnmuteMicPresent' | /* @conditional-compile-remove(media-access) */ 'capabilityUnmuteMicAbsent' | /* @conditional-compile-remove(together-mode) */ 'togetherModeStarted' | /* @conditional-compile-remove(together-mode) */ 'togetherModeEnded';
export type NotificationTarget = /* @conditional-compile-remove(breakout-rooms) */ 'assignedBreakoutRoomOpened' | /* @conditional-compile-remove(breakout-rooms) */ 'assignedBreakoutRoomOpenedPromptJoin' | /* @conditional-compile-remove(breakout-rooms) */ 'assignedBreakoutRoomChanged' | /* @conditional-compile-remove(breakout-rooms) */ 'breakoutRoomJoined' | /* @conditional-compile-remove(breakout-rooms) */ 'breakoutRoomClosingSoon' | 'capabilityTurnVideoOnPresent' | 'capabilityTurnVideoOnAbsent' | 'capabilityUnmuteMicPresent' | 'capabilityUnmuteMicAbsent' | /* @conditional-compile-remove(together-mode) */ 'togetherModeStarted' | /* @conditional-compile-remove(together-mode) */ 'togetherModeEnded';

// @public
export type NotificationType = keyof NotificationStackStrings;
Expand Down
Loading

0 comments on commit 167e634

Please sign in to comment.