move unrolled mime type check for broader use (#3326)

* move unrolled mime type check for broader use

* Use in IsSvcCodec and make MimeType exported

* test

* tidy branches

* tidy

---------

Co-authored-by: Paul Wells <paulwe@gmail.com>
This commit is contained in:
Raja Subramanian
2025-01-13 10:24:03 +05:30
committed by GitHub
co-authored by Paul Wells
parent 53d300ba71
commit 7c58fdf329
3 changed files with 175 additions and 9 deletions
+8 -9
View File
@@ -785,8 +785,9 @@ func (b *Buffer) getExtPacket(rtpPacket *rtp.Packet, arrivalTime int64, flowStat
// DD-TODO : notify active decode target change if changed.
}
}
switch b.mime {
case "video/vp8":
switch utils.MatchMimeType(b.mime) {
case utils.MimeTypeVP8:
vp8Packet := VP8{}
if err := vp8Packet.Unmarshal(rtpPacket.Payload); err != nil {
b.logger.Warnw("could not unmarshal VP8 packet", err)
@@ -802,7 +803,7 @@ func (b *Buffer) getExtPacket(rtpPacket *rtp.Packet, arrivalTime int64, flowStat
ep.Payload = vp8Packet
ep.Spatial = InvalidLayerSpatial // vp8 don't have spatial scalability, reset to invalid
case "video/vp9":
case utils.MimeTypeVP9:
if ep.DependencyDescriptor == nil {
var vp9Packet codecs.VP9Packet
_, err := vp9Packet.Unmarshal(rtpPacket.Payload)
@@ -818,11 +819,11 @@ func (b *Buffer) getExtPacket(rtpPacket *rtp.Packet, arrivalTime int64, flowStat
}
ep.KeyFrame = IsVP9KeyFrame(rtpPacket.Payload)
case "video/h264":
case utils.MimeTypeH264:
ep.KeyFrame = IsH264KeyFrame(rtpPacket.Payload)
ep.Spatial = InvalidLayerSpatial // h.264 don't have spatial scalability, reset to invalid
case "video/av1":
case utils.MimeTypeAV1:
ep.KeyFrame = IsAV1KeyFrame(rtpPacket.Payload)
}
@@ -1122,10 +1123,8 @@ func (b *Buffer) GetTemporalLayerFpsForSpatial(layer int32) []float32 {
// SVC-TODO: May only need to differentiate between simulcast and non-simulcast
// SVC-TODO: i. e. may be possible to treat single layer as SVC to get proper/intended functionality.
func IsSvcCodec(mime string) bool {
switch strings.ToLower(mime) {
case "video/av1":
fallthrough
case "video/vp9":
switch utils.MatchMimeType(mime) {
case utils.MimeTypeAV1, utils.MimeTypeVP9:
return true
}
return false