-
Notifications
You must be signed in to change notification settings - Fork 305
Description
After some discussion in Slack:
https://academysoftwarefdn.slack.com/archives/CMQ9J4BQC/p1729878665473649
I wanted to create a proposal for adding core C++ support for otioz and otiod. I think adding them to the C++ API would have a couple of benefits:
- Broader adoption by users of the C++ API and other language bindings.
- Provide a common interface to ensure bundles are created according to the specification.
I propose adding minizip-ng as a new dependency to support otioz. It has a permissive license (zlib), and is also used by OpenColorIO for their .ocioz files. The use of minizip-ng would be internal and not part of the OTIO public API.
Outline of the required work:
Add an enum for the media reference policy
(https://opentimelineio.readthedocs.io/en/stable/tutorials/otio-filebundles.html#mediareferencepolicy)
enum class MediaReferencePolicy
{
ErrorIfNotFile,
MissingIfNotFile,
AllMissing
};
Add constants for the file bundle versions
static std::string const otiozVersion = "1.0.0";
static std::string const otiodVersion = "1.0.0";
Add I/O functions to SerializableObject
bool to_otioz_file(
std::string const& file_name,
MediaReferencePolicy media_reference_policy = MediaReferencePolicy::ErrorIfNotFile,
ErrorStatus* error_status = nullptr,
const schema_version_map* target_family_label_spec = nullptr,
int indent = 4) const;
- Create a new ZIP file.
- Resolve external references based on the media reference policy and add them to the ZIP file.
- Create the
version
file and add it to the ZIP file. - Clone the
SerializableObject
and modify it based upon the media reference policy, and to change the external reference paths. - Call
to_json_string()
to createcontent.otio
and add it to the ZIP file.
static SerializableObject* from_otioz_file(
std::string const& file_name,
std::string const& temp_dir,
ErrorStatus* error_status = nullptr);
- Unzip the file to the temporary directory.
- Call
from_json_file()
on thecontent.otio
file in the temporary directory.
Should we also add a version of this function that reads the otioz directly without unzipping it (i.e., memory-mapping)?
bool to_otiod_bundle(
std::string const& dir_name,
MediaReferencePolicy media_reference_policy = MediaReferencePolicy::ErrorIfNotFile,
ErrorStatus* error_status = nullptr,
const schema_version_map* target_family_label_spec = nullptr,
int indent = 4) const;
- Create the given directory.
- Resolve external references based on the media reference policy and copy them to the directory.
- Create the
version
file in the directory. - Clone the
SerializableObject
and modify it based upon the media reference policy, and to change the external reference paths. - Call
to_json_string()
to create thecontent.otio
file in the directory.
static SerializableObject* from_otiod_bundle(
std::string const& file_name,
ErrorStatus* error_status = nullptr);
- Call
from_json_file()
on thecontent.otio
file in the otiod directory.
Python bindings
Add Python bindings for the new C++ functionality and update the otioz/otiod Python adapters to use the new code.