// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
 * @private
 */
export class MediaAccessSubscriber {
    constructor(callIdRef, context, mediaAccessCallFeature) {
        this.subscribe = () => {
            this._mediaAccessCallFeature.on('mediaAccessChanged', this.mediaAccessChanged);
            this._mediaAccessCallFeature.on('meetingMediaAccessChanged', this.meetingMediaAccessChanged);
        };
        this.unsubscribe = () => {
            this._mediaAccessCallFeature.off('mediaAccessChanged', this.mediaAccessChanged);
            this._mediaAccessCallFeature.off('meetingMediaAccessChanged', this.meetingMediaAccessChanged);
        };
        this.mediaAccessChanged = (data) => this._context.setMediaAccesses(this._callIdRef.callId, data.mediaAccesses);
        this.meetingMediaAccessChanged = (data) => this._context.setMeetingMediaAccess(this._callIdRef.callId, data.meetingMediaAccess);
        this._callIdRef = callIdRef;
        this._context = context;
        this._mediaAccessCallFeature = mediaAccessCallFeature;
        const mediaAccesses = this._mediaAccessCallFeature.getAllOthersMediaAccess();
        const meetingMediaAccess = this._mediaAccessCallFeature.getMeetingMediaAccess();
        this._context.setMediaAccesses(this._callIdRef.callId, mediaAccesses);
        this._context.setMeetingMediaAccess(this._callIdRef.callId, meetingMediaAccess);
        this.subscribe();
    }
}
//# sourceMappingURL=MediaAccessSubscriber.js.map