• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 3-Clause Clear License
5  * and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear
6  * License was not distributed with this source code in the LICENSE file, you
7  * can obtain it at www.aomedia.org/license/software-license/bsd-3-c-c. If the
8  * Alliance for Open Media Patent License 1.0 was not distributed with this
9  * source code in the PATENTS file, you can obtain it at
10  * www.aomedia.org/license/patent.
11  */
12 #ifndef CLI_PROFILE_FILTER_H_
13 #define CLI_PROFILE_FILTER_H_
14 
15 #include <cstdint>
16 
17 #include "absl/container/flat_hash_map.h"
18 #include "absl/container/flat_hash_set.h"
19 #include "absl/status/status.h"
20 #include "absl/strings/string_view.h"
21 #include "iamf/cli/audio_element_with_data.h"
22 #include "iamf/obu/audio_element.h"
23 #include "iamf/obu/ia_sequence_header.h"
24 #include "iamf/obu/mix_presentation.h"
25 
26 namespace iamf_tools {
27 
28 /*!\brief A class to help filter out profile-specific limiations.
29  *
30  * This class is intended to be used to determine under which contexts OBUs
31  * should be ignored. Properties which are not obviously extension points or
32  * currently profile-specific are not considered.
33  */
34 class ProfileFilter {
35  public:
36   /*!\brief Filter out profiles that should ignore the audio element.
37    *
38    * \param debugging_context Context to use for error messages.
39    * \param audio_element_obu Audio element to filter based on.
40    * \param profile_versions Profiles to filter. Unsupported profiles will be
41    *        removed from the set.
42    * \return `absl::OkStatus` if the audio element is supported by at least one
43    *         of the input profile. A specific error otherwise.
44    */
45   static absl::Status FilterProfilesForAudioElement(
46       absl::string_view debugging_context,
47       const AudioElementObu& audio_element_obu,
48       absl::flat_hash_set<ProfileVersion>& profile_versions);
49 
50   /*!\brief Filter out profiles that should ignore the mix presentation.
51    *
52    * \param audio_elements Audio elements in the IA sequence.
53    * \param mix_presentation_obu Mix presentation to filter based on.
54    * \param profile_versions Profiles to filter. Unsupported profiles will be
55    *        removed from the set.
56    * \return `absl::OkStatus` if the mix presentation is supported by at least
57    *         one of the input profile. A specific error otherwise.
58    */
59   static absl::Status FilterProfilesForMixPresentation(
60       const absl::flat_hash_map<uint32_t, AudioElementWithData>& audio_elements,
61       const MixPresentationObu& mix_presentation_obu,
62       absl::flat_hash_set<ProfileVersion>& profile_versions);
63 };
64 
65 }  // namespace iamf_tools
66 
67 #endif  // CLI_PROFILE_FILTER_H_
68