import { TypedEventEmitter } from "../models/typed-event-emitter";
import { Room } from "../models/room";
import { MatrixClient } from "../client";
import { CallMembership } from "./CallMembership";
import { Focus } from "./focus";
import { MatrixEvent } from "../matrix";
export declare enum MatrixRTCSessionEvent {
    MembershipsChanged = "memberships_changed",
    JoinStateChanged = "join_state_changed",
    EncryptionKeyChanged = "encryption_key_changed"
}
export type MatrixRTCSessionEventHandlerMap = {
    [MatrixRTCSessionEvent.MembershipsChanged]: (oldMemberships: CallMembership[], newMemberships: CallMembership[]) => void;
    [MatrixRTCSessionEvent.JoinStateChanged]: (isJoined: boolean) => void;
    [MatrixRTCSessionEvent.EncryptionKeyChanged]: (key: Uint8Array, encryptionKeyIndex: number, participantId: string) => void;
};
/**
 * A MatrixRTCSession manages the membership & properties of a MatrixRTC session.
 * This class doesn't deal with media at all, just membership & properties of a session.
 */
export declare class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, MatrixRTCSessionEventHandlerMap> {
    private readonly client;
    readonly room: Room;
    memberships: CallMembership[];
    private relativeExpiry;
    private membershipId;
    private memberEventTimeout?;
    private expiryTimeout?;
    private keysEventUpdateTimeout?;
    private makeNewKeyTimeout?;
    private setNewKeyTimeouts;
    private activeFoci;
    private updateCallMembershipRunning;
    private needCallMembershipUpdate;
    private manageMediaKeys;
    private encryptionKeys;
    private lastEncryptionKeyUpdateRequest?;
    /**
     * Returns all the call memberships for a room, oldest first
     */
    static callMembershipsForRoom(room: Room): CallMembership[];
    /**
     * Return a the MatrixRTC for the room, whether there are currently active members or not
     */
    static roomSessionForRoom(client: MatrixClient, room: Room): MatrixRTCSession;
    private constructor();
    isJoined(): boolean;
    /**
     * Performs cleanup & removes timers for client shutdown
     */
    stop(): Promise<void>;
    /**
     * Announces this user and device as joined to the MatrixRTC session,
     * and continues to update the membership event to keep it valid until
     * leaveRoomSession() is called
     * This will not subscribe to updates: remember to call subscribe() separately if
     * desired.
     * This method will return immediately and the session will be joined in the background.
     *
     * @param activeFoci - The list of foci to set as currently active in the call member event
     * @param manageMediaKeys - If true, generate and share a a media key for this participant,
     *                          and emit MatrixRTCSessionEvent.EncryptionKeyChanged when
     *                          media keys for other participants become available.
     */
    joinRoomSession(activeFoci: Focus[], manageMediaKeys?: boolean): void;
    /**
     * Announces this user and device as having left the MatrixRTC session
     * and stops scheduled updates.
     * This will not unsubscribe from updates: remember to call unsubscribe() separately if
     * desired.
     * The membership update required to leave the session will retry if it fails.
     * Without network connection the promise will never resolve.
     * A timeout can be provided so that there is a guarantee for the promise to resolve.
     */
    leaveRoomSession(timeout?: number | undefined): Promise<boolean>;
    getKeysForParticipant(userId: string, deviceId: string): Array<Uint8Array> | undefined;
    /**
     * A map of keys used to encrypt and decrypt (we are using a symmetric
     * cipher) given participant's media. This also includes our own key
     */
    getEncryptionKeys(): IterableIterator<[string, Array<Uint8Array>]>;
    private getNewEncryptionKeyIndex;
    /**
     * Sets an encryption key at a specified index for a participant.
     * The encryption keys for the local participanmt are also stored here under the
     * user and device ID of the local participant.
     * @param userId - The user ID of the participant
     * @param deviceId - Device ID of the participant
     * @param encryptionKeyIndex - The index of the key to set
     * @param encryptionKeyString - The string represenation of the key to set in base64
     * @param delayBeforeuse - If true, delay before emitting a key changed event. Useful when setting
     *                         encryption keys for the local participant to allow time for the key to
     *                         be distributed.
     */
    private setEncryptionKey;
    /**
     * Generate a new sender key and add it at the next available index
     * @param delayBeforeUse - If true, wait for a short period before settign the key for the
     *                         media encryptor to use. If false, set the key immediately.
     */
    private makeNewSenderKey;
    /**
     * Requests that we resend our keys to the room. May send a keys event immediately
     * or queue for alter if one has already been sent recently.
     */
    private requestKeyEventSend;
    /**
     * Re-sends the encryption keys room event
     */
    private sendEncryptionKeysEvent;
    /**
     * Sets a timer for the soonest membership expiry
     */
    private setExpiryTimer;
    getOldestMembership(): CallMembership | undefined;
    onCallEncryption: (event: MatrixEvent) => void;
    onMembershipUpdate: () => void;
    /**
     * Constructs our own membership
     * @param prevEvent - The previous version of our call membership, if any
     */
    private makeMyMembership;
    /**
     * Returns true if our membership event needs to be updated
     */
    private membershipEventNeedsUpdate;
    /**
     * Makes a new membership list given the old list alonng with this user's previous membership event
     * (if any) and this device's previous membership (if any)
     */
    private makeNewMemberships;
    private triggerCallMembershipEventUpdate;
    private updateCallMembershipEvent;
    private onRotateKeyTimeout;
}
//# sourceMappingURL=MatrixRTCSession.d.ts.map