import { ConnectionId, NetworkEvent } from "./index";
import { Output, SLogger } from "./Helper";
import { NetworkConfig } from "index";
import { RtcEvent } from "./IWebRtcNetwork";
export declare class SignalingInfo {
    private mSignalingConnected;
    IsSignalingConnected(): boolean;
    private mConnectionId;
    get ConnectionId(): ConnectionId;
    private mIsIncoming;
    IsIncoming(): boolean;
    private mCreationTime;
    GetCreationTimeMs(): number;
    constructor(id: ConnectionId, isIncoming: boolean, timeStamp: number);
    SignalingDisconnected(): void;
}
export declare enum WebRtcPeerState {
    Invalid = 0,
    Created = 1,
    Signaling = 2,
    SignalingFailed = 3,
    Connected = 4,
    Closing = 5,
    Closed = 6
}
export declare enum WebRtcInternalState {
    None = 0,
    Signaling = 1,
    SignalingFailed = 2,
    Connected = 3,
    Closed = 4
}
export declare class PeerConfig {
    RtcConfig: RTCConfiguration;
    MaxIceRestart: number;
    constructor(netConfig: NetworkConfig);
}
export declare abstract class AWebRtcPeer {
    readonly DEBUG = false;
    LOG_SIGNALING: boolean;
    protected USE_ICE_RESTART: boolean;
    protected USE_ICE_RESTART_DC_WORKAROUND: boolean;
    protected MAX_RETRIES: number;
    private mRetries;
    private mState;
    GetState(): WebRtcPeerState;
    private mRtcInternalState;
    protected mPeer: RTCPeerConnection;
    private mIncomingSignalingQueue;
    private mOutgoingSignalingQueue;
    /**new experimental peer configuration: It tries to avoid negotiation to allow cutting the signaling connection
     * For this transceivers are always created with sendrecv even if no track is available yet.
     * Later replaceTrack is used to attach / detach any tracks
     * This causes a bug in browsers though: If an audio track is active but no video track yet audio playback does not start
     */
    readonly SINGLE_NEGOTIATION = false;
    readonly RENEGOTATE_ROLES = true;
    private mInActiveRoleNegotiation;
    private mUseRoleNegotiation;
    private mRandomNumberSent;
    private mReadyForIce;
    private mBufferedIceCandidates;
    protected mIsOfferer: boolean;
    private static sNextId;
    protected readonly mId: any;
    protected log: SLogger;
    constructor(peerConfig: PeerConfig, baseLogger: SLogger);
    protected abstract OnSetup(): void;
    protected abstract OnStartSignaling(): void;
    protected abstract OnCleanup(): void;
    protected abstract TryUpdateConnectedStatus(): void;
    private SetupPeer;
    protected DisposeInternal(): void;
    Dispose(): void;
    private Cleanup;
    Update(): void;
    private UpdateState;
    private BufferIceCandidate;
    /**Called after setRemoteDescription succeeded.
     * After this call we accept ice candidates and add all buffered ice candidates we received
     * until then.
     *
     * This is a workaround for problems between Safari & Firefox. Safari sometimes sends ice candidates before
     * it sends an answer causing an error in firefox.
     */
    private StartIce;
    private AddIceCandidate;
    HandleIncomingSignaling(): void;
    AddSignalingMessage(msg: string): void;
    DequeueSignalingMessage(/*out*/ msg: Output<string>): boolean;
    private EnqueueOutgoing;
    StartSignaling(): void;
    private StartSignalingInternal;
    NegotiateSignaling(): void;
    /**Triggers the actual createOffer method on the Peer
     * Can be overridden to ensure specific transceiver configurations are performed
     * before the actual answer is created.
     * @returns Promise returned by createOffer
     */
    protected CreateOfferImpl(): Promise<RTCSessionDescriptionInit>;
    private CreateOffer;
    protected ProcessLocalSdp(desc: RTCSessionDescription): RTCSessionDescription;
    protected ProcessRemoteSdp(desc: RTCSessionDescription): RTCSessionDescription;
    /**Triggers the actual createAnswer method on the Peer
     * Can be overridden to ensure specific transceiver configurations are performed
     * before the actual answer is created.
     * @returns Promise returned by createAnswer
     */
    protected CreateAnswerImpl(): Promise<RTCSessionDescriptionInit>;
    private CreateAnswer;
    private RecAnswer;
    private RtcSetSignalingStarted;
    protected RtcSetSignalingFailed(reason: string): void;
    protected RtcSetConnected(): void;
    /**Called if a WebRTC side event leads to this peer closing
     * e.g. ice failed, data channel suddenly closed
     * This must not be an error. It might just be the remote side ending the call
     * which will usually result in the data channels closing.
     * @param reason Additional information for logging
     */
    protected RtcSetClosed(reason: string): void;
    private OnIceCandidate;
    private OnConnectionStateChange;
    private TriggerRestartIce;
    private RestartIce;
    private OnIceGatheringStateChange;
    private OnNegotiationNeeded;
    private OnSignalingChange;
}
export declare class WebRtcDataPeer extends AWebRtcPeer {
    private mConnectionId;
    get ConnectionId(): ConnectionId;
    private mInfo;
    get SignalingInfo(): SignalingInfo;
    SetSignalingInfo(info: SignalingInfo): void;
    private mEvents;
    private mRtcEvents;
    protected get UseDataChannels(): boolean;
    private static sLabelReliable;
    private static sLabelUnreliable;
    private mReliableDataChannelReady;
    private mUnreliableDataChannelReady;
    private mReliableDataChannel;
    private mUnreliableDataChannel;
    constructor(id: ConnectionId, peerConfig: PeerConfig, baseLogger: SLogger);
    protected OnSetup(): void;
    /** Switches the public state to Connected if the conditions are met.
     * Must have connected ice and all required data channels opened.
     */
    protected TryUpdateConnectedStatus(): void;
    protected OnStartSignaling(): void;
    protected OnCleanup(): void;
    private RegisterObserverReliable;
    private RegisterObserverUnreliable;
    SendData(data: Uint8Array, /* offset : number, length : number,*/ reliable: boolean): boolean;
    GetBufferedAmount(reliable: boolean): number;
    DequeueEvent(/*out*/ ev: Output<NetworkEvent>): boolean;
    private Enqueue;
    OnDataChannel(data_channel: RTCDataChannel): void;
    private RtcOnMessageReceived;
    private ReliableDataChannel_OnMessage;
    private ReliableDataChannel_OnOpen;
    private ReliableDataChannel_OnClose;
    private ReliableDataChannel_OnError;
    private UnreliableDataChannel_OnMessage;
    private UnreliableDataChannel_OnOpen;
    private UnreliableDataChannel_OnClose;
    private UnreliableDataChannel_OnError;
    private IsRtcConnected;
    RequestStats(): void;
    DequeueRtcEvent(): RtcEvent;
}
