Chromium Code Reviews| Index: webrtc/config.cc |
| diff --git a/webrtc/config.cc b/webrtc/config.cc |
| index e0c490d1ecd8038d546b7298fc9a885ab02718df..07cf0767c84980a5429a969bce1a3b9eb6234f5b 100644 |
| --- a/webrtc/config.cc |
| +++ b/webrtc/config.cc |
| @@ -41,6 +41,9 @@ std::string RtpExtension::ToString() const { |
| std::stringstream ss; |
| ss << "{uri: " << uri; |
| ss << ", id: " << id; |
| + if (encrypt) { |
| + ss << ", encrypt"; |
| + } |
| ss << '}'; |
| return ss.str(); |
| } |
| @@ -72,6 +75,9 @@ const char* RtpExtension::kPlayoutDelayUri = |
| "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; |
| const int RtpExtension::kPlayoutDelayDefaultId = 6; |
| +const char* RtpExtension::kEncryptHeaderExtensionsUri = |
| + "urn:ietf:params:rtp-hdrext:encrypt"; |
| + |
| const int RtpExtension::kMinId = 1; |
| const int RtpExtension::kMaxId = 14; |
| @@ -88,6 +94,62 @@ bool RtpExtension::IsSupportedForVideo(const std::string& uri) { |
| uri == webrtc::RtpExtension::kPlayoutDelayUri; |
| } |
| +bool RtpExtension::IsEncryptionSupported(const std::string& uri) { |
| + // TODO(jbauch): Figure out a way to add "kTimestampOffsetUri" here |
| + // and filter out later if external auth is used in srtpfilter. |
|
Taylor Brandstetter
2017/04/19 06:48:39
Does this TODO need to be addressed before landing
joachim
2017/04/19 23:40:19
Just noticed it should have been "kAbsSendTimeUri"
|
| + return uri == webrtc::RtpExtension::kAudioLevelUri || |
| + uri == webrtc::RtpExtension::kTimestampOffsetUri || |
| + uri == webrtc::RtpExtension::kVideoRotationUri || |
| + uri == webrtc::RtpExtension::kTransportSequenceNumberUri || |
| + uri == webrtc::RtpExtension::kPlayoutDelayUri; |
| +} |
| + |
| +const RtpExtension* RtpExtension::FindHeaderExtensionByUri( |
| + const std::vector<RtpExtension>& extensions, |
| + const std::string& uri) { |
| + for (const auto& extension : extensions) { |
| + if (extension.uri == uri) { |
| + return &extension; |
| + } |
| + } |
| + return nullptr; |
| +} |
| + |
| +std::vector<RtpExtension> RtpExtension::FilterDuplicateNonEncrypted( |
| + const std::vector<RtpExtension>& extensions) { |
| + std::vector<RtpExtension> filtered; |
| + for (auto it = extensions.begin(); it != extensions.end(); ++it) { |
| + if (it->encrypt) { |
| + filtered.push_back(*it); |
| + } else { |
| + // Only add non-encrypted extension if no encrypted with the same URI |
| + // is also present... |
| + bool found = false; |
| + for (auto it2 = it + 1; it2 != extensions.end(); ++it2) { |
| + if (it->uri == it2->uri) { |
| + found = true; |
| + break; |
| + } |
| + } |
| + |
| + if (!found) { |
| + // ...and has not been added before. |
| + for (const RtpExtension& existing : filtered) { |
| + if (it->uri == existing.uri) { |
| + found = true; |
| + break; |
| + } |
| + } |
| + |
| + if (!found) { |
| + filtered.push_back(*it); |
| + } |
| + } |
| + } |
| + } |
| + return filtered; |
| +} |
| + |
| VideoStream::VideoStream() |
| : width(0), |
| height(0), |