xref: /aosp_15_r20/external/webrtc/api/video_codecs/av1_profile.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef API_VIDEO_CODECS_AV1_PROFILE_H_
12 #define API_VIDEO_CODECS_AV1_PROFILE_H_
13 
14 #include <string>
15 
16 #include "absl/strings/string_view.h"
17 #include "absl/types/optional.h"
18 #include "api/video_codecs/sdp_video_format.h"
19 #include "rtc_base/system/rtc_export.h"
20 
21 namespace webrtc {
22 
23 // Profile information for AV1 video.
24 extern RTC_EXPORT const char kAV1FmtpProfile[];
25 
26 // Profiles can be found at:
27 // https://aomedia.org/av1/specification/annex-a/#profiles
28 // The enum values match the number specified in the SDP.
29 enum class AV1Profile {
30   kProfile0 = 0,
31   kProfile1 = 1,
32   kProfile2 = 2,
33 };
34 
35 // Helper function which converts an AV1Profile to std::string. Returns "0" if
36 // an unknown value is passed in.
37 RTC_EXPORT absl::string_view AV1ProfileToString(AV1Profile profile);
38 
39 // Helper function which converts a std::string to AV1Profile. Returns null if
40 // |profile| is not a valid profile string.
41 absl::optional<AV1Profile> StringToAV1Profile(absl::string_view profile);
42 
43 // Parses an SDP key-value map of format parameters to retrive an AV1 profile.
44 // Returns an AV1Profile if one has been specified, `kProfile0` if no profile is
45 // specified and an empty value if the profile key is present but contains an
46 // invalid value.
47 RTC_EXPORT absl::optional<AV1Profile> ParseSdpForAV1Profile(
48     const SdpVideoFormat::Parameters& params);
49 
50 // Returns true if the parameters have the same AV1 profile or neither contains
51 // an AV1 profile, otherwise false.
52 bool AV1IsSameProfile(const SdpVideoFormat::Parameters& params1,
53                       const SdpVideoFormat::Parameters& params2);
54 
55 }  // namespace webrtc
56 
57 #endif  // API_VIDEO_CODECS_AV1_PROFILE_H_
58