Do not offer H.264 high profile in subscriber offer. (#1997)
* Do not offer H.264 high profile in subscriber offer. Do not register H.264 high profile with media engine in subscriber direction. * add comments
This commit is contained in:
@@ -26,7 +26,7 @@ import (
|
|||||||
var opusCodecCapability = webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeOpus, ClockRate: 48000, Channels: 2, SDPFmtpLine: "minptime=10;useinbandfec=1"}
|
var opusCodecCapability = webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeOpus, ClockRate: 48000, Channels: 2, SDPFmtpLine: "minptime=10;useinbandfec=1"}
|
||||||
var redCodecCapability = webrtc.RTPCodecCapability{MimeType: sfu.MimeTypeAudioRed, ClockRate: 48000, Channels: 2, SDPFmtpLine: "111/111"}
|
var redCodecCapability = webrtc.RTPCodecCapability{MimeType: sfu.MimeTypeAudioRed, ClockRate: 48000, Channels: 2, SDPFmtpLine: "111/111"}
|
||||||
|
|
||||||
func registerCodecs(me *webrtc.MediaEngine, codecs []*livekit.Codec, rtcpFeedback RTCPFeedbackConfig) error {
|
func registerCodecs(me *webrtc.MediaEngine, codecs []*livekit.Codec, rtcpFeedback RTCPFeedbackConfig, filterOutH264HighProfile bool) error {
|
||||||
opusCodec := opusCodecCapability
|
opusCodec := opusCodecCapability
|
||||||
opusCodec.RTCPFeedback = rtcpFeedback.Audio
|
opusCodec.RTCPFeedback = rtcpFeedback.Audio
|
||||||
var opusPayload webrtc.PayloadType
|
var opusPayload webrtc.PayloadType
|
||||||
@@ -49,6 +49,7 @@ func registerCodecs(me *webrtc.MediaEngine, codecs []*livekit.Codec, rtcpFeedbac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h264HighProfileFmtp := "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032"
|
||||||
for _, codec := range []webrtc.RTPCodecParameters{
|
for _, codec := range []webrtc.RTPCodecParameters{
|
||||||
{
|
{
|
||||||
RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeVP8, ClockRate: 90000, RTCPFeedback: rtcpFeedback.Video},
|
RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeVP8, ClockRate: 90000, RTCPFeedback: rtcpFeedback.Video},
|
||||||
@@ -71,7 +72,7 @@ func registerCodecs(me *webrtc.MediaEngine, codecs []*livekit.Codec, rtcpFeedbac
|
|||||||
PayloadType: 108,
|
PayloadType: 108,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeH264, ClockRate: 90000, SDPFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032", RTCPFeedback: rtcpFeedback.Video},
|
RTPCodecCapability: webrtc.RTPCodecCapability{MimeType: webrtc.MimeTypeH264, ClockRate: 90000, SDPFmtpLine: h264HighProfileFmtp, RTCPFeedback: rtcpFeedback.Video},
|
||||||
PayloadType: 123,
|
PayloadType: 123,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -79,6 +80,9 @@ func registerCodecs(me *webrtc.MediaEngine, codecs []*livekit.Codec, rtcpFeedbac
|
|||||||
PayloadType: 35,
|
PayloadType: 35,
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
|
if filterOutH264HighProfile && codec.RTPCodecCapability.SDPFmtpLine == h264HighProfileFmtp {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if IsCodecEnabled(codecs, codec.RTPCodecCapability) {
|
if IsCodecEnabled(codecs, codec.RTPCodecCapability) {
|
||||||
if err := me.RegisterCodec(codec, webrtc.RTPCodecTypeVideo); err != nil {
|
if err := me.RegisterCodec(codec, webrtc.RTPCodecTypeVideo); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -104,9 +108,9 @@ func registerHeaderExtensions(me *webrtc.MediaEngine, rtpHeaderExtension RTPHead
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createMediaEngine(codecs []*livekit.Codec, config DirectionConfig) (*webrtc.MediaEngine, error) {
|
func createMediaEngine(codecs []*livekit.Codec, config DirectionConfig, filterOutH264HighProfile bool) (*webrtc.MediaEngine, error) {
|
||||||
me := &webrtc.MediaEngine{}
|
me := &webrtc.MediaEngine{}
|
||||||
if err := registerCodecs(me, codecs, config.RTCPFeedback); err != nil {
|
if err := registerCodecs(me, codecs, config.RTCPFeedback, filterOutH264HighProfile); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -263,7 +263,10 @@ func newPeerConnection(params TransportParams, onBandwidthEstimator func(estimat
|
|||||||
directionConfig.RTPHeaderExtension.Video = append(directionConfig.RTPHeaderExtension.Video, rtpextension.PlayoutDelayURI)
|
directionConfig.RTPHeaderExtension.Video = append(directionConfig.RTPHeaderExtension.Video, rtpextension.PlayoutDelayURI)
|
||||||
}
|
}
|
||||||
|
|
||||||
me, err := createMediaEngine(params.EnabledCodecs, directionConfig)
|
// Some of the browser clients do not handle H.264 High Profile in signalling properly.
|
||||||
|
// They still decode if the actual stream is H.264 High Profile, but do not handle it well in signalling.
|
||||||
|
// So, disable H.264 High Profile for SUBSCRIBER peer connection to ensure it is not offered.
|
||||||
|
me, err := createMediaEngine(params.EnabledCodecs, directionConfig, params.IsOfferer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user