| // 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. |
| // |
| |
| #include "formats/core_registry.h" |
| |
| #include <memory> |
| #include <utility> |
| |
| #include "absl/log/log.h" |
| #include "absl/status/statusor.h" |
| #include "absl/strings/string_view.h" |
| #include "formats/bmff/format.h" |
| #include "formats/format.h" |
| #include "formats/gif/format.h" |
| #include "formats/id3/format.h" |
| #include "formats/jpeg/format.h" |
| #include "formats/pdf/format.h" |
| #include "formats/png/format.h" |
| #include "formats/registry.h" |
| #include "formats/riff/format.h" |
| #include "formats/tiff/format.h" |
| #include "formats/zip/format.h" |
| |
| namespace credentio { |
| |
| std::unique_ptr<FormatRegistry> CreateCoreFormatRegistry() { |
| auto registry = std::make_unique<FormatRegistry>(); |
| |
| auto register_format = [&](absl::StatusOr<std::unique_ptr<Format>> format, |
| absl::string_view name) { |
| if (format.ok()) { |
| registry->Register(std::move(*format)); |
| } else { |
| LOG(WARNING) << "Failed to create and register format: " << name; |
| } |
| }; |
| |
| register_format(CreateJpegFormat(), "jpeg"); |
| register_format(CreatePngFormat(), "png"); |
| register_format(CreateBmffFormat(), "bmff"); |
| register_format(CreateTiffFormat(), "tiff"); |
| register_format(CreateRiffFormat(), "riff"); |
| register_format(CreateGifFormat(), "gif"); |
| register_format(CreatePdfFormat(), "pdf"); |
| register_format(CreateId3Format(), "id3"); |
| register_format(CreateZipFormat(), "zip"); |
| |
| return registry; |
| } |
| |
| } // namespace credentio |