2022-01-19 17:24:11 +01:00
|
|
|
import { Pipe, PipeTransform } from '@angular/core';
|
2022-01-26 11:30:30 +01:00
|
|
|
import { StreamModel, ParticipantAbstractModel } from '../models/participant.model';
|
2022-01-19 17:24:11 +01:00
|
|
|
|
2022-02-15 13:24:08 +01:00
|
|
|
@Pipe({ name: 'streams' })
|
|
|
|
export class ParticipantStreamsPipe implements PipeTransform {
|
2022-01-19 17:24:11 +01:00
|
|
|
constructor() {}
|
|
|
|
|
2022-01-26 11:30:30 +01:00
|
|
|
transform(participants: ParticipantAbstractModel[] | ParticipantAbstractModel): StreamModel[] {
|
2022-02-15 13:24:08 +01:00
|
|
|
let streams: StreamModel[] = [];
|
2022-01-19 17:24:11 +01:00
|
|
|
if (Array.isArray(participants)) {
|
|
|
|
participants.forEach((p) => {
|
2022-02-15 13:24:08 +01:00
|
|
|
streams = streams.concat(Array.from(p.streams.values()));
|
2022-01-19 17:24:11 +01:00
|
|
|
});
|
|
|
|
} else {
|
2022-02-15 13:24:08 +01:00
|
|
|
streams = Array.from(participants.streams.values());
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
2022-02-15 13:24:08 +01:00
|
|
|
return streams;
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-15 13:24:08 +01:00
|
|
|
@Pipe({ name: 'streamsEnabled', pure: false })
|
|
|
|
export class StreamsEnabledPipe implements PipeTransform {
|
2022-01-19 17:24:11 +01:00
|
|
|
constructor() {}
|
|
|
|
|
|
|
|
transform(participant: ParticipantAbstractModel): string {
|
2022-02-25 11:19:21 +01:00
|
|
|
return `(${participant?.getConnectionTypesActive().toString().replace(',', ', ')})`;
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
}
|