import type { AddTrackRequest, ConnectionQualityUpdate, JoinResponse, RegionSettings, StreamStateUpdate, SubscriptionPermissionUpdate, SubscriptionResponse } from '@livekit/protocol';
import { DataPacket, DataTrackSubscriberHandles, DisconnectReason, Encryption_Type, ParticipantInfo, PublishDataTrackResponse, RequestResponse, Room as RoomModel, RoomMovedResponse, ServerInfo, SpeakerInfo, SubscribedQualityUpdate, TrackInfo, TrackUnpublishedResponse, Transcription, UnpublishDataTrackResponse } from '@livekit/protocol';
import type TypedEventEmitter from 'typed-emitter';
import type { SignalOptions } from '../api/SignalClient';
import { SignalClient } from '../api/SignalClient';
import type { BaseE2EEManager } from '../e2ee/E2eeManager';
import type { InternalRoomOptions } from '../options';
import PCTransport from './PCTransport';
import { PCTransportManager } from './PCTransportManager';
import { DataTrackInfo } from './data-track/types';
import { RpcError } from './rpc';
import type LocalTrack from './track/LocalTrack';
import type LocalTrackPublication from './track/LocalTrackPublication';
import LocalVideoTrack from './track/LocalVideoTrack';
import type { SimulcastTrackInfo } from './track/LocalVideoTrack';
import type RemoteTrackPublication from './track/RemoteTrackPublication';
import type { Track } from './track/Track';
import type { TrackPublishOptions, VideoCodec } from './track/options';
export declare enum DataChannelKind {
    RELIABLE = 0,
    LOSSY = 1,
    DATA_TRACK_LOSSY = 2
}
declare const RTCEngine_base: new () => TypedEventEmitter<EngineEventCallbacks>;
/** @internal */
export default class RTCEngine extends RTCEngine_base {
    private options;
    client: SignalClient;
    rtcConfig: RTCConfiguration;
    peerConnectionTimeout: number;
    fullReconnectOnNext: boolean;
    pcManager?: PCTransportManager;
    /**
     * @internal
     */
    latestJoinResponse?: JoinResponse;
    /**
     * @internal
     */
    latestRemoteOfferId: number;
    /** @internal */
    e2eeManager: BaseE2EEManager | undefined;
    get isClosed(): boolean;
    get isNewlyCreated(): boolean;
    get pendingReconnect(): boolean;
    private lossyDC?;
    private lossyDCSub?;
    private reliableDC?;
    private reliableDCSub?;
    private dataTrackDC?;
    private dataTrackDCSub?;
    private dcBufferStatus;
    private subscriberPrimary;
    private pcState;
    private _isClosed;
    private _isNewlyCreated;
    private pendingTrackResolvers;
    private url?;
    private token?;
    private signalOpts?;
    private reconnectAttempts;
    private reconnectStart;
    private clientConfiguration?;
    private attemptingReconnect;
    private reconnectPolicy;
    private reconnectTimeout?;
    private participantSid?;
    /** keeps track of how often an initial join connection has been tried */
    private joinAttempts;
    /** specifies how often an initial join connection is allowed to retry */
    private maxJoinAttempts;
    private closingLock;
    private dataProcessLock;
    private shouldFailNext;
    private shouldFailOnV1Path;
    private regionStrategy?;
    private log;
    private loggerOptions;
    private publisherConnectionPromise;
    private reliableDataSequence;
    private reliableMessageBuffer;
    private reliableReceivedState;
    private lossyDataStatCurrentBytes;
    private lossyDataStatByterate;
    private lossyDataStatInterval;
    private lossyDataDropCount;
    private midToTrackId;
    /** used to indicate whether the browser is currently waiting to reconnect */
    private isWaitingForNetworkReconnect;
    private bufferStatusLowClosingFuture;
    constructor(options: InternalRoomOptions);
    /** @internal */
    get logContext(): {
        room: string | undefined;
        roomID: string | undefined;
        participant: string | undefined;
        participantID: string | undefined;
    };
    join(url: string, token: string, opts: SignalOptions, abortSignal?: AbortSignal, 
    /** setting this to true results in dual peer connection mode being used */
    useV0Path?: boolean): Promise<{
        joinResponse: JoinResponse;
        serverInfo: Partial<ServerInfo>;
    }>;
    close(): Promise<void>;
    cleanupPeerConnections(): Promise<void>;
    cleanupLossyDataStats(): void;
    cleanupClient(): Promise<void>;
    addTrack(req: AddTrackRequest): Promise<TrackInfo>;
    /**
     * Removes sender from PeerConnection, returning true if it was removed successfully
     * and a negotiation is necessary
     * @param sender
     * @returns
     */
    removeTrack(sender: RTCRtpSender): boolean;
    updateMuteStatus(trackSid: string, muted: boolean): void;
    get dataSubscriberReadyState(): string | undefined;
    getConnectedServerAddress(): Promise<string | undefined>;
    setRegionStrategy(strategy: RegionStrategy | undefined): void;
    private configure;
    private setupSignalClientCallbacks;
    private makeRTCConfiguration;
    private addMediaSections;
    private createDataChannels;
    private handleDataChannel;
    private handleDataMessage;
    private handleDataTrackMessage;
    private handleDataError;
    private handleBufferedAmountLow;
    createSender(track: LocalTrack, opts: TrackPublishOptions, encodings?: RTCRtpEncodingParameters[]): Promise<RTCRtpSender>;
    createSimulcastSender(track: LocalVideoTrack, simulcastTrack: SimulcastTrackInfo, opts: TrackPublishOptions, encodings?: RTCRtpEncodingParameters[]): Promise<RTCRtpSender | undefined>;
    private setupPacketTrailerSender;
    private createTransceiverRTCRtpSender;
    private createSimulcastTransceiverSender;
    private createRTCRtpSender;
    private handleDisconnect;
    private attemptReconnect;
    private getNextRetryDelay;
    private restartConnection;
    private resumeConnection;
    waitForPCInitialConnection(timeout?: number, abortController?: AbortController): Promise<void>;
    private waitForPCReconnected;
    waitForRestarted: () => Promise<void>;
    /** @internal */
    publishRpcResponse(destinationIdentity: string, requestId: string, payload: string | null, error: RpcError | null): Promise<void>;
    /** @internal */
    publishRpcAck(destinationIdentity: string, requestId: string): Promise<void>;
    sendDataPacket(packet: DataPacket, kind: DataChannelKind): Promise<void>;
    sendLossyBytes(bytes: NonSharedUint8Array, kind: Exclude<DataChannelKind, DataChannelKind.RELIABLE>, bufferStatusLowBehavior?: 'drop' | 'wait'): Promise<void>;
    private resendReliableMessagesForResume;
    private updateAndEmitDCBufferStatus;
    private isBufferStatusLow;
    waitForBufferStatusLow(kind: DataChannelKind): Promise<void>;
    /**
     * @internal
     */
    ensureDataTransportConnected(kind: DataChannelKind, subscriber?: boolean): Promise<void>;
    private ensurePublisherConnected;
    verifyTransport(): boolean;
    /** @internal */
    negotiate(): Promise<void>;
    dataChannelForKind(kind: DataChannelKind, sub?: boolean): RTCDataChannel | undefined;
    /** @internal */
    sendSyncState(remoteTracks: RemoteTrackPublication[], localTracks: LocalTrackPublication[], localDataTrackInfos: Array<DataTrackInfo>): void;
    failNext(): void;
    failNextV1Path(): void;
    private dataChannelsInfo;
    private clearReconnectTimeout;
    private clearPendingReconnect;
    private handleBrowserOnLine;
    private handleBrowserOffline;
    private registerOnLineListener;
    private deregisterOnLineListener;
    getTrackIdForReceiver(receiver: RTCRtpReceiver): string | undefined;
}
export type EngineEventCallbacks = {
    connected: (joinResp: JoinResponse) => void;
    disconnected: (reason?: DisconnectReason) => void;
    resuming: () => void;
    resumed: () => void;
    restarting: () => void;
    restarted: () => void;
    signalResumed: () => void;
    signalRestarted: (joinResp: JoinResponse) => void;
    closing: () => void;
    mediaTrackAdded: (track: MediaStreamTrack, streams: MediaStream, receiver: RTCRtpReceiver) => void;
    activeSpeakersUpdate: (speakers: Array<SpeakerInfo>) => void;
    dataPacketReceived: (packet: DataPacket, encryptionType: Encryption_Type) => void;
    transcriptionReceived: (transcription: Transcription) => void;
    transportsCreated: (publisher: PCTransport, subscriber?: PCTransport) => void;
    /** @internal */
    trackSenderAdded: (track: Track, sender: RTCRtpSender) => void;
    rtpVideoMapUpdate: (rtpMap: Map<number, VideoCodec>) => void;
    dcBufferStatusChanged: (isLow: boolean, kind: DataChannelKind) => void;
    participantUpdate: (infos: ParticipantInfo[]) => void;
    roomUpdate: (room: RoomModel) => void;
    roomMoved: (room: RoomMovedResponse) => void;
    connectionQualityUpdate: (update: ConnectionQualityUpdate) => void;
    speakersChanged: (speakerUpdates: SpeakerInfo[]) => void;
    streamStateChanged: (update: StreamStateUpdate) => void;
    subscriptionError: (resp: SubscriptionResponse) => void;
    subscriptionPermissionUpdate: (update: SubscriptionPermissionUpdate) => void;
    subscribedQualityUpdate: (update: SubscribedQualityUpdate) => void;
    localTrackUnpublished: (unpublishedResponse: TrackUnpublishedResponse) => void;
    localTrackSubscribed: (trackSid: string) => void;
    remoteMute: (trackSid: string, muted: boolean) => void;
    offline: () => void;
    signalRequestResponse: (response: RequestResponse) => void;
    signalConnected: (joinResp: JoinResponse) => void;
    publishDataTrackResponse: (event: PublishDataTrackResponse) => void;
    unPublishDataTrackResponse: (event: UnpublishDataTrackResponse) => void;
    dataTrackSubscriberHandles: (event: DataTrackSubscriberHandles) => void;
    dataTrackPacketReceived: (packet: Uint8Array) => void;
    joined: (joinResponse: JoinResponse) => void;
    tokenRefreshed: (token: string) => void;
    serverRegionsReported: (regions: RegionSettings) => void;
};
export interface RegionStrategy {
    getNextUrl(abortSignal?: AbortSignal): Promise<string | null>;
    resetAttempts(): void;
}
export {};
//# sourceMappingURL=RTCEngine.d.ts.map
