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 OBU_TEMPORAL_DELIMITER_H_ 13 #define OBU_TEMPORAL_DELIMITER_H_ 14 15 #include <cstdint> 16 17 #include "absl/status/status.h" 18 #include "absl/status/statusor.h" 19 #include "iamf/common/read_bit_buffer.h" 20 #include "iamf/common/utils/macros.h" 21 #include "iamf/common/write_bit_buffer.h" 22 #include "iamf/obu/obu_base.h" 23 #include "iamf/obu/obu_header.h" 24 25 namespace iamf_tools { 26 27 class TemporalDelimiterObu : public ObuBase { 28 public: 29 /*!\brief Creates a `TemporalDelimiterObu`, 30 * 31 * This is a factory method that creates a `TemporalDelimiterObu` from the 32 * given `ObuHeader` and `ReadBitBuffer`. It is simple because 33 * `TemporalDelimiterObu` has no payload. 34 * 35 * \param header `ObuHeader` of the OBU. 36 * \param payload_size Size of the obu payload in bytes. 37 * \param rb `ReadBitBuffer` where the `TemporalDelimiterObu` data is stored. 38 * Data read from the buffer is consumed. 39 * \return a `TemporalDelimiterObu` on success. A specific status on failure. 40 */ CreateFromBuffer(const ObuHeader & header,int64_t payload_size,ReadBitBuffer & rb)41 static absl::StatusOr<TemporalDelimiterObu> CreateFromBuffer( 42 const ObuHeader& header, int64_t payload_size, ReadBitBuffer& rb) { 43 TemporalDelimiterObu obu(header); 44 RETURN_IF_NOT_OK(obu.ReadAndValidatePayload(payload_size, rb)); 45 return obu; 46 } 47 48 /*!\brief Constructor. */ TemporalDelimiterObu(ObuHeader header)49 explicit TemporalDelimiterObu(ObuHeader header) 50 : ObuBase(header, kObuIaTemporalDelimiter) {} 51 52 /*!\brief Destructor. */ 53 ~TemporalDelimiterObu() override = default; 54 55 /*!\brief Prints logging information about the OBU.*/ PrintObu()56 void PrintObu() const override { 57 // There is nothing to print for a Temporal Delimiter OBU. 58 }; 59 60 // Temporal delimiter has no payload 61 62 private: 63 /*!\brief Writes the OBU payload to the buffer. 64 * 65 * \param wb Buffer to write to. 66 * \return `absl::OkStatus()` always. 67 */ ValidateAndWritePayload(WriteBitBuffer &)68 absl::Status ValidateAndWritePayload(WriteBitBuffer& /*wb*/) const override { 69 // There is nothing to write for a Temporal Delimiter OBU payload. 70 return absl::OkStatus(); 71 } 72 73 /*!\brief Reads the OBU payload from the buffer. 74 * 75 * \param rb Buffer to read from. 76 * \return `absl::OkStatus()` always. 77 */ ReadAndValidatePayloadDerived(int64_t,ReadBitBuffer & rb)78 absl::Status ReadAndValidatePayloadDerived(int64_t /*payload_size*/, 79 ReadBitBuffer& rb) override { 80 return absl::OkStatus(); 81 }; 82 }; 83 } // namespace iamf_tools 84 85 #endif // OBU_TEMPORAL_DELIMITER_H_ 86