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 #ifndef CLI_PROTO_CONVERSION_PROTO_TO_OBU_ARBITRARY_OBU_GENERATOR_H_ 13 #define CLI_PROTO_CONVERSION_PROTO_TO_OBU_ARBITRARY_OBU_GENERATOR_H_ 14 15 #include <list> 16 17 #include "absl/status/status.h" 18 #include "iamf/cli/proto/arbitrary_obu.pb.h" 19 #include "iamf/obu/arbitrary_obu.h" 20 #include "src/google/protobuf/repeated_ptr_field.h" 21 22 namespace iamf_tools { 23 24 class ArbitraryObuGenerator { 25 public: 26 /*!\brief Constructor. 27 * \param arbitrary_obu_metadata Input arbitrary OBU metadata. 28 */ ArbitraryObuGenerator(const::google::protobuf::RepeatedPtrField<iamf_tools_cli_proto::ArbitraryObuMetadata> & arbitrary_obu_metadata)29 ArbitraryObuGenerator( 30 const ::google::protobuf::RepeatedPtrField< 31 iamf_tools_cli_proto::ArbitraryObuMetadata>& arbitrary_obu_metadata) 32 : arbitrary_obu_metadata_(arbitrary_obu_metadata) {} 33 34 /*!\brief Generates a list of arbitrary OBUs from the input metadata. 35 * 36 * The generator only performs enough validation required to construct the 37 * OBU; it validates that enumeration values are known. It does not validate 38 * IAMF requirements or restrictions of the fields which is typically 39 * performed in functions of the OBU class. 40 * 41 * Performing minimal validation allows OBUs which are not compliant with 42 * IAMF to be generated. These can be used to create illegal streams for 43 * debugging purposes. 44 * 45 * \param ArbitraryObu Output list of OBUs. 46 * \return `absl::OkStatus()` on success. `absl::InvalidArgumentError()` if 47 * invalid values of enumerations are used. 48 */ 49 absl::Status Generate(std::list<ArbitraryObu>& arbitrary_obus_with_metadata); 50 51 private: 52 const ::google::protobuf::RepeatedPtrField< 53 iamf_tools_cli_proto::ArbitraryObuMetadata> 54 arbitrary_obu_metadata_; 55 }; 56 57 } // namespace iamf_tools 58 59 #endif // CLI_PROTO_CONVERSION_PROTO_TO_OBU_ARBITRARY_OBU_GENERATOR_H_ 60