Skip to content

Commit 44938fd

Browse files
chore: reorganize data exported by media-signaling lib (#39870)
1 parent 01159c0 commit 44938fd

26 files changed

+600
-187
lines changed

packages/media-signaling/src/definition/call/IClientMediaCall.ts

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
import type { Emitter } from '@rocket.chat/emitter';
22

33
import type { CallEvents } from './CallEvents';
4-
import type { IMediaStreamWrapper } from '../media/IMediaStreamWrapper';
5-
6-
export type CallActorType = 'user' | 'sip';
7-
8-
export type CallContact = {
9-
type?: CallActorType;
10-
id?: string;
11-
contractId?: string;
12-
13-
displayName?: string;
14-
username?: string;
15-
sipExtension?: string;
16-
};
17-
18-
export type CallRole = 'caller' | 'callee';
4+
import type {
5+
AnyClientMediaCallParticipant,
6+
IClientMediaCallLocalParticipant,
7+
IClientMediaCallRemoteParticipant,
8+
} from './IClientMediaCallParticipant';
9+
import type { CallActorType } from './common';
1910

2011
export type CallService = 'webrtc';
2112

@@ -77,26 +68,13 @@ export type CallFlag = 'internal' | 'create-data-channel';
7768

7869
export interface IClientMediaCall {
7970
callId: string;
80-
role: CallRole;
81-
service: CallService | null;
82-
flags: readonly CallFlag[];
83-
features: readonly CallFeature[];
8471

8572
state: CallState;
8673
ignored: boolean;
8774
signed: boolean;
8875
hidden: boolean;
89-
muted: boolean;
90-
/* if the call was put on hold */
91-
held: boolean;
9276
/* busy = state >= 'accepted' && state < 'hangup' */
9377
busy: boolean;
94-
/* if the other side has put the call on hold */
95-
remoteHeld: boolean;
96-
remoteMute: boolean;
97-
98-
contact: CallContact;
99-
transferredBy: CallContact | null;
10078

10179
/** The timestamp of the moment the call was marked as active for the first time */
10280
activeTimestamp?: Date;
@@ -108,14 +86,9 @@ export interface IClientMediaCall {
10886

10987
emitter: Emitter<CallEvents>;
11088

111-
getLocalMediaStream(tag?: string): IMediaStreamWrapper | null;
112-
getRemoteMediaStream(tag?: string): IMediaStreamWrapper | null;
113-
11489
accept(): void;
11590
reject(): void;
11691
hangup(): void;
117-
setMuted(muted: boolean): void;
118-
setHeld(onHold: boolean): void;
11992
requestScreenShare(requested: boolean): void;
12093
setScreenVideoTrack(videoTrack: MediaStreamTrack | null): Promise<void>;
12194
hasScreenVideoTrack(): boolean;
@@ -126,4 +99,9 @@ export interface IClientMediaCall {
12699

127100
getStats(selector?: MediaStreamTrack | null): Promise<RTCStatsReport | null>;
128101
isFeatureAvailable(feature: CallFeature): boolean;
102+
hasFlag(flag: CallFlag): boolean;
103+
104+
readonly localParticipant: IClientMediaCallLocalParticipant;
105+
readonly remoteParticipants: IClientMediaCallRemoteParticipant[];
106+
readonly participants: AnyClientMediaCallParticipant[];
129107
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import type { IMediaStreamWrapper } from '../media';
2+
import type { CallActorType, CallContact, CallRole } from './common';
3+
4+
export interface IClientMediaCallParticipant {
5+
readonly local: boolean;
6+
7+
readonly participantId: string;
8+
9+
readonly actorType: CallActorType;
10+
11+
readonly actorId: string;
12+
13+
readonly role: CallRole;
14+
15+
readonly muted: boolean;
16+
17+
readonly held: boolean;
18+
19+
readonly contact: CallContact;
20+
21+
getMediaStream(tag?: string): IMediaStreamWrapper | null;
22+
}
23+
24+
export interface IClientMediaCallLocalParticipant extends IClientMediaCallParticipant {
25+
readonly local: true;
26+
27+
setMuted(muted: boolean): void;
28+
setHeld(onHold: boolean): void;
29+
}
30+
31+
export interface IClientMediaCallRemoteParticipant extends IClientMediaCallParticipant {
32+
readonly local: false;
33+
}
34+
35+
export type AnyClientMediaCallParticipant = IClientMediaCallLocalParticipant | IClientMediaCallRemoteParticipant;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import type { IDirectMediaCallData } from './IDirectMediaCallData';
2+
import type { ITempMediaCallData } from './ITempMediaCallData';
3+
4+
export type AnyMediaCallData = ITempMediaCallData | IDirectMediaCallData;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { CallFeature, CallFlag, CallService, CallState } from '../IClientMediaCall';
2+
import type { IClientMediaCallLocalParticipant, IClientMediaCallRemoteParticipant } from '../IClientMediaCallParticipant';
3+
import type { CallContact } from '../common';
4+
5+
export interface IDirectMediaCallData {
6+
readonly confirmed: true;
7+
8+
readonly callId: string;
9+
readonly service: CallService | null;
10+
readonly flags: readonly CallFlag[];
11+
readonly features: readonly CallFeature[];
12+
readonly state: CallState;
13+
readonly hidden: boolean;
14+
15+
readonly transferredBy: CallContact | null;
16+
17+
readonly activeTimestamp?: Date;
18+
19+
readonly tempCallId: string;
20+
21+
readonly localParticipant: IClientMediaCallLocalParticipant;
22+
readonly remoteParticipant: IClientMediaCallRemoteParticipant;
23+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { CallState } from '../IClientMediaCall';
2+
import type { IClientMediaCallLocalParticipant } from '../IClientMediaCallParticipant';
3+
4+
export interface ITempMediaCallData {
5+
readonly confirmed: false;
6+
readonly tempCallId: string;
7+
8+
readonly state: CallState;
9+
10+
readonly title: string;
11+
12+
readonly localParticipant: IClientMediaCallLocalParticipant;
13+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export type * from './AnyMediaCallData';
2+
export type * from './IDirectMediaCallData';
3+
export type * from './ITempMediaCallData';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export type CallActorType = 'user' | 'sip';
2+
3+
export type CallContact = {
4+
type?: CallActorType;
5+
id?: string;
6+
contractId?: string;
7+
8+
displayName?: string;
9+
username?: string;
10+
sipExtension?: string;
11+
};
12+
13+
export type CallRole = 'caller' | 'callee';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
export type * from './CallEvents';
2+
export type * from './callStates';
3+
export type * from './common';
24
export * from './IClientMediaCall';
5+
export type * from './IClientMediaCallParticipant';

0 commit comments

Comments
 (0)