1 /* 2 * Copyright (c) 2023, 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_PROTO_CONVERSION_PROTO_TO_OBU_AUDIO_ELEMENT_GENERATOR_H_ 14 #define CLI_PROTO_CONVERSION_PROTO_TO_OBU_AUDIO_ELEMENT_GENERATOR_H_ 15 16 #include <cstdint> 17 18 #include "absl/container/flat_hash_map.h" 19 #include "absl/status/status.h" 20 #include "iamf/cli/audio_element_with_data.h" 21 #include "iamf/cli/proto/audio_element.pb.h" 22 #include "iamf/obu/codec_config.h" 23 #include "iamf/obu/types.h" 24 #include "src/google/protobuf/repeated_ptr_field.h" 25 26 namespace iamf_tools { 27 28 class AudioElementGenerator { 29 public: 30 /*!\brief Constructor. 31 * \param audio_element_metadata Input audio element metadata. 32 */ AudioElementGenerator(const::google::protobuf::RepeatedPtrField<iamf_tools_cli_proto::AudioElementObuMetadata> & audio_element_metadata)33 AudioElementGenerator(const ::google::protobuf::RepeatedPtrField< 34 iamf_tools_cli_proto::AudioElementObuMetadata>& 35 audio_element_metadata) 36 : audio_element_metadata_(audio_element_metadata) {} 37 38 /*!\brief Generates a list of Audio Element OBUs from the input metadata. 39 * 40 * \param codec_conifgs Map of Codec Config IDs to Codec Config OBUs. 41 * \param audio_elements Map of Audio Element IDs to generated OBUs with data. 42 * \return `absl::OkStatus()` on success. A specific status on failure. 43 */ 44 absl::Status Generate( 45 const absl::flat_hash_map<uint32_t, CodecConfigObu>& codec_configs, 46 absl::flat_hash_map<DecodedUleb128, AudioElementWithData>& 47 audio_elements); 48 49 private: 50 const ::google::protobuf::RepeatedPtrField< 51 iamf_tools_cli_proto::AudioElementObuMetadata> 52 audio_element_metadata_; 53 }; 54 55 } // namespace iamf_tools 56 57 #endif // CLI_PROTO_CONVERSION_PROTO_TO_OBU_AUDIO_ELEMENT_GENERATOR_H_ 58