import { ScopedLogger } from '../logger';
import type { CallEventListener } from '../coordinator/connection/types';
import { CallState } from '../store';
import { PeerType, TrackType } from '../gen/video/sfu/models/models';
import { StreamSfuClient } from '../StreamSfuClient';
import { AllSfuEvents, Dispatcher } from './Dispatcher';
import { StatsTracer, Tracer } from '../stats';
import { BasePeerConnectionOpts, OnReconnectionNeeded, OnRemoteTrackUnmute } from './types';
import type { ClientPublishOptions } from '../types';
/**
 * A base class for the `Publisher` and `Subscriber` classes.
 * @internal
 */
export declare abstract class BasePeerConnection {
    protected readonly logger: ScopedLogger;
    protected readonly peerType: PeerType;
    protected readonly pc: RTCPeerConnection;
    protected readonly state: CallState;
    protected readonly dispatcher: Dispatcher;
    protected readonly clientPublishOptions?: ClientPublishOptions;
    protected tag: string;
    protected sfuClient: StreamSfuClient;
    protected onReconnectionNeeded?: OnReconnectionNeeded;
    private onIceConnected?;
    private onPeerConnectionStateChange?;
    protected onRemoteTrackUnmute?: OnRemoteTrackUnmute;
    private readonly iceRestartDelay;
    private iceHasEverConnected;
    private iceRestartTimeout?;
    private preConnectStuckTimeout?;
    protected isIceRestarting: boolean;
    protected isDisposed: boolean;
    protected trackIdToTrackType: Map<string, TrackType>;
    readonly tracer?: Tracer;
    readonly stats: StatsTracer;
    private subscriptions;
    private unsubscribeIceTrickle?;
    protected readonly lock: string;
    /**
     * Constructs a new `BasePeerConnection` instance.
     */
    protected constructor(peerType: PeerType, { sfuClient, connectionConfig, state, dispatcher, onReconnectionNeeded, onIceConnected, onPeerConnectionStateChange, onRemoteTrackUnmute, tag, enableTracing, clientPublishOptions, iceRestartDelay, statsTimestampDriftThresholdMs, }: BasePeerConnectionOpts);
    private createPeerConnection;
    /**
     * Disposes the `RTCPeerConnection` instance.
     */
    dispose(): Promise<void>;
    /**
     * Detaches the event handlers from the `RTCPeerConnection`.
     */
    detachEventHandlers(): void;
    /**
     * Performs an ICE restart on the `RTCPeerConnection`.
     */
    protected abstract restartIce(): Promise<void>;
    /**
     * Attempts to restart ICE on the `RTCPeerConnection`.
     * This method intentionally doesn't await the `restartIce()` method,
     * allowing it to run in the background and handle any errors that may occur.
     */
    protected tryRestartIce: () => void;
    /**
     * Handles events synchronously.
     * Consecutive events are queued and executed one after the other.
     */
    protected on: <E extends keyof AllSfuEvents>(event: E, fn: CallEventListener<E>) => void;
    /**
     * Returns the per-event `withoutConcurrency` tag used to serialize the
     * dispatcher handler for `event` on this peer connection.
     */
    protected eventLockKey: (event: keyof AllSfuEvents) => string;
    /**
     * Appends the trickled ICE candidates to the `RTCPeerConnection`.
     */
    protected addTrickledIceCandidates: () => void;
    /**
     * Sets the SFU client to use.
     *
     * @param sfuClient the SFU client to use.
     */
    setSfuClient: (sfuClient: StreamSfuClient) => void;
    /**
     * Returns the result of the `RTCPeerConnection.getStats()` method
     * @param selector an optional `MediaStreamTrack` to get the stats for.
     */
    getStats: (selector?: MediaStreamTrack | null) => Promise<RTCStatsReport>;
    /**
     * Maps the given track ID to the corresponding track type.
     */
    getTrackType: (trackId: string) => TrackType | undefined;
    /**
     * Checks if the `RTCPeerConnection` is healthy.
     * It checks the ICE connection state and the peer connection state.
     * If either state is `failed`, `disconnected`, or `closed`,
     * it returns `false`, otherwise it returns `true`.
     */
    isHealthy: () => boolean;
    /**
     * Handles the ICECandidate event and
     * Initiates an ICE Trickle process with the SFU.
     */
    private onIceCandidate;
    /**
     * Handles the ConnectionStateChange event.
     */
    private onConnectionStateChange;
    /**
     * Handles the ICE connection state change event.
     */
    private onIceConnectionStateChange;
    private fireOnPeerConnectionStateChange;
    private handleConnectionStateUpdate;
    /**
     * Handles the ICE candidate error event.
     */
    private onIceCandidateError;
    /**
     * Handles the ICE gathering state change event.
     */
    private onIceGatherChange;
    /**
     * Handles the signaling state change event.
     */
    private onSignalingChange;
}
