include "rtpParameters.fbs";
include "rtxStream.fbs";

namespace FBS.RtpStream;

table Params {
    encoding_idx: uint32;
    ssrc: uint32;
    payload_type: uint8;
    mime_type: string (required);
    clock_rate: uint32;
    rid: string;
    cname: string (required);
    rtx_ssrc: uint32 = null;
    rtx_payload_type: uint8 = null;
    use_nack: bool;
    use_pli: bool;
    use_fir: bool;
    use_in_band_fec: bool;
    use_dtx: bool;
    spatial_layers: uint8;
    temporal_layers: uint8;
}

table Dump {
    params: Params (required);
    score: uint8;
    rtx_stream: FBS.RtxStream.RtxDump;
}

table BitrateByLayer {
    layer: string (required);
    bitrate: uint32;
}

union StatsData {
    BaseStats,
    RecvStats,
    SendStats,
}

table Stats {
    data: StatsData (required);
}

table BaseStats {
    timestamp: uint64;
    ssrc: uint32;
    kind: FBS.RtpParameters.MediaKind;
    mime_type: string (required);
    packets_lost: int32;
    fraction_lost: uint8;
    jitter: uint32;
    packets_discarded: uint64;
    packets_retransmitted: uint64;
    packets_repaired: uint64;
    nack_count: uint64;
    nack_packet_count: uint64;
    pli_count: uint64;
    fir_count: uint64;
    rid: string;
    rtx_ssrc: uint32 = null;
    rtx_packets_discarded: uint64;
    round_trip_time: float;
    score: uint8;
}

table RecvStats {
    base: Stats (required);
    packet_count: uint64;
    byte_count: uint64;
    bitrate: uint32;
    bitrate_by_layer: [BitrateByLayer] (required);
}

table SendStats {
    base: Stats (required);
    packet_count: uint64;
    byte_count: uint64;
    bitrate: uint32;
}

