blob: 728332d3309cae63b0a90af7cf83e42034f1e9f5 [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_FORMATS_JPEG_C2PA_SEGMENT_HANDLER_H_
#define THIRD_PARTY_CREDENTIO_FORMATS_JPEG_C2PA_SEGMENT_HANDLER_H_
#include <cstdint>
#include <string>
#include <vector>
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/status/statusor.h"
#include "formats/jpeg/reader.h"
#include "riegeli/bytes/reader.h"
namespace credentio {
class C2paSegmentHandler {
public:
struct Segment {
JpegSegment segment;
std::string manifest_store;
};
void RecordSegment(JpegSegment segment);
absl::StatusOr<C2paSegmentHandler::Segment> GetC2paSegment(
riegeli::Reader& input) const;
protected:
const absl::flat_hash_map<uint16_t, std::vector<JpegSegment>>& GetSegmentMap()
const {
return segment_map_;
}
const absl::flat_hash_set<uint16_t>& GetIgnoredSegmentIds() const {
return ignored_segment_ids_;
}
private:
absl::flat_hash_set<uint16_t> ignored_segment_ids_;
absl::flat_hash_map<uint16_t, std::vector<JpegSegment>> segment_map_;
};
} // namespace credentio
#endif // THIRD_PARTY_CREDENTIO_FORMATS_JPEG_C2PA_SEGMENT_HANDLER_H_