fix(gateway): close Phase 3C audit gaps
This commit is contained in:
@@ -112,7 +112,10 @@ func (b *NativeApolloBackend) performRTSPHandshake(ctx context.Context, work pro
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
announceBody := apolloAnnounceProfile()
|
||||
announceBody, err := apolloAnnounceProfile(work.StreamPolicy)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
announce, err := request("ANNOUNCE", "streamid=control/13/0", sessionID, []apolloRTSPHeader{{"Content-Type", "application/sdp"}}, announceBody, 6)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@@ -468,18 +471,33 @@ func apolloRTSPConnectData(message apolloRTSPMessage) (uint32, error) {
|
||||
return uint32(parsed), nil
|
||||
}
|
||||
|
||||
func apolloAnnounceProfile() []byte {
|
||||
func apolloAnnounceProfile(policy protocol.ProviderStreamPolicy) ([]byte, error) {
|
||||
if err := validateApolloStreamPolicy(policy); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
format, supportsHEVC := int64(0), int64(0)
|
||||
if policy.Codec == "HEVC" {
|
||||
format, supportsHEVC = 1, 1
|
||||
}
|
||||
maximumBitrate := policy.BitrateKbps * 80 / 100
|
||||
if maximumBitrate > 100000 {
|
||||
maximumBitrate = 100000
|
||||
}
|
||||
return []byte("v=0\r\n" +
|
||||
"o=android 0 0 IN IP4 0.0.0.0\r\n" +
|
||||
"s=NVIDIA Streaming Client\r\n" +
|
||||
"a=x-nv-video[0].clientViewportWd:1920\r\n" +
|
||||
"a=x-nv-video[0].clientViewportHt:1080\r\n" +
|
||||
"a=x-nv-video[0].maxFPS:60\r\n" +
|
||||
fmt.Sprintf("a=x-nv-video[0].clientViewportWd:%d\r\n", policy.ResolutionWidth) +
|
||||
fmt.Sprintf("a=x-nv-video[0].clientViewportHt:%d\r\n", policy.ResolutionHeight) +
|
||||
fmt.Sprintf("a=x-nv-video[0].maxFPS:%d\r\n", policy.Fps) +
|
||||
"a=x-nv-video[0].packetSize:1024\r\n" +
|
||||
"a=x-nv-video[0].videoEncoderSlicesPerFrame:1\r\n" +
|
||||
"a=x-nv-video[0].maxNumReferenceFrames:0\r\n" +
|
||||
"a=x-nv-vqos[0].bitStreamFormat:0\r\n" +
|
||||
"a=x-nv-vqos[0].bw.maximumBitrateKbps:8000\r\n" +
|
||||
fmt.Sprintf("a=x-nv-clientSupportHevc:%d\r\n", supportsHEVC) +
|
||||
fmt.Sprintf("a=x-nv-vqos[0].bitStreamFormat:%d\r\n", format) +
|
||||
fmt.Sprintf("a=x-nv-video[0].initialBitrateKbps:%d\r\n", maximumBitrate) +
|
||||
fmt.Sprintf("a=x-nv-video[0].initialPeakBitrateKbps:%d\r\n", maximumBitrate) +
|
||||
fmt.Sprintf("a=x-nv-vqos[0].bw.minimumBitrateKbps:%d\r\n", maximumBitrate) +
|
||||
fmt.Sprintf("a=x-nv-vqos[0].bw.maximumBitrateKbps:%d\r\n", maximumBitrate) +
|
||||
"a=x-nv-vqos[0].fec.minRequiredFecPackets:2\r\n" +
|
||||
"a=x-nv-vqos[0].qosTrafficType:5\r\n" +
|
||||
"a=x-nv-audio.surround.numChannels:2\r\n" +
|
||||
@@ -490,10 +508,17 @@ func apolloAnnounceProfile() []byte {
|
||||
"a=x-nv-general.useReliableUdp:13\r\n" +
|
||||
"a=x-nv-general.featureFlags:167\r\n" +
|
||||
"a=x-ml-general.featureFlags:0\r\n" +
|
||||
"a=x-ml-video.configuredBitrateKbps:8000\r\n" +
|
||||
fmt.Sprintf("a=x-ml-video.configuredBitrateKbps:%d\r\n", policy.BitrateKbps) +
|
||||
"a=x-ss-general.encryptionEnabled:7\r\n" +
|
||||
"a=x-ss-video[0].chromaSamplingType:0\r\n" +
|
||||
"a=x-ss-video[0].intraRefresh:0\r\n")
|
||||
"a=x-ss-video[0].intraRefresh:0\r\n"), nil
|
||||
}
|
||||
|
||||
func validateApolloStreamPolicy(policy protocol.ProviderStreamPolicy) error {
|
||||
if err := policy.Validate(); err != nil || !policy.AudioEnabled || (policy.Codec != "H264" && policy.Codec != "HEVC") {
|
||||
return ErrProviderMalformed
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validApolloRTSPToken(value string) bool {
|
||||
|
||||
Reference in New Issue
Block a user