blob: de094287875e18415166d0edd23818a673c82a57 [file]
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef THIRD_PARTY_CREDENTIO_JUMBF_UTILS_H_
#define THIRD_PARTY_CREDENTIO_JUMBF_UTILS_H_
#include <cstdint>
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "jumbf/box.h"
#include "uuid/uuid.h"
namespace jumbf {
// Remove the JUMBF box header (LBox, TBox, XLBox). Returns the box content. For
// superboxes, this is both the description and the contents.
absl::StatusOr<absl::string_view> StripBoxHeaders(absl::string_view raw_bytes);
// Checks if the top-level JUMBF box within the supplied bytes has a description
// box matching the supplied UUID, toggles and label by inspecting the raw
// bytes.
//
// Note: ConsumeSuperBox() function is not used because it requires passing a
// complete JUMBF box which may not be available for every use. (JPEGs possibly
// need to spread the full data across multiple segments with it being
// inadvisable to force them to combine prior to this check).
absl::StatusOr<bool> HasDescriptionBoxMatching(absl::string_view raw_bytes,
const credentio::Uuid& uuid,
uint8_t toggles_mask,
absl::string_view label);
// Returns the size of the box payload.
int GetContextBoxSize(const ContentBox& box);
} // namespace jumbf
#endif // THIRD_PARTY_CREDENTIO_JUMBF_UTILS_H_