Don't create DDParser for non-svc codec (#2883)

This commit is contained in:
cnderrauber
2024-07-19 10:52:27 +08:00
committed by GitHub
parent a877ba2352
commit 0c5b5537b2
3 changed files with 30 additions and 28 deletions
+1 -1
View File
@@ -245,7 +245,7 @@ func (t *MediaTrackReceiver) SetPotentialCodecs(codecs []webrtc.RTPCodecParamete
}
if !exist {
extHeaders := headers
if !sfu.IsSvcCodec(c.MimeType) {
if !buffer.IsSvcCodec(c.MimeType) {
extHeaders = headersWithoutDD
}
receivers = append(receivers, &simulcastReceiver{
+27 -7
View File
@@ -229,14 +229,16 @@ func (b *Buffer) Bind(params webrtc.RTPParameters, codec webrtc.RTPCodecCapabili
for _, ext := range params.HeaderExtensions {
switch ext.URI {
case dd.ExtensionURI:
b.ddExtID = uint8(ext.ID)
frc := NewFrameRateCalculatorDD(b.clockRate, b.logger)
for i := range b.frameRateCalculator {
b.frameRateCalculator[i] = frc.GetFrameRateCalculatorForSpatial(int32(i))
if IsSvcCodec(codec.MimeType) {
b.ddExtID = uint8(ext.ID)
frc := NewFrameRateCalculatorDD(b.clockRate, b.logger)
for i := range b.frameRateCalculator {
b.frameRateCalculator[i] = frc.GetFrameRateCalculatorForSpatial(int32(i))
}
b.ddParser = NewDependencyDescriptorParser(b.ddExtID, b.logger, func(spatial, temporal int32) {
frc.SetMaxLayer(spatial, temporal)
})
}
b.ddParser = NewDependencyDescriptorParser(b.ddExtID, b.logger, func(spatial, temporal int32) {
frc.SetMaxLayer(spatial, temporal)
})
case sdp.AudioLevelURI:
b.audioLevelExtID = uint8(ext.ID)
@@ -1149,3 +1151,21 @@ func (b *Buffer) GetTemporalLayerFpsForSpatial(layer int32) []float32 {
}
return nil
}
// SVC-TODO: Have to use more conditions to differentiate between
// SVC-TODO: SVC and non-SVC (could be single layer or simulcast).
// 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":
return true
}
return false
}
func IsRedCodec(mime string) bool {
return strings.HasSuffix(strings.ToLower(mime), "red")
}
+2 -20
View File
@@ -132,24 +132,6 @@ type WebRTCReceiver struct {
forwardStats *ForwardStats
}
// SVC-TODO: Have to use more conditions to differentiate between
// SVC-TODO: SVC and non-SVC (could be single layer or simulcast).
// 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":
return true
}
return false
}
func IsRedCodec(mime string) bool {
return strings.HasSuffix(strings.ToLower(mime), "red")
}
type ReceiverOpts func(w *WebRTCReceiver) *WebRTCReceiver
// WithPliThrottleConfig indicates minimum time(ms) between sending PLIs
@@ -220,8 +202,8 @@ func NewWebRTCReceiver(
codec: track.Codec(),
kind: track.Kind(),
onRTCP: onRTCP,
isSVC: IsSvcCodec(track.Codec().MimeType),
isRED: IsRedCodec(track.Codec().MimeType),
isSVC: buffer.IsSvcCodec(track.Codec().MimeType),
isRED: buffer.IsRedCodec(track.Codec().MimeType),
}
for _, opt := range opts {