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-03-03 10:21:33 +01:00
|
|
|
@Pipe({ name: 'streams' })
|
2022-02-15 13:24:08 +01:00
|
|
|
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-03-03 10:21:33 +01:00
|
|
|
if(participants && Object.keys(participants).length > 0){
|
2022-03-02 17:35:14 +01:00
|
|
|
if (Array.isArray(participants)) {
|
|
|
|
participants.forEach((p) => {
|
|
|
|
streams = streams.concat(p.getAvailableConnections());
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
|
|
|
|
streams = participants.getAvailableConnections();
|
|
|
|
}
|
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-03-23 13:48:17 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-03-03 10:21:33 +01:00
|
|
|
@Pipe({ name: 'streamTypesEnabled' })
|
2022-03-02 17:35:14 +01:00
|
|
|
export class StreamTypesEnabledPipe implements PipeTransform {
|
2022-01-19 17:24:11 +01:00
|
|
|
constructor() {}
|
|
|
|
|
|
|
|
transform(participant: ParticipantAbstractModel): string {
|
2022-03-03 10:21:33 +01:00
|
|
|
const activeStreams = participant?.getConnectionTypesActive().toString();
|
|
|
|
return `(${activeStreams.replace(',', ', ')})`;
|
2022-01-19 17:24:11 +01:00
|
|
|
}
|
|
|
|
}
|