mirror of
https://github.com/vector-im/element-call.git
synced 2026-10-16 23:45:50 +00:00
use the matrixRtcSdk
This commit is contained in:
@@ -6,34 +6,33 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { type RemoteParticipant } from "livekit-client";
|
||||
import {
|
||||
type AudioMediaTrack,
|
||||
type Behavior,
|
||||
type ObservableScope,
|
||||
} from "@element-hq/matrixrtc-sdk";
|
||||
import { combineLatest, map, of, switchMap } from "rxjs";
|
||||
import { logger } from "matrix-js-sdk/lib/logger";
|
||||
|
||||
import { type Behavior } from "../Behavior";
|
||||
import { createVolumeControls, type VolumeControls } from "../VolumeControls";
|
||||
import {
|
||||
type BaseUserMediaInputs,
|
||||
type BaseUserMediaViewModel,
|
||||
createBaseUserMedia,
|
||||
} from "./UserMediaViewModel";
|
||||
import { type ObservableScope } from "../ObservableScope";
|
||||
import { memberTrack$ } from "./MemberMediaViewModel";
|
||||
|
||||
export interface RemoteUserMediaViewModel
|
||||
extends BaseUserMediaViewModel, VolumeControls {
|
||||
local: false;
|
||||
/**
|
||||
* Whether we are waiting for this user's LiveKit participant to exist. This
|
||||
* could be because either we or the remote party are still connecting.
|
||||
* Whether we are waiting for this user's media to arrive. This could be
|
||||
* because either we or the remote party are still connecting.
|
||||
*/
|
||||
waitingForMedia$: Behavior<boolean>;
|
||||
}
|
||||
|
||||
export interface RemoteUserMediaInputs extends Omit<
|
||||
BaseUserMediaInputs,
|
||||
"statsType"
|
||||
> {
|
||||
participant$: Behavior<RemoteParticipant | null>;
|
||||
export interface RemoteUserMediaInputs extends BaseUserMediaInputs {
|
||||
pretendToBeDisconnected$: Behavior<boolean>;
|
||||
}
|
||||
|
||||
@@ -41,19 +40,15 @@ export function createRemoteUserMedia(
|
||||
scope: ObservableScope,
|
||||
{ pretendToBeDisconnected$, ...inputs }: RemoteUserMediaInputs,
|
||||
): RemoteUserMediaViewModel {
|
||||
const baseUserMedia = createBaseUserMedia(scope, {
|
||||
...inputs,
|
||||
statsType: "inbound-rtp",
|
||||
});
|
||||
const baseUserMedia = createBaseUserMedia(scope, inputs);
|
||||
|
||||
const waitingForMedia$ = scope.behavior(
|
||||
combineLatest(
|
||||
[inputs.livekitRoom$, inputs.participant$],
|
||||
(livekitRoom, participant) =>
|
||||
// If livekitRoom is undefined, the user is not attempting to publish on
|
||||
// any transport and so we shouldn't expect a participant. (They might
|
||||
// be a subscribe-only bot for example.)
|
||||
livekitRoom !== undefined && participant === null,
|
||||
[inputs.focusUrl$, inputs.media$],
|
||||
// Without a transport the user is not attempting to publish anywhere
|
||||
// and so we shouldn't expect media. (They might be a subscribe-only bot
|
||||
// for example.)
|
||||
(focusUrl, media) => focusUrl !== undefined && media === null,
|
||||
),
|
||||
);
|
||||
waitingForMedia$.pipe(scope.bind()).subscribe((waiting) => {
|
||||
@@ -65,7 +60,9 @@ export function createRemoteUserMedia(
|
||||
...createVolumeControls(scope, {
|
||||
pretendToBeDisconnected$,
|
||||
sink$: scope.behavior(
|
||||
inputs.participant$.pipe(map((p) => (volume) => p?.setVolume(volume))),
|
||||
memberTrack$<AudioMediaTrack>(inputs.media$, "microphone").pipe(
|
||||
map((track) => (volume: number) => track?.setVolume(volume)),
|
||||
),
|
||||
),
|
||||
}),
|
||||
local: false,
|
||||
|
||||
Reference in New Issue
Block a user