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_IA_SEQUENCE_HEADER_GENERATOR_H_ 13 #define CLI_PROTO_CONVERSION_PROTO_TO_OBU_IA_SEQUENCE_HEADER_GENERATOR_H_ 14 15 #include <optional> 16 17 #include "absl/status/status.h" 18 #include "iamf/cli/proto/ia_sequence_header.pb.h" 19 #include "iamf/obu/ia_sequence_header.h" 20 21 namespace iamf_tools { 22 23 class IaSequenceHeaderGenerator { 24 public: 25 /*!\brief Constructor. 26 * \param user_metadata Input user metadata. 27 */ IaSequenceHeaderGenerator(const iamf_tools_cli_proto::IASequenceHeaderObuMetadata & ia_sequence_header_metadata)28 IaSequenceHeaderGenerator( 29 const iamf_tools_cli_proto::IASequenceHeaderObuMetadata& 30 ia_sequence_header_metadata) 31 : ia_sequence_header_metadata_(ia_sequence_header_metadata) {} 32 33 /*!\brief Generates an IA Sequence Header OBU from the input metadata. 34 * 35 * The generator only performs enough validation required to construct the 36 * OBU; it validates that enumeration values are known and casting of fields 37 * does not result in lost information. It does not validate IAMF requirements 38 * or restrictions of the fields which is typically performed in functions of 39 * 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 ia_sequence_header_obu Output OBU. 46 * \return `absl::OkStatus()` on success. `absl::InvalidArgumentError()` if 47 * invalid values of enumerations are used. 48 */ 49 absl::Status Generate( 50 std::optional<IASequenceHeaderObu>& ia_sequence_header_obu) const; 51 52 private: 53 const iamf_tools_cli_proto::IASequenceHeaderObuMetadata 54 ia_sequence_header_metadata_; 55 }; 56 57 } // namespace iamf_tools 58 59 #endif // CLI_PROTO_CONVERSION_PROTO_TO_OBU_IA_SEQUENCE_HEADER_GENERATOR_H_ 60