Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 11 additions & 33 deletions packages/media-signaling/src/definition/call/IClientMediaCall.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
import type { Emitter } from '@rocket.chat/emitter';

import type { CallEvents } from './CallEvents';
import type { IMediaStreamWrapper } from '../media/IMediaStreamWrapper';

export type CallActorType = 'user' | 'sip';

export type CallContact = {
type?: CallActorType;
id?: string;
contractId?: string;

displayName?: string;
username?: string;
sipExtension?: string;
};

export type CallRole = 'caller' | 'callee';
import type {
AnyClientMediaCallParticipant,
IClientMediaCallLocalParticipant,
IClientMediaCallRemoteParticipant,
} from './IClientMediaCallParticipant';
import type { CallActorType } from './common';

export type CallService = 'webrtc';

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

export interface IClientMediaCall {
callId: string;
role: CallRole;
service: CallService | null;
flags: readonly CallFlag[];
features: readonly CallFeature[];

state: CallState;
ignored: boolean;
signed: boolean;
hidden: boolean;
muted: boolean;
/* if the call was put on hold */
held: boolean;
/* busy = state >= 'accepted' && state < 'hangup' */
busy: boolean;
/* if the other side has put the call on hold */
remoteHeld: boolean;
remoteMute: boolean;

contact: CallContact;
transferredBy: CallContact | null;

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

emitter: Emitter<CallEvents>;

getLocalMediaStream(tag?: string): IMediaStreamWrapper | null;
getRemoteMediaStream(tag?: string): IMediaStreamWrapper | null;

accept(): void;
reject(): void;
hangup(): void;
setMuted(muted: boolean): void;
setHeld(onHold: boolean): void;
requestScreenShare(requested: boolean): void;
setScreenVideoTrack(videoTrack: MediaStreamTrack | null): Promise<void>;
hasScreenVideoTrack(): boolean;
Expand All @@ -126,4 +99,9 @@ export interface IClientMediaCall {

getStats(selector?: MediaStreamTrack | null): Promise<RTCStatsReport | null>;
isFeatureAvailable(feature: CallFeature): boolean;
hasFlag(flag: CallFlag): boolean;

readonly localParticipant: IClientMediaCallLocalParticipant;
readonly remoteParticipants: IClientMediaCallRemoteParticipant[];
readonly participants: AnyClientMediaCallParticipant[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { IMediaStreamWrapper } from '../media';
import type { CallActorType, CallContact, CallRole } from './common';

export interface IClientMediaCallParticipant {
readonly local: boolean;

readonly participantId: string;

readonly actorType: CallActorType;

readonly actorId: string;

readonly role: CallRole;

readonly muted: boolean;

readonly held: boolean;

readonly contact: CallContact;

getMediaStream(tag?: string): IMediaStreamWrapper | null;
}

export interface IClientMediaCallLocalParticipant extends IClientMediaCallParticipant {
readonly local: true;

setMuted(muted: boolean): void;
setHeld(onHold: boolean): void;
}

export interface IClientMediaCallRemoteParticipant extends IClientMediaCallParticipant {
readonly local: false;
}

export type AnyClientMediaCallParticipant = IClientMediaCallLocalParticipant | IClientMediaCallRemoteParticipant;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { IDirectMediaCallData } from './IDirectMediaCallData';
import type { ITempMediaCallData } from './ITempMediaCallData';

export type AnyMediaCallData = ITempMediaCallData | IDirectMediaCallData;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { CallFeature, CallFlag, CallService, CallState } from '../IClientMediaCall';
import type { IClientMediaCallLocalParticipant, IClientMediaCallRemoteParticipant } from '../IClientMediaCallParticipant';
import type { CallContact } from '../common';

export interface IDirectMediaCallData {
readonly confirmed: true;

readonly callId: string;
readonly service: CallService | null;
readonly flags: readonly CallFlag[];
readonly features: readonly CallFeature[];
readonly state: CallState;
readonly hidden: boolean;

readonly transferredBy: CallContact | null;

readonly activeTimestamp?: Date;

readonly tempCallId: string;

readonly localParticipant: IClientMediaCallLocalParticipant;
readonly remoteParticipant: IClientMediaCallRemoteParticipant;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { CallState } from '../IClientMediaCall';
import type { IClientMediaCallLocalParticipant } from '../IClientMediaCallParticipant';

export interface ITempMediaCallData {
readonly confirmed: false;
readonly tempCallId: string;

readonly state: CallState;

readonly title: string;

readonly localParticipant: IClientMediaCallLocalParticipant;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type * from './AnyMediaCallData';
export type * from './IDirectMediaCallData';
export type * from './ITempMediaCallData';
13 changes: 13 additions & 0 deletions packages/media-signaling/src/definition/call/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export type CallActorType = 'user' | 'sip';

export type CallContact = {
type?: CallActorType;
id?: string;
contractId?: string;

displayName?: string;
username?: string;
sipExtension?: string;
};

export type CallRole = 'caller' | 'callee';
3 changes: 3 additions & 0 deletions packages/media-signaling/src/definition/call/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
export type * from './CallEvents';
export type * from './callStates';
export type * from './common';
export * from './IClientMediaCall';
export type * from './IClientMediaCallParticipant';
Loading
Loading