• 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 
13 #ifndef CLI_USER_METADATA_BUILDER_AUDIO_ELEMENT_METADATA_BUILDER_H_
14 #define CLI_USER_METADATA_BUILDER_AUDIO_ELEMENT_METADATA_BUILDER_H_
15 
16 #include <cstdint>
17 
18 #include "absl/status/status.h"
19 #include "iamf/cli/proto/audio_element.pb.h"
20 #include "iamf/cli/proto/ia_sequence_header.pb.h"
21 #include "iamf/cli/user_metadata_builder/iamf_input_layout.h"
22 
23 namespace iamf_tools {
24 
25 /*!\brief Helps create consistent audio element metadata for an IAMF stream.
26  *
27  * This class stores state information to avoid conflicts between audio
28  * elements in a single IAMF stream. It helps generate audio streams that may
29  * have multiple audio elements while ensuring they all have unique substream
30  * IDs.
31  *
32  * `PopulateAudioElementMetadata()` will generate a single audio element
33  * metadata. It can be called multiple times to generate additional audio
34  * element metadata. The output audio elements are simplistically configured
35  * based on the input layout.
36  *
37  * This class is intended to be used to generate simple audio elements for any
38  * compatibility layers between non-IAMF formats and IAMF.
39  */
40 class AudioElementMetadataBuilder {
41  public:
42   AudioElementMetadataBuilder() = default;
43 
44   /*!\brief Populates a simplistic `AudioElementObuMetadata`.
45    *
46    * The populated metadata will be based on the input layout, with various
47    * settings (parameters, number of layers, etc.) set to simplistic default
48    * values.
49    *
50    * \param codec_config_id Codec config ID.
51    * \param audio_element_id Audio element ID.
52    * \param input_layout Input layout of the audio element.
53    * \param audio_element_obu_metadata Audio element OBU metadata.
54    * \return `absl::OkStatus()` on success. A specific error code on failure.
55    */
56   absl::Status PopulateAudioElementMetadata(
57       uint32_t audio_element_id, uint32_t codec_config_id,
58       IamfInputLayout input_layout,
59       iamf_tools_cli_proto::AudioElementObuMetadata&
60           audio_element_obu_metadata);
61 
62  private:
63   int64_t audio_stream_id_counter_ = 0;
64 };
65 
66 }  // namespace iamf_tools
67 
68 #endif  // CLI_USER_METADATA_BUILDER_AUDIO_ELEMENT_METADATA_BUILDER_H_
69