from typing import Callable


class ICERemoteCandidate:
    ...


class UDPDumper:
    ...


class RTPOutgoingSourceGroupShared:
    ...


class RTPIncomingSourceGroupShared:
    ...


class TimeService:
    ...


class RTPIncomingMediaStreamShared:
    ...


class MediaFrameType:
    ...


class MediaFrameListenerShared:
    ...


class UDPReader:
    ...


class RTPSenderShared:
    ...


class RTPReceiverShared:
    ...


class MediaServer:
    @staticmethod
    def initialize() -> bool: ...

    @staticmethod
    def terminate() -> None: ...

    @staticmethod
    def enable_log(flag: bool) -> None: ...

    @staticmethod
    def enable_debug(flag: bool) -> None: ...

    @staticmethod
    def enable_ultradebug(flag: bool) -> None: ...

    @staticmethod
    def set_port_range(min_port: int, max_port: int) -> bool: ...

    @staticmethod
    def set_certificate(cert: str, key: str) -> bool: ...

    @staticmethod
    def get_fingerprint() -> str: ...

    @staticmethod
    def set_affinity(cpu: int) -> bool: ...

    @staticmethod
    def set_thread_name(name: str) -> bool: ...


class Properties:
    def set_int(self, key: str, value: int) -> None: ...

    def set_string(self, key: str, value: str) -> None: ...

    def set_bool(self, key: str, value: bool) -> None: ...


class EventLoop:
    def start(self) -> bool: ...

    def stop(self) -> bool: ...


class DTLSICETransportListener:
    def __init__(self, on_ice_timeout: Callable, on_dtls_state_changed: Callable,
                 on_remote_ice_candidate_activated: Callable): ...


class SenderSideEstimatorListener:
    def __init__(self, on_target_bitrate: Callable): ...


class DTLSICETransport:
    def set_listener(self, listener: DTLSICETransportListener) -> None: ...

    def start(self) -> None: ...

    def stop(self) -> None: ...

    def set_srtp_protection_profiles(self, profiles: str) -> ...: ...

    def set_remote_properties(self, properties: Properties) -> None: ...

    def set_local_properties(self, properties: Properties) -> None: ...

    def dump(self, arg0: str | UDPDumper, inbound: bool, outbound: bool, rtcp: bool,
             rtcp_headers_only: bool) -> int: ...

    def stop_dump(self) -> int: ...

    def dump_bwe_stats(self, filename: str) -> int: ...

    def stop_dump_bwe_stats(self) -> int: ...

    def reset(self) -> None: ...

    def activate_remote_candidate(self, candidate: ICERemoteCandidate, use_candidate: bool, priority: int) -> None: ...

    def set_remote_crypto_dtls(self, setup: str, hash: str, fingerprint: str) -> int: ...

    def set_local_stun_credentials(self, username: str, pwd: str) -> int: ...

    def set_remote_stun_credentials(self, username: str, pwd: str) -> int: ...

    def add_outgoing_source_group(self, group: RTPOutgoingSourceGroupShared) -> bool: ...

    def remove_outgoing_source_group(self, group: RTPOutgoingSourceGroupShared) -> bool: ...

    def add_incoming_source_group(self, group: RTPIncomingSourceGroupShared) -> bool: ...

    def remove_incoming_source_group(self, group: RTPIncomingSourceGroupShared) -> bool: ...

    def set_bandwidth_probing(self, probe: bool) -> None: ...

    def set_max_probing_bitrate(self, bitrate: int) -> None: ...

    def set_probing_bitrate_limit(self, bitrate: int) -> None: ...

    def enable_sender_side_estimation(self, enabled: bool) -> None: ...

    def set_sender_side_estimator_listener(self, listener: SenderSideEstimatorListener) -> None: ...

    def get_available_outgoing_bitrate(self) -> int: ...

    def get_estimated_outgoing_bitrate(self) -> int: ...

    def get_total_sent_bitrate(self) -> int: ...

    def set_remote_override_bwe(self, override_bwe: bool) -> None: ...

    def set_remote_override_bitrate(self, bitrate: int) -> None: ...

    def get_remote_username(self) -> str: ...

    def get_remote_pwd(self) -> str: ...

    def get_local_username(self) -> str: ...

    def get_local_pwd(self) -> str: ...

    def get_rtt(self) -> int: ...

    def get_time_service(self) -> TimeService: ...


class RTPBundleTransport:
    def __init__(self, packetPoolSize: int): ...

    def init(self, port: int | None = None) -> int: ...

    def add_ice_transport(self, username: str, properties: Properties) -> RTPBundleTransportConnection: ...

    def restart_ice_transport(self, username: str, restarted: str, properties: Properties) -> bool: ...

    def remove_ice_transport(self, username: str) -> int: ...

    def end(self) -> int: ...

    def get_local_port(self) -> int: ...

    def add_remote_candidate(self, username: str, ip: str, port: int) -> int: ...

    def set_candidate_raw_tx_data(self, ip: str, port: int, selfAddr: int, dstLladdr: str) -> None: ...

    def set_raw_tx(self, ifindex: int, sndbuf: int, skipQdisc: bool, selfLladdr: str, defaultSelfAddr: int,
                   defaultDstLladdr: str, port: int) -> None: ...

    def clear_raw_tx(self, ) -> None: ...

    def set_affinity(self, cpu: int) -> bool: ...

    def set_thread_name(self, name: str) -> bool: ...

    def set_priority(self, priority: int) -> bool: ...

    def set_ice_timeout(self, timeout: int) -> None: ...

    def get_time_service(self, ) -> TimeService: ...


class RTPBundleTransportConnection:
    transport: DTLSICETransport


class RTPIncomingMediaStream:
    def get_media_ssrc(self) -> int: ...

    def get_time_service(self) -> TimeService: ...

    def mute(self, muting: bool) -> None: ...


class RTPIncomingMediaStreamMultiplexer:
    def __init__(self, stream: RTPIncomingMediaStreamShared, time_service: TimeService): ...

    def stop(self) -> None: ...


class RTPIncomingSource:
    num_frames: int
    num_frames_delta: int
    lost_packets: int
    lost_packets_delta: int
    lost_packets_max_gap: int
    lost_packets_gap_count: int
    drop_packets: int
    total_packets_since_last_sr: int
    total_bytes_since_last_sr: int
    min_ext_seq_num_since_last_sr: int
    lost_packets_since_last_sr: int
    last_received_sender_ntp_timestamp: int
    last_received_sender_report: int
    last_report: int
    total_plis: int
    total_nacks: int
    frame_delay: int
    frame_delay_max: int
    frame_capture_delay: int
    frame_capture_delay_max: int
    skew: int
    drift: int
    aggregated_layers: bool
    width: int
    height: int

    def get_target_bitrate(self) -> int: ...

    def get_target_width(self) -> int: ...

    def get_target_height(self) -> int: ...

    def get_target_fps(self) -> int: ...


class RTPOutgoingSource:
    time: int
    num_frames: int
    num_frames_delta: int
    last_timestamp: int
    last_sender_report: int
    last_sender_report_ntp: int
    remb: int
    report_count: int
    report_count_delta: int
    reported_lost_count: int
    reported_lost_count_delta: int
    reported_fraction_lost: int
    reported_jitter: int
    rtt: int


class RTPIncomingSourceGroup:
    rid: str
    mid: str
    rtt: int
    type: MediaFrameType
    media: RTPIncomingSource
    rtx: RTPIncomingSource
    lost: int
    min_waited_time: int
    max_waited_time: int
    avg_waited_time: int
    last_updated: int

    def __init__(self, type: MediaFrameType, time_service: TimeService): ...

    def set_max_wait_time(self, max_wait_time: int) -> None: ...

    def reset_max_wait_time(self) -> None: ...

    def update(self) -> None: ...

    def stop(self) -> None: ...


class RTPOutgoingSourceGroup:
    type: MediaFrameType
    media: RTPOutgoingSource
    fec: RTPOutgoingSource
    rtx: RTPOutgoingSource
    last_updated: int

    def __init__(self, frame_type: MediaFrameType, time_service: TimeService): ...

    def set_forced_playout_delay(self, min_delay: int, max_delay: int) -> None: ...

    def update(self) -> None: ...

    def stop(self) -> None: ...


class RTPReceiver:
    def send_pli(self, ssrc: int) -> int: ...

    def reset(self, ssrc: int) -> int: ...


class MediaFrameProducer:
    def add_media_listener(self, listener: MediaFrameListenerShared) -> None: ...

    def remove_media_listener(self, listener: MediaFrameListenerShared) -> None: ...


class LayerInfo:
    max_layer_id: int
    temporal_layer_id: int
    spatial_layer_id: int


class LayerSource:
    num_packets: int
    total_bytes: int
    bitrate: int
    total_bitrate: int
    active: bool

    def get_target_bitrate(self) -> int: ...

    def get_target_width(self) -> int: ...

    def get_target_height(self) -> int: ...

    def get_target_fps(self) -> int: ...


class RTPSource:
    ssrc: int
    ext_seq_num: int
    cycles: int
    jitter: int
    num_packets: int
    num_packets_delta: int
    num_rtcp_packets: int
    total_bytes: int
    total_rtcp_bytes: int
    bitrate: int
    total_bitrate: int
    clockrate: int


class RTPSessionFacade:
    def __init__(self, frame_type: MediaFrameType): ...

    def init(self, properties: Properties) -> int: ...

    def set_local_port(self, recv_port: int) -> int: ...

    def get_local_port(self) -> int: ...

    def set_remote_port(self, ip: str, send_port: int) -> int: ...

    def get_outgoing_source_group(self) -> RTPOutgoingSourceGroupShared: ...

    def get_incoming_source_group(self) -> RTPIncomingSourceGroupShared: ...

    def end(self) -> int: ...

    def send_pli(self, ssrc: int) -> int: ...

    def reset(self, ssrc: int) -> int: ...

    def get_time_service(self) -> TimeService: ...


class PCAPTransportEmulator:
    def set_remote_properties(self, properties: Properties) -> None: ...

    def add_incoming_source_group(self, group: RTPIncomingSourceGroupShared) -> bool: ...

    def remove_incoming_source_group(self, group: RTPIncomingSourceGroupShared) -> bool: ...

    def open(self, filename: str) -> bool: ...

    def set_reader(self, reader: UDPReader) -> bool: ...

    def play(self) -> bool: ...

    def seek(self, time: int) -> int: ...

    def stop(self) -> bool: ...

    def close(self) -> bool: ...


class ActiveSpeakerDetectorFacade:
    def __init__(self, on_active_speaker_changed: Callable): ...

    def set_min_change_period(self, min_change_perion: int) -> None: ...

    def set_max_accumulated_score(self, max_accumulated_score: int) -> None: ...

    def set_noise_gating_threshold(self, noise_gating_threshold: int) -> None: ...

    def set_min_activation_score(self, min_activation_score: int) -> None: ...

    def add_incoming_source_group(self, incoming: RTPIncomingMediaStreamShared, id: int) -> None: ...

    def remove_incoming_source_group(self, incoming: RTPIncomingMediaStreamShared) -> None: ...


class RTPStreamTransponderFacade:
    def __init__(self, group: RTPOutgoingSourceGroupShared, sender: RTPSenderShared, on_remb: Callable): ...

    def set_incoming(self, outgoing: RTPOutgoingSourceGroupShared, receiver: RTPReceiverShared,
                     smooth: bool) -> None: ...

    def reset_incoming(self) -> None: ...

    def append_h_parameter_sets(self, sprops: str) -> bool: ...

    def select_layer(self, spartial_layer_id: int, temp_layer_id: int) -> None: ...

    def mute(self, muting: bool) -> None: ...

    def set_intra_only_forwarding(self, infra_only_forwarding: bool) -> None: ...

    def close(self) -> None: ...


class ActiveSpeakerMultiplexerFacade:
    def __init__(self, time_service: TimeService, on_active_speaker_changed: Callable,
                 on_active_speaker_removed: Callable): ...

    def set_max_accumulated_score(self, max_accumulated_score: int) -> None: ...

    def set_noise_gating_threshold(self, noise_gating_threshold: int) -> None: ...

    def set_min_activation_score(self, min_activation_score: int) -> None: ...

    def add_incoming_source_group(self, incoming: RTPIncomingMediaStreamShared, id: int) -> None: ...

    def remove_incoming_source_group(self, incoming: RTPIncomingMediaStreamShared) -> None: ...

    def add_rtp_stream_transponder(self, transponder: RTPStreamTransponderFacade, id: int) -> None: ...

    def remove_rtp_stream_transponder(self, transponder: RTPStreamTransponderFacade) -> None: ...

    def stop(self) -> None: ...


class RTPIncomingMediaStreamDepacketizer:
    def __init__(self, stream: RTPIncomingMediaStreamShared): ...

    def stop(self) -> None: ...


class MediaFrameReader:
    def __init__(self, on_media_frame: Callable, intra_only: bool, min_period: int, on_demand: bool): ...

    def grab_next_frame(self) -> None: ...


class MP4RecorderFacade:
    def __init__(self, on_first_frame: Callable, on_closed: Callable): ...

    def create(self, filename: str) -> bool: ...

    def record(self, wait_video: bool, disable_hints: bool) -> bool: ...

    def stop(self) -> bool: ...

    def close(self, async_: bool | None = None) -> bool: ...

    def set_time_shift_duration(self, duration: int) -> None: ...

    def set_h_parameter_sets(self, sprops: str) -> bool: ...


class PlayerFacade:
    def __init__(self, on_end: Callable): ...

    def get_audio_source(self) -> RTPIncomingSourceGroupShared: ...

    def get_video_source(self) -> RTPIncomingSourceGroupShared: ...

    def reset(self) -> None: ...

    def open(self, filename: str) -> int: ...

    def has_audio_track(self) -> bool: ...

    def has_video_track(self) -> bool: ...

    def get_audio_codec(self) -> int: ...

    def get_video_codec(self) -> int: ...

    def get_duration(self) -> int: ...

    def get_video_width(self) -> int: ...

    def get_video_height(self) -> int: ...

    def get_video_bitrate(self) -> int: ...

    def get_video_framerate(self) -> int: ...

    def play(self) -> int: ...

    def pre_seek(self, time: int) -> int: ...

    def seek(self, time: int) -> int: ...

    def tell(self) -> int: ...

    def stop(self) -> int: ...

    def close(self) -> int: ...


class MediaFrameListener:
    ...


class RemoteRateEstimatorListener:
    ...
