Add codec comparison function to SdpVideoFormat
SdpVideoFormat is used to configure video encoder and decoders.
This CL adds support for comparing two SdpVideoFormat objects
to determine if they specify the same video codec.
This functionality previously only existed in media/base/codec.h
which made the code sensitive to circular dependencies. Once
downstream projects stop using cricket::IsSameCodec, this code
can be removed.
Bug: chromium:1187565
Change-Id: I242069aa6af07917637384c80ee4820887defc7d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/213427
Commit-Queue: Johannes Kron <kron@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33794}
diff --git a/api/video_codecs/sdp_video_format.h b/api/video_codecs/sdp_video_format.h
index 97bb754..a1e23f4 100644
--- a/api/video_codecs/sdp_video_format.h
+++ b/api/video_codecs/sdp_video_format.h
@@ -14,6 +14,7 @@
#include <map>
#include <string>
+#include "api/array_view.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
@@ -32,6 +33,13 @@
~SdpVideoFormat();
+ // Returns true if the SdpVideoFormats have the same names as well as codec
+ // specific parameters. Please note that two SdpVideoFormats can represent the
+ // same codec even though not all parameters are the same.
+ bool IsSameCodec(const SdpVideoFormat& other) const;
+ bool IsCodecInList(
+ rtc::ArrayView<const webrtc::SdpVideoFormat> formats) const;
+
std::string ToString() const;
friend RTC_EXPORT bool operator==(const SdpVideoFormat& a,