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

//go:build !js
// +build !js

package webrtc

// GetConnectionStats is a helper method to return the associated stats for a given PeerConnection.
func ( StatsReport) ( *PeerConnection) (PeerConnectionStats, bool) {
	 := .getStatsID()
	,  := []
	if ! {
		return PeerConnectionStats{}, false
	}

	,  := .(PeerConnectionStats)
	if ! {
		return PeerConnectionStats{}, false
	}

	return , true
}

// GetDataChannelStats is a helper method to return the associated stats for a given DataChannel.
func ( StatsReport) ( *DataChannel) (DataChannelStats, bool) {
	 := .getStatsID()
	,  := []
	if ! {
		return DataChannelStats{}, false
	}

	,  := .(DataChannelStats)
	if ! {
		return DataChannelStats{}, false
	}

	return , true
}

// GetICECandidateStats is a helper method to return the associated stats for a given ICECandidate.
func ( StatsReport) ( *ICECandidate) (ICECandidateStats, bool) {
	 := .statsID
	,  := []
	if ! {
		return ICECandidateStats{}, false
	}

	,  := .(ICECandidateStats)
	if ! {
		return ICECandidateStats{}, false
	}

	return , true
}

// GetICECandidatePairStats is a helper method to return the associated stats for a given ICECandidatePair.
func ( StatsReport) ( *ICECandidatePair) (ICECandidatePairStats, bool) {
	 := .statsID
	,  := []
	if ! {
		return ICECandidatePairStats{}, false
	}

	,  := .(ICECandidatePairStats)
	if ! {
		return ICECandidatePairStats{}, false
	}

	return , true
}

// GetCertificateStats is a helper method to return the associated stats for a given Certificate.
func ( StatsReport) ( *Certificate) (CertificateStats, bool) {
	 := .statsID
	,  := []
	if ! {
		return CertificateStats{}, false
	}

	,  := .(CertificateStats)
	if ! {
		return CertificateStats{}, false
	}

	return , true
}

// GetCodecStats is a helper method to return the associated stats for a given Codec.
func ( StatsReport) ( *RTPCodecParameters) (CodecStats, bool) {
	 := .statsID
	,  := []
	if ! {
		return CodecStats{}, false
	}

	,  := .(CodecStats)
	if ! {
		return CodecStats{}, false
	}

	return , true
}