diff --git a/src/rtsp.cpp b/src/rtsp.cpp index 00eb7f41..35300e6e 100644 --- a/src/rtsp.cpp +++ b/src/rtsp.cpp @@ -5,6 +5,7 @@ #define BOOST_BIND_GLOBAL_PLACEHOLDERS extern "C" { +#include #include } @@ -705,6 +706,7 @@ namespace rtsp_stream { args.try_emplace("x-nv-vqos[0].qosTrafficType"sv, "5"sv); args.try_emplace("x-nv-aqos.qosTrafficType"sv, "4"sv); args.try_emplace("x-ml-video.configuredBitrateKbps"sv, "0"sv); + args.try_emplace("x-ss-general.encryptionEnabled"sv, "0"sv); stream::config_t config; @@ -721,10 +723,15 @@ namespace rtsp_stream { config.controlProtocolType = util::from_view(args.at("x-nv-general.useReliableUdp"sv)); config.packetsize = util::from_view(args.at("x-nv-video[0].packetSize"sv)); config.minRequiredFecPackets = util::from_view(args.at("x-nv-vqos[0].fec.minRequiredFecPackets"sv)); - config.nvFeatureFlags = util::from_view(args.at("x-nv-general.featureFlags"sv)); config.mlFeatureFlags = util::from_view(args.at("x-ml-general.featureFlags"sv)); config.audioQosType = util::from_view(args.at("x-nv-aqos.qosTrafficType"sv)); config.videoQosType = util::from_view(args.at("x-nv-vqos[0].qosTrafficType"sv)); + config.encryptionFlagsEnabled = util::from_view(args.at("x-ss-general.encryptionEnabled"sv)); + + // Legacy clients use nvFeatureFlags to indicate support for audio encryption + if (util::from_view(args.at("x-nv-general.featureFlags"sv)) & 0x20) { + config.encryptionFlagsEnabled |= SS_ENC_AUDIO; + } config.monitor.height = util::from_view(args.at("x-nv-video[0].clientViewportHt"sv)); config.monitor.width = util::from_view(args.at("x-nv-video[0].clientViewportWd"sv)); diff --git a/src/stream.cpp b/src/stream.cpp index 0b547271..1c162589 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -235,9 +235,9 @@ namespace stream { // return bytes written on success // return -1 on error static inline int - encode_audio(int featureSet, const audio::buffer_t &plaintext, audio_packet_t &destination, std::uint32_t avRiKeyIv, crypto::cipher::cbc_t &cbc) { + encode_audio(bool encrypted, const audio::buffer_t &plaintext, audio_packet_t &destination, std::uint32_t avRiKeyIv, crypto::cipher::cbc_t &cbc) { // If encryption isn't enabled - if (!(featureSet & 0x20)) { + if (!encrypted) { std::copy(std::begin(plaintext), std::end(plaintext), destination->payload()); return plaintext.size(); } @@ -1415,7 +1415,7 @@ namespace stream { // For now, encode_audio needs it to be the proper sequenceNumber audio_packet->rtp.sequenceNumber = sequenceNumber; - auto bytes = encode_audio(session->config.nvFeatureFlags, packet_data, audio_packet, session->audio.avRiKeyId, session->audio.cipher); + auto bytes = encode_audio(session->config.encryptionFlagsEnabled & SS_ENC_AUDIO, packet_data, audio_packet, session->audio.avRiKeyId, session->audio.cipher); if (bytes < 0) { BOOST_LOG(error) << "Couldn't encode audio packet"sv; break; diff --git a/src/stream.h b/src/stream.h index ee04c537..1e2dcd4e 100644 --- a/src/stream.h +++ b/src/stream.h @@ -22,12 +22,13 @@ namespace stream { int packetsize; int minRequiredFecPackets; - int nvFeatureFlags; int mlFeatureFlags; int controlProtocolType; int audioQosType; int videoQosType; + uint32_t encryptionFlagsEnabled; + std::optional gcmap; };