package com.foxx.androidcast.network.control;

/*********************************************************************
 * NetworkStatsSnapshot.java
 * Created at: Fri 15 May 2026 17:47:09 +0200
 * Updated at: Wed 20 May 2026 15:17:13 +0200 by Anton Afanasyeu <a.afanasieff@gmail.com>
 * Commit: 5d8e82d2e60a21fff3138d2a394ee4e8b4c6dcb8
 * class NetworkStatsSnapshot
 * Contributors:
 *    - Anton Afanasyeu <a.afanasieff@gmail.com> (5 commits, 107 lines)
 *    - Cursor Agent (project assistant)
 * Digest: SHA256	f63d6815d874e115f739dd6c42a23c64df6615f4ea267ef5e132af59a78e2a45
**********************************************************************/
/** Point-in-time network metrics exchanged between sender and receiver. */
public class NetworkStatsSnapshot {
    public long sequence;
    public long timestampMs;
    public int rttMs;
    public float lossRatio;
    public int sendBitrateKbps;
    public int recvBitrateKbps;
    public int congestionLevel;
    public int jitterMs;

    /** v2 extension: sender encode FPS (receiver: decode/render FPS). */
    public float encodeFps;
    public int encodeQueueDepth;
    public int droppedPFrames;
    public boolean audioActive;
    public long audioFramesSent;
    public int suggestedBitrateKbps;
    public int targetBitrateKbps;

    /** v3: sender pre-encode PCM levels (receiver: post-decode levels in overlay only). */
    public int audioCaptureVuPercent;
    public long audioCaptureSilentBlocks;
    public long audioCaptureAudibleBlocks;
    public float audioCapturePeakDb;
    public float audioCaptureRmsDb;

    /** v4: UDP + app-layer loss (see {@link com.foxx.androidcast.network.transport.TransportLossStats}). */
    public long udpDatagramsRx;
    public long udpDatagramsTx;
    public long udpDatagramsInvalid;
    public long udpFragmentsRx;
    public long udpFragmentsDuplicate;
    public long udpReassemblyOk;
    public long udpReassemblyLost;
    public long udpWireDropped;
    public long udpMalformed;
    public int droppedAudioFrames;
    public long recvVideoPackets;
    public long recvAudioPackets;
    public long recvVideoSkippedKey;
    public long recvVideoDecodeErrors;
    public long recvAudioDecodeErrors;
    public long recvAudioQueueDrops;
    public long recvDamagedVideoFrames;
    public String protectionMode = "NONE";
    public long fecStubPackets;
    public long fecPacketsDecoded;
    public long fecDecodeFailures;
    public long nackStubRequests;

    public NetworkStatsSnapshot copy() {
        NetworkStatsSnapshot c = new NetworkStatsSnapshot();
        c.sequence = sequence;
        c.timestampMs = timestampMs;
        c.rttMs = rttMs;
        c.lossRatio = lossRatio;
        c.sendBitrateKbps = sendBitrateKbps;
        c.recvBitrateKbps = recvBitrateKbps;
        c.congestionLevel = congestionLevel;
        c.jitterMs = jitterMs;
        c.encodeFps = encodeFps;
        c.encodeQueueDepth = encodeQueueDepth;
        c.droppedPFrames = droppedPFrames;
        c.audioActive = audioActive;
        c.audioFramesSent = audioFramesSent;
        c.suggestedBitrateKbps = suggestedBitrateKbps;
        c.targetBitrateKbps = targetBitrateKbps;
        c.audioCaptureVuPercent = audioCaptureVuPercent;
        c.audioCaptureSilentBlocks = audioCaptureSilentBlocks;
        c.audioCaptureAudibleBlocks = audioCaptureAudibleBlocks;
        c.audioCapturePeakDb = audioCapturePeakDb;
        c.audioCaptureRmsDb = audioCaptureRmsDb;
        c.udpDatagramsRx = udpDatagramsRx;
        c.udpDatagramsTx = udpDatagramsTx;
        c.udpDatagramsInvalid = udpDatagramsInvalid;
        c.udpFragmentsRx = udpFragmentsRx;
        c.udpFragmentsDuplicate = udpFragmentsDuplicate;
        c.udpReassemblyOk = udpReassemblyOk;
        c.udpReassemblyLost = udpReassemblyLost;
        c.udpWireDropped = udpWireDropped;
        c.udpMalformed = udpMalformed;
        c.droppedAudioFrames = droppedAudioFrames;
        c.recvVideoPackets = recvVideoPackets;
        c.recvAudioPackets = recvAudioPackets;
        c.recvVideoSkippedKey = recvVideoSkippedKey;
        c.recvVideoDecodeErrors = recvVideoDecodeErrors;
        c.recvAudioDecodeErrors = recvAudioDecodeErrors;
        c.recvAudioQueueDrops = recvAudioQueueDrops;
        c.recvDamagedVideoFrames = recvDamagedVideoFrames;
        c.protectionMode = protectionMode;
        c.fecStubPackets = fecStubPackets;
        c.fecPacketsDecoded = fecPacketsDecoded;
        c.fecDecodeFailures = fecDecodeFailures;
        c.nackStubRequests = nackStubRequests;
        return c;
    }
}
