// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package rtpfb

import (
	"time"

	"github.com/pion/rtcp"
)

type PacketReport struct {
	// SSRC of the stream the packet was sent on.
	SSRC uint32

	// Sequence number of the packet generated by the rtpfb.Interceptor. The
	// sequence number increases by 1 for every outgoing packet independent of
	// the stream it is sent on.
	SequenceNumber uint64

	// Sequence number from the RTP header.
	RTPSequenceNumber uint16

	// IsTWCC is true if the packet was tracked by the
	// transport-wide-congestion-control header extension instead of the
	// combination of SSRC and RTPSequenceNumber.
	IsTWCC bool

	// Sequence number from the transport-wide-congestion-control header
	// extension.
	TWCCSequenceNumber uint16

	// Size is the size of the packet in bytes.
	Size int

	// Arrived indicates if the packet arrived at the receiver. False does not
	// necessarily mean the packet was lost, it might still be in transit.
	Arrived bool

	// Departure is the departure time of the packet taken at the sender. It
	// should be the time measured at the latest possible moment before sending
	// the packet.
	Departure time.Time

	// Arrival is the arrival time of the packet at the receiver. Arrival and
	// Departure do not require synchronized clocks and can therefore not
	// directly be compared.
	Arrival time.Time

	// ECN marking of the packet when it arrived.
	ECN rtcp.ECN
}

// A Report contains the Arrival time of a CCFB or TWCC packet, the estimated
// RTT based on the feedback packet and a list of PacketReport for all
// acknowledged packets that were still in the history and not yet included in
// an earlier Report.
type Report struct {
	Arrival       time.Time
	RTT           time.Duration
	PacketReports []PacketReport
}
