-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip AC-3, EC-3, closed caption tracks
- Loading branch information
Showing
6 changed files
with
644 additions
and
281 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
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
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,47 @@ | ||
package hls | ||
|
||
import ( | ||
"encoding/hex" | ||
"strconv" | ||
"strings" | ||
|
||
"github.com/aler9/gortsplib/v2/pkg/codecs/h265" | ||
"github.com/aler9/gortsplib/v2/pkg/format" | ||
) | ||
|
||
func codecParametersGenerate(track format.Format) string { | ||
switch ttrack := track.(type) { | ||
case *format.H264: | ||
sps := ttrack.SafeSPS() | ||
if len(sps) >= 4 { | ||
return "avc1." + hex.EncodeToString(sps[1:4]) | ||
} | ||
|
||
case *format.H265: | ||
var sps h265.SPS | ||
err := sps.Unmarshal(ttrack.SafeSPS()) | ||
if err == nil { | ||
return "hvc1." + strconv.FormatInt(int64(sps.ProfileTierLevel.GeneralProfileIdc), 10) + | ||
".4.L" + strconv.FormatInt(int64(sps.ProfileTierLevel.GeneralLevelIdc), 10) + ".B0" | ||
} | ||
|
||
case *format.MPEG4Audio: | ||
// https://developer.mozilla.org/en-US/docs/Web/Media/Formats/codecs_parameter | ||
return "mp4a.40." + strconv.FormatInt(int64(ttrack.Config.Type), 10) | ||
|
||
case *format.Opus: | ||
return "opus" | ||
} | ||
|
||
return "" | ||
} | ||
|
||
func codecParametersAreSupported(codecs string) bool { | ||
for _, codec := range strings.Split(codecs, ",") { | ||
if !strings.HasPrefix(codec, "avc1.") && | ||
!strings.HasPrefix(codec, "mp4a.") { | ||
return false | ||
} | ||
} | ||
return true | ||
} |
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.