123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- import { getLogger } from '@jitsi/logger';
-
- import { MediaType } from '../../service/RTC/MediaType';
- import { type IPeerMediaInfo, default as SignalingLayer } from '../../service/RTC/SignalingLayer';
- import ChatRoom from '../xmpp/ChatRoom';
-
- const logger = getLogger('modules/proxyconnection/CustomSignalingLayer');
-
- /**
- * Custom semi-mock implementation for the Proxy connection service.
- */
- export default class CustomSignalingLayer extends SignalingLayer {
- /**
- * A map that stores SSRCs of remote streams.
- * @type {Map<number, string>} maps SSRC number to jid
- */
- private ssrcOwners: Map<number, string>;
-
- /**
- *
- * @type {ChatRoom|null}
- */
- public chatRoom: ChatRoom | null;
-
- /**
- * Creates new instance.
- */
- constructor() {
- super();
-
- this.ssrcOwners = new Map<number, string>();
- this.chatRoom = null;
- }
-
- /**
- * @inheritDoc
- */
- getPeerMediaInfo(_owner: string, _mediaType: MediaType, _sourceName: string): IPeerMediaInfo {
- return { };
- }
-
- /**
- * @inheritDoc
- */
- getPeerSourceInfo(_owner: string, _sourceName: string): any {
- return undefined;
- }
-
- /**
- * @inheritDoc
- */
- getSSRCOwner(ssrc: number): string | undefined {
- return this.ssrcOwners.get(ssrc);
- }
-
- /**
- * @inheritDoc
- */
- getTrackSourceName(_ssrc: number): string | undefined {
- return undefined;
- }
-
- /**
- * @inheritDoc
- */
- removeSSRCOwners(ssrcList: number[]): void {
- if (!ssrcList?.length) {
- return;
- }
-
- for (const ssrc of ssrcList) {
- this.ssrcOwners.delete(ssrc);
- }
- }
-
- /**
- * Sets the <tt>ChatRoom</tt> instance used.
- * @param {ChatRoom} room
- */
- setChatRoom(room: ChatRoom): void {
- this.chatRoom = room;
- }
-
- /**
- * @inheritDoc
- */
- setSSRCOwner(ssrc: number, endpointId: string): void {
- if (typeof ssrc !== 'number') {
- throw new TypeError(`SSRC(${ssrc}) must be a number`);
- }
-
- // Now signaling layer instance is shared between different JingleSessionPC instances, so although very unlikely
- // an SSRC conflict could potentially occur. Log a message to make debugging easier.
- const existingOwner = this.ssrcOwners.get(ssrc);
-
- if (existingOwner && existingOwner !== endpointId) {
- logger.error(`SSRC owner re-assigned from ${existingOwner} to ${endpointId}`);
- }
- this.ssrcOwners.set(ssrc, endpointId);
- }
-
- /**
- * @inheritDoc
- */
- setTrackMuteStatus(_sourceName: string, _muted: boolean): boolean {
- return false;
- }
-
- /**
- * @inheritDoc
- */
- setTrackVideoType(_sourceName: string, _videoType: string): boolean {
- return false;
- }
-
- /**
- * @inheritDoc
- */
- updateSsrcOwnersOnLeave(id: string): void {
- const ssrcs = Array.from(this.ssrcOwners)
- .filter((entry: [number, string]) => entry[1] === id)
- .map((entry: [number, string]) => entry[0]);
-
- if (!ssrcs?.length) {
- return;
- }
-
- this.removeSSRCOwners(ssrcs);
- }
- }
|