import * as VScript from "http://172.16.0.12/bladerunner_sdk/vscript@2.5.2/deno/release/mod.ts";
import * as VAPI from "./mod.ts";
import { split_sdp } from "./toplevel/sdp.ts";
export const lift = {
  PhaseControlSettingsAuto: (
    _raw: [],
    _socket: VScript.VSocket,
  ): PhaseControlSettingsAuto => {
    return {};
  },
  JpegXsCaptureStateAwaitingCSCapture: (
    _raw: [],
    _socket: VScript.VSocket,
  ): JpegXsCaptureStateAwaitingCSCapture => {
    return {};
  },
  JpegXsCaptureStateAwaitingCSCaptureTrigger: (
    _raw: [],
    _socket: VScript.VSocket,
  ): JpegXsCaptureStateAwaitingCSCaptureTrigger => {
    return {};
  },
  SwitchTypeBreakBeforeMake: (
    _raw: [number | string],
    _socket: VScript.VSocket,
  ): SwitchTypeBreakBeforeMake => {
    return {
      switch_time: VScript.VAPIHelpers.liftTimestamp(_raw[0], _socket),
    };
  },
  CapabilityRequestIDs: (
    _raw: [null | number, null | number],
    _socket: VScript.VSocket,
  ): CapabilityRequestIDs => {
    return {
      request_id: _raw[0],
      grant_id: _raw[1],
    };
  },
  CountableErrorHandler: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new CountableErrorHandler(_raw),
  CurrentRedundancyLevels: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new CurrentRedundancyLevels(_raw),
  Egress: (
    _raw: [Array<null | [boolean, null | number]>],
    _socket: VScript.VSocket,
  ): Egress => {
    return {
      freeze_state: _raw[0].map((el) =>
        el === null ? null : VAPI.RTPReceiver.lift.FreezeState(el, _socket),
      ),
    };
  },
  ErrorCounter: (
    _raw: [null | number, number, number],
    _socket: VScript.VSocket,
  ): ErrorCounter => {
    return {
      last_seen_at:
        _raw[0] === null
          ? null
          : VScript.VAPIHelpers.liftNanoseconds(_raw[0], _socket),
      consec_err_count: _raw[1],
      err_acc: _raw[2],
    };
  },
  Expectations: (
    _raw: [boolean, [boolean, boolean]],
    _socket: VScript.VSocket,
  ): Expectations => {
    return {
      sof: _raw[0],
      mpacket_from: VAPI.RTPReceiver.lift.ExpectationsMpacketFrom(
        _raw[1],
        _socket,
      ),
    };
  },
  FreezeState: (
    _raw: [boolean, null | number],
    _socket: VScript.VSocket,
  ): FreezeState => {
    return {
      frozen: _raw[0],
      fence: _raw[1],
    };
  },
  Ingress: (
    _raw: [
      VAPI.RTPReceiver.IngressTrackState,
      VAPI.RTPReceiver.IngressTrackState,
    ],
    _socket: VScript.VSocket,
  ): Ingress => {
    return {
      sdp_a: _raw[0],
      sdp_b: _raw[1],
    };
  },
  InternalBufferSizes: (
    _raw: [number, number, number, number, number, number],
    _socket: VScript.VSocket,
  ): InternalBufferSizes => {
    return {
      for_audio: _raw[0],
      for_2022_6: _raw[1],
      for_2110_20_uhd_singlelink: _raw[2],
      for_2110_20_other: _raw[3],
      for_2042_2: _raw[4],
      for_passthrough: _raw[5],
    };
  },
  JpegXsCaptureState: (
    _raw: [0, []] | [1, []] | [2, [Array<number>]],
    _socket: VScript.VSocket,
  ): JpegXsCaptureState => {
    switch (_raw[0]) {
      case 0:
        return {
          variant: "AwaitingCSCaptureTrigger",
          value:
            VAPI.RTPReceiver.lift.JpegXsCaptureStateAwaitingCSCaptureTrigger(
              _raw[1],
              _socket,
            ),
        };
      case 1:
        return {
          variant: "AwaitingCSCapture",
          value: VAPI.RTPReceiver.lift.JpegXsCaptureStateAwaitingCSCapture(
            _raw[1],
            _socket,
          ),
        };
      case 2:
        return {
          variant: "SteadyState",
          value: VAPI.RTPReceiver.lift.JpegXsCaptureStateSteadyState(
            _raw[1],
            _socket,
          ),
        };
    }
  },
  MPacket: (
    _raw: [number, number, number],
    _socket: VScript.VSocket,
  ): MPacket => {
    return {
      extended_frc: _raw[0],
      seqnr: _raw[1],
      format: _raw[2],
    };
  },
  MPacketDebugInfo: (
    _raw: [number, boolean, number, number, number, number, number, number],
    _socket: VScript.VSocket,
  ): MPacketDebugInfo => {
    return {
      packet_stream_index: _raw[0],
      m_flag: _raw[1],
      seqnr: _raw[2],
      last_word: _raw[3],
      empty: _raw[4],
      rtp_timestamp: _raw[5],
      frc: _raw[6],
      misc: _raw[7],
    };
  },
  SwitchTypeMakeBeforeBreak: (
    _raw: [number | string],
    _socket: VScript.VSocket,
  ): SwitchTypeMakeBeforeBreak => {
    return {
      switch_time: VScript.VAPIHelpers.liftTimestamp(_raw[0], _socket),
    };
  },
  PhaseControlSettingsManual: (
    _raw: [
      null | number,
      null | number,
      boolean,
      [boolean, number, number],
      null | [number, number],
      null | number,
    ],
    _socket: VScript.VSocket,
  ): PhaseControlSettingsManual => {
    return {
      jump_threshold: _raw[0],
      restart_threshold: _raw[1],
      protect_safety_margin: _raw[2],
      drift_sensitivity:
        VAPI.RTPReceiver.lift.PhaseControlSettingsManualDriftSensitivity(
          _raw[3],
          _socket,
        ),
      phase_sensitivity:
        _raw[4] === null
          ? null
          : VAPI.RTPReceiver.lift.PhaseControlSettingsManualPhaseSensitivity(
              _raw[4],
              _socket,
            ),
      auto_eject_threshold:
        _raw[5] === null
          ? null
          : VScript.VAPIHelpers.liftSeconds(_raw[5], _socket),
    };
  },
  PacketTracerRun: (
    _raw: [
      number,
      number | string,
      number | string,
      number,
      number,
      number,
      number,
      number,
      number,
      VAPI.RTPReceiver.PacketTracerRunPacketDetails,
      VAPI.RTPReceiver.PacketTracerMode,
    ],
    _socket: VScript.VSocket,
  ): PacketTracerRun => {
    return {
      n_run: _raw[0],
      ts_start: VScript.VAPIHelpers.liftTimestamp(_raw[1], _socket),
      ts_end: VScript.VAPIHelpers.liftTimestamp(_raw[2], _socket),
      num_streams_detected: _raw[3],
      mean_packets_per_second: _raw[4],
      num_warnings_generated: _raw[5],
      num_events_captured: _raw[6],
      num_data_flags_lost: _raw[7],
      num_irq_packets_lost: _raw[8],
      packet_details: _raw[9],
      mode: _raw[10],
    };
  },
  SwitchTypePatch: (_raw: [], _socket: VScript.VSocket): SwitchTypePatch => {
    return {};
  },
  PhaseControlSettings: (
    _raw:
      | [0, []]
      | [
          1,
          [
            null | number,
            null | number,
            boolean,
            [boolean, number, number],
            null | [number, number],
            null | number,
          ],
        ],
    _socket: VScript.VSocket,
  ): PhaseControlSettings => {
    switch (_raw[0]) {
      case 0:
        return {
          variant: "Auto",
          value: VAPI.RTPReceiver.lift.PhaseControlSettingsAuto(
            _raw[1],
            _socket,
          ),
        };
      case 1:
        return {
          variant: "Manual",
          value: VAPI.RTPReceiver.lift.PhaseControlSettingsManual(
            _raw[1],
            _socket,
          ),
        };
    }
  },
  SingleVideoDecoderWorkingSet: (
    _raw: [0, []] | [1, [[0, []] | [1, []] | [2, [Array<number>]], number]],
    _socket: VScript.VSocket,
  ): SingleVideoDecoderWorkingSet => {
    switch (_raw[0]) {
      case 0:
        return {
          variant: "WSOther",
          value: VAPI.RTPReceiver.lift.SingleVideoDecoderWorkingSetWSOther(
            _raw[1],
            _socket,
          ),
        };
      case 1:
        return {
          variant: "WSJpegXS",
          value: VAPI.RTPReceiver.lift.SingleVideoDecoderWorkingSetWSJpegXS(
            _raw[1],
            _socket,
          ),
        };
    }
  },
  SoftMetadataStatistics: (
    _raw: [
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
    ],
    _socket: VScript.VSocket,
  ): SoftMetadataStatistics => {
    return {
      packets_received: _raw[0],
      packets_too_old: _raw[1],
      packets_considered: _raw[2],
      packets_missing: _raw[3],
      parse_errors: _raw[4],
      type_unknown: _raw[5],
      parsed_as_empty_cea708: _raw[6],
      parsed_as_proper_cea708: _raw[7],
      parsed_as_empty_op47: _raw[8],
      parsed_as_proper_op47: _raw[9],
      parsed_as_empty_st12: _raw[10],
      parsed_as_proper_st12: _raw[11],
    };
  },
  StatsID: (_raw: [number, number], _socket: VScript.VSocket): StatsID => {
    return {
      irq_number: _raw[0],
      id: _raw[1],
    };
  },
  JpegXsCaptureStateSteadyState: (
    _raw: [Array<number>],
    _socket: VScript.VSocket,
  ): JpegXsCaptureStateSteadyState => {
    return {
      cs_capture_data: _raw[0],
    };
  },
  SwitchType: (
    _raw: [0, []] | [1, [number | string]] | [2, [number | string]],
    _socket: VScript.VSocket,
  ): SwitchType => {
    switch (_raw[0]) {
      case 0:
        return {
          variant: "Patch",
          value: VAPI.RTPReceiver.lift.SwitchTypePatch(_raw[1], _socket),
        };
      case 1:
        return {
          variant: "MakeBeforeBreak",
          value: VAPI.RTPReceiver.lift.SwitchTypeMakeBeforeBreak(
            _raw[1],
            _socket,
          ),
        };
      case 2:
        return {
          variant: "BreakBeforeMake",
          value: VAPI.RTPReceiver.lift.SwitchTypeBreakBeforeMake(
            _raw[1],
            _socket,
          ),
        };
    }
  },
  TaggedNetworkSourceID: (
    _raw: [number, VAPI.RTPReceiver.NetworkSourceType, number],
    _socket: VScript.VSocket,
  ): TaggedNetworkSourceID => {
    return {
      source_id: _raw[0],
      intended_use: _raw[1],
      estimated_bandwidth: _raw[2],
    };
  },
  UsedReceiverTracks: (
    _raw: [
      VAPI.RTPReceiver.TrackSet,
      VAPI.RTPReceiver.OrderedTrackSet,
      null | VAPI.RTPReceiver.Track,
      null | VAPI.RTPReceiver.Track,
      null | VAPI.RTPReceiver.Track,
      null | VAPI.RTPReceiver.Track,
    ],
    _socket: VScript.VSocket,
  ): UsedReceiverTracks => {
    return {
      ingress: _raw[0],
      egress: _raw[1],
      hard_metadata: _raw[2],
      soft_metadata: _raw[3],
      current_target: _raw[4],
      next_target: _raw[5],
    };
  },
  UsedSessionTracks: (
    _raw: [
      VAPI.RTPReceiver.TrackSet,
      VAPI.RTPReceiver.TrackSet,
      VAPI.RTPReceiver.TrackSet,
      VAPI.RTPReceiver.TrackSet,
    ],
    _socket: VScript.VSocket,
  ): UsedSessionTracks => {
    return {
      ingress: _raw[0],
      egress: _raw[1],
      current_target: _raw[2],
      next_target: _raw[3],
    };
  },
  SingleVideoDecoderWorkingSetWSJpegXS: (
    _raw: [[0, []] | [1, []] | [2, [Array<number>]], number],
    _socket: VScript.VSocket,
  ): SingleVideoDecoderWorkingSetWSJpegXS => {
    return {
      cs_capture_state: VAPI.RTPReceiver.lift.JpegXsCaptureState(
        _raw[0],
        _socket,
      ),
      soc_offset: _raw[1],
    };
  },
  SingleVideoDecoderWorkingSetWSOther: (
    _raw: [],
    _socket: VScript.VSocket,
  ): SingleVideoDecoderWorkingSetWSOther => {
    return {};
  },
  AllDerivedPtpTraits: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new AllDerivedPtpTraits(_raw),
  PhaseControlSettingsManualDriftSensitivity: (
    _raw: [boolean, number, number],
    _socket: VScript.VSocket,
  ): PhaseControlSettingsManualDriftSensitivity => {
    return {
      suppress_phase_error_on_drift: _raw[0],
      value: _raw[1],
      error: _raw[2],
    };
  },
  MediaReceiverErrorCounters: (
    _raw: VScript.DataViews.Subtree<VScript.VSocket>,
  ) => new MediaReceiverErrorCounters(_raw),
  VideoReceiverMediaSpecificErrorCounters: (
    _raw: VScript.DataViews.Subtree<VScript.VSocket>,
  ) => new VideoReceiverMediaSpecificErrorCounters(_raw),
  MediaReceiverEventCounters: (
    _raw: VScript.DataViews.Subtree<VScript.VSocket>,
  ) => new MediaReceiverEventCounters(_raw),
  SessionEventCounters: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new SessionEventCounters(_raw),
  VideoReceiverMediaSpecificEventCounters: (
    _raw: VScript.DataViews.Subtree<VScript.VSocket>,
  ) => new VideoReceiverMediaSpecificEventCounters(_raw),
  PacketTracerFilters: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new PacketTracerFilters(_raw),
  MediaReceiverFlightPermit: (
    _raw: VScript.DataViews.Subtree<VScript.VSocket>,
  ) => new MediaReceiverFlightPermit(_raw),
  VideoReceiverMediaSpecificHardMetadataDecoder: (
    _raw: VScript.DataViews.Subtree<VScript.VSocket>,
  ) => new VideoReceiverMediaSpecificHardMetadataDecoder(_raw),
  SessionInterfaces: (
    _raw: [null | string, null | string],
    _socket: VScript.VSocket,
  ): SessionInterfaces => {
    return {
      primary:
        _raw[0] === null
          ? null
          : new VAPI.NetworkInterfaces.VirtualInterface(
              VScript.VAPIHelpers.get_subtree(
                _socket,
                _raw[0] as VScript.KWLName<"full">,
              ),
            ),
      secondary:
        _raw[1] === null
          ? null
          : new VAPI.NetworkInterfaces.VirtualInterface(
              VScript.VAPIHelpers.get_subtree(
                _socket,
                _raw[1] as VScript.KWLName<"full">,
              ),
            ),
    };
  },
  SessionLastAcceptedTrack: (
    _raw: [VAPI.RTPReceiver.Track, number, number, Array<number>],
    _socket: VScript.VSocket,
  ): SessionLastAcceptedTrack => {
    return {
      track: _raw[0],
      fc: _raw[1],
      controller_version: _raw[2],
      controller_id: _raw[3],
    };
  },
  MediaReceiverLatencySpread: (
    _raw: VScript.DataViews.Subtree<VScript.VSocket>,
  ) => new MediaReceiverLatencySpread(_raw),
  AllLicenseInformation: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new AllLicenseInformation(_raw),
  ExpectationsMpacketFrom: (
    _raw: [boolean, boolean],
    _socket: VScript.VSocket,
  ): ExpectationsMpacketFrom => {
    return {
      sdp_a: _raw[0],
      sdp_b: _raw[1],
    };
  },
  AllDiagnosticsMpacketTracer: (
    _raw: VScript.DataViews.Subtree<VScript.VSocket>,
  ) => new AllDiagnosticsMpacketTracer(_raw),
  SessionEventCountersNumRejectedSdps: (
    _raw: VScript.DataViews.Subtree<VScript.VSocket>,
  ) => new SessionEventCountersNumRejectedSdps(_raw),
  TimingPhaseControl: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new TimingPhaseControl(_raw),
  PhaseControlSettingsManualPhaseSensitivity: (
    _raw: [number, number],
    _socket: VScript.VSocket,
  ): PhaseControlSettingsManualPhaseSensitivity => {
    return {
      value: VScript.VAPIHelpers.liftSeconds(_raw[0], _socket),
      error: _raw[1],
    };
  },
  TimingReadDelay: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new TimingReadDelay(_raw),
  TimingReadDelayBounds: (
    _raw: [null | number, null | number],
    _socket: VScript.VSocket,
  ): TimingReadDelayBounds => {
    return {
      min:
        _raw[0] === null
          ? null
          : VScript.VAPIHelpers.liftSeconds(_raw[0], _socket),
      max:
        _raw[1] === null
          ? null
          : VScript.VAPIHelpers.liftSeconds(_raw[1], _socket),
    };
  },
  MediaReceiverRedundancyLevels: (
    _raw: VScript.DataViews.Subtree<VScript.VSocket>,
  ) => new MediaReceiverRedundancyLevels(_raw),
  MediaReceiverRequiredRedundancyLevel: (
    _raw: [number, number],
    _socket: VScript.VSocket,
  ): MediaReceiverRequiredRedundancyLevel => {
    return {
      sdp_a: _raw[0],
      sdp_b: _raw[1],
    };
  },
  VideoReceiverMediaSpecificSoftMetadataDecoderRtpChannelStatistics: (
    _raw: [number, number],
    _socket: VScript.VSocket,
  ): VideoReceiverMediaSpecificSoftMetadataDecoderRtpChannelStatistics => {
    return {
      packets_lost: _raw[0],
      packets_sent: _raw[1],
    };
  },
  VideoReceiverMediaSpecificSoftMetadataDecoder: (
    _raw: VScript.DataViews.Subtree<VScript.VSocket>,
  ) => new VideoReceiverMediaSpecificSoftMetadataDecoder(_raw),
  VideoReceiverMediaSpecificHardMetadataDecoderStatistics: (
    _raw: [number, number, number, number],
    _socket: VScript.VSocket,
  ): VideoReceiverMediaSpecificHardMetadataDecoderStatistics => {
    return {
      num_relocations: _raw[0],
      num_embedded_packets: _raw[1],
      fc: _raw[2],
      micro_epoch_index: _raw[3],
    };
  },
  PacketTracerFiltersUdpDstPortRange: (
    _raw: [number, number],
    _socket: VScript.VSocket,
  ): PacketTracerFiltersUdpDstPortRange => {
    return {
      min: _raw[0],
      max: _raw[1],
    };
  },
  SessionVersionWindow: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new SessionVersionWindow(_raw),
} as const;
export const lower = {
  PhaseControlSettingsAuto: (_x: {}, _socket: VScript.VSocket): [] => [],
  JpegXsCaptureStateAwaitingCSCapture: (
    _x: {},
    _socket: VScript.VSocket,
  ): [] => [],
  JpegXsCaptureStateAwaitingCSCaptureTrigger: (
    _x: {},
    _socket: VScript.VSocket,
  ): [] => [],
  SwitchTypeBreakBeforeMake: (
    _x: { switch_time: VAPI.Primitives.Timestamp },
    _socket: VScript.VSocket,
  ): [number | string] => [
    VScript.VAPIHelpers.lowerTimestamp(_x.switch_time, _socket),
  ],
  CapabilityRequestIDs: (
    _x: {
      request_id: null | VAPI.RTPReceiver.CapabilityRequestID;
      grant_id: null | VAPI.RTPReceiver.CapabilityRequestID;
    },
    _socket: VScript.VSocket,
  ): [null | number, null | number] => [_x.request_id, _x.grant_id],
  CountableErrorHandler: (_x: CountableErrorHandler) => _x.raw.kwl,
  CurrentRedundancyLevels: (_x: CurrentRedundancyLevels) => _x.raw.kwl,
  Egress: (
    _x: { freeze_state: Array<null | VAPI.RTPReceiver.FreezeState> },
    _socket: VScript.VSocket,
  ): [Array<null | [boolean, null | number]>] => [
    _x.freeze_state.map((el) =>
      el === null ? null : VAPI.RTPReceiver.lower.FreezeState(el, _socket),
    ),
  ],
  ErrorCounter: (
    _x: {
      /**
          internal timestamp, initialized to zero at process startup
        */
      last_seen_at: null | VAPI.RTPReceiver.DriverTime;
      consec_err_count: VAPI.Primitives.SaturatingCounter16;
      err_acc: VAPI.Primitives.SaturatingCounter16;
    },
    _socket: VScript.VSocket,
  ): [null | number, number, number] => [
    _x.last_seen_at === null
      ? null
      : VScript.VAPIHelpers.lowerNanoseconds(_x.last_seen_at, _socket),
    _x.consec_err_count,
    _x.err_acc,
  ],
  Expectations: (
    _x: {
      sof: boolean;
      mpacket_from: VAPI.RTPReceiver.ExpectationsMpacketFrom;
    },
    _socket: VScript.VSocket,
  ): [boolean, [boolean, boolean]] => [
    _x.sof,
    VAPI.RTPReceiver.lower.ExpectationsMpacketFrom(_x.mpacket_from, _socket),
  ],
  FreezeState: (
    _x: { frozen: boolean; fence: null | VAPI.Time.FreeRunningCounter },
    _socket: VScript.VSocket,
  ): [boolean, null | number] => [_x.frozen, _x.fence],
  Ingress: (
    _x: {
      sdp_a: VAPI.RTPReceiver.IngressTrackState;
      sdp_b: VAPI.RTPReceiver.IngressTrackState;
    },
    _socket: VScript.VSocket,
  ): [
    VAPI.RTPReceiver.IngressTrackState,
    VAPI.RTPReceiver.IngressTrackState,
  ] => [_x.sdp_a, _x.sdp_b],
  InternalBufferSizes: (
    _x: {
      for_audio: number;
      for_2022_6: number;
      for_2110_20_uhd_singlelink: number;
      for_2110_20_other: number;
      for_2042_2: number;
      for_passthrough: number;
    },
    _socket: VScript.VSocket,
  ): [number, number, number, number, number, number] => [
    _x.for_audio,
    _x.for_2022_6,
    _x.for_2110_20_uhd_singlelink,
    _x.for_2110_20_other,
    _x.for_2042_2,
    _x.for_passthrough,
  ],
  JpegXsCaptureState: (
    _x:
      | {
          variant: "AwaitingCSCaptureTrigger";
          value: VAPI.RTPReceiver.JpegXsCaptureStateAwaitingCSCaptureTrigger;
        }
      | {
          variant: "AwaitingCSCapture";
          value: VAPI.RTPReceiver.JpegXsCaptureStateAwaitingCSCapture;
        }
      | {
          variant: "SteadyState";
          value: VAPI.RTPReceiver.JpegXsCaptureStateSteadyState;
        },
    _socket: VScript.VSocket,
  ): [0, []] | [1, []] | [2, [Array<number>]] => {
    switch (_x.variant) {
      case "AwaitingCSCaptureTrigger":
        return [
          0,
          VAPI.RTPReceiver.lower.JpegXsCaptureStateAwaitingCSCaptureTrigger(
            _x.value,
            _socket,
          ),
        ];
      case "AwaitingCSCapture":
        return [
          1,
          VAPI.RTPReceiver.lower.JpegXsCaptureStateAwaitingCSCapture(
            _x.value,
            _socket,
          ),
        ];
      case "SteadyState":
        return [
          2,
          VAPI.RTPReceiver.lower.JpegXsCaptureStateSteadyState(
            _x.value,
            _socket,
          ),
        ];
    }
  },
  MPacket: (
    _x: {
      extended_frc: VAPI.RTPReceiver.ExtendedFRC;
      seqnr: VAPI.RTPReceiver.Seqnr;
      format: VAPI.RTPReceiver.MPacketFormat;
    },
    _socket: VScript.VSocket,
  ): [number, number, number] => [_x.extended_frc, _x.seqnr, _x.format],
  MPacketDebugInfo: (
    _x: {
      packet_stream_index: VAPI.RTPReceiver.PacketStreamIndex;
      m_flag: boolean;
      seqnr: VAPI.RTPReceiver.Seqnr;
      last_word: number;
      empty: number;
      rtp_timestamp: VAPI.Primitives.Unsigned32;
      frc: VAPI.Time.FreeRunningCounter;
      misc: VAPI.Primitives.Unsigned32;
    },
    _socket: VScript.VSocket,
  ): [number, boolean, number, number, number, number, number, number] => [
    _x.packet_stream_index,
    _x.m_flag,
    _x.seqnr,
    _x.last_word,
    _x.empty,
    _x.rtp_timestamp,
    _x.frc,
    _x.misc,
  ],
  SwitchTypeMakeBeforeBreak: (
    _x: { switch_time: VAPI.Primitives.Timestamp },
    _socket: VScript.VSocket,
  ): [number | string] => [
    VScript.VAPIHelpers.lowerTimestamp(_x.switch_time, _socket),
  ],
  PhaseControlSettingsManual: (
    _x: {
      /**
          only permit corrective jumps (audio) or drop/repeat frames (video)
          after this many consecutive `phase_mismatch` errors. Set to `null`
          to disallow jumping entirely. Note that audio jumps require a
          nonzero number of reserve decoders, as defined under
          `settings.num_audio_reserve_receivers`.
        */
      jump_threshold: null | number;

      /**
          only permit corrective receiver restarts after this many
          consecutive `phase_mismatch` errors. Set to `null` to disallow
          entirely.
        */
      restart_threshold: null | number;

      /**
          If this is set to true, any phase mismatch closer than
          `safety_margin - current_phase.error` to the buffer boundary will
          be interpreted as a phase error.
        */
      protect_safety_margin: boolean;

      /**
          Interpret phase as asynchronous if `|current_phase.drift.value| >
          drift_sensitivity.value`, and if `current_phase.drift.error <
          drift_sensitivity.error × |current_phase.drift.value|`
        */
      drift_sensitivity: VAPI.RTPReceiver.PhaseControlSettingsManualDriftSensitivity;

      /**
          interpret `current_phase` as a phase error if
          `|current_phase.offset.value| > phase_sensitivity.value` and
          `current_phase.offset.error < phase_sensitivity.error ×
          |current_phase.offset.value|`
        */
      phase_sensitivity: null | VAPI.RTPReceiver.PhaseControlSettingsManualPhaseSensitivity;

      /**
          interpret current trajectory as a phase error if
          `expected_time_to_collision` < `auto_eject_threshold`; set to
          `null` to disable.
        */
      auto_eject_threshold: null | VScript.Duration;
    },
    _socket: VScript.VSocket,
  ): [
    null | number,
    null | number,
    boolean,
    [boolean, number, number],
    null | [number, number],
    null | number,
  ] => [
    _x.jump_threshold,
    _x.restart_threshold,
    _x.protect_safety_margin,
    VAPI.RTPReceiver.lower.PhaseControlSettingsManualDriftSensitivity(
      _x.drift_sensitivity,
      _socket,
    ),
    _x.phase_sensitivity === null
      ? null
      : VAPI.RTPReceiver.lower.PhaseControlSettingsManualPhaseSensitivity(
          _x.phase_sensitivity,
          _socket,
        ),
    _x.auto_eject_threshold === null
      ? null
      : VScript.VAPIHelpers.lowerSeconds(_x.auto_eject_threshold, _socket),
  ],
  PacketTracerRun: (
    _x: {
      n_run: VAPI.Primitives.Unsigned64;
      ts_start: VAPI.Primitives.Timestamp;
      ts_end: VAPI.Primitives.Timestamp;
      num_streams_detected: VAPI.Primitives.Unsigned32;
      mean_packets_per_second: number;
      num_warnings_generated: VAPI.Primitives.Unsigned32;
      num_events_captured: VAPI.Primitives.Unsigned64;
      num_data_flags_lost: VAPI.Primitives.Unsigned64;
      num_irq_packets_lost: VAPI.Primitives.Unsigned64;
      packet_details: VAPI.RTPReceiver.PacketTracerRunPacketDetails;
      mode: VAPI.RTPReceiver.PacketTracerMode;
    },
    _socket: VScript.VSocket,
  ): [
    number,
    number | string,
    number | string,
    number,
    number,
    number,
    number,
    number,
    number,
    VAPI.RTPReceiver.PacketTracerRunPacketDetails,
    VAPI.RTPReceiver.PacketTracerMode,
  ] => [
    _x.n_run,
    VScript.VAPIHelpers.lowerTimestamp(_x.ts_start, _socket),
    VScript.VAPIHelpers.lowerTimestamp(_x.ts_end, _socket),
    _x.num_streams_detected,
    _x.mean_packets_per_second,
    _x.num_warnings_generated,
    _x.num_events_captured,
    _x.num_data_flags_lost,
    _x.num_irq_packets_lost,
    _x.packet_details,
    _x.mode,
  ],
  SwitchTypePatch: (_x: {}, _socket: VScript.VSocket): [] => [],
  PhaseControlSettings: (
    _x:
      | { variant: "Auto"; value: VAPI.RTPReceiver.PhaseControlSettingsAuto }
      | {
          variant: "Manual";
          value: VAPI.RTPReceiver.PhaseControlSettingsManual;
        },
    _socket: VScript.VSocket,
  ):
    | [0, []]
    | [
        1,
        [
          null | number,
          null | number,
          boolean,
          [boolean, number, number],
          null | [number, number],
          null | number,
        ],
      ] => {
    switch (_x.variant) {
      case "Auto":
        return [
          0,
          VAPI.RTPReceiver.lower.PhaseControlSettingsAuto(_x.value, _socket),
        ];
      case "Manual":
        return [
          1,
          VAPI.RTPReceiver.lower.PhaseControlSettingsManual(_x.value, _socket),
        ];
    }
  },
  SingleVideoDecoderWorkingSet: (
    _x:
      | {
          variant: "WSOther";
          value: VAPI.RTPReceiver.SingleVideoDecoderWorkingSetWSOther;
        }
      | {
          variant: "WSJpegXS";
          value: VAPI.RTPReceiver.SingleVideoDecoderWorkingSetWSJpegXS;
        },
    _socket: VScript.VSocket,
  ): [0, []] | [1, [[0, []] | [1, []] | [2, [Array<number>]], number]] => {
    switch (_x.variant) {
      case "WSOther":
        return [
          0,
          VAPI.RTPReceiver.lower.SingleVideoDecoderWorkingSetWSOther(
            _x.value,
            _socket,
          ),
        ];
      case "WSJpegXS":
        return [
          1,
          VAPI.RTPReceiver.lower.SingleVideoDecoderWorkingSetWSJpegXS(
            _x.value,
            _socket,
          ),
        ];
    }
  },
  SoftMetadataStatistics: (
    _x: {
      packets_received: VAPI.Primitives.CyclicCounter32;
      packets_too_old: VAPI.Primitives.CyclicCounter32;
      packets_considered: VAPI.Primitives.CyclicCounter32;
      packets_missing: VAPI.Primitives.CyclicCounter32;
      parse_errors: VAPI.Primitives.CyclicCounter32;
      type_unknown: VAPI.Primitives.CyclicCounter32;
      parsed_as_empty_cea708: VAPI.Primitives.CyclicCounter32;
      parsed_as_proper_cea708: VAPI.Primitives.CyclicCounter32;
      parsed_as_empty_op47: VAPI.Primitives.CyclicCounter32;
      parsed_as_proper_op47: VAPI.Primitives.CyclicCounter32;
      parsed_as_empty_st12: VAPI.Primitives.CyclicCounter32;
      parsed_as_proper_st12: VAPI.Primitives.CyclicCounter32;
    },
    _socket: VScript.VSocket,
  ): [
    number,
    number,
    number,
    number,
    number,
    number,
    number,
    number,
    number,
    number,
    number,
    number,
  ] => [
    _x.packets_received,
    _x.packets_too_old,
    _x.packets_considered,
    _x.packets_missing,
    _x.parse_errors,
    _x.type_unknown,
    _x.parsed_as_empty_cea708,
    _x.parsed_as_proper_cea708,
    _x.parsed_as_empty_op47,
    _x.parsed_as_proper_op47,
    _x.parsed_as_empty_st12,
    _x.parsed_as_proper_st12,
  ],
  StatsID: (
    _x: { irq_number: number; id: number },
    _socket: VScript.VSocket,
  ): [number, number] => [_x.irq_number, _x.id],
  JpegXsCaptureStateSteadyState: (
    _x: { cs_capture_data: Array<VAPI.Primitives.Unsigned8> },
    _socket: VScript.VSocket,
  ): [Array<number>] => [_x.cs_capture_data],
  SwitchType: (
    _x:
      | { variant: "Patch"; value: VAPI.RTPReceiver.SwitchTypePatch }
      | {
          variant: "MakeBeforeBreak";
          value: VAPI.RTPReceiver.SwitchTypeMakeBeforeBreak;
        }
      | {
          variant: "BreakBeforeMake";
          value: VAPI.RTPReceiver.SwitchTypeBreakBeforeMake;
        },
    _socket: VScript.VSocket,
  ): [0, []] | [1, [number | string]] | [2, [number | string]] => {
    switch (_x.variant) {
      case "Patch":
        return [0, VAPI.RTPReceiver.lower.SwitchTypePatch(_x.value, _socket)];
      case "MakeBeforeBreak":
        return [
          1,
          VAPI.RTPReceiver.lower.SwitchTypeMakeBeforeBreak(_x.value, _socket),
        ];
      case "BreakBeforeMake":
        return [
          2,
          VAPI.RTPReceiver.lower.SwitchTypeBreakBeforeMake(_x.value, _socket),
        ];
    }
  },
  TaggedNetworkSourceID: (
    _x: {
      /**
          lower 16 bits designate UDP port, upper 16 bits designate portless
          part
        */
      source_id: VAPI.RTPReceiver.NetworkSourceID;
      intended_use: VAPI.RTPReceiver.NetworkSourceType;

      /**
          measured in units of Kibit/s
        */
      estimated_bandwidth: number;
    },
    _socket: VScript.VSocket,
  ): [number, VAPI.RTPReceiver.NetworkSourceType, number] => [
    _x.source_id,
    _x.intended_use,
    _x.estimated_bandwidth,
  ],
  UsedReceiverTracks: (
    _x: {
      ingress: VAPI.RTPReceiver.TrackSet;
      egress: VAPI.RTPReceiver.OrderedTrackSet;
      hard_metadata: null | VAPI.RTPReceiver.Track;
      soft_metadata: null | VAPI.RTPReceiver.Track;
      current_target: null | VAPI.RTPReceiver.Track;
      next_target: null | VAPI.RTPReceiver.Track;
    },
    _socket: VScript.VSocket,
  ): [
    VAPI.RTPReceiver.TrackSet,
    VAPI.RTPReceiver.OrderedTrackSet,
    null | VAPI.RTPReceiver.Track,
    null | VAPI.RTPReceiver.Track,
    null | VAPI.RTPReceiver.Track,
    null | VAPI.RTPReceiver.Track,
  ] => [
    _x.ingress,
    _x.egress,
    _x.hard_metadata,
    _x.soft_metadata,
    _x.current_target,
    _x.next_target,
  ],
  UsedSessionTracks: (
    _x: {
      ingress: VAPI.RTPReceiver.TrackSet;
      egress: VAPI.RTPReceiver.TrackSet;
      current_target: VAPI.RTPReceiver.TrackSet;
      next_target: VAPI.RTPReceiver.TrackSet;
    },
    _socket: VScript.VSocket,
  ): [
    VAPI.RTPReceiver.TrackSet,
    VAPI.RTPReceiver.TrackSet,
    VAPI.RTPReceiver.TrackSet,
    VAPI.RTPReceiver.TrackSet,
  ] => [_x.ingress, _x.egress, _x.current_target, _x.next_target],
  SingleVideoDecoderWorkingSetWSJpegXS: (
    _x: {
      cs_capture_state: VAPI.RTPReceiver.JpegXsCaptureState;
      soc_offset: number;
    },
    _socket: VScript.VSocket,
  ): [[0, []] | [1, []] | [2, [Array<number>]], number] => [
    VAPI.RTPReceiver.lower.JpegXsCaptureState(_x.cs_capture_state, _socket),
    _x.soc_offset,
  ],
  SingleVideoDecoderWorkingSetWSOther: (
    _x: {},
    _socket: VScript.VSocket,
  ): [] => [],
  AllDerivedPtpTraits: (_x: AllDerivedPtpTraits) => _x.raw.kwl,
  PhaseControlSettingsManualDriftSensitivity: (
    _x: {
      /**
            set this to `true` to suppress phase errors if the receiver's
            output phase is classified as asynchronous. This way,
            asynchronous streams can be received with a minimum of signal
            disturbances even when running in `LockToGenlock` mode (note that
            `auto_eject_threshold` remains in effect, so safety-violating
            phase errors will still give rise to drop/repeat frame events or
            audio jumps)
          */
      suppress_phase_error_on_drift: boolean;
      value: number;
      error: number;
    },
    _socket: VScript.VSocket,
  ): [boolean, number, number] => [
    _x.suppress_phase_error_on_drift,
    _x.value,
    _x.error,
  ],
  MediaReceiverErrorCounters: (_x: MediaReceiverErrorCounters) => _x.raw.kwl,
  VideoReceiverMediaSpecificErrorCounters: (
    _x: VideoReceiverMediaSpecificErrorCounters,
  ) => _x.raw.kwl,
  MediaReceiverEventCounters: (_x: MediaReceiverEventCounters) => _x.raw.kwl,
  SessionEventCounters: (_x: SessionEventCounters) => _x.raw.kwl,
  VideoReceiverMediaSpecificEventCounters: (
    _x: VideoReceiverMediaSpecificEventCounters,
  ) => _x.raw.kwl,
  PacketTracerFilters: (_x: PacketTracerFilters) => _x.raw.kwl,
  MediaReceiverFlightPermit: (_x: MediaReceiverFlightPermit) => _x.raw.kwl,
  VideoReceiverMediaSpecificHardMetadataDecoder: (
    _x: VideoReceiverMediaSpecificHardMetadataDecoder,
  ) => _x.raw.kwl,
  SessionInterfaces: (
    _x: {
      primary: null | VAPI.NetworkInterfaces.VirtualInterface;
      secondary: null | VAPI.NetworkInterfaces.VirtualInterface;
    },
    _socket: VScript.VSocket,
  ): [null | string, null | string] => [
    _x.primary === null ? null : _x.primary.raw.kwl,
    _x.secondary === null ? null : _x.secondary.raw.kwl,
  ],
  SessionLastAcceptedTrack: (
    _x: {
      track: VAPI.RTPReceiver.Track;
      fc: VAPI.Time.FreeRunningCounter;
      controller_version: VAPI.SDP.ControllerVersion;

      /**
                            Currently set to all zeroes if the given SDP does
                            not specify a `controller-id`; in version 2.0
                            this will be replaced by a proper optional.
                          */
      controller_id: VAPI.SDP.ControllerID;
    },
    _socket: VScript.VSocket,
  ): [VAPI.RTPReceiver.Track, number, number, Array<number>] => [
    _x.track,
    _x.fc,
    _x.controller_version,
    _x.controller_id,
  ],
  MediaReceiverLatencySpread: (_x: MediaReceiverLatencySpread) => _x.raw.kwl,
  AllLicenseInformation: (_x: AllLicenseInformation) => _x.raw.kwl,
  ExpectationsMpacketFrom: (
    _x: { sdp_a: boolean; sdp_b: boolean },
    _socket: VScript.VSocket,
  ): [boolean, boolean] => [_x.sdp_a, _x.sdp_b],
  AllDiagnosticsMpacketTracer: (_x: AllDiagnosticsMpacketTracer) => _x.raw.kwl,
  SessionEventCountersNumRejectedSdps: (
    _x: SessionEventCountersNumRejectedSdps,
  ) => _x.raw.kwl,
  TimingPhaseControl: (_x: TimingPhaseControl) => _x.raw.kwl,
  PhaseControlSettingsManualPhaseSensitivity: (
    _x: { value: VScript.Duration; error: number },
    _socket: VScript.VSocket,
  ): [number, number] => [
    VScript.VAPIHelpers.lowerSeconds(_x.value, _socket),
    _x.error,
  ],
  TimingReadDelay: (_x: TimingReadDelay) => _x.raw.kwl,
  TimingReadDelayBounds: (
    _x: { min: null | VScript.Duration; max: null | VScript.Duration },
    _socket: VScript.VSocket,
  ): [null | number, null | number] => [
    _x.min === null ? null : VScript.VAPIHelpers.lowerSeconds(_x.min, _socket),
    _x.max === null ? null : VScript.VAPIHelpers.lowerSeconds(_x.max, _socket),
  ],
  MediaReceiverRedundancyLevels: (_x: MediaReceiverRedundancyLevels) =>
    _x.raw.kwl,
  MediaReceiverRequiredRedundancyLevel: (
    _x: {
      /**
                                          number of packet streams referenced
                                          by this receiver's media
                                          description at track A that must
                                          have been registered at their
                                          respective network interfaces for
                                          the receiver to attempt readout
                                        */
      sdp_a: VAPI.RTPReceiver.RedundancyLevel;

      /**
                                          number of packet streams referenced
                                          by this receiver's media
                                          description at track B that must
                                          have been registered at their
                                          respective network interfaces for
                                          the receiver to attempt readout
                                        */
      sdp_b: VAPI.RTPReceiver.RedundancyLevel;
    },
    _socket: VScript.VSocket,
  ): [number, number] => [_x.sdp_a, _x.sdp_b],
  VideoReceiverMediaSpecificSoftMetadataDecoderRtpChannelStatistics: (
    _x: {
      packets_lost: VAPI.Primitives.CyclicCounter32;
      packets_sent: VAPI.Primitives.CyclicCounter32;
    },
    _socket: VScript.VSocket,
  ): [number, number] => [_x.packets_lost, _x.packets_sent],
  VideoReceiverMediaSpecificSoftMetadataDecoder: (
    _x: VideoReceiverMediaSpecificSoftMetadataDecoder,
  ) => _x.raw.kwl,
  VideoReceiverMediaSpecificHardMetadataDecoderStatistics: (
    _x: {
      num_relocations: number;
      num_embedded_packets: number;
      fc: VAPI.Time.FreeRunningCounter;
      micro_epoch_index: VAPI.Time.MicroEpochIndex;
    },
    _socket: VScript.VSocket,
  ): [number, number, number, number] => [
    _x.num_relocations,
    _x.num_embedded_packets,
    _x.fc,
    _x.micro_epoch_index,
  ],
  PacketTracerFiltersUdpDstPortRange: (
    _x: { min: VAPI.Primitives.Unsigned16; max: VAPI.Primitives.Unsigned16 },
    _socket: VScript.VSocket,
  ): [number, number] => [_x.min, _x.max],
  SessionVersionWindow: (_x: SessionVersionWindow) => _x.raw.kwl,
} as const;
export type AudioBlockIndex = number;
export type AudioInstanceIndex = number;
export interface PhaseControlSettingsAuto {}
export interface JpegXsCaptureStateAwaitingCSCapture {}
export interface JpegXsCaptureStateAwaitingCSCaptureTrigger {}
export type BackpressurePolicy = "Yield" | "Resist";
export type BlockCount = number;
export interface SwitchTypeBreakBeforeMake {
  switch_time: VAPI.Primitives.Timestamp;
}
export type BufferID = number;
export type CapabilityRequestID = number;
/**
  Ideally, this keyword shouldn't exist. In practice however, capability
  requests are currently processed eagerly, s.t. the outcome of a capability
  allocation attempt may depend on the order in which individual receivers
  are serviced. To ensure full state recovery across reboots, we thus store
  this ordering explicitly
*/
export interface CapabilityRequestIDs {
  request_id: null | VAPI.RTPReceiver.CapabilityRequestID;
  grant_id: null | VAPI.RTPReceiver.CapabilityRequestID;
}
export type ChannelCapacity = number;
/**
  if `clean_switching_policy` is set to `Tolerant`, packet rates and ST2042
  compression ratios may change across switching boundaries. This ensures
  interoperability between a wider range of transmitters but comes at a
  slight performance penalty, as the receiver first has to determine the
  current packet rate before a switch can be effected. When set to
  `Whatever`, impossible clean switching requests will silently be converted
  into patching operations. Please only use this option as a measure of last
  resort, if at all.
*/
export type CleanSwitchingPolicy = "Strict" | "Tolerant" | "Whatever";
export type CoarseGrainingLevel = number;
export class CountableErrorHandler
  implements VScript.Referenceable<"RTPReceiver::Data::CountableErrorHandler">
{
  readonly type_identifier =
    "RTPReceiver::Data::CountableErrorHandler" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get threshold(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    number,
    number,
    VAPI.RTPReceiver.CountableErrorHandler
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      number,
      number,
      VAPI.RTPReceiver.CountableErrorHandler
    >(
      this,
      "threshold" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get above_threshold_do(): VScript.rwKeyword<
    VScript.VSocket,
    VAPI.RTPReceiver.ErrorHandler,
    VAPI.RTPReceiver.ErrorHandler,
    VAPI.RTPReceiver.ErrorHandler,
    VAPI.RTPReceiver.ErrorHandler,
    VAPI.RTPReceiver.CountableErrorHandler
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      VAPI.RTPReceiver.ErrorHandler,
      VAPI.RTPReceiver.ErrorHandler,
      VAPI.RTPReceiver.ErrorHandler,
      VAPI.RTPReceiver.ErrorHandler,
      VAPI.RTPReceiver.CountableErrorHandler
    >(
      this,
      "above_threshold_do" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
}
export class CurrentRedundancyLevels
  implements VScript.Referenceable<"RTPReceiver::Data::CurrentRedundancyLevels">
{
  readonly type_identifier =
    "RTPReceiver::Data::CurrentRedundancyLevels" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}

  /**
    Number of streams referenced by this receiver's SDP that are actually
    present, indexed by subflow number. The latter is typically 0, but for
    quad-link video receivers can range from 0 to 3, and is 4 for 2110-40
    flows routed into a 2110-20 video receiver.
  */
  get per_subflow(): VScript.rKeyword<
    VScript.VSocket,
    Array<number>,
    Array<VAPI.Primitives.Unsigned8>,
    VAPI.RTPReceiver.CurrentRedundancyLevels
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      Array<number>,
      Array<VAPI.Primitives.Unsigned8>,
      VAPI.RTPReceiver.CurrentRedundancyLevels
    >(this, "per_subflow" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get overall(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.RTPReceiver.RedundancyLevel,
    VAPI.RTPReceiver.CurrentRedundancyLevels
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.RTPReceiver.RedundancyLevel,
      VAPI.RTPReceiver.CurrentRedundancyLevels
    >(this, "overall" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
}
/**
  internal timestamp, initialized to zero at process startup
*/
export type DriverTime = VScript.Duration;
export interface Egress {
  freeze_state: Array<null | VAPI.RTPReceiver.FreezeState>;
}
export type ErrorCondition =
  | "RXErrors"
  | "PrematureRead"
  | "LivenessTimeout"
  | "MPacketError"
  | "OffsetError2110"
  | "LinenrError2110";
export interface ErrorCounter {
  /**
    internal timestamp, initialized to zero at process startup
  */
  last_seen_at: null | VAPI.RTPReceiver.DriverTime;
  consec_err_count: VAPI.Primitives.SaturatingCounter16;
  err_acc: VAPI.Primitives.SaturatingCounter16;
}
export type ErrorHandler = "Ignore" | "RestartReceiver";
export interface Expectations {
  sof: boolean;
  mpacket_from: VAPI.RTPReceiver.ExpectationsMpacketFrom;
}
export type ExtendedFRC = number;
export type FrameShiftPolicy =
  | "Prohibit"
  | "PermitFrameShifts"
  | "PermitSubframeShifts";
export interface FreezeState {
  frozen: boolean;
  fence: null | VAPI.Time.FreeRunningCounter;
}
export type HashtableIndex = number;
export type HashtableMetadata = number;
export interface Ingress {
  sdp_a: VAPI.RTPReceiver.IngressTrackState;
  sdp_b: VAPI.RTPReceiver.IngressTrackState;
}
export type IngressTrackState = "Inactive" | "Activating" | "Active";
export interface InternalBufferSizes {
  for_audio: number;
  for_2022_6: number;
  for_2110_20_uhd_singlelink: number;
  for_2110_20_other: number;
  for_2042_2: number;
  for_passthrough: number;
}
export type JpegXsBlockIndex = number;
export type JpegXsCaptureState =
  | {
      variant: "AwaitingCSCaptureTrigger";
      value: VAPI.RTPReceiver.JpegXsCaptureStateAwaitingCSCaptureTrigger;
    }
  | {
      variant: "AwaitingCSCapture";
      value: VAPI.RTPReceiver.JpegXsCaptureStateAwaitingCSCapture;
    }
  | {
      variant: "SteadyState";
      value: VAPI.RTPReceiver.JpegXsCaptureStateSteadyState;
    };
export type JpegXsDecoderInstance = number;
export type JumpResponse = "Pending" | "Refused";
export type LocalSliceIndex = number;
export type LogicalSwitchTime =
  | "Patch"
  | "Past"
  | "WithinCooldownTime"
  | "WithinPreparationTime"
  | "Future";
export type MMUReadIndex = number;
export interface MPacket {
  extended_frc: VAPI.RTPReceiver.ExtendedFRC;
  seqnr: VAPI.RTPReceiver.Seqnr;
  format: VAPI.RTPReceiver.MPacketFormat;
}
export interface MPacketDebugInfo {
  packet_stream_index: VAPI.RTPReceiver.PacketStreamIndex;
  m_flag: boolean;
  seqnr: VAPI.RTPReceiver.Seqnr;
  last_word: number;
  empty: number;
  rtp_timestamp: VAPI.Primitives.Unsigned32;
  frc: VAPI.Time.FreeRunningCounter;
  misc: VAPI.Primitives.Unsigned32;
}
export interface SwitchTypeMakeBeforeBreak {
  switch_time: VAPI.Primitives.Timestamp;
}
export interface PhaseControlSettingsManual {
  /**
    only permit corrective jumps (audio) or drop/repeat frames (video) after
    this many consecutive `phase_mismatch` errors. Set to `null` to disallow
    jumping entirely. Note that audio jumps require a nonzero number of
    reserve decoders, as defined under
    `settings.num_audio_reserve_receivers`.
  */
  jump_threshold: null | number;

  /**
    only permit corrective receiver restarts after this many consecutive
    `phase_mismatch` errors. Set to `null` to disallow entirely.
  */
  restart_threshold: null | number;

  /**
    If this is set to true, any phase mismatch closer than `safety_margin -
    current_phase.error` to the buffer boundary will be interpreted as a
    phase error.
  */
  protect_safety_margin: boolean;

  /**
    Interpret phase as asynchronous if `|current_phase.drift.value| >
    drift_sensitivity.value`, and if `current_phase.drift.error <
    drift_sensitivity.error × |current_phase.drift.value|`
  */
  drift_sensitivity: VAPI.RTPReceiver.PhaseControlSettingsManualDriftSensitivity;

  /**
    interpret `current_phase` as a phase error if
    `|current_phase.offset.value| > phase_sensitivity.value` and
    `current_phase.offset.error < phase_sensitivity.error ×
    |current_phase.offset.value|`
  */
  phase_sensitivity: null | VAPI.RTPReceiver.PhaseControlSettingsManualPhaseSensitivity;

  /**
    interpret current trajectory as a phase error if
    `expected_time_to_collision` < `auto_eject_threshold`; set to `null` to
    disable.
  */
  auto_eject_threshold: null | VScript.Duration;
}
export type MediaReceiverType = "AncBurst" | "Audio" | "Video";
export type MemoryRegion = "Main" | "Alternate";
export type MetadataStreamID = number;
export type NativeVideoBlockIndex = number;
export type NativeVideoDecoderInstance = number;
/**
  lower 16 bits designate UDP port, upper 16 bits designate portless part
*/
export type NetworkSourceID = number;
export type NetworkSourceType =
  | "Audio"
  | "Video2042_2"
  | "Video2110_20"
  | "Video2110_20_UHD"
  | "VideoJpegXs"
  | "Video2022_6"
  | "Video2110_40_SoftMetadata"
  | "Video2110_40_NativeMetadata"
  | "Video2110_40_JpegXSMetadata"
  | "Video2110_40_AncBurst"
  | "MipMap"
  | "J2K"
  | "Passthrough";
export type NumDownloads = number;
/**
  Single video substreams pertaining to a quadlink UHD flow may be subscribed
  to independently, and used as separate 3G streams instead. By default, the
  resulting 3G video essences will be stripped of their substream attributes,
  which affects SDPs generated on retransmission, as well as 352 payloads. If
  you wish to retain original substream attributes, set this setting to
  `PropagateSubstreamAttribute` (but note that this setting only takes effect
  on readout).
*/
export type OnIsolatedSubstream =
  | "PropagateSubstreamAttribute"
  | "StripSubstreamAttribute";
export type OrderedTrackSet = "X" | "A" | "B" | "AB" | "BA" | "XA" | "XB";
export type PacketCapacity = number;
export type PacketStreamIndex = number;
export type PacketStreamType =
  | "Audio"
  | "Video2022_6"
  | "VideoOther"
  | "Video2110_40_Metadata"
  | "VideoJpegXs"
  | "MipMap"
  | "J2K"
  | "Passthrough";
export type PacketTracerMode =
  | "Seqnr"
  | "DstPort_Delta"
  | "Frc_Seqnr"
  | "SrcIp_DstIp_DstPort"
  | "Frc_Seqnr_DstPort_Timestamp";
export interface PacketTracerRun {
  n_run: VAPI.Primitives.Unsigned64;
  ts_start: VAPI.Primitives.Timestamp;
  ts_end: VAPI.Primitives.Timestamp;
  num_streams_detected: VAPI.Primitives.Unsigned32;
  mean_packets_per_second: number;
  num_warnings_generated: VAPI.Primitives.Unsigned32;
  num_events_captured: VAPI.Primitives.Unsigned64;
  num_data_flags_lost: VAPI.Primitives.Unsigned64;
  num_irq_packets_lost: VAPI.Primitives.Unsigned64;
  packet_details: VAPI.RTPReceiver.PacketTracerRunPacketDetails;
  mode: VAPI.RTPReceiver.PacketTracerMode;
}
export type PartitionID = number;
export interface SwitchTypePatch {}
export type PhaseControlSettings =
  | { variant: "Auto"; value: VAPI.RTPReceiver.PhaseControlSettingsAuto }
  | { variant: "Manual"; value: VAPI.RTPReceiver.PhaseControlSettingsManual };
export type PhaseMismatchSeverity = "TargetViolation" | "SafetyViolation";
/**
  0 and 1 are never used
*/
export type PortlessNetworkSourceID = number;
export type RedundancyLevel = number;
/**
  some configuration attempts cannot be executed completely. For example, a
  session containing 3 audio receivers will not be able to service a
  connection request if the corresponding SDP contains 4 or more audio
  essences. In these cases, the receiver may either set up as many
  connections as possible and discard the rest (`BestEffort`), or refuse the
  configuration attempt and raise an error message instead (`Refuse`).
*/
export type ResourceExhaustionPolicy = "Refuse" | "BestEffort";
export type SSRC = number;
export type SamplingStructure = "Interlaced" | "Progressive";
export type Seqnr = number;
/**
  Seqnr offset relative to other packet streams mapped to the same memory
  region. N packet streams hence define N-1 meaningful offsets.
*/
export type SeqnrDifference = number;
export type SingleVideoDecoderWorkingSet =
  | {
      variant: "WSOther";
      value: VAPI.RTPReceiver.SingleVideoDecoderWorkingSetWSOther;
    }
  | {
      variant: "WSJpegXS";
      value: VAPI.RTPReceiver.SingleVideoDecoderWorkingSetWSJpegXS;
    };
export interface SoftMetadataStatistics {
  packets_received: VAPI.Primitives.CyclicCounter32;
  packets_too_old: VAPI.Primitives.CyclicCounter32;
  packets_considered: VAPI.Primitives.CyclicCounter32;
  packets_missing: VAPI.Primitives.CyclicCounter32;
  parse_errors: VAPI.Primitives.CyclicCounter32;
  type_unknown: VAPI.Primitives.CyclicCounter32;
  parsed_as_empty_cea708: VAPI.Primitives.CyclicCounter32;
  parsed_as_proper_cea708: VAPI.Primitives.CyclicCounter32;
  parsed_as_empty_op47: VAPI.Primitives.CyclicCounter32;
  parsed_as_proper_op47: VAPI.Primitives.CyclicCounter32;
  parsed_as_empty_st12: VAPI.Primitives.CyclicCounter32;
  parsed_as_proper_st12: VAPI.Primitives.CyclicCounter32;
}
export interface StatsID {
  irq_number: number;
  id: number;
}
export type StatsSubscriptionType = "InsertNew" | "ReplaceOld";
export interface JpegXsCaptureStateSteadyState {
  cs_capture_data: Array<VAPI.Primitives.Unsigned8>;
}
export type SubflowIndex = number;
export type SwitchType =
  | { variant: "Patch"; value: VAPI.RTPReceiver.SwitchTypePatch }
  | {
      variant: "MakeBeforeBreak";
      value: VAPI.RTPReceiver.SwitchTypeMakeBeforeBreak;
    }
  | {
      variant: "BreakBeforeMake";
      value: VAPI.RTPReceiver.SwitchTypeBreakBeforeMake;
    };
export interface TaggedNetworkSourceID {
  /**
    lower 16 bits designate UDP port, upper 16 bits designate portless part
  */
  source_id: VAPI.RTPReceiver.NetworkSourceID;
  intended_use: VAPI.RTPReceiver.NetworkSourceType;

  /**
    measured in units of Kibit/s
  */
  estimated_bandwidth: number;
}
export type Track = "A" | "B";
export type TrackSet = "Empty" | "A" | "B" | "AB";
export interface UsedReceiverTracks {
  ingress: VAPI.RTPReceiver.TrackSet;
  egress: VAPI.RTPReceiver.OrderedTrackSet;
  hard_metadata: null | VAPI.RTPReceiver.Track;
  soft_metadata: null | VAPI.RTPReceiver.Track;
  current_target: null | VAPI.RTPReceiver.Track;
  next_target: null | VAPI.RTPReceiver.Track;
}
export interface UsedSessionTracks {
  ingress: VAPI.RTPReceiver.TrackSet;
  egress: VAPI.RTPReceiver.TrackSet;
  current_target: VAPI.RTPReceiver.TrackSet;
  next_target: VAPI.RTPReceiver.TrackSet;
}
/**
  SMPTE 2022-6 video streams should advertise their video format within the
  m-packet header. Additionally, the video format may be specified in advance
  using the `fmtp` SDP attribute (for SMPTE 2110 and ST 2042 streams, this is
  the only way to specify video standards). Should the standard extracted
  from an incoming m-packet disagree with a previously specified `fmtp`
  attribute, this setting determines which one takes precedence.
*/
export type VidStd20226Authority = "SDPFmtpAttribute" | "MPacketMetadata";
export interface SingleVideoDecoderWorkingSetWSJpegXS {
  cs_capture_state: VAPI.RTPReceiver.JpegXsCaptureState;
  soc_offset: number;
}
export interface SingleVideoDecoderWorkingSetWSOther {}
export class AllDerivedPtpTraits
  implements VScript.Referenceable<"RTPReceiver::Data::All::DerivedPtpTraits">
{
  readonly type_identifier =
    "RTPReceiver::Data::All::DerivedPtpTraits" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get packet_stream_media_clock() {
    return VAPI.PTP.lift.Traits(
      VScript.VAPIHelpers.subtree_child_checked(
        this.raw,
        0,
        "packet_stream_media_clock",
      ),
    );
  }
  get video_sof() {
    return VAPI.PTP.lift.Traits(
      VScript.VAPIHelpers.subtree_child_checked(this.raw, 1, "video_sof"),
    );
  }
}
/**
  Interpret phase as asynchronous if `|current_phase.drift.value| >
  drift_sensitivity.value`, and if `current_phase.drift.error <
  drift_sensitivity.error × |current_phase.drift.value|`
*/
export interface PhaseControlSettingsManualDriftSensitivity {
  /**
    set this to `true` to suppress phase errors if the receiver's output
    phase is classified as asynchronous. This way, asynchronous streams can
    be received with a minimum of signal disturbances even when running in
    `LockToGenlock` mode (note that `auto_eject_threshold` remains in effect,
    so safety-violating phase errors will still give rise to drop/repeat
    frame events or audio jumps)
  */
  suppress_phase_error_on_drift: boolean;
  value: number;
  error: number;
}
export class MediaReceiverErrorCounters
  implements
    VScript.Referenceable<"RTPReceiver::Data::MediaReceiver::ErrorCounters">
{
  readonly type_identifier =
    "RTPReceiver::Data::MediaReceiver::ErrorCounters" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get rx_error(): VScript.rKeyword<
    VScript.VSocket,
    [null | number, number, number],
    VAPI.RTPReceiver.ErrorCounter,
    VAPI.RTPReceiver.MediaReceiverErrorCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      [null | number, number, number],
      VAPI.RTPReceiver.ErrorCounter,
      VAPI.RTPReceiver.MediaReceiverErrorCounters
    >(this, "rx_error" as VScript.SysName, {
      lift: VAPI.RTPReceiver.lift.ErrorCounter,
      lower: VAPI.RTPReceiver.lower.ErrorCounter,
    });
  }

  /**
    premature read errors are signalled when the decoder attempts to process
    data that has not yet been delivered by the memory controller
  */
  get premature_read(): VScript.rKeyword<
    VScript.VSocket,
    [null | number, number, number],
    VAPI.RTPReceiver.ErrorCounter,
    VAPI.RTPReceiver.MediaReceiverErrorCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      [null | number, number, number],
      VAPI.RTPReceiver.ErrorCounter,
      VAPI.RTPReceiver.MediaReceiverErrorCounters
    >(this, "premature_read" as VScript.SysName, {
      lift: VAPI.RTPReceiver.lift.ErrorCounter,
      lower: VAPI.RTPReceiver.lower.ErrorCounter,
    });
  }
  get liveness_timeout(): VScript.rKeyword<
    VScript.VSocket,
    [null | number, number, number],
    VAPI.RTPReceiver.ErrorCounter,
    VAPI.RTPReceiver.MediaReceiverErrorCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      [null | number, number, number],
      VAPI.RTPReceiver.ErrorCounter,
      VAPI.RTPReceiver.MediaReceiverErrorCounters
    >(this, "liveness_timeout" as VScript.SysName, {
      lift: VAPI.RTPReceiver.lift.ErrorCounter,
      lower: VAPI.RTPReceiver.lower.ErrorCounter,
    });
  }
  get phase_mismatch(): VScript.rKeyword<
    VScript.VSocket,
    [null | number, number, number],
    VAPI.RTPReceiver.ErrorCounter,
    VAPI.RTPReceiver.MediaReceiverErrorCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      [null | number, number, number],
      VAPI.RTPReceiver.ErrorCounter,
      VAPI.RTPReceiver.MediaReceiverErrorCounters
    >(this, "phase_mismatch" as VScript.SysName, {
      lift: VAPI.RTPReceiver.lift.ErrorCounter,
      lower: VAPI.RTPReceiver.lower.ErrorCounter,
    });
  }
}
export class VideoReceiverMediaSpecificErrorCounters
  implements
    VScript.Referenceable<"RTPReceiver::Data::VideoReceiver::MediaSpecific::ErrorCounters">
{
  readonly type_identifier =
    "RTPReceiver::Data::VideoReceiver::MediaSpecific::ErrorCounters" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get mpacket_error(): VScript.rKeyword<
    VScript.VSocket,
    [null | number, number, number],
    VAPI.RTPReceiver.ErrorCounter,
    VAPI.RTPReceiver.VideoReceiverMediaSpecificErrorCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      [null | number, number, number],
      VAPI.RTPReceiver.ErrorCounter,
      VAPI.RTPReceiver.VideoReceiverMediaSpecificErrorCounters
    >(this, "mpacket_error" as VScript.SysName, {
      lift: VAPI.RTPReceiver.lift.ErrorCounter,
      lower: VAPI.RTPReceiver.lower.ErrorCounter,
    });
  }
  get offset_2110_error(): VScript.rKeyword<
    VScript.VSocket,
    [null | number, number, number],
    VAPI.RTPReceiver.ErrorCounter,
    VAPI.RTPReceiver.VideoReceiverMediaSpecificErrorCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      [null | number, number, number],
      VAPI.RTPReceiver.ErrorCounter,
      VAPI.RTPReceiver.VideoReceiverMediaSpecificErrorCounters
    >(this, "offset_2110_error" as VScript.SysName, {
      lift: VAPI.RTPReceiver.lift.ErrorCounter,
      lower: VAPI.RTPReceiver.lower.ErrorCounter,
    });
  }
  get linenr_2110_error(): VScript.rKeyword<
    VScript.VSocket,
    [null | number, number, number],
    VAPI.RTPReceiver.ErrorCounter,
    VAPI.RTPReceiver.VideoReceiverMediaSpecificErrorCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      [null | number, number, number],
      VAPI.RTPReceiver.ErrorCounter,
      VAPI.RTPReceiver.VideoReceiverMediaSpecificErrorCounters
    >(this, "linenr_2110_error" as VScript.SysName, {
      lift: VAPI.RTPReceiver.lift.ErrorCounter,
      lower: VAPI.RTPReceiver.lower.ErrorCounter,
    });
  }

  /**
    raised on audio deembedder overflow; only applies in 2022-6 mode
  */
  get audio_2022_6_deemb_read_overflow(): VScript.rKeyword<
    VScript.VSocket,
    [null | number, number, number],
    VAPI.RTPReceiver.ErrorCounter,
    VAPI.RTPReceiver.VideoReceiverMediaSpecificErrorCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      [null | number, number, number],
      VAPI.RTPReceiver.ErrorCounter,
      VAPI.RTPReceiver.VideoReceiverMediaSpecificErrorCounters
    >(this, "audio_2022_6_deemb_read_overflow" as VScript.SysName, {
      lift: VAPI.RTPReceiver.lift.ErrorCounter,
      lower: VAPI.RTPReceiver.lower.ErrorCounter,
    });
  }

  /**
    raised on audio deembedder underflow; only applies in 2022-6 mode
  */
  get audio_2022_6_deemb_read_underflow(): VScript.rKeyword<
    VScript.VSocket,
    [null | number, number, number],
    VAPI.RTPReceiver.ErrorCounter,
    VAPI.RTPReceiver.VideoReceiverMediaSpecificErrorCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      [null | number, number, number],
      VAPI.RTPReceiver.ErrorCounter,
      VAPI.RTPReceiver.VideoReceiverMediaSpecificErrorCounters
    >(this, "audio_2022_6_deemb_read_underflow" as VScript.SysName, {
      lift: VAPI.RTPReceiver.lift.ErrorCounter,
      lower: VAPI.RTPReceiver.lower.ErrorCounter,
    });
  }
}
export class MediaReceiverEventCounters
  implements
    VScript.Referenceable<"RTPReceiver::Data::MediaReceiver::EventCounters">
{
  readonly type_identifier =
    "RTPReceiver::Data::MediaReceiver::EventCounters" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}

  /**
    increased by 1 on every start attempt targeting SDP A
  */
  get start_a(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.CyclicCounter16,
    VAPI.RTPReceiver.MediaReceiverEventCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.CyclicCounter16,
      VAPI.RTPReceiver.MediaReceiverEventCounters
    >(this, "start_a" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }

  /**
    increased by 1 on every start attempt targeting SDP B
  */
  get start_b(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.CyclicCounter16,
    VAPI.RTPReceiver.MediaReceiverEventCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.CyclicCounter16,
      VAPI.RTPReceiver.MediaReceiverEventCounters
    >(this, "start_b" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }

  /**
    increased by 1 on every A → B switch attempt
  */
  get switch_ab(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.CyclicCounter16,
    VAPI.RTPReceiver.MediaReceiverEventCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.CyclicCounter16,
      VAPI.RTPReceiver.MediaReceiverEventCounters
    >(this, "switch_ab" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }

  /**
    increased by 1 on every B → A switch attempt
  */
  get switch_ba(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.CyclicCounter16,
    VAPI.RTPReceiver.MediaReceiverEventCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.CyclicCounter16,
      VAPI.RTPReceiver.MediaReceiverEventCounters
    >(this, "switch_ba" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }

  /**
    increased by 1 on every receiver stop
  */
  get stop(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.CyclicCounter16,
    VAPI.RTPReceiver.MediaReceiverEventCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.CyclicCounter16,
      VAPI.RTPReceiver.MediaReceiverEventCounters
    >(this, "stop" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }

  /**
    increased by 1 on every error-induced receiver restart
  */
  get restart(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.CyclicCounter16,
    VAPI.RTPReceiver.MediaReceiverEventCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.CyclicCounter16,
      VAPI.RTPReceiver.MediaReceiverEventCounters
    >(this, "restart" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }

  /**
    increased by 1 every time an accepted SDP request evicts another SDP
    currently targeted by the decoder backend
  */
  get stop_evicted(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.CyclicCounter16,
    VAPI.RTPReceiver.MediaReceiverEventCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.CyclicCounter16,
      VAPI.RTPReceiver.MediaReceiverEventCounters
    >(this, "stop_evicted" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }

  /**
    BBM video receivers that have their RX buffer supplied by other
    receivers' network streams do not attempt to freeze their decoder
    backends at switch time. If these foreign streams are withdrawn before
    the BBM switch has completed, the BBM receiver's decoder backend will be
    stopped, and `stop_abandoned` will increase by 1
  */
  get stop_abandoned(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.CyclicCounter16,
    VAPI.RTPReceiver.MediaReceiverEventCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.CyclicCounter16,
      VAPI.RTPReceiver.MediaReceiverEventCounters
    >(this, "stop_abandoned" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }

  /**
    if, during SDP request processing, the completion of a previously issued
    start command has not been verified conclusively, the decoder backend may
    be stopped, in which case `stop_unfinished_start_attempt` will increase
    by 1
  */
  get stop_unfinished_start_attempt(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.CyclicCounter16,
    VAPI.RTPReceiver.MediaReceiverEventCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.CyclicCounter16,
      VAPI.RTPReceiver.MediaReceiverEventCounters
    >(this, "stop_unfinished_start_attempt" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }

  /**
    if `clean_switching_policy` is set to `Whatever`, impossible
    clean-switching requests are silently converted to patch requests, thus
    causing loss-of-signal events at switch time
  */
  get downgraded_switch_requests(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.CyclicCounter16,
    VAPI.RTPReceiver.MediaReceiverEventCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.CyclicCounter16,
      VAPI.RTPReceiver.MediaReceiverEventCounters
    >(this, "downgraded_switch_requests" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }

  /**
    increased by 1 every time the receiver formally switches between
    identical media flows on tracks A and B
  */
  get elided_switch_requests(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.CyclicCounter16,
    VAPI.RTPReceiver.MediaReceiverEventCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.CyclicCounter16,
      VAPI.RTPReceiver.MediaReceiverEventCounters
    >(this, "elided_switch_requests" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
}
export class SessionEventCounters
  implements VScript.Referenceable<"RTPReceiver::Data::Session::EventCounters">
{
  readonly type_identifier =
    "RTPReceiver::Data::Session::EventCounters" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get num_rejected_sdps() {
    return VAPI.RTPReceiver.lift.SessionEventCountersNumRejectedSdps(
      VScript.VAPIHelpers.subtree_child_checked(
        this.raw,
        0,
        "num_rejected_sdps",
      ),
    );
  }
}
export class VideoReceiverMediaSpecificEventCounters
  implements
    VScript.Referenceable<"RTPReceiver::Data::VideoReceiver::MediaSpecific::EventCounters">
{
  readonly type_identifier =
    "RTPReceiver::Data::VideoReceiver::MediaSpecific::EventCounters" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get frame_drop_repeat_events(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.CyclicCounter32,
    VAPI.RTPReceiver.VideoReceiverMediaSpecificEventCounters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.CyclicCounter32,
      VAPI.RTPReceiver.VideoReceiverMediaSpecificEventCounters
    >(this, "frame_drop_repeat_events" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
}
export class PacketTracerFilters
  implements VScript.Referenceable<"RTPReceiver::Data::PacketTracer::Filters">
{
  readonly type_identifier =
    "RTPReceiver::Data::PacketTracer::Filters" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get udp_dst_port_range(): VScript.dKeyword<
    VScript.VSocket,
    null | [number, number],
    null | [number, number],
    null | VAPI.RTPReceiver.PacketTracerFiltersUdpDstPortRange,
    null | VAPI.RTPReceiver.PacketTracerFiltersUdpDstPortRange,
    VAPI.RTPReceiver.PacketTracerFilters
  > {
    return new VScript.dKeyword<
      VScript.VSocket,
      null | [number, number],
      null | [number, number],
      null | VAPI.RTPReceiver.PacketTracerFiltersUdpDstPortRange,
      null | VAPI.RTPReceiver.PacketTracerFiltersUdpDstPortRange,
      VAPI.RTPReceiver.PacketTracerFilters
    >(
      this,
      "udp_dst_port_range" as VScript.SysName,
      {
        lift: VScript.VAPIHelpers.liftOrLowerNullable(
          VAPI.RTPReceiver.lift.PacketTracerFiltersUdpDstPortRange,
        ),
        lower: VScript.VAPIHelpers.liftOrLowerNullable(
          VAPI.RTPReceiver.lower.PacketTracerFiltersUdpDstPortRange,
        ),
      },
      {
        lift: VScript.VAPIHelpers.liftOrLowerNullable(
          VAPI.RTPReceiver.lift.PacketTracerFiltersUdpDstPortRange,
        ),
        lower: VScript.VAPIHelpers.liftOrLowerNullable(
          VAPI.RTPReceiver.lower.PacketTracerFiltersUdpDstPortRange,
        ),
      },
      null,
    );
  }
  get vlan_id(): VScript.dKeyword<
    VScript.VSocket,
    null | number,
    null | number,
    null | VAPI.Primitives.VlanID,
    null | VAPI.Primitives.VlanID,
    VAPI.RTPReceiver.PacketTracerFilters
  > {
    return new VScript.dKeyword<
      VScript.VSocket,
      null | number,
      null | number,
      null | VAPI.Primitives.VlanID,
      null | VAPI.Primitives.VlanID,
      VAPI.RTPReceiver.PacketTracerFilters
    >(
      this,
      "vlan_id" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get dst_address(): VScript.dKeyword<
    VScript.VSocket,
    null | string,
    null | string,
    null | string,
    null | string,
    VAPI.RTPReceiver.PacketTracerFilters
  > {
    return new VScript.dKeyword<
      VScript.VSocket,
      null | string,
      null | string,
      null | string,
      null | string,
      VAPI.RTPReceiver.PacketTracerFilters
    >(
      this,
      "dst_address" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
}
export class MediaReceiverFlightPermit
  implements
    VScript.Referenceable<"RTPReceiver::Data::MediaReceiver::FlightPermit">
{
  readonly type_identifier =
    "RTPReceiver::Data::MediaReceiver::FlightPermit" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get denied(): VScript.rKeyword<
    VScript.VSocket,
    boolean,
    boolean,
    VAPI.RTPReceiver.MediaReceiverFlightPermit
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      boolean,
      boolean,
      VAPI.RTPReceiver.MediaReceiverFlightPermit
    >(this, "denied" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get remaining_patience(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | VScript.Duration,
    VAPI.RTPReceiver.MediaReceiverFlightPermit
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | VScript.Duration,
      VAPI.RTPReceiver.MediaReceiverFlightPermit
    >(this, "remaining_patience" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.liftNanoseconds,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.lowerNanoseconds,
      ),
    });
  }

  /**
    internal timestamp, initialized to zero at process startup
  */
  get prev_request_at(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | VAPI.RTPReceiver.DriverTime,
    VAPI.RTPReceiver.MediaReceiverFlightPermit
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | VAPI.RTPReceiver.DriverTime,
      VAPI.RTPReceiver.MediaReceiverFlightPermit
    >(this, "prev_request_at" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.liftNanoseconds,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.lowerNanoseconds,
      ),
    });
  }
}
export type MPacketFormat = number;
export class VideoReceiverMediaSpecificHardMetadataDecoder
  implements
    VScript.Referenceable<"RTPReceiver::Data::VideoReceiver::MediaSpecific::HardMetadataDecoder">
{
  readonly type_identifier =
    "RTPReceiver::Data::VideoReceiver::MediaSpecific::HardMetadataDecoder" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get statistics(): VScript.rKeyword<
    VScript.VSocket,
    null | [number, number, number, number],
    null | VAPI.RTPReceiver.VideoReceiverMediaSpecificHardMetadataDecoderStatistics,
    VAPI.RTPReceiver.VideoReceiverMediaSpecificHardMetadataDecoder
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | [number, number, number, number],
      null | VAPI.RTPReceiver.VideoReceiverMediaSpecificHardMetadataDecoderStatistics,
      VAPI.RTPReceiver.VideoReceiverMediaSpecificHardMetadataDecoder
    >(this, "statistics" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.RTPReceiver.lift
          .VideoReceiverMediaSpecificHardMetadataDecoderStatistics,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.RTPReceiver.lower
          .VideoReceiverMediaSpecificHardMetadataDecoderStatistics,
      ),
    });
  }
}
/**
  when set to `FirstStreamPresent`, the first packet stream to provide this
  receiver with valid format and timing characteristics will be used as the
  basis for the ensuing readout attempt. When set to `AllStreamsPresent`, the
  receiver will stall until all packet streams have been registered at their
  respective network interfaces. Whereas `FirstStreamPresent` may slightly
  reduce the time to readout, `AllStreamsPresent` is safer as it ensures
  immediate SPS protection (if so configured), and allows the receiver to
  correctly pick a rearguard stream if different network paths exhibit
  different transmission delays. In both cases, the set of packet streams
  considered encompasses only those flows directly referenced by this
  receiver's media description, not the auxiliary flows that may be routed to
  the receiver through stream sharing.
*/
export type MediaReceiverInitiateReadoutOn =
  | "FirstStreamPresent"
  | "AllStreamsPresent";
export interface SessionInterfaces {
  primary: null | VAPI.NetworkInterfaces.VirtualInterface;
  secondary: null | VAPI.NetworkInterfaces.VirtualInterface;
}
export type AllIssues = {
  out_of_bandwidth: boolean;
  required_port_down: boolean;
};
export type MediaReceiverIssues = {
  impossible_clean_switch_request: boolean;
  missing_or_uncalibrated_t_src: boolean;
  missing_streams: boolean;
  phase_mismatch: boolean;
  uncalibrated_genlock: boolean;
  undersized_timing_window: boolean;
  unsatisfied_capability_request: boolean;
  useless_capability_assignment: boolean;
};
export type PacketTracerIssues = {
  cannot_activate_while_downloading: boolean;
  cannot_reconfigure_while_active: boolean;
  invalid_port_assignment: boolean;
  missing_port_assignment: boolean;
  non_ipv4_dst_address: boolean;
  non_multicast_dst_address: boolean;
  unordered_port_range: boolean;
};
export type PassthroughReceiverIssues = { subscription_failed: boolean };
export type SessionIssues = { switch_type_request_blocked: boolean };
export type VideoReceiverMediaSpecificIssues = {
  audio_deembedder_errors: boolean;
  drop_repeat_frames: boolean;
  misaligned_anc_data: boolean;
  no_bbm_capabilities: boolean;
  video_decoding_errors: boolean;
};
export interface SessionLastAcceptedTrack {
  track: VAPI.RTPReceiver.Track;
  fc: VAPI.Time.FreeRunningCounter;
  controller_version: VAPI.SDP.ControllerVersion;

  /**
    Currently set to all zeroes if the given SDP does not specify a
    `controller-id`; in version 2.0 this will be replaced by a proper
    optional.
  */
  controller_id: VAPI.SDP.ControllerID;
}
export class MediaReceiverLatencySpread
  implements
    VScript.Referenceable<"RTPReceiver::Data::MediaReceiver::LatencySpread">
{
  readonly type_identifier =
    "RTPReceiver::Data::MediaReceiver::LatencySpread" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get per_subflow(): VScript.rKeyword<
    VScript.VSocket,
    Array<null | number>,
    Array<null | VScript.Duration>,
    VAPI.RTPReceiver.MediaReceiverLatencySpread
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      Array<null | number>,
      Array<null | VScript.Duration>,
      VAPI.RTPReceiver.MediaReceiverLatencySpread
    >(this, "per_subflow" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftArray(
        VScript.VAPIHelpers.liftOrLowerNullable(
          VScript.VAPIHelpers.liftSeconds,
        ),
      ),
      lower: VScript.VAPIHelpers.lowerArray(
        VScript.VAPIHelpers.liftOrLowerNullable(
          VScript.VAPIHelpers.lowerSeconds,
        ),
      ),
    });
  }
  get overall(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | VScript.Duration,
    VAPI.RTPReceiver.MediaReceiverLatencySpread
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | VScript.Duration,
      VAPI.RTPReceiver.MediaReceiverLatencySpread
    >(this, "overall" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.liftSeconds,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.lowerSeconds,
      ),
    });
  }
}
export class AllLicenseInformation
  implements VScript.Referenceable<"RTPReceiver::Data::All::LicenseInformation">
{
  readonly type_identifier =
    "RTPReceiver::Data::All::LicenseInformation" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get num_jpeg_xs_receivers(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.Unsigned16,
    VAPI.RTPReceiver.AllLicenseInformation
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.Unsigned16,
      VAPI.RTPReceiver.AllLicenseInformation
    >(this, "num_jpeg_xs_receivers" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
}
export interface ExpectationsMpacketFrom {
  sdp_a: boolean;
  sdp_b: boolean;
}
export class AllDiagnosticsMpacketTracer
  implements
    VScript.Referenceable<"RTPReceiver::Data::All::Diagnostics::MpacketTracer">
{
  readonly type_identifier =
    "RTPReceiver::Data::All::Diagnostics::MpacketTracer" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}

  /**
    write m-packet characteristics to `prev_mpacket`. Note that this may
    cause noticeable processing overhead, and thus will not be retained
    across reboots
  */
  get active(): VScript.dKeyword<
    VScript.VSocket,
    boolean,
    boolean,
    boolean,
    boolean,
    VAPI.RTPReceiver.AllDiagnosticsMpacketTracer
  > {
    return new VScript.dKeyword<
      VScript.VSocket,
      boolean,
      boolean,
      boolean,
      boolean,
      VAPI.RTPReceiver.AllDiagnosticsMpacketTracer
    >(
      this,
      "active" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get prev_mpacket(): VScript.rKeyword<
    VScript.VSocket,
    null | [number, boolean, number, number, number, number, number, number],
    null | VAPI.RTPReceiver.MPacketDebugInfo,
    VAPI.RTPReceiver.AllDiagnosticsMpacketTracer
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | [number, boolean, number, number, number, number, number, number],
      null | VAPI.RTPReceiver.MPacketDebugInfo,
      VAPI.RTPReceiver.AllDiagnosticsMpacketTracer
    >(this, "prev_mpacket" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.RTPReceiver.lift.MPacketDebugInfo,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.RTPReceiver.lower.MPacketDebugInfo,
      ),
    });
  }
}
export class SessionEventCountersNumRejectedSdps
  implements
    VScript.Referenceable<"RTPReceiver::Data::Session::EventCounters::NumRejectedSdps">
{
  readonly type_identifier =
    "RTPReceiver::Data::Session::EventCounters::NumRejectedSdps" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}

  /**
    increased by 1 every time a SDP command sent to track A is rejected
  */
  get sdp_a(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.Unsigned32,
    VAPI.RTPReceiver.SessionEventCountersNumRejectedSdps
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.Unsigned32,
      VAPI.RTPReceiver.SessionEventCountersNumRejectedSdps
    >(this, "sdp_a" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }

  /**
    increased by 1 every time a SDP command sent to track B is rejected
  */
  get sdp_b(): VScript.rKeyword<
    VScript.VSocket,
    number,
    VAPI.Primitives.Unsigned32,
    VAPI.RTPReceiver.SessionEventCountersNumRejectedSdps
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      VAPI.Primitives.Unsigned32,
      VAPI.RTPReceiver.SessionEventCountersNumRejectedSdps
    >(this, "sdp_b" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
}
/**
  when in clean-switching mode (i.e., if `switch_time` is neither 0 nor 1),
  SDP writes to `current_target` are rejected, followed by an informational
  error message. Set `on_sdp_collision` to `RejectSilently` to suppress this
  error message.
*/
export type AllSettingsOnSdpCollision = "RejectAndInform" | "RejectSilently";
/**
  Set this to `Store` to have the packet tracer store packet details (up to
  some limited maximum log file size) that can later be downloaded via HTTP.
*/
export type PacketTracerPacketDetails = "Discard" | "Store";
export type PacketTracerRunPacketDetails =
  | "Omitted"
  | "Stored"
  | "PartiallyStored";
export class TimingPhaseControl
  implements VScript.Referenceable<"RTPReceiver::Data::Timing::PhaseControl">
{
  readonly type_identifier = "RTPReceiver::Data::Timing::PhaseControl" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get settings(): VScript.dKeyword<
    VScript.VSocket,
    | [0, []]
    | [
        1,
        [
          null | number,
          null | number,
          boolean,
          [boolean, number, number],
          null | [number, number],
          null | number,
        ],
      ],
    | [0, []]
    | [
        1,
        [
          null | number,
          null | number,
          boolean,
          [boolean, number, number],
          null | [number, number],
          null | number,
        ],
      ],
    VAPI.RTPReceiver.PhaseControlSettings,
    VAPI.RTPReceiver.PhaseControlSettings,
    VAPI.RTPReceiver.TimingPhaseControl
  > {
    return new VScript.dKeyword<
      VScript.VSocket,
      | [0, []]
      | [
          1,
          [
            null | number,
            null | number,
            boolean,
            [boolean, number, number],
            null | [number, number],
            null | number,
          ],
        ],
      | [0, []]
      | [
          1,
          [
            null | number,
            null | number,
            boolean,
            [boolean, number, number],
            null | [number, number],
            null | number,
          ],
        ],
      VAPI.RTPReceiver.PhaseControlSettings,
      VAPI.RTPReceiver.PhaseControlSettings,
      VAPI.RTPReceiver.TimingPhaseControl
    >(
      this,
      "settings" as VScript.SysName,
      {
        lift: VAPI.RTPReceiver.lift.PhaseControlSettings,
        lower: VAPI.RTPReceiver.lower.PhaseControlSettings,
      },
      {
        lift: VAPI.RTPReceiver.lift.PhaseControlSettings,
        lower: VAPI.RTPReceiver.lower.PhaseControlSettings,
      },
      null,
    );
  }

  /**
    estimated time until |distance to buffer boundary| < 0.5 *
    `safety_margin`
  */
  get expected_time_to_collision(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | VScript.Duration,
    VAPI.RTPReceiver.TimingPhaseControl
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | VScript.Duration,
      VAPI.RTPReceiver.TimingPhaseControl
    >(this, "expected_time_to_collision" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.liftSeconds,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.lowerSeconds,
      ),
    });
  }

  /**
    This receiver's output phase is currently drifting, as defined by
    `settings.status.drift_tolerance`. Defaults to `true` if `current_phase`
    fails to supply a drift estimate
  */
  get drifting_phase(): VScript.rKeyword<
    VScript.VSocket,
    boolean,
    boolean,
    VAPI.RTPReceiver.TimingPhaseControl
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      boolean,
      boolean,
      VAPI.RTPReceiver.TimingPhaseControl
    >(this, "drifting_phase" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
}
/**
  interpret `current_phase` as a phase error if `|current_phase.offset.value|
  > phase_sensitivity.value` and `current_phase.offset.error <
  phase_sensitivity.error × |current_phase.offset.value|`
*/
export interface PhaseControlSettingsManualPhaseSensitivity {
  value: VScript.Duration;
  error: number;
}
export type AudioServoPrioritize = "Quality" | "Responsiveness";
export class TimingReadDelay
  implements VScript.Referenceable<"RTPReceiver::Data::Timing::ReadDelay">
{
  readonly type_identifier = "RTPReceiver::Data::Timing::ReadDelay" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get overall(): VScript.rKeyword<
    VScript.VSocket,
    null | [number, number, number, number],
    null | VAPI.Time.TimestampedOffset,
    VAPI.RTPReceiver.TimingReadDelay
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | [number, number, number, number],
      null | VAPI.Time.TimestampedOffset,
      VAPI.RTPReceiver.TimingReadDelay
    >(this, "overall" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.Time.lift.TimestampedOffset,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.Time.lower.TimestampedOffset,
      ),
    });
  }
  get rearguard(): VScript.rKeyword<
    VScript.VSocket,
    null | [number, number, number, number],
    null | VAPI.Time.TimestampedOffset,
    VAPI.RTPReceiver.TimingReadDelay
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | [number, number, number, number],
      null | VAPI.Time.TimestampedOffset,
      VAPI.RTPReceiver.TimingReadDelay
    >(this, "rearguard" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.Time.lift.TimestampedOffset,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.Time.lower.TimestampedOffset,
      ),
    });
  }
}
export interface TimingReadDelayBounds {
  min: null | VScript.Duration;
  max: null | VScript.Duration;
}
export class MediaReceiverRedundancyLevels
  implements
    VScript.Referenceable<"RTPReceiver::Data::MediaReceiver::RedundancyLevels">
{
  readonly type_identifier =
    "RTPReceiver::Data::MediaReceiver::RedundancyLevels" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get nominally_present() {
    return VAPI.RTPReceiver.lift.CurrentRedundancyLevels(
      VScript.VAPIHelpers.subtree_child_checked(
        this.raw,
        0,
        "nominally_present",
      ),
    );
  }
  get within_safe_bounds() {
    return VAPI.RTPReceiver.lift.CurrentRedundancyLevels(
      VScript.VAPIHelpers.subtree_child_checked(
        this.raw,
        1,
        "within_safe_bounds",
      ),
    );
  }
}
export interface MediaReceiverRequiredRedundancyLevel {
  /**
    number of packet streams referenced by this receiver's media description
    at track A that must have been registered at their respective network
    interfaces for the receiver to attempt readout
  */
  sdp_a: VAPI.RTPReceiver.RedundancyLevel;

  /**
    number of packet streams referenced by this receiver's media description
    at track B that must have been registered at their respective network
    interfaces for the receiver to attempt readout
  */
  sdp_b: VAPI.RTPReceiver.RedundancyLevel;
}
export interface VideoReceiverMediaSpecificSoftMetadataDecoderRtpChannelStatistics {
  packets_lost: VAPI.Primitives.CyclicCounter32;
  packets_sent: VAPI.Primitives.CyclicCounter32;
}
/**
  determines how SDP files entered into `sdp_a_command` or `sdp_b_command`
  translate into their respective `status` counterparts. If `sdp_generation`
  is set to `Verbatim`, accepted SDP files are copied to `status` unmodified,
  even if some or all of the media descriptions within could not be serviced
  due to resource exhaustion. If `sdp_generation` is set to `Semantic`, only
  operationally effective parts of the SDP will be emitted.
*/
export type AllSettingsSdpGeneration = "Semantic" | "Verbatim";
export class VideoReceiverMediaSpecificSoftMetadataDecoder
  implements
    VScript.Referenceable<"RTPReceiver::Data::VideoReceiver::MediaSpecific::SoftMetadataDecoder">
{
  readonly type_identifier =
    "RTPReceiver::Data::VideoReceiver::MediaSpecific::SoftMetadataDecoder" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get statistics(): VScript.rKeyword<
    VScript.VSocket,
    | null
    | [
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
      ],
    null | VAPI.RTPReceiver.SoftMetadataStatistics,
    VAPI.RTPReceiver.VideoReceiverMediaSpecificSoftMetadataDecoder
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      | null
      | [
          number,
          number,
          number,
          number,
          number,
          number,
          number,
          number,
          number,
          number,
          number,
          number,
        ],
      null | VAPI.RTPReceiver.SoftMetadataStatistics,
      VAPI.RTPReceiver.VideoReceiverMediaSpecificSoftMetadataDecoder
    >(this, "statistics" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.RTPReceiver.lift.SoftMetadataStatistics,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VAPI.RTPReceiver.lower.SoftMetadataStatistics,
      ),
    });
  }
  get rtp_channel_statistics(): VScript.rKeyword<
    VScript.VSocket,
    [number, number],
    VAPI.RTPReceiver.VideoReceiverMediaSpecificSoftMetadataDecoderRtpChannelStatistics,
    VAPI.RTPReceiver.VideoReceiverMediaSpecificSoftMetadataDecoder
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      [number, number],
      VAPI.RTPReceiver.VideoReceiverMediaSpecificSoftMetadataDecoderRtpChannelStatistics,
      VAPI.RTPReceiver.VideoReceiverMediaSpecificSoftMetadataDecoder
    >(this, "rtp_channel_statistics" as VScript.SysName, {
      lift: VAPI.RTPReceiver.lift
        .VideoReceiverMediaSpecificSoftMetadataDecoderRtpChannelStatistics,
      lower:
        VAPI.RTPReceiver.lower
          .VideoReceiverMediaSpecificSoftMetadataDecoderRtpChannelStatistics,
    });
  }
}
export interface VideoReceiverMediaSpecificHardMetadataDecoderStatistics {
  num_relocations: number;
  num_embedded_packets: number;
  fc: VAPI.Time.FreeRunningCounter;
  micro_epoch_index: VAPI.Time.MicroEpochIndex;
}
export interface PacketTracerFiltersUdpDstPortRange {
  min: VAPI.Primitives.Unsigned16;
  max: VAPI.Primitives.Unsigned16;
}
export type Unsigned12 = number;
export class SessionVersionWindow
  implements VScript.Referenceable<"RTPReceiver::Data::Session::VersionWindow">
{
  readonly type_identifier =
    "RTPReceiver::Data::Session::VersionWindow" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}

  /**
    Reject incoming SDPs unless their version (specified using a
    session-level `a=controller-version:` attribute) exceeds the most
    recently accepted version by at least this much, using cyclic 32-bit
    arithmetic
  */
  get min_delta(): VScript.dKeyword<
    VScript.VSocket,
    null | number,
    null | number,
    null | number,
    null | number,
    VAPI.RTPReceiver.SessionVersionWindow
  > {
    return new VScript.dKeyword<
      VScript.VSocket,
      null | number,
      null | number,
      null | number,
      null | number,
      VAPI.RTPReceiver.SessionVersionWindow
    >(
      this,
      "min_delta" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }

  /**
    Reject incoming SDPs unless their version (specified using a
    session-level `a=controller-version:` attribute) exceeds the most
    recently accepted version by no more than this much, using cyclic 32-bit
    arithmetic
  */
  get max_delta(): VScript.dKeyword<
    VScript.VSocket,
    null | number,
    null | number,
    null | number,
    null | number,
    VAPI.RTPReceiver.SessionVersionWindow
  > {
    return new VScript.dKeyword<
      VScript.VSocket,
      null | number,
      null | number,
      null | number,
      null | number,
      VAPI.RTPReceiver.SessionVersionWindow
    >(
      this,
      "max_delta" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
}
export const Enums = {
  VidStd20226Authority: [
    "SDPFmtpAttribute",
    "MPacketMetadata",
  ] as VidStd20226Authority[],
  TrackSet: ["Empty", "A", "B", "AB"] as TrackSet[],
  Track: ["A", "B"] as Track[],
  StatsSubscriptionType: ["InsertNew", "ReplaceOld"] as StatsSubscriptionType[],
  SamplingStructure: ["Interlaced", "Progressive"] as SamplingStructure[],
  ResourceExhaustionPolicy: [
    "Refuse",
    "BestEffort",
  ] as ResourceExhaustionPolicy[],
  PhaseMismatchSeverity: [
    "TargetViolation",
    "SafetyViolation",
  ] as PhaseMismatchSeverity[],
  PacketTracerMode: [
    "Seqnr",
    "DstPort_Delta",
    "Frc_Seqnr",
    "SrcIp_DstIp_DstPort",
    "Frc_Seqnr_DstPort_Timestamp",
  ] as PacketTracerMode[],
  PacketStreamType: [
    "Audio",
    "Video2022_6",
    "VideoOther",
    "Video2110_40_Metadata",
    "VideoJpegXs",
    "MipMap",
    "J2K",
    "Passthrough",
  ] as PacketStreamType[],
  OrderedTrackSet: ["X", "A", "B", "AB", "BA", "XA", "XB"] as OrderedTrackSet[],
  OnIsolatedSubstream: [
    "PropagateSubstreamAttribute",
    "StripSubstreamAttribute",
  ] as OnIsolatedSubstream[],
  NetworkSourceType: [
    "Audio",
    "Video2042_2",
    "Video2110_20",
    "Video2110_20_UHD",
    "VideoJpegXs",
    "Video2022_6",
    "Video2110_40_SoftMetadata",
    "Video2110_40_NativeMetadata",
    "Video2110_40_JpegXSMetadata",
    "Video2110_40_AncBurst",
    "MipMap",
    "J2K",
    "Passthrough",
  ] as NetworkSourceType[],
  MemoryRegion: ["Main", "Alternate"] as MemoryRegion[],
  MediaReceiverType: ["AncBurst", "Audio", "Video"] as MediaReceiverType[],
  LogicalSwitchTime: [
    "Patch",
    "Past",
    "WithinCooldownTime",
    "WithinPreparationTime",
    "Future",
  ] as LogicalSwitchTime[],
  JumpResponse: ["Pending", "Refused"] as JumpResponse[],
  IngressTrackState: [
    "Inactive",
    "Activating",
    "Active",
  ] as IngressTrackState[],
  FrameShiftPolicy: [
    "Prohibit",
    "PermitFrameShifts",
    "PermitSubframeShifts",
  ] as FrameShiftPolicy[],
  ErrorHandler: ["Ignore", "RestartReceiver"] as ErrorHandler[],
  ErrorCondition: [
    "RXErrors",
    "PrematureRead",
    "LivenessTimeout",
    "MPacketError",
    "OffsetError2110",
    "LinenrError2110",
  ] as ErrorCondition[],
  CleanSwitchingPolicy: [
    "Strict",
    "Tolerant",
    "Whatever",
  ] as CleanSwitchingPolicy[],
  BackpressurePolicy: ["Yield", "Resist"] as BackpressurePolicy[],
} as const;
