-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently, AV1 or VP9 formats are matched regardless of the profile parameter. This was not noticeable until browsers started advertising multiple VP9 formats at the same time, each with a different profile ID, in order to allow the counterpart to send different streams on the basis of supported profiles. This causes two issues: first, the library includes in the SDP all formats passed by the browser, regardless of the fact that the profile ID is registered in the API or not. Then, the library is unable to choose the correct format for streaming, causing an intermittent failure. This patch fixes the matching algorithm and also covers the case in which the profile ID is missing, by using values dictated by specifications. Tests were refactored since previous ones covered the same lines multiple times.
- Loading branch information
Showing
5 changed files
with
573 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly> | ||
// SPDX-License-Identifier: MIT | ||
|
||
package fmtp | ||
|
||
type av1FMTP struct { | ||
parameters map[string]string | ||
} | ||
|
||
func (h *av1FMTP) MimeType() string { | ||
return "video/av1" | ||
} | ||
|
||
func (h *av1FMTP) Match(b FMTP) bool { | ||
c, ok := b.(*av1FMTP) | ||
if !ok { | ||
return false | ||
} | ||
|
||
// AV1 RTP specification: | ||
// If the profile parameter is not present, it MUST be inferred to be 0 (“Main” profile). | ||
hProfile, ok := h.parameters["profile"] | ||
if !ok { | ||
hProfile = "0" | ||
} | ||
cProfile, ok := c.parameters["profile"] | ||
if !ok { | ||
cProfile = "0" | ||
} | ||
if hProfile != cProfile { | ||
return false | ||
} | ||
|
||
return true | ||
} | ||
|
||
func (h *av1FMTP) Parameter(key string) (string, bool) { | ||
v, ok := h.parameters[key] | ||
return v, ok | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.