Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
CodeQL / analyze (push) Failing after 1s
Fuzz / fuzz (push) Failing after 0s
58 lines
1.6 KiB
Go
58 lines
1.6 KiB
Go
// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package fmtp
|
|
|
|
import "strings"
|
|
|
|
type h265FMTP struct {
|
|
parameters map[string]string
|
|
}
|
|
|
|
func (h *h265FMTP) MimeType() string {
|
|
return "video/h265"
|
|
}
|
|
|
|
// Match returns true if h and b describe compatible H.265 media formats.
|
|
// draft-ietf-avtcore-hevc-webrtc-09 Section 2.1 defines profile-id,
|
|
// tier-flag, and tx-mode as the H.265 media format parameters for WebRTC:
|
|
// https://datatracker.ietf.org/doc/html/draft-ietf-avtcore-hevc-webrtc-09#section-2.1
|
|
//
|
|
// level-id is intentionally not compared, as required by W3C WebRTC candidate
|
|
// correction 52:
|
|
// https://www.w3.org/TR/webrtc/#codec-match-without-level-id
|
|
// RFC 7798 Section 7.2.2 permits an answer to lower it, so treating it as a
|
|
// symmetric parameter would reject a valid offer/answer exchange:
|
|
// https://www.rfc-editor.org/rfc/rfc7798.html#section-7.2.2
|
|
func (h *h265FMTP) Match(b FMTP) bool {
|
|
fmtp, ok := b.(*h265FMTP)
|
|
if !ok {
|
|
return false
|
|
}
|
|
|
|
return strings.EqualFold(
|
|
h.parameterOrDefault("profile-id", "1"),
|
|
fmtp.parameterOrDefault("profile-id", "1"),
|
|
) && strings.EqualFold(
|
|
h.parameterOrDefault("tier-flag", "0"),
|
|
fmtp.parameterOrDefault("tier-flag", "0"),
|
|
) && strings.EqualFold(
|
|
h.parameterOrDefault("tx-mode", "SRST"),
|
|
fmtp.parameterOrDefault("tx-mode", "SRST"),
|
|
)
|
|
}
|
|
|
|
func (h *h265FMTP) Parameter(key string) (string, bool) {
|
|
v, ok := h.parameters[key]
|
|
|
|
return v, ok
|
|
}
|
|
|
|
func (h *h265FMTP) parameterOrDefault(key, defaultValue string) string {
|
|
if value, ok := h.Parameter(key); ok {
|
|
return value
|
|
}
|
|
|
|
return defaultValue
|
|
}
|