From 5662e183403c6e826b8611f927e577bffae9161c Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Mon, 19 Sep 2022 22:02:46 -0700 Subject: [PATCH 1/3] feat: Initial work for binding OTIO's C API --- .devcontainer/devcontainer.json | 26 + .gitignore | 3 + Cargo.toml | 15 +- Dockerfile | 66 +++ README.md | 7 + generatebindings.py | 25 - opentimelineio-sys/Cargo.toml | 8 + opentimelineio-sys/bindgen.py | 27 + opentimelineio-sys/build.rs | 7 + opentimelineio-sys/src/lib.h | 56 ++ {src => opentimelineio-sys/src}/lib.rs | 458 ++++++++-------- opentimelineio/Cargo.toml | 10 + opentimelineio/src/lib.rs | 1 + opentimelineio/src/opentime/error_status.rs | 276 ++++++++++ opentimelineio/src/opentime/mod.rs | 2 + opentimelineio/src/opentime/rational_time.rs | 505 ++++++++++++++++++ src/copentime/errorStatus.h | 32 -- src/copentime/optionalOpenTime.h | 37 -- src/copentime/rationalTime.h | 86 --- src/copentime/timeRange.h | 60 --- src/copentime/timeTransform.h | 40 -- src/copentime/util.h | 38 -- src/copentimelineio/any.h | 12 - src/copentimelineio/anyDictionary.h | 51 -- src/copentimelineio/anyVector.h | 78 --- src/copentimelineio/clip.h | 66 --- src/copentimelineio/composable.h | 48 -- .../composableRetainerVector.h | 87 --- src/copentimelineio/composableVector.h | 51 -- src/copentimelineio/composition.h | 119 ----- src/copentimelineio/deserialization.h | 17 - src/copentimelineio/effect.h | 51 -- src/copentimelineio/effectRetainerVector.h | 84 --- src/copentimelineio/effectVector.h | 73 --- src/copentimelineio/errorStatus.h | 53 -- src/copentimelineio/externalReference.h | 57 -- src/copentimelineio/freezeFrame.h | 49 -- src/copentimelineio/gap.h | 96 ---- src/copentimelineio/generatorReference.h | 47 -- src/copentimelineio/item.h | 68 --- src/copentimelineio/linearTimeWarp.h | 54 -- src/copentimelineio/mapComposableTimeRange.h | 78 --- src/copentimelineio/marker.h | 55 -- src/copentimelineio/markerRetainerVector.h | 83 --- src/copentimelineio/markerVector.h | 73 --- src/copentimelineio/mediaReference.h | 39 -- src/copentimelineio/missingReference.h | 51 -- .../optionalPairRationalTime.h | 23 - src/copentimelineio/retainerPairComposable.h | 22 - src/copentimelineio/safely_typed_any.h | 45 -- src/copentimelineio/serializableCollection.h | 55 -- src/copentimelineio/serializableObject.h | 46 -- .../serializableObjectRetainerVector.h | 106 ---- .../serializableObjectVector.h | 61 --- .../serializableObjectWithMetadata.h | 46 -- src/copentimelineio/serialization.h | 20 - src/copentimelineio/stack.h | 107 ---- src/copentimelineio/stackAlgorithm.h | 17 - src/copentimelineio/timeEffect.h | 34 -- src/copentimelineio/timeline.h | 47 -- src/copentimelineio/track.h | 123 ----- src/copentimelineio/trackAlgorithm.h | 14 - src/copentimelineio/trackVector.h | 74 --- src/copentimelineio/transition.h | 59 -- src/copentimelineio/typeInfo.h | 6 - src/copentimelineio/typeRegistry.h | 49 -- src/copentimelineio/unknownSchema.h | 40 -- src/lib.h | 50 -- 68 files changed, 1214 insertions(+), 3155 deletions(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 Dockerfile delete mode 100644 generatebindings.py create mode 100644 opentimelineio-sys/Cargo.toml create mode 100644 opentimelineio-sys/bindgen.py create mode 100644 opentimelineio-sys/build.rs create mode 100644 opentimelineio-sys/src/lib.h rename {src => opentimelineio-sys/src}/lib.rs (94%) create mode 100644 opentimelineio/Cargo.toml create mode 100644 opentimelineio/src/lib.rs create mode 100644 opentimelineio/src/opentime/error_status.rs create mode 100644 opentimelineio/src/opentime/mod.rs create mode 100644 opentimelineio/src/opentime/rational_time.rs delete mode 100644 src/copentime/errorStatus.h delete mode 100644 src/copentime/optionalOpenTime.h delete mode 100644 src/copentime/rationalTime.h delete mode 100644 src/copentime/timeRange.h delete mode 100644 src/copentime/timeTransform.h delete mode 100644 src/copentime/util.h delete mode 100644 src/copentimelineio/any.h delete mode 100644 src/copentimelineio/anyDictionary.h delete mode 100644 src/copentimelineio/anyVector.h delete mode 100644 src/copentimelineio/clip.h delete mode 100644 src/copentimelineio/composable.h delete mode 100644 src/copentimelineio/composableRetainerVector.h delete mode 100644 src/copentimelineio/composableVector.h delete mode 100644 src/copentimelineio/composition.h delete mode 100644 src/copentimelineio/deserialization.h delete mode 100644 src/copentimelineio/effect.h delete mode 100644 src/copentimelineio/effectRetainerVector.h delete mode 100644 src/copentimelineio/effectVector.h delete mode 100644 src/copentimelineio/errorStatus.h delete mode 100644 src/copentimelineio/externalReference.h delete mode 100644 src/copentimelineio/freezeFrame.h delete mode 100644 src/copentimelineio/gap.h delete mode 100644 src/copentimelineio/generatorReference.h delete mode 100644 src/copentimelineio/item.h delete mode 100644 src/copentimelineio/linearTimeWarp.h delete mode 100644 src/copentimelineio/mapComposableTimeRange.h delete mode 100644 src/copentimelineio/marker.h delete mode 100644 src/copentimelineio/markerRetainerVector.h delete mode 100644 src/copentimelineio/markerVector.h delete mode 100644 src/copentimelineio/mediaReference.h delete mode 100644 src/copentimelineio/missingReference.h delete mode 100644 src/copentimelineio/optionalPairRationalTime.h delete mode 100644 src/copentimelineio/retainerPairComposable.h delete mode 100644 src/copentimelineio/safely_typed_any.h delete mode 100644 src/copentimelineio/serializableCollection.h delete mode 100644 src/copentimelineio/serializableObject.h delete mode 100644 src/copentimelineio/serializableObjectRetainerVector.h delete mode 100644 src/copentimelineio/serializableObjectVector.h delete mode 100644 src/copentimelineio/serializableObjectWithMetadata.h delete mode 100644 src/copentimelineio/serialization.h delete mode 100644 src/copentimelineio/stack.h delete mode 100644 src/copentimelineio/stackAlgorithm.h delete mode 100644 src/copentimelineio/timeEffect.h delete mode 100644 src/copentimelineio/timeline.h delete mode 100644 src/copentimelineio/track.h delete mode 100644 src/copentimelineio/trackAlgorithm.h delete mode 100644 src/copentimelineio/trackVector.h delete mode 100644 src/copentimelineio/transition.h delete mode 100644 src/copentimelineio/typeInfo.h delete mode 100644 src/copentimelineio/typeRegistry.h delete mode 100644 src/copentimelineio/unknownSchema.h delete mode 100644 src/lib.h diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..498fef4 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,26 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/docker-existing-dockerfile +{ + "name": "Existing Dockerfile", + + // Sets the run context to one level up instead of the .devcontainer folder. + "context": "..", + + // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. + "dockerFile": "../Dockerfile", + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Uncomment the next line to run commands after the container is created - for example installing curl. + // "postCreateCommand": "apt-get update && apt-get install -y curl", + + // Uncomment when using a ptrace-based debugger like C++, Go, and Rust + // "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], + + // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker. + // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], + + // Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vfxrs" +} diff --git a/.gitignore b/.gitignore index 6985cf1..99c7778 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ Cargo.lock # MSVC Windows builds of rustc generate these, which store debugging information *.pdb + +# Editor +.vscode/ diff --git a/Cargo.toml b/Cargo.toml index c57c61b..c3f952c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,5 @@ -[package] -name = "opentimelineio-bind" -version = "0.1.0" -build = "build.rs" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -libc = "0.2" +[workspace] +members = [ + "opentimelineio", + "opentimelineio-sys", +] diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..312df78 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,66 @@ +FROM aswf/ci-otio:2022.2 + +ARG USERNAME=vfxrs +ARG USER_UID=1000 +ARG USER_GID=$USER_UID + +# Create the user +RUN groupadd --gid $USER_GID $USERNAME && \ + useradd --uid $USER_UID --gid $USER_GID -m $USERNAME && \ + echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \ + chmod 0440 /etc/sudoers.d/$USERNAME + +# Install Rust +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH \ + RUST_VERSION=1.63.0 \ + RUST_ARCH=x86_64-unknown-linux-gnu \ + RUST_ANALYZER_VERSION=2022-09-12 +RUN curl -O "https://static.rust-lang.org/rustup/archive/1.25.1/${RUST_ARCH}/rustup-init" && \ + chmod +x rustup-init && \ + ./rustup-init -y --no-modify-path --profile default --default-toolchain $RUST_VERSION --default-host ${RUST_ARCH} && \ + rm rustup-init && \ + chmod -R a+w $RUSTUP_HOME $CARGO_HOME && \ + chgrp -R $USERNAME $RUSTUP_HOME $CARGO_HOME && \ + rustup --version && \ + cargo --version && \ + rustc --version + +# Install Rust Analyzer +RUN cd /tmp && \ + git clone https://github.com/rust-lang/rust-analyzer.git && \ + cd rust-analyzer && \ + git checkout $RUST_ANALYZER_VERSION && \ + cargo xtask install --server && \ + cd ../ && \ + rm -rf rust-analyzer +# Gets installed to /usr/local/cargo/bin/rust-analyzer + +# # Compile OpenTimelineIO +ENV OTIO_VERSION=v0.14.1 \ + COTIO_VERSION=9745fe5911d3d6495184da1ce3a6efba1d68b389 +RUN mkdir -p /tmp/otio +# Compile OpenTimelineIO C bindings +RUN cd /tmp/otio && \ + git clone --recurse-submodules https://github.com/OpenTimelineIO/OpenTimelineIO-C-Bindings.git && \ + cd OpenTimelineIO-C-Bindings && \ + git checkout $COTIO_VERSION && \ + mkdir build && \ + cd build && \ + cmake -DCMAKE_INSTALL_PREFIX=/opt/otio -DCOTIO_SHARED_LIBS=ON ../ && \ + make -j $(nproc --all) && \ + make install && \ + cp /tmp/otio/OpenTimelineIO-C-Bindings/include/copentimelineio/typeInfo.h /opt/otio/include/copentimelineio/typeInfo.h +# Cleanup +RUN rm -rf /tmp/otio + +ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:$LD_LIBRARY_PATH + +# Add useful tools +RUN rustup component add llvm-tools-preview && \ + cargo install bindgen && \ + cargo install cargo-valgrind && \ + cargo install cargo-llvm-cov + +USER $USERNAME diff --git a/README.md b/README.md index 001461a..ff25ba5 100644 --- a/README.md +++ b/README.md @@ -33,3 +33,10 @@ Cloning into 'opentimelineio-bind'... ``` > cargo build ``` + +Testing + +```bash +clear && LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/otio/lib:/opt/otio/lib64 cargo llvm-cov --html + +``` diff --git a/generatebindings.py b/generatebindings.py deleted file mode 100644 index faf3eaa..0000000 --- a/generatebindings.py +++ /dev/null @@ -1,25 +0,0 @@ -""" -Run this in either Python 2 or Python 3 to automatically build the sys bindings. - -You'll need: - -- bindgen (see https://rust-lang.github.io/rust-bindgen/command-line-usage.html) -- Python 2 or 3 - -""" - -import subprocess -import os - -ROOT_DIR = os.path.join(os.path.dirname(__file__), "src") - - -def main(): - rs_path = os.path.join(ROOT_DIR, "lib.rs") - header_path = os.path.join(ROOT_DIR, "lib.h") - # This runs bindgen -o lib.rs lib.h -- -I/path/to/src - subprocess.check_call(["bindgen", "-o", rs_path, header_path, "--", "-I{}".format(ROOT_DIR)], cwd=ROOT_DIR) - - -if __name__ == "__main__": - main() diff --git a/opentimelineio-sys/Cargo.toml b/opentimelineio-sys/Cargo.toml new file mode 100644 index 0000000..d1ce1d5 --- /dev/null +++ b/opentimelineio-sys/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "opentimelineio-sys" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/opentimelineio-sys/bindgen.py b/opentimelineio-sys/bindgen.py new file mode 100644 index 0000000..d8e4330 --- /dev/null +++ b/opentimelineio-sys/bindgen.py @@ -0,0 +1,27 @@ +import os +import subprocess +import sys +from pathlib import Path + +_SYS_SRC_PATH = Path(os.path.dirname(__file__)) / "src" + + +def main(include_dir: Path): + rust_path = _SYS_SRC_PATH / "lib.rs" + header_path = _SYS_SRC_PATH / "lib.h" + + subprocess.check_call( + [ + "bindgen", + "-o", + str(rust_path), + str(header_path), + "--", + f"-I{str(include_dir)}", + ], + cwd=_SYS_SRC_PATH, + ) + + +if __name__ == "__main__": + main(Path(sys.argv[1])) diff --git a/opentimelineio-sys/build.rs b/opentimelineio-sys/build.rs new file mode 100644 index 0000000..6fb8be2 --- /dev/null +++ b/opentimelineio-sys/build.rs @@ -0,0 +1,7 @@ +fn main() { + // TODO: Use proper way to get the search paths and libraries. + println!("cargo:rustc-link-search=native=/opt/otio/lib"); + println!("cargo:rustc-link-search=native=/opt/otio/lib64"); + println!("cargo:rustc-link-lib=dylib=copentime"); + println!("cargo:rustc-link-lib=dylib=copentimelineio"); +} diff --git a/opentimelineio-sys/src/lib.h b/opentimelineio-sys/src/lib.h new file mode 100644 index 0000000..22b9793 --- /dev/null +++ b/opentimelineio-sys/src/lib.h @@ -0,0 +1,56 @@ +#pragma once + +// #include +// #include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/src/lib.rs b/opentimelineio-sys/src/lib.rs similarity index 94% rename from src/lib.rs rename to opentimelineio-sys/src/lib.rs index c99638f..f4ec92b 100644 --- a/src/lib.rs +++ b/opentimelineio-sys/src/lib.rs @@ -1,18 +1,19 @@ -/* automatically generated by rust-bindgen 0.59.2 */ +/* automatically generated by rust-bindgen 0.60.1 */ pub const true_: u32 = 1; pub const false_: u32 = 0; pub const __bool_true_false_are_defined: u32 = 1; pub const _STDINT_H: u32 = 1; pub const _FEATURES_H: u32 = 1; -pub const _DEFAULT_SOURCE: u32 = 1; -pub const __GLIBC_USE_ISOC2X: u32 = 0; +pub const __USE_ANSI: u32 = 1; +pub const _BSD_SOURCE: u32 = 1; +pub const _SVID_SOURCE: u32 = 1; pub const __USE_ISOC11: u32 = 1; pub const __USE_ISOC99: u32 = 1; pub const __USE_ISOC95: u32 = 1; -pub const __USE_POSIX_IMPLICITLY: u32 = 1; pub const _POSIX_SOURCE: u32 = 1; pub const _POSIX_C_SOURCE: u32 = 200809; +pub const __USE_POSIX_IMPLICITLY: u32 = 1; pub const __USE_POSIX: u32 = 1; pub const __USE_POSIX2: u32 = 1; pub const __USE_POSIX199309: u32 = 1; @@ -20,45 +21,27 @@ pub const __USE_POSIX199506: u32 = 1; pub const __USE_XOPEN2K: u32 = 1; pub const __USE_XOPEN2K8: u32 = 1; pub const _ATFILE_SOURCE: u32 = 1; -pub const __WORDSIZE: u32 = 64; -pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1; -pub const __SYSCALL_WORDSIZE: u32 = 64; -pub const __TIMESIZE: u32 = 64; pub const __USE_MISC: u32 = 1; +pub const __USE_BSD: u32 = 1; +pub const __USE_SVID: u32 = 1; pub const __USE_ATFILE: u32 = 1; pub const __USE_FORTIFY_LEVEL: u32 = 0; -pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0; -pub const __GLIBC_USE_DEPRECATED_SCANF: u32 = 0; pub const _STDC_PREDEF_H: u32 = 1; pub const __STDC_IEC_559__: u32 = 1; pub const __STDC_IEC_559_COMPLEX__: u32 = 1; -pub const __STDC_ISO_10646__: u32 = 201706; +pub const __STDC_ISO_10646__: u32 = 201103; +pub const __STDC_NO_THREADS__: u32 = 1; pub const __GNU_LIBRARY__: u32 = 6; pub const __GLIBC__: u32 = 2; -pub const __GLIBC_MINOR__: u32 = 34; +pub const __GLIBC_MINOR__: u32 = 17; +pub const __GLIBC_HAVE_LONG_LONG: u32 = 1; pub const _SYS_CDEFS_H: u32 = 1; -pub const __glibc_c99_flexarr_available: u32 = 1; -pub const __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI: u32 = 0; -pub const __HAVE_GENERIC_SELECTION: u32 = 1; -pub const __GLIBC_USE_LIB_EXT2: u32 = 0; -pub const __GLIBC_USE_IEC_60559_BFP_EXT: u32 = 0; -pub const __GLIBC_USE_IEC_60559_BFP_EXT_C2X: u32 = 0; -pub const __GLIBC_USE_IEC_60559_EXT: u32 = 0; -pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: u32 = 0; -pub const __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X: u32 = 0; -pub const __GLIBC_USE_IEC_60559_TYPES_EXT: u32 = 0; -pub const _BITS_TYPES_H: u32 = 1; -pub const _BITS_TYPESIZES_H: u32 = 1; -pub const __OFF_T_MATCHES_OFF64_T: u32 = 1; -pub const __INO_T_MATCHES_INO64_T: u32 = 1; -pub const __RLIM_T_MATCHES_RLIM64_T: u32 = 1; -pub const __STATFS_MATCHES_STATFS64: u32 = 1; -pub const __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64: u32 = 1; -pub const __FD_SETSIZE: u32 = 1024; -pub const _BITS_TIME64_H: u32 = 1; +pub const __WORDSIZE: u32 = 64; +pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1; +pub const __SYSCALL_WORDSIZE: u32 = 64; pub const _BITS_WCHAR_H: u32 = 1; -pub const _BITS_STDINT_INTN_H: u32 = 1; -pub const _BITS_STDINT_UINTN_H: u32 = 1; +pub const __WCHAR_MIN: i32 = -2147483648; +pub const __WCHAR_MAX: u32 = 2147483647; pub const INT8_MIN: i32 = -128; pub const INT16_MIN: i32 = -32768; pub const INT32_MIN: i32 = -2147483648; @@ -94,6 +77,8 @@ pub const PTRDIFF_MAX: u64 = 9223372036854775807; pub const SIG_ATOMIC_MIN: i32 = -2147483648; pub const SIG_ATOMIC_MAX: u32 = 2147483647; pub const SIZE_MAX: i32 = -1; +pub const WCHAR_MIN: i32 = -2147483648; +pub const WCHAR_MAX: u32 = 2147483647; pub const WINT_MIN: u32 = 0; pub const WINT_MAX: u32 = 4294967295; #[repr(C)] @@ -164,26 +149,40 @@ fn bindgen_test_layout_RationalTime() { 8usize, concat!("Alignment of ", stringify!(RationalTime)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).value as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(RationalTime), - "::", - stringify!(value) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rate as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(RationalTime), - "::", - stringify!(rate) - ) - ); + fn test_field_value() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).value) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(RationalTime), + "::", + stringify!(value) + ) + ); + } + test_field_value(); + fn test_field_rate() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rate) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(RationalTime), + "::", + stringify!(rate) + ) + ); + } + test_field_rate(); } pub const OpenTime_IsDropFrameRate__OpenTime_IsDropFrameRate_InferFromRate: OpenTime_IsDropFrameRate_ = -1; @@ -316,26 +315,40 @@ fn bindgen_test_layout_TimeRange() { 8usize, concat!("Alignment of ", stringify!(TimeRange)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).start_time as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(TimeRange), - "::", - stringify!(start_time) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).duration as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(TimeRange), - "::", - stringify!(duration) - ) - ); + fn test_field_start_time() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).start_time) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(TimeRange), + "::", + stringify!(start_time) + ) + ); + } + test_field_start_time(); + fn test_field_duration() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).duration) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(TimeRange), + "::", + stringify!(duration) + ) + ); + } + test_field_duration(); } extern "C" { pub fn TimeRange_create() -> TimeRange; @@ -422,36 +435,57 @@ fn bindgen_test_layout_TimeTransform() { 8usize, concat!("Alignment of ", stringify!(TimeTransform)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).offset as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(TimeTransform), - "::", - stringify!(offset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).scale as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(TimeTransform), - "::", - stringify!(scale) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rate as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(TimeTransform), - "::", - stringify!(rate) - ) - ); + fn test_field_offset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).offset) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(TimeTransform), + "::", + stringify!(offset) + ) + ); + } + test_field_offset(); + fn test_field_scale() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).scale) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(TimeTransform), + "::", + stringify!(scale) + ) + ); + } + test_field_scale(); + fn test_field_rate() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).rate) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(TimeTransform), + "::", + stringify!(rate) + ) + ); + } + test_field_rate(); } extern "C" { pub fn TimeTransform_create() -> TimeTransform; @@ -512,26 +546,40 @@ fn bindgen_test_layout_OptionalRationalTime() { 8usize, concat!("Alignment of ", stringify!(OptionalRationalTime)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).value as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(OptionalRationalTime), - "::", - stringify!(value) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).valid as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(OptionalRationalTime), - "::", - stringify!(valid) - ) - ); + fn test_field_value() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).value) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(OptionalRationalTime), + "::", + stringify!(value) + ) + ); + } + test_field_value(); + fn test_field_valid() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).valid) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(OptionalRationalTime), + "::", + stringify!(valid) + ) + ); + } + test_field_valid(); } extern "C" { pub fn OptionalRationalTime_create(rationalTime: RationalTime) -> OptionalRationalTime; @@ -563,26 +611,40 @@ fn bindgen_test_layout_OptionalTimeRange() { 8usize, concat!("Alignment of ", stringify!(OptionalTimeRange)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).value as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(OptionalTimeRange), - "::", - stringify!(value) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).valid as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(OptionalTimeRange), - "::", - stringify!(valid) - ) - ); + fn test_field_value() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).value) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(OptionalTimeRange), + "::", + stringify!(value) + ) + ); + } + test_field_value(); + fn test_field_valid() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).valid) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(OptionalTimeRange), + "::", + stringify!(valid) + ) + ); + } + test_field_valid(); } extern "C" { pub fn OptionalTimeRange_create(timeRange: TimeRange) -> OptionalTimeRange; @@ -3233,104 +3295,14 @@ extern "C" { extern "C" { pub fn RetainerPairComposable_destroy(self_: *mut RetainerPairComposable); } -pub type __u_char = ::std::os::raw::c_uchar; -pub type __u_short = ::std::os::raw::c_ushort; -pub type __u_int = ::std::os::raw::c_uint; -pub type __u_long = ::std::os::raw::c_ulong; -pub type __int8_t = ::std::os::raw::c_schar; -pub type __uint8_t = ::std::os::raw::c_uchar; -pub type __int16_t = ::std::os::raw::c_short; -pub type __uint16_t = ::std::os::raw::c_ushort; -pub type __int32_t = ::std::os::raw::c_int; -pub type __uint32_t = ::std::os::raw::c_uint; -pub type __int64_t = ::std::os::raw::c_long; -pub type __uint64_t = ::std::os::raw::c_ulong; -pub type __int_least8_t = __int8_t; -pub type __uint_least8_t = __uint8_t; -pub type __int_least16_t = __int16_t; -pub type __uint_least16_t = __uint16_t; -pub type __int_least32_t = __int32_t; -pub type __uint_least32_t = __uint32_t; -pub type __int_least64_t = __int64_t; -pub type __uint_least64_t = __uint64_t; -pub type __quad_t = ::std::os::raw::c_long; -pub type __u_quad_t = ::std::os::raw::c_ulong; -pub type __intmax_t = ::std::os::raw::c_long; -pub type __uintmax_t = ::std::os::raw::c_ulong; -pub type __dev_t = ::std::os::raw::c_ulong; -pub type __uid_t = ::std::os::raw::c_uint; -pub type __gid_t = ::std::os::raw::c_uint; -pub type __ino_t = ::std::os::raw::c_ulong; -pub type __ino64_t = ::std::os::raw::c_ulong; -pub type __mode_t = ::std::os::raw::c_uint; -pub type __nlink_t = ::std::os::raw::c_ulong; -pub type __off_t = ::std::os::raw::c_long; -pub type __off64_t = ::std::os::raw::c_long; -pub type __pid_t = ::std::os::raw::c_int; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct __fsid_t { - pub __val: [::std::os::raw::c_int; 2usize], -} -#[test] -fn bindgen_test_layout___fsid_t() { - assert_eq!( - ::std::mem::size_of::<__fsid_t>(), - 8usize, - concat!("Size of: ", stringify!(__fsid_t)) - ); - assert_eq!( - ::std::mem::align_of::<__fsid_t>(), - 4usize, - concat!("Alignment of ", stringify!(__fsid_t)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::<__fsid_t>())).__val as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__fsid_t), - "::", - stringify!(__val) - ) - ); -} -pub type __clock_t = ::std::os::raw::c_long; -pub type __rlim_t = ::std::os::raw::c_ulong; -pub type __rlim64_t = ::std::os::raw::c_ulong; -pub type __id_t = ::std::os::raw::c_uint; -pub type __time_t = ::std::os::raw::c_long; -pub type __useconds_t = ::std::os::raw::c_uint; -pub type __suseconds_t = ::std::os::raw::c_long; -pub type __suseconds64_t = ::std::os::raw::c_long; -pub type __daddr_t = ::std::os::raw::c_int; -pub type __key_t = ::std::os::raw::c_int; -pub type __clockid_t = ::std::os::raw::c_int; -pub type __timer_t = *mut ::std::os::raw::c_void; -pub type __blksize_t = ::std::os::raw::c_long; -pub type __blkcnt_t = ::std::os::raw::c_long; -pub type __blkcnt64_t = ::std::os::raw::c_long; -pub type __fsblkcnt_t = ::std::os::raw::c_ulong; -pub type __fsblkcnt64_t = ::std::os::raw::c_ulong; -pub type __fsfilcnt_t = ::std::os::raw::c_ulong; -pub type __fsfilcnt64_t = ::std::os::raw::c_ulong; -pub type __fsword_t = ::std::os::raw::c_long; -pub type __ssize_t = ::std::os::raw::c_long; -pub type __syscall_slong_t = ::std::os::raw::c_long; -pub type __syscall_ulong_t = ::std::os::raw::c_ulong; -pub type __loff_t = __off64_t; -pub type __caddr_t = *mut ::std::os::raw::c_char; -pub type __intptr_t = ::std::os::raw::c_long; -pub type __socklen_t = ::std::os::raw::c_uint; -pub type __sig_atomic_t = ::std::os::raw::c_int; -pub type int_least8_t = __int_least8_t; -pub type int_least16_t = __int_least16_t; -pub type int_least32_t = __int_least32_t; -pub type int_least64_t = __int_least64_t; -pub type uint_least8_t = __uint_least8_t; -pub type uint_least16_t = __uint_least16_t; -pub type uint_least32_t = __uint_least32_t; -pub type uint_least64_t = __uint_least64_t; +pub type int_least8_t = ::std::os::raw::c_schar; +pub type int_least16_t = ::std::os::raw::c_short; +pub type int_least32_t = ::std::os::raw::c_int; +pub type int_least64_t = ::std::os::raw::c_long; +pub type uint_least8_t = ::std::os::raw::c_uchar; +pub type uint_least16_t = ::std::os::raw::c_ushort; +pub type uint_least32_t = ::std::os::raw::c_uint; +pub type uint_least64_t = ::std::os::raw::c_ulong; pub type int_fast8_t = ::std::os::raw::c_schar; pub type int_fast16_t = ::std::os::raw::c_long; pub type int_fast32_t = ::std::os::raw::c_long; @@ -3339,8 +3311,8 @@ pub type uint_fast8_t = ::std::os::raw::c_uchar; pub type uint_fast16_t = ::std::os::raw::c_ulong; pub type uint_fast32_t = ::std::os::raw::c_ulong; pub type uint_fast64_t = ::std::os::raw::c_ulong; -pub type intmax_t = __intmax_t; -pub type uintmax_t = __uintmax_t; +pub type intmax_t = ::std::os::raw::c_long; +pub type uintmax_t = ::std::os::raw::c_ulong; extern "C" { pub fn create_safely_typed_any_bool(boolValue: bool) -> *mut Any; } diff --git a/opentimelineio/Cargo.toml b/opentimelineio/Cargo.toml new file mode 100644 index 0000000..ef2f193 --- /dev/null +++ b/opentimelineio/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "opentimelineio" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +libc = "0.2.133" +opentimelineio-sys = { path = "../opentimelineio-sys" } diff --git a/opentimelineio/src/lib.rs b/opentimelineio/src/lib.rs new file mode 100644 index 0000000..5b74dfe --- /dev/null +++ b/opentimelineio/src/lib.rs @@ -0,0 +1 @@ +pub mod opentime; diff --git a/opentimelineio/src/opentime/error_status.rs b/opentimelineio/src/opentime/error_status.rs new file mode 100644 index 0000000..5257b25 --- /dev/null +++ b/opentimelineio/src/opentime/error_status.rs @@ -0,0 +1,276 @@ +use std::fmt::Error; + +use opentimelineio_sys as sys; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ErrorStatusOutcome { + Ok, + InvalidTimecodeRate, + NonDropframeRate, + InvalidteTimecodeString, + InvalidTimeString, + TimecodeRateMismatch, + NegativeValue, + InvalidRateForDropFrameTimecode, +} + +impl std::fmt::Display for ErrorStatusOutcome { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let outcome = unsafe { + // SAFETY: The OpenTimeErrorStatus_outcome_to_string doesn't make + // use of the ErrorStatus type at all, so should be safe to null. + let c_outcome = + sys::OpenTimeErrorStatus_outcome_to_string(std::ptr::null_mut(), self.into()); + + // TODO: Should this return an error, or just panic? + assert!(!c_outcome.is_null()); + + // TODO: Should this return a result or panic? + let result = std::ffi::CStr::from_ptr(c_outcome) + .to_str() + .unwrap() + .to_string(); + // SAFETY: The C code creates a copy of the pointer that we should + // clean up. So, we create a copy of the string in Rust then free + // the C pointer. + libc::free(c_outcome as *mut libc::c_void); + + result + }; + + f.write_str(&outcome) + } +} + +impl std::convert::From for ErrorStatusOutcome { + fn from(status: sys::OpenTime_ErrorStatus_Outcome_) -> Self { + match status { + sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_OK => Self::Ok, + sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_RATE => Self::InvalidTimecodeRate, + sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_NON_DROPFRAME_RATE => Self::NonDropframeRate, + sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_STRING => { + Self::InvalidteTimecodeString + } + sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIME_STRING => Self::InvalidTimeString, + sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_TIMECODE_RATE_MISMATCH => Self::TimecodeRateMismatch, + sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_NEGATIVE_VALUE => Self::NegativeValue, + sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_RATE_FOR_DROP_FRAME_TIMECODE => { + Self::InvalidRateForDropFrameTimecode + }, + // TODO: Should this return a result or panic? + _ => panic!() + } + } +} + +impl std::convert::Into for ErrorStatusOutcome { + fn into(self) -> sys::OpenTime_ErrorStatus_Outcome_ { + match self { + Self::Ok=> sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_OK, + Self::InvalidTimecodeRate=> sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_RATE, + Self::NonDropframeRate=> sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_NON_DROPFRAME_RATE, + Self::InvalidteTimecodeString=> sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_STRING, + Self::InvalidTimeString=> sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIME_STRING, + Self::TimecodeRateMismatch=> sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_TIMECODE_RATE_MISMATCH, + Self::NegativeValue=> sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_NEGATIVE_VALUE, + Self::InvalidRateForDropFrameTimecode=> sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_RATE_FOR_DROP_FRAME_TIMECODE, + } + } +} + +impl std::convert::Into for ErrorStatusOutcome { + fn into(self) -> sys::OpenTime_ErrorStatus_Outcome { + >::into(self) + as sys::OpenTime_ErrorStatus_Outcome + } +} + +impl std::convert::Into for &ErrorStatusOutcome { + fn into(self) -> sys::OpenTime_ErrorStatus_Outcome_ { + let owned_self = self.to_owned(); + owned_self.into() + } +} + +impl std::convert::Into for &ErrorStatusOutcome { + fn into(self) -> sys::OpenTime_ErrorStatus_Outcome { + >::into(self) + as sys::OpenTime_ErrorStatus_Outcome + } +} + +#[derive(Debug)] +pub struct ErrorStatus { + inner: *mut sys::OpenTimeErrorStatus, +} + +impl ErrorStatus { + pub fn new() -> Self { + let inner = unsafe { sys::OpenTimeErrorStatus_create() }; + + // TODO: Should this return an error, or just panic? + assert!(!inner.is_null()); + + Self { inner } + } + + pub fn with_outcome(outcome: ErrorStatusOutcome) -> Self { + let inner = unsafe { sys::OpenTimeErrorStatus_create_with_outcome(outcome.into()) }; + + // TODO: Should this return an error, or just panic? + assert!(!inner.is_null()); + + Self { inner } + } + + pub fn with_outcome_and_details(outcome: ErrorStatusOutcome, details: &str) -> Self { + let inner = unsafe { + // TODO: Should this return a result or panic? + let c_details = std::ffi::CString::new(details).unwrap(); + // SAFETY: c_details should be copied in the otio ErrorStatus, so it + // should be safe to drop. + sys::OpenTimeErrorStatus_create_with_outcome_and_details( + outcome.into(), + c_details.as_ptr(), + ) + }; + + assert!(!inner.is_null()); + + Self { inner } + } + + pub(crate) fn as_sys_ptr(&self) -> *const sys::OpenTimeErrorStatus { + self.inner + } + + pub(crate) fn as_mut_sys_ptr(&mut self) -> *mut sys::OpenTimeErrorStatus { + self.inner + } +} + +impl Drop for ErrorStatus { + fn drop(&mut self) { + unsafe { sys::OpenTimeErrorStatus_destroy(self.inner) } + } +} + +impl std::fmt::Display for ErrorStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + // TODO: Cannot access error status info from C API. + todo!() + } +} + +impl std::error::Error for ErrorStatus {} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_error_status_outcome_display_success() { + let result = ErrorStatusOutcome::Ok.to_string(); + assert_eq!(&result, ""); + let result = ErrorStatusOutcome::InvalidTimecodeRate.to_string(); + assert_eq!(&result, "invalid timecode rate"); + } + + #[test] + fn test_error_status_outcome_from_ffi_success() { + for (sys_value, api_value) in [ + (sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_OK, ErrorStatusOutcome::Ok), + (sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_RATE, ErrorStatusOutcome::InvalidTimecodeRate), + (sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_NON_DROPFRAME_RATE, ErrorStatusOutcome::NonDropframeRate), + (sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_STRING, ErrorStatusOutcome::InvalidteTimecodeString), + (sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIME_STRING, ErrorStatusOutcome::InvalidTimeString), + (sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_TIMECODE_RATE_MISMATCH, ErrorStatusOutcome::TimecodeRateMismatch), + (sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_NEGATIVE_VALUE, ErrorStatusOutcome::NegativeValue), + (sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_RATE_FOR_DROP_FRAME_TIMECODE, ErrorStatusOutcome::InvalidRateForDropFrameTimecode), + ] { + let result = ErrorStatusOutcome::from( + sys_value, + ); + + assert_eq!(result, api_value); + } + } + + #[test] + fn test_error_status_outcome_to_ffi_success() { + for (api_value, sys_value) in [ + (ErrorStatusOutcome::Ok, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_OK), + (ErrorStatusOutcome::InvalidTimecodeRate, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_RATE), + (ErrorStatusOutcome::NonDropframeRate, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_NON_DROPFRAME_RATE), + (ErrorStatusOutcome::InvalidteTimecodeString, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_STRING), + (ErrorStatusOutcome::InvalidTimeString, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIME_STRING), + (ErrorStatusOutcome::TimecodeRateMismatch, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_TIMECODE_RATE_MISMATCH), + (ErrorStatusOutcome::NegativeValue, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_NEGATIVE_VALUE), + (ErrorStatusOutcome::InvalidRateForDropFrameTimecode, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_RATE_FOR_DROP_FRAME_TIMECODE), + ] { + let result: sys::OpenTime_ErrorStatus_Outcome_ = api_value.into(); + + assert_eq!(result, sys_value); + } + + for (api_value, sys_value) in [ + (ErrorStatusOutcome::Ok, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_OK), + (ErrorStatusOutcome::InvalidTimecodeRate, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_RATE), + (ErrorStatusOutcome::NonDropframeRate, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_NON_DROPFRAME_RATE), + (ErrorStatusOutcome::InvalidteTimecodeString, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_STRING), + (ErrorStatusOutcome::InvalidTimeString, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIME_STRING), + (ErrorStatusOutcome::TimecodeRateMismatch, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_TIMECODE_RATE_MISMATCH), + (ErrorStatusOutcome::NegativeValue, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_NEGATIVE_VALUE), + (ErrorStatusOutcome::InvalidRateForDropFrameTimecode, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_RATE_FOR_DROP_FRAME_TIMECODE), + ] { + let result: sys::OpenTime_ErrorStatus_Outcome = api_value.into(); + + assert_eq!(result as u32, sys_value); + } + + for (api_value, sys_value) in &[ + (ErrorStatusOutcome::Ok, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_OK), + (ErrorStatusOutcome::InvalidTimecodeRate, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_RATE), + (ErrorStatusOutcome::NonDropframeRate, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_NON_DROPFRAME_RATE), + (ErrorStatusOutcome::InvalidteTimecodeString, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_STRING), + (ErrorStatusOutcome::InvalidTimeString, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIME_STRING), + (ErrorStatusOutcome::TimecodeRateMismatch, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_TIMECODE_RATE_MISMATCH), + (ErrorStatusOutcome::NegativeValue, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_NEGATIVE_VALUE), + (ErrorStatusOutcome::InvalidRateForDropFrameTimecode, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_RATE_FOR_DROP_FRAME_TIMECODE), + ] { + let result: sys::OpenTime_ErrorStatus_Outcome_ = api_value.into(); + + assert_eq!(&result, sys_value); + } + + for (api_value, sys_value) in &[ + (ErrorStatusOutcome::Ok, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_OK), + (ErrorStatusOutcome::InvalidTimecodeRate, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_RATE), + (ErrorStatusOutcome::NonDropframeRate, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_NON_DROPFRAME_RATE), + (ErrorStatusOutcome::InvalidteTimecodeString, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_STRING), + (ErrorStatusOutcome::InvalidTimeString, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_TIME_STRING), + (ErrorStatusOutcome::TimecodeRateMismatch, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_TIMECODE_RATE_MISMATCH), + (ErrorStatusOutcome::NegativeValue, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_NEGATIVE_VALUE), + (ErrorStatusOutcome::InvalidRateForDropFrameTimecode, sys::OpenTime_ErrorStatus_Outcome__OpenTime_ErrorStatus_Outcome_INVALID_RATE_FOR_DROP_FRAME_TIMECODE), + ] { + let result: sys::OpenTime_ErrorStatus_Outcome = api_value.into(); + + assert_eq!(&(result as u32), sys_value); + } + } + + #[test] + fn test_error_status_new_success() { + ErrorStatus::new(); + } + + #[test] + fn test_error_status_with_outcome_success() { + ErrorStatus::with_outcome(ErrorStatusOutcome::Ok); + } + + #[test] + fn test_error_status_with_outcome_and_details_success() { + ErrorStatus::with_outcome_and_details(ErrorStatusOutcome::Ok, "test"); + } +} diff --git a/opentimelineio/src/opentime/mod.rs b/opentimelineio/src/opentime/mod.rs new file mode 100644 index 0000000..0bd9438 --- /dev/null +++ b/opentimelineio/src/opentime/mod.rs @@ -0,0 +1,2 @@ +pub mod error_status; +pub mod rational_time; diff --git a/opentimelineio/src/opentime/rational_time.rs b/opentimelineio/src/opentime/rational_time.rs new file mode 100644 index 0000000..c45d2b1 --- /dev/null +++ b/opentimelineio/src/opentime/rational_time.rs @@ -0,0 +1,505 @@ +use super::error_status::{ErrorStatus, ErrorStatusOutcome}; +use opentimelineio_sys as sys; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum IsDropFrameRate { + InferFrameRate, + ForceNo, + ForceYes, +} + +impl std::convert::From for IsDropFrameRate { + fn from(value: sys::OpenTime_IsDropFrameRate_) -> Self { + match value { + sys::OpenTime_IsDropFrameRate__OpenTime_IsDropFrameRate_InferFromRate => { + Self::InferFrameRate + } + sys::OpenTime_IsDropFrameRate__OpenTime_IsDropFrameRate_ForceNo => Self::ForceNo, + sys::OpenTime_IsDropFrameRate__OpenTime_IsDropFrameRate_ForceYes => Self::ForceYes, + // TODO: Should this panic or return a result? + _ => panic!(), + } + } +} + +impl std::convert::Into for IsDropFrameRate { + fn into(self) -> sys::OpenTime_IsDropFrameRate_ { + match self { + Self::InferFrameRate => { + sys::OpenTime_IsDropFrameRate__OpenTime_IsDropFrameRate_InferFromRate + } + Self::ForceNo => sys::OpenTime_IsDropFrameRate__OpenTime_IsDropFrameRate_ForceNo, + Self::ForceYes => sys::OpenTime_IsDropFrameRate__OpenTime_IsDropFrameRate_ForceYes, + } + } +} + +#[derive(Debug, Copy, Clone)] +pub struct RationalTime { + pub value: f64, + pub rate: f64, +} + +impl std::convert::From for RationalTime { + fn from(value: sys::RationalTime) -> Self { + Self { + value: value.value, + rate: value.rate, + } + } +} + +impl std::convert::Into for RationalTime { + fn into(self) -> sys::RationalTime { + sys::RationalTime { + value: self.value, + rate: self.rate, + } + } +} + +// TODO: Most of the unsafe APIs can be replaced with native Rust. The only real +// exceptions would be string -> RationalTime -> string conversions. +impl RationalTime { + pub fn new(value: f64, rate: f64) -> Self { + // May be sufficient to just to `Self { value, rate }` here and skip the + // C API. + let inner = unsafe { sys::RationalTime_create(value, rate) }; + + Self { + value: inner.value, + rate: inner.rate, + } + } + + pub fn is_invalid_time(self) -> bool { + unsafe { sys::RationalTime_is_invalid_time(self.into()) } + } + + pub fn rescaled_to(self, new_rate: f64) -> Self { + Self::from(unsafe { sys::RationalTime_rescaled_to(self.into(), new_rate) }) + } + + pub fn rescaled_to_rational_time(self, rt: Self) -> Self { + Self::from(unsafe { sys::RationalTime_rescaled_to_rational_time(self.into(), rt.into()) }) + } + + pub fn value_rescaled_to_rate(self, new_rate: f64) -> f64 { + unsafe { sys::RationalTime_value_rescaled_to_rate(self.into(), new_rate) } + } + + pub fn value_rescaled_to_rational_time(self, rt: Self) -> f64 { + unsafe { sys::RationalTime_value_rescaled_to_rational_time(self.into(), rt.into()) } + } + + pub fn almost_equal(self, other: Self, delta: f64) -> bool { + unsafe { sys::RationalTime_almost_equal(self.into(), other.into(), delta) } + } + + pub fn duration_from_start_end_time(self, end_time_exclusive: Self) -> Self { + Self::from(unsafe { + sys::RationalTime_duration_from_start_end_time(self.into(), end_time_exclusive.into()) + }) + } + + pub fn is_valid_timecode_rate(rate: f64) -> bool { + unsafe { sys::RationalTime_is_valid_timecode_rate(rate) } + } + + pub fn from_frames(frame: f64, rate: f64) -> Self { + Self::from(unsafe { sys::RationalTime_from_frames(frame, rate) }) + } + + pub fn from_seconds(seconds: f64) -> Self { + Self::from(unsafe { sys::RationalTime_from_seconds(seconds) }) + } + + pub fn from_timecode(timecode: &str, rate: f64) -> Result { + let c_timecode = match std::ffi::CString::new(timecode) { + Ok(t) => t, + Err(err) => { + return Err(ErrorStatus::with_outcome_and_details( + ErrorStatusOutcome::InvalidteTimecodeString, + &err.to_string(), + )) + } + }; + + unsafe { + let mut error_status = ErrorStatus::new(); + let ptr = error_status.as_mut_sys_ptr(); + let result = sys::RationalTime_from_timecode(c_timecode.as_ptr(), rate, ptr); + + // TODO: Cannot access error status result. + todo!(); + + Ok(Self::from(result)) + } + } + + pub fn from_time_string(time_string: &str, rate: f64) -> Result { + let c_time = match std::ffi::CString::new(time_string) { + Ok(t) => t, + Err(err) => { + return Err(ErrorStatus::with_outcome_and_details( + ErrorStatusOutcome::InvalidteTimecodeString, + &err.to_string(), + )) + } + }; + + unsafe { + let mut error_status = ErrorStatus::new(); + let ptr = error_status.as_mut_sys_ptr(); + // TODO: This can panic in the C layer. + let result = sys::RationalTime_from_time_string(c_time.as_ptr(), rate, ptr); + + // TODO: Cannot access error status result. + todo!(); + + Ok(Self::from(result)) + } + } + + pub fn to_frames(self) -> i32 { + unsafe { sys::RationalTime_to_frames(self.into()) } + } + + pub fn to_frames_with_rate(self, rate: f64) -> i32 { + unsafe { sys::RationalTime_to_frames_with_rate(self.into(), rate) } + } + + pub fn to_seconds(self) -> f64 { + unsafe { sys::RationalTime_to_seconds(self.into()) } + } + + pub fn to_timecode( + self, + rate: f64, + drop_frame: IsDropFrameRate, + ) -> Result { + unsafe { + let mut error_status = ErrorStatus::new(); + let ptr = error_status.as_mut_sys_ptr(); + let c_timecode = + sys::RationalTime_to_timecode(self.into(), rate, drop_frame.into(), ptr); + + // TODO: Cannot access error status result. + todo!(); + + match std::ffi::CStr::from_ptr(c_timecode).to_str() { + Ok(timecode) => { + let timecode = timecode.to_string(); + // SAFETY: The C code creates a copy of the pointer that we + // should clean up. So, we create a copy of the string in + // Rust then free the C pointer. + libc::free(c_timecode as *mut libc::c_void); + Ok(timecode) + } + Err(err) => Err(ErrorStatus::with_outcome_and_details( + ErrorStatusOutcome::InvalidTimeString, + &err.to_string(), + )), + } + } + } + + pub fn to_timecode_auto(self) -> Result { + unsafe { + let mut error_status = ErrorStatus::new(); + let ptr = error_status.as_mut_sys_ptr(); + let c_timecode = sys::RationalTime_to_timecode_auto(self.into(), ptr); + + // TODO: Cannot access error status result. + todo!(); + + match std::ffi::CStr::from_ptr(c_timecode).to_str() { + Ok(timecode) => { + let timecode = timecode.to_string(); + // SAFETY: The C code creates a copy of the pointer that we + // should clean up. So, we create a copy of the string in + // Rust then free the C pointer. + libc::free(c_timecode as *mut libc::c_void); + Ok(timecode) + } + Err(err) => Err(ErrorStatus::with_outcome_and_details( + ErrorStatusOutcome::InvalidTimeString, + &err.to_string(), + )), + } + } + } + + pub fn to_time_string(self) -> String { + unsafe { + let c_time = sys::RationalTime_to_time_string(self.into()); + + // TODO: Should this return a result or panic? + let result = std::ffi::CStr::from_ptr(c_time) + .to_str() + .unwrap() + .to_string(); + // SAFETY: The C code creates a copy of the pointer that we should + // clean up. So, we create a copy of the string in Rust then free + // the C pointer. + libc::free(c_time as *mut libc::c_void); + + result + } + } +} + +impl std::ops::Add for RationalTime { + type Output = Self; + + fn add(self, rhs: Self) -> Self::Output { + Self::Output::from(unsafe { sys::RationalTime_add(self.into(), rhs.into()) }) + } +} + +impl std::ops::Sub for RationalTime { + type Output = Self; + + fn sub(self, rhs: Self) -> Self::Output { + Self::Output::from(unsafe { sys::RationalTime_subtract(self.into(), rhs.into()) }) + } +} + +impl std::cmp::PartialEq for RationalTime { + fn eq(&self, other: &Self) -> bool { + unsafe { sys::RationalTime_equal(self.to_owned().into(), other.to_owned().into()) } + } + + fn ne(&self, other: &Self) -> bool { + unsafe { sys::RationalTime_not_equal(self.to_owned().into(), other.to_owned().into()) } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_is_drop_frame_rate_from_sys_success() { + assert_eq!( + IsDropFrameRate::from( + sys::OpenTime_IsDropFrameRate__OpenTime_IsDropFrameRate_InferFromRate + ), + IsDropFrameRate::InferFrameRate + ); + assert_eq!( + IsDropFrameRate::from(sys::OpenTime_IsDropFrameRate__OpenTime_IsDropFrameRate_ForceNo), + IsDropFrameRate::ForceNo + ); + assert_eq!( + IsDropFrameRate::from(sys::OpenTime_IsDropFrameRate__OpenTime_IsDropFrameRate_ForceYes), + IsDropFrameRate::ForceYes + ); + } + + #[test] + fn test_is_drop_frame_rate_into_sys_success() { + assert_eq!( + sys::OpenTime_IsDropFrameRate__OpenTime_IsDropFrameRate_InferFromRate, + IsDropFrameRate::InferFrameRate.into() + ); + assert_eq!( + sys::OpenTime_IsDropFrameRate__OpenTime_IsDropFrameRate_ForceNo, + IsDropFrameRate::ForceNo.into() + ); + assert_eq!( + sys::OpenTime_IsDropFrameRate__OpenTime_IsDropFrameRate_ForceYes, + IsDropFrameRate::ForceYes.into() + ); + } + + #[test] + fn test_rational_time_from_sys_success() { + assert_eq!( + RationalTime::from(sys::RationalTime { + value: 1.0, + rate: 1.0 + }), + RationalTime::new(1.0, 1.0) + ) + } + + #[test] + fn test_rational_time_into_sys_success() { + assert!(unsafe { + sys::RationalTime_equal( + sys::RationalTime { + value: 1.0, + rate: 1.0, + }, + RationalTime::new(1.0, 1.0).into(), + ) + }) + } + + #[test] + fn test_rational_time_is_invalid_time_success() { + assert!(!RationalTime::new(1.0, 1.0).is_invalid_time()); + assert!(RationalTime::new(1.0, 0.0).is_invalid_time()); + } + + #[test] + fn test_rational_time_rescaled_to_success() { + let old_time = RationalTime::new(1.0, 24.0); + let new_time = old_time.rescaled_to(48.0); + + assert_eq!(new_time.value, 2.0); + } + + #[test] + fn test_rational_time_rescaled_to_rational_time_success() { + let old_time = RationalTime::new(1.0, 24.0); + let new_time = old_time.rescaled_to_rational_time(RationalTime::new(1.0, 48.0)); + + assert_eq!(new_time.value, 2.0); + } + + #[test] + fn test_rational_time_value_rescaled_to_rate_success() { + let old_time = RationalTime::new(1.0, 24.0); + let new_time = old_time.value_rescaled_to_rate(48.0); + + assert_eq!(new_time, 2.0); + } + + #[test] + fn test_rational_time_value_rescaled_to_rational_time_success() { + let old_time = RationalTime::new(1.0, 24.0); + let new_time = old_time.value_rescaled_to_rational_time(RationalTime::new(1.0, 48.0)); + + assert_eq!(new_time, 2.0); + } + + #[test] + fn test_rational_time_almost_equal() { + let a = RationalTime::new(1.0, 1.0); + let b = RationalTime::new(1.0, 1.0); + + assert!(a.almost_equal(b, 0.1)); + + let a = RationalTime::new(1.0, 1.0); + let b = RationalTime::new(2.0, 1.0); + + assert!(!a.almost_equal(b, 0.1)); + } + + #[test] + fn test_rational_time_from_start_end_time_success() { + let a = RationalTime::new(1.0, 1.0); + let b = RationalTime::new(2.0, 1.0); + let result = a.duration_from_start_end_time(b); + + assert_eq!(result.value, 1.0); + } + + #[test] + fn test_rational_time_is_valid_timecode_rate() { + assert!(RationalTime::is_valid_timecode_rate(1.0)); + assert!(!RationalTime::is_valid_timecode_rate(0.0)); + } + + #[test] + fn test_rational_time_from_frames_success() { + assert_eq!( + RationalTime::new(1.0, 24.0), + RationalTime::from_frames(1.0, 24.0) + ); + } + + #[test] + fn test_rational_time_from_seconds() { + assert_eq!(RationalTime::new(1.0, 1.0), RationalTime::from_seconds(1.0)); + } + + #[test] + #[should_panic] + fn test_rational_time_from_timecode_success() { + assert_eq!( + RationalTime::from_timecode("00:00:00:01", 24.0).unwrap(), + RationalTime::new(1.0, 1.0) + ); + } + + #[test] + #[should_panic] + fn test_rational_time_from_time_string_success() { + let a = RationalTime::from_time_string("00:00:00.041667", 24.0).unwrap(); + let b = RationalTime::new(1.0, 1.0); + + assert_eq!(a, b); + } + + #[test] + fn test_rational_time_to_frames_success() { + assert_eq!(RationalTime::new(1.0, 24.0).to_frames(), 1); + } + + #[test] + fn test_rational_time_to_frames_with_rate_success() { + assert_eq!(RationalTime::new(1.0, 24.0).to_frames_with_rate(24.0), 1); + } + + #[test] + fn test_rational_time_to_seconds_success() { + assert_eq!(RationalTime::new(24.0, 24.0).to_seconds(), 1.0); + } + + #[test] + #[should_panic] + fn test_rational_time_to_timecode_success() { + assert_eq!( + &RationalTime::new(1.0, 1.0) + .to_timecode(1.0, IsDropFrameRate::ForceNo) + .unwrap(), + "00:00:00:01" + ); + } + + #[test] + #[should_panic] + fn test_rational_time_to_timecode_auto_success() { + assert_eq!( + &RationalTime::new(1.0, 1.0).to_timecode_auto().unwrap(), + "00:00:00:01" + ); + } + + #[test] + fn test_rational_time_to_time_string_success() { + assert_eq!(&RationalTime::new(1.0, 1.0).to_time_string(), "00:00:01.0"); + } + + #[test] + fn test_rational_time_add_success() { + let a = RationalTime::new(1.0, 1.0); + let b = RationalTime::new(1.0, 1.0); + + assert_eq!(a + b, RationalTime::new(2.0, 1.0)); + } + + #[test] + fn test_rational_time_subtract_success() { + let a = RationalTime::new(1.0, 1.0); + let b = RationalTime::new(1.0, 1.0); + + assert_eq!(a - b, RationalTime::new(0.0, 1.0)); + } + + #[test] + fn test_rational_time_partial_eq_success() { + let a = RationalTime::new(1.0, 1.0); + let b = RationalTime::new(1.0, 1.0); + + assert!(a == b); + + let a = RationalTime::new(1.0, 1.0); + let b = RationalTime::new(2.0, 1.0); + + assert!(a != b); + } +} diff --git a/src/copentime/errorStatus.h b/src/copentime/errorStatus.h deleted file mode 100644 index 667e667..0000000 --- a/src/copentime/errorStatus.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct OpenTimeErrorStatus OpenTimeErrorStatus; -typedef struct ErrorStatus ErrorStatus; - -typedef enum -{ - OpenTime_ErrorStatus_Outcome_OK = 0, - OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_RATE = 1, - OpenTime_ErrorStatus_Outcome_NON_DROPFRAME_RATE = 2, - OpenTime_ErrorStatus_Outcome_INVALID_TIMECODE_STRING = 3, - OpenTime_ErrorStatus_Outcome_INVALID_TIME_STRING = 4, - OpenTime_ErrorStatus_Outcome_TIMECODE_RATE_MISMATCH = 5, - OpenTime_ErrorStatus_Outcome_NEGATIVE_VALUE = 6, - OpenTime_ErrorStatus_Outcome_INVALID_RATE_FOR_DROP_FRAME_TIMECODE = 7, -} OpenTime_ErrorStatus_Outcome_; - -typedef int OpenTime_ErrorStatus_Outcome; -OTIO_API OpenTimeErrorStatus* OpenTimeErrorStatus_create(); -OTIO_API OpenTimeErrorStatus* OpenTimeErrorStatus_create_with_outcome( - OpenTime_ErrorStatus_Outcome in_outcome); -OTIO_API OpenTimeErrorStatus* OpenTimeErrorStatus_create_with_outcome_and_details( - OpenTime_ErrorStatus_Outcome in_outcome, const char* in_details); -OTIO_API const char* OpenTimeErrorStatus_outcome_to_string( - OpenTimeErrorStatus* self, OpenTime_ErrorStatus_Outcome var1); -OTIO_API void OpenTimeErrorStatus_destroy(OpenTimeErrorStatus* self); diff --git a/src/copentime/optionalOpenTime.h b/src/copentime/optionalOpenTime.h deleted file mode 100644 index 5f7cd33..0000000 --- a/src/copentime/optionalOpenTime.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include "rationalTime.h" -#include "timeRange.h" -#include "timeTransform.h" - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct { - RationalTime value; - bool valid; -} OptionalRationalTime; - -OTIO_API OptionalRationalTime OptionalRationalTime_create(RationalTime rationalTime); - -OTIO_API OptionalRationalTime OptionalRationalTime_create_null(); - -OTIO_API bool OptionalRationalTime_valid(OptionalRationalTime optionalRationalTime); - -OTIO_API RationalTime OptionalRationalTime_value(OptionalRationalTime optionalRationalTime); - -typedef struct { - TimeRange value; - bool valid; -} OptionalTimeRange; - -OTIO_API OptionalTimeRange OptionalTimeRange_create(TimeRange timeRange); - -OTIO_API OptionalTimeRange OptionalTimeRange_create_null(); - -OTIO_API bool OptionalTimeRange_valid(OptionalTimeRange optionalTimeRange); - -OTIO_API TimeRange OptionalTimeRange_value(OptionalTimeRange optionalTimeRange); diff --git a/src/copentime/rationalTime.h b/src/copentime/rationalTime.h deleted file mode 100644 index 7cd4ca2..0000000 --- a/src/copentime/rationalTime.h +++ /dev/null @@ -1,86 +0,0 @@ -#pragma once - -#include "copentime/errorStatus.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct { - double value; - double rate; -} RationalTime; - -typedef enum { - OpenTime_IsDropFrameRate_InferFromRate = -1, - OpenTime_IsDropFrameRate_ForceNo = 0, - OpenTime_IsDropFrameRate_ForceYes = 1, -} OpenTime_IsDropFrameRate_; -typedef int OpenTime_IsDropFrameRate; - -OTIO_API RationalTime RationalTime_create(double value, double rate); - -OTIO_API bool RationalTime_is_invalid_time(RationalTime self); - -OTIO_API double RationalTime_value(RationalTime self); - -OTIO_API double RationalTime_rate(RationalTime self); - -OTIO_API RationalTime RationalTime_rescaled_to(RationalTime self, double new_rate); - -OTIO_API RationalTime RationalTime_rescaled_to_rational_time( - RationalTime self, RationalTime rt); - -OTIO_API double -RationalTime_value_rescaled_to_rate(RationalTime self, double new_rate); - -OTIO_API double RationalTime_value_rescaled_to_rational_time( - RationalTime self, RationalTime rt); - -OTIO_API bool RationalTime_almost_equal( - RationalTime self, RationalTime other, double delta); - -OTIO_API RationalTime RationalTime_duration_from_start_end_time( - RationalTime start_time, RationalTime end_time_exclusive); - -OTIO_API bool RationalTime_is_valid_timecode_rate(double rate); - -OTIO_API RationalTime RationalTime_from_frames(double frame, double rate); - -OTIO_API RationalTime RationalTime_from_seconds(double seconds); - -OTIO_API RationalTime RationalTime_from_timecode( - const char *timecode, double rate, OpenTimeErrorStatus *error_status); - -OTIO_API RationalTime RationalTime_from_time_string( - const char *time_string, double rate, OpenTimeErrorStatus *error_status); - -OTIO_API int RationalTime_to_frames(RationalTime self); - -OTIO_API int RationalTime_to_frames_with_rate(RationalTime self, double rate); - -OTIO_API double RationalTime_to_seconds(RationalTime self); - -OTIO_API const char *RationalTime_to_timecode( - RationalTime self, - double rate, - OpenTime_IsDropFrameRate drop_frame, - OpenTimeErrorStatus *error_status); - -OTIO_API const char *RationalTime_to_timecode_auto( - RationalTime self, OpenTimeErrorStatus *error_status); - -OTIO_API const char *RationalTime_to_time_string(RationalTime self); - -OTIO_API RationalTime RationalTime_add(RationalTime lhs, RationalTime rhs); - -OTIO_API RationalTime RationalTime_subtract(RationalTime lhs, RationalTime rhs); - -OTIO_API RationalTime RationalTime_compare(RationalTime lhs, RationalTime rhs); - -OTIO_API bool RationalTime_equal(RationalTime lhs, RationalTime rhs); - -OTIO_API bool RationalTime_not_equal(RationalTime lhs, RationalTime rhs); diff --git a/src/copentime/timeRange.h b/src/copentime/timeRange.h deleted file mode 100644 index b02f11a..0000000 --- a/src/copentime/timeRange.h +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once - -#include "rationalTime.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct { - RationalTime start_time; - RationalTime duration; -} TimeRange; - -OTIO_API TimeRange TimeRange_create(); - -OTIO_API TimeRange TimeRange_create_with_start_time(RationalTime start_time); - -OTIO_API TimeRange TimeRange_create_with_duration(RationalTime duration); - -OTIO_API TimeRange TimeRange_create_with_start_time_and_duration( - RationalTime start_time, RationalTime duration); - -OTIO_API RationalTime TimeRange_start_time(TimeRange self); - -OTIO_API RationalTime TimeRange_duration(TimeRange self); - -OTIO_API RationalTime TimeRange_end_time_inclusive(TimeRange self); - -OTIO_API RationalTime TimeRange_end_time_exclusive(TimeRange self); - -OTIO_API TimeRange -TimeRange_duration_extended_by(TimeRange self, RationalTime other); - -OTIO_API TimeRange TimeRange_extended_by(TimeRange self, TimeRange other); - -OTIO_API RationalTime -TimeRange_clamped_with_rational_time(TimeRange self, RationalTime other); - -OTIO_API TimeRange -TimeRange_clamped_with_time_range(TimeRange self, TimeRange other); - -OTIO_API bool -TimeRange_contains_rational_time(TimeRange self, RationalTime other); - -OTIO_API bool TimeRange_contains_time_range(TimeRange self, TimeRange other); - -OTIO_API bool -TimeRange_overlaps_rational_time(TimeRange self, RationalTime other); - -OTIO_API bool TimeRange_overlaps_time_range(TimeRange self, TimeRange other); - -OTIO_API bool TimeRange_equal(TimeRange lhs, TimeRange rhs); - -OTIO_API bool TimeRange_not_equal(TimeRange lhs, TimeRange rhs); - -OTIO_API TimeRange TimeRange_range_from_start_end_time( - RationalTime start_time, RationalTime end_time_exclusive); diff --git a/src/copentime/timeTransform.h b/src/copentime/timeTransform.h deleted file mode 100644 index fd5b5ed..0000000 --- a/src/copentime/timeTransform.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include "rationalTime.h" -#include "timeRange.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct { - RationalTime offset; - double scale; - double rate; -} TimeTransform; - -OTIO_API TimeTransform TimeTransform_create(); - -OTIO_API TimeTransform -TimeTransform_create_with_offset_scale_rate(RationalTime offset, double scale, double rate); - -OTIO_API RationalTime TimeTransform_offset(TimeTransform self); - -OTIO_API double TimeTransform_scale(TimeTransform self); - -OTIO_API double TimeTransform_rate(TimeTransform self); - -OTIO_API TimeRange TimeTransform_applied_to_time_range(TimeTransform self, TimeRange other); - -OTIO_API TimeTransform -TimeTransform_applied_to_time_transform(TimeTransform self, TimeTransform other); - -OTIO_API RationalTime -TimeTransform_applied_to_rational_time(TimeTransform self, RationalTime other); - -OTIO_API bool TimeTransform_equal(TimeTransform lhs, TimeTransform rhs); - -OTIO_API bool TimeTransform_not_equal(TimeTransform lhs, TimeTransform rhs); diff --git a/src/copentime/util.h b/src/copentime/util.h deleted file mode 100644 index 959999d..0000000 --- a/src/copentime/util.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include "rationalTime.h" -#include "timeRange.h" -#include "timeTransform.h" -#include -#include -#include - -inline RationalTime CppRationalTime_to_CRationalTime(opentime::RationalTime rationalTime) { - return RationalTime_create(rationalTime.value(), rationalTime.rate()); -} - -inline opentime::RationalTime CRationalTime_to_CppRationalTime(RationalTime rationalTime) { - return opentime::RationalTime(rationalTime.value, rationalTime.rate); -} - -inline TimeRange CppTimeRange_to_CTimeRange(opentime::TimeRange timeRange) { - RationalTime startTime = CppRationalTime_to_CRationalTime(timeRange.start_time()); - RationalTime duration = CppRationalTime_to_CRationalTime(timeRange.duration()); - return TimeRange_create_with_start_time_and_duration(startTime, duration); -} - -inline opentime::TimeRange CTimeRange_to_CppTimeRange(TimeRange timeRange) { - opentime::RationalTime startTime = CRationalTime_to_CppRationalTime(timeRange.start_time); - opentime::RationalTime duration = CRationalTime_to_CppRationalTime(timeRange.duration); - return opentime::TimeRange(startTime, duration); -} - -inline TimeTransform CppTimeTransform_to_CTimeTransform(opentime::TimeTransform timeTransform) { - RationalTime offset = CppRationalTime_to_CRationalTime(timeTransform.offset()); - return TimeTransform_create_with_offset_scale_rate(offset, timeTransform.scale(), timeTransform.rate()); -} - -inline opentime::TimeTransform CTimeTransform_to_CppTimeTransform(TimeTransform timeTransform) { - opentime::RationalTime offset = CRationalTime_to_CppRationalTime(timeTransform.offset); - return opentime::TimeTransform(offset, timeTransform.scale, timeTransform.rate); -} diff --git a/src/copentimelineio/any.h b/src/copentimelineio/any.h deleted file mode 100644 index 139a60a..0000000 --- a/src/copentimelineio/any.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -struct Any; -typedef struct Any Any; - -OTIO_API void Any_destroy(Any *self); diff --git a/src/copentimelineio/anyDictionary.h b/src/copentimelineio/anyDictionary.h deleted file mode 100644 index 16ea506..0000000 --- a/src/copentimelineio/anyDictionary.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once -#include "any.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct AnyDictionaryIterator AnyDictionaryIterator; -typedef struct AnyDictionary AnyDictionary; -typedef struct AnyDictionaryMutationStamp AnyDictionaryMutationStamp; - -OTIO_API AnyDictionary* AnyDictionary_create(); -OTIO_API void AnyDictionary_destroy(AnyDictionary* self); -OTIO_API void AnyDictionary_clear(AnyDictionary* self); -OTIO_API AnyDictionaryIterator* AnyDictionary_begin(AnyDictionary* self); -OTIO_API AnyDictionaryIterator* AnyDictionary_end(AnyDictionary* self); -OTIO_API void AnyDictionary_swap(AnyDictionary* self, AnyDictionary* other); -OTIO_API AnyDictionaryIterator* - AnyDictionary_erase(AnyDictionary* self, AnyDictionaryIterator* pos); -OTIO_API AnyDictionaryIterator* AnyDictionary_erase_range( - AnyDictionary* self, - AnyDictionaryIterator* first, - AnyDictionaryIterator* last); -OTIO_API int AnyDictionary_erase_key(AnyDictionary* self, const char* key); -OTIO_API int AnyDictionary_size(AnyDictionary* self); -OTIO_API int AnyDictionary_max_size(AnyDictionary* self); -OTIO_API bool AnyDictionary_empty(AnyDictionary* self); -OTIO_API AnyDictionaryIterator* - AnyDictionary_find(AnyDictionary* self, const char* key); -OTIO_API AnyDictionaryIterator* - AnyDictionary_insert(AnyDictionary* self, const char* key, Any* anyObj); -OTIO_API void AnyDictionaryIterator_advance(AnyDictionaryIterator* iter, int dist); -OTIO_API AnyDictionaryIterator* - AnyDictionaryIterator_next(AnyDictionaryIterator* iter, int dist); -OTIO_API AnyDictionaryIterator* - AnyDictionaryIterator_prev(AnyDictionaryIterator* iter, int dist); -OTIO_API const char* AnyDictionaryIterator_key(AnyDictionaryIterator* iter); -OTIO_API Any* AnyDictionaryIterator_value(AnyDictionaryIterator* iter); -OTIO_API bool AnyDictionaryIterator_equal( - AnyDictionaryIterator* lhs, AnyDictionaryIterator* rhs); -OTIO_API bool AnyDictionaryIterator_not_equal( - AnyDictionaryIterator* lhs, AnyDictionaryIterator* rhs); -OTIO_API void AnyDictionaryIterator_destroy(AnyDictionaryIterator* self); -OTIO_API AnyDictionaryMutationStamp* - AnyDictionaryMutationStamp_create(AnyDictionary* d); -OTIO_API void AnyDictionaryMutationStamp_destroy(AnyDictionaryMutationStamp* self); -OTIO_API AnyDictionaryMutationStamp* - AnyDictionary_get_or_create_mutation_stamp(AnyDictionary* self); diff --git a/src/copentimelineio/anyVector.h b/src/copentimelineio/anyVector.h deleted file mode 100644 index a737f31..0000000 --- a/src/copentimelineio/anyVector.h +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once - -#include "any.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif -typedef struct AnyVectorIterator AnyVectorIterator; -typedef struct AnyVector AnyVector; -typedef struct AnyVectorMutationStamp AnyVectorMutationStamp; - -OTIO_API AnyVector *AnyVector_create(); - -OTIO_API void AnyVector_destroy(AnyVector *self); - -OTIO_API AnyVectorIterator *AnyVector_begin(AnyVector *self); - -OTIO_API AnyVectorIterator *AnyVector_end(AnyVector *self); - -OTIO_API int AnyVector_size(AnyVector *self); - -OTIO_API int AnyVector_max_size(AnyVector *self); - -OTIO_API int AnyVector_capacity(AnyVector *self); - -OTIO_API void AnyVector_resize(AnyVector *self, int n); - -OTIO_API bool AnyVector_empty(AnyVector *self); - -OTIO_API void AnyVector_shrink_to_fit(AnyVector *self); - -OTIO_API void AnyVector_reserve(AnyVector *self, int n); - -OTIO_API void AnyVector_swap(AnyVector *self, AnyVector *other); - -OTIO_API Any *AnyVector_at(AnyVector *self, int pos); - -OTIO_API void AnyVector_push_back(AnyVector *self, Any *value); - -OTIO_API void AnyVector_pop_back(AnyVector *self); - -OTIO_API AnyVectorIterator * -AnyVector_insert(AnyVector *self, AnyVectorIterator *pos, Any *val); - -OTIO_API void AnyVector_clear(AnyVector *self); - -OTIO_API AnyVectorIterator *AnyVector_erase(AnyVector *self, AnyVectorIterator *pos); - -OTIO_API AnyVectorIterator *AnyVector_erase_range( - AnyVector *self, AnyVectorIterator *first, AnyVectorIterator *last); - -OTIO_API void AnyVectorIterator_advance(AnyVectorIterator *iter, int dist); - -OTIO_API AnyVectorIterator * -AnyVectorIterator_next(AnyVectorIterator *iter, int dist); - -OTIO_API AnyVectorIterator * -AnyVectorIterator_prev(AnyVectorIterator *iter, int dist); - -OTIO_API Any *AnyVectorIterator_value(AnyVectorIterator *iter); - -OTIO_API bool -AnyVectorIterator_equal(AnyVectorIterator *lhs, AnyVectorIterator *rhs); - -OTIO_API bool -AnyVectorIterator_not_equal(AnyVectorIterator *lhs, AnyVectorIterator *rhs); - -OTIO_API void AnyVectorIterator_destroy(AnyVectorIterator *self); - -OTIO_API AnyVectorMutationStamp *MutationStamp_create(AnyVector *v); - -OTIO_API void MutationStamp_destroy(AnyVectorMutationStamp *self); - -OTIO_API AnyVectorMutationStamp * -AnyVector_get_or_create_mutation_stamp(AnyVector *self); diff --git a/src/copentimelineio/clip.h b/src/copentimelineio/clip.h deleted file mode 100644 index 3995d0a..0000000 --- a/src/copentimelineio/clip.h +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -#include "composition.h" -#include "copentime/timeRange.h" -#include "effectRetainerVector.h" -#include "errorStatus.h" -#include "item.h" -#include "markerRetainerVector.h" -#include "mediaReference.h" -#include "copentime/optionalOpenTime.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct Clip Clip; - -OTIO_API Clip *Clip_create( - const char *name, - MediaReference *media_reference, - OptionalTimeRange source_range, - AnyDictionary *metadata); -OTIO_API void Clip_set_media_reference(Clip *self, MediaReference *media_reference); -OTIO_API MediaReference *Clip_media_reference(Clip *self); -OTIO_API TimeRange Clip_available_range(Clip *self, OTIOErrorStatus *error_status); -OTIO_API OptionalTimeRange Clip_source_range(Clip *self); -OTIO_API void Clip_set_source_range(Clip *self, OptionalTimeRange source_range); -OTIO_API EffectRetainerVector *Clip_effects(Clip *self); -OTIO_API MarkerRetainerVector *Clip_markers(Clip *self); -OTIO_API RationalTime Clip_duration(Clip *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange Clip_trimmed_range(Clip *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange Clip_visible_range(Clip *self, OTIOErrorStatus *error_status); -OTIO_API OptionalTimeRange Clip_trimmed_range_in_parent(Clip *self, - OTIOErrorStatus *error_status); -OTIO_API TimeRange Clip_range_in_parent(Clip *self, OTIOErrorStatus *error_status); -OTIO_API RationalTime Clip_transformed_time( - Clip *self, - RationalTime time, - Item *to_item, - OTIOErrorStatus *error_status); -OTIO_API TimeRange Clip_transformed_time_range( - Clip *self, - TimeRange time_range, - Item *to_item, - OTIOErrorStatus *error_status); -OTIO_API bool Clip_visible(Clip *self); -OTIO_API bool Clip_overlapping(Clip *self); -OTIO_API Composition *Clip_parent(Clip *self); -OTIO_API const char *Clip_name(Clip *self); -OTIO_API AnyDictionary *Clip_metadata(Clip *self); -OTIO_API void Clip_set_name(Clip *self, const char *name); -OTIO_API bool Clip_to_json_file( - Clip *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); -OTIO_API const char * -Clip_to_json_string(Clip *self, OTIOErrorStatus *error_status, int indent); -OTIO_API bool Clip_is_equivalent_to(Clip *self, OTIOSerializableObject *other); -OTIO_API Clip *Clip_clone(Clip *self, OTIOErrorStatus *error_status); -OTIO_API const char *Clip_schema_name(Clip *self); -OTIO_API int Clip_schema_version(Clip *self); diff --git a/src/copentimelineio/composable.h b/src/copentimelineio/composable.h deleted file mode 100644 index d2c43d9..0000000 --- a/src/copentimelineio/composable.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -/*#include "composition.h" //importing this give an error (Composable not defined) in mapCOmposableTimeRange.h */ -#include "copentime/rationalTime.h" -#include "errorStatus.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct RetainerComposable RetainerComposable; -typedef struct Composable Composable; -struct Composition; /*A workaround for now, - * instead of including composition.h*/ -typedef struct Composition Composition; - -OTIO_API RetainerComposable *RetainerComposable_create(Composable *obj); -OTIO_API Composable *RetainerComposable_take_value(RetainerComposable *self); -OTIO_API Composable *RetainerComposable_value(RetainerComposable *self); -OTIO_API void RetainerComposable_managed_destroy(RetainerComposable *self); - -OTIO_API Composable *Composable_create(); -OTIO_API Composable *Composable_create_with_name_and_metadata( - const char *name, AnyDictionary *metadata); -OTIO_API bool Composable_visible(Composable *self); -OTIO_API bool Composable_overlapping(Composable *self); -OTIO_API Composition *Composable_parent(Composable *self); -OTIO_API RationalTime -Composable_duration(Composable *self, OTIOErrorStatus *error_status); -OTIO_API const char *Composable_name(Composable *self); -OTIO_API AnyDictionary *Composable_metadata(Composable *self); -OTIO_API void Composable_set_name(Composable *self, const char *name); -OTIO_API bool Composable_to_json_file( - Composable *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); -OTIO_API const char *Composable_to_json_string( - Composable *self, OTIOErrorStatus *error_status, int indent); -OTIO_API bool Composable_is_equivalent_to(Composable *self, OTIOSerializableObject *other); -OTIO_API Composable * -Composable_clone(Composable *self, OTIOErrorStatus *error_status); -OTIO_API const char *Composable_schema_name(Composable *self); -OTIO_API int Composable_schema_version(Composable *self); diff --git a/src/copentimelineio/composableRetainerVector.h b/src/copentimelineio/composableRetainerVector.h deleted file mode 100644 index 338deb5..0000000 --- a/src/copentimelineio/composableRetainerVector.h +++ /dev/null @@ -1,87 +0,0 @@ -#pragma once - -#include "composable.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif -typedef struct ComposableRetainerVectorIterator - ComposableRetainerVectorIterator; -typedef struct ComposableRetainerVector ComposableRetainerVector; - -OTIO_API ComposableRetainerVector *ComposableRetainerVector_create(); - -OTIO_API void ComposableRetainerVector_destroy(ComposableRetainerVector *self); - -OTIO_API ComposableRetainerVectorIterator * -ComposableRetainerVector_begin(ComposableRetainerVector *self); - -OTIO_API ComposableRetainerVectorIterator * -ComposableRetainerVector_end(ComposableRetainerVector *self); - -OTIO_API int ComposableRetainerVector_size(ComposableRetainerVector *self); - -OTIO_API int ComposableRetainerVector_max_size(ComposableRetainerVector *self); - -OTIO_API int ComposableRetainerVector_capacity(ComposableRetainerVector *self); - -OTIO_API void ComposableRetainerVector_resize(ComposableRetainerVector *self, int n); - -OTIO_API bool ComposableRetainerVector_empty(ComposableRetainerVector *self); - -OTIO_API void ComposableRetainerVector_shrink_to_fit(ComposableRetainerVector *self); - -OTIO_API void -ComposableRetainerVector_reserve(ComposableRetainerVector *self, int n); - -OTIO_API void ComposableRetainerVector_swap( - ComposableRetainerVector *self, ComposableRetainerVector *other); - -OTIO_API RetainerComposable * -ComposableRetainerVector_at(ComposableRetainerVector *self, int pos); - -OTIO_API void ComposableRetainerVector_push_back( - ComposableRetainerVector *self, RetainerComposable *value); - -OTIO_API void ComposableRetainerVector_pop_back(ComposableRetainerVector *self); - -OTIO_API ComposableRetainerVectorIterator *ComposableRetainerVector_insert( - ComposableRetainerVector *self, - ComposableRetainerVectorIterator *pos, - RetainerComposable *val); - -OTIO_API void ComposableRetainerVector_clear(ComposableRetainerVector *self); - -OTIO_API ComposableRetainerVectorIterator *ComposableRetainerVector_erase( - ComposableRetainerVector *self, ComposableRetainerVectorIterator *pos); - -OTIO_API ComposableRetainerVectorIterator *ComposableRetainerVector_erase_range( - ComposableRetainerVector *self, - ComposableRetainerVectorIterator *first, - ComposableRetainerVectorIterator *last); - -OTIO_API void ComposableRetainerVectorIterator_advance( - ComposableRetainerVectorIterator *iter, int dist); - -OTIO_API ComposableRetainerVectorIterator *ComposableRetainerVectorIterator_next( - ComposableRetainerVectorIterator *iter, int dist); - -OTIO_API ComposableRetainerVectorIterator *ComposableRetainerVectorIterator_prev( - ComposableRetainerVectorIterator *iter, int dist); - -OTIO_API RetainerComposable *ComposableRetainerVectorIterator_value( - ComposableRetainerVectorIterator *iter); - -OTIO_API bool ComposableRetainerVectorIterator_equal( - ComposableRetainerVectorIterator *lhs, - ComposableRetainerVectorIterator *rhs); - -OTIO_API bool ComposableRetainerVectorIterator_not_equal( - ComposableRetainerVectorIterator *lhs, - ComposableRetainerVectorIterator *rhs); - -OTIO_API void ComposableRetainerVectorIterator_destroy( - ComposableRetainerVectorIterator *self); diff --git a/src/copentimelineio/composableVector.h b/src/copentimelineio/composableVector.h deleted file mode 100644 index 8cbbd30..0000000 --- a/src/copentimelineio/composableVector.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include "composable.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -struct ComposableVectorIterator; -typedef struct ComposableVectorIterator ComposableVectorIterator; -struct ComposableVector; -typedef struct ComposableVector ComposableVector; - -OTIO_API ComposableVector* ComposableVector_create(); -OTIO_API void ComposableVector_destroy(ComposableVector* self); -OTIO_API ComposableVectorIterator* ComposableVector_begin(ComposableVector* self); -OTIO_API ComposableVectorIterator* ComposableVector_end(ComposableVector* self); -OTIO_API int ComposableVector_size(ComposableVector* self); -OTIO_API int ComposableVector_max_size(ComposableVector* self); -OTIO_API int ComposableVector_capacity(ComposableVector* self); -OTIO_API void ComposableVector_resize(ComposableVector* self, int n); -OTIO_API bool ComposableVector_empty(ComposableVector* self); -OTIO_API void ComposableVector_shrink_to_fit(ComposableVector* self); -OTIO_API void ComposableVector_reserve(ComposableVector* self, int n); -OTIO_API void ComposableVector_swap(ComposableVector* self, ComposableVector* other); -OTIO_API Composable* ComposableVector_at(ComposableVector* self, int pos); -OTIO_API void ComposableVector_push_back(ComposableVector* self, Composable* value); -OTIO_API void ComposableVector_pop_back(ComposableVector* self); -OTIO_API ComposableVectorIterator* ComposableVector_insert( - ComposableVector* self, ComposableVectorIterator* pos, Composable* val); -OTIO_API void ComposableVector_clear(ComposableVector* self); -OTIO_API ComposableVectorIterator* ComposableVector_erase( - ComposableVector* self, ComposableVectorIterator* pos); -OTIO_API ComposableVectorIterator* ComposableVector_erase_range( - ComposableVector* self, - ComposableVectorIterator* first, - ComposableVectorIterator* last); -OTIO_API void ComposableVectorIterator_advance(ComposableVectorIterator* iter, int dist); -OTIO_API ComposableVectorIterator* - ComposableVectorIterator_next(ComposableVectorIterator* iter, int dist); -OTIO_API ComposableVectorIterator* - ComposableVectorIterator_prev(ComposableVectorIterator* iter, int dist); -OTIO_API Composable* ComposableVectorIterator_value(ComposableVectorIterator* iter); -OTIO_API bool ComposableVectorIterator_equal( - ComposableVectorIterator* lhs, ComposableVectorIterator* rhs); -OTIO_API bool ComposableVectorIterator_not_equal( - ComposableVectorIterator* lhs, ComposableVectorIterator* rhs); -OTIO_API void ComposableVectorIterator_destroy(ComposableVectorIterator* self); diff --git a/src/copentimelineio/composition.h b/src/copentimelineio/composition.h deleted file mode 100644 index eb2078b..0000000 --- a/src/copentimelineio/composition.h +++ /dev/null @@ -1,119 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -#include "composable.h" -#include "composableRetainerVector.h" -#include "composableVector.h" -#include "copentime/timeRange.h" -#include "effectRetainerVector.h" -#include "effectVector.h" -#include "errorStatus.h" -#include "item.h" -#include "mapComposableTimeRange.h" -#include "markerRetainerVector.h" -#include "markerVector.h" -#include "optionalPairRationalTime.h" -#include "copentime/optionalOpenTime.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct Composition Composition; -typedef struct Item Item; - -OTIO_API Composition *Composition_create( - const char *name, - OptionalTimeRange source_range, - AnyDictionary *metadata, - EffectVector *effects, - MarkerVector *markers); -OTIO_API const char *Composition_composition_kind(Composition *self); -OTIO_API ComposableRetainerVector *Composition_children(Composition *self); -OTIO_API void Composition_clear_children(Composition *self); -OTIO_API bool Composition_set_children( - Composition *self, - ComposableVector *children, - OTIOErrorStatus *error_status); -OTIO_API bool Composition_insert_child( - Composition *self, - int index, - Composable *child, - OTIOErrorStatus *error_status); -OTIO_API bool Composition_set_child( - Composition *self, - int index, - Composable *child, - OTIOErrorStatus *error_status); -OTIO_API bool Composition_remove_child( - Composition *self, int index, OTIOErrorStatus *error_status); -OTIO_API bool Composition_append_child( - Composition *self, Composable *child, OTIOErrorStatus *error_status); -OTIO_API bool Composition_is_parent_of(Composition *self, Composable *other); -OTIO_API OptionalPairRationalTime *Composition_handles_of_child( - Composition *self, Composable *child, OTIOErrorStatus *error_status); -OTIO_API TimeRange Composition_range_of_child_at_index( - Composition *self, int index, OTIOErrorStatus *error_status); -OTIO_API TimeRange Composition_trimmed_range_of_child_at_index( - Composition *self, int index, OTIOErrorStatus *error_status); -OTIO_API TimeRange Composition_range_of_child( - Composition *self, Composable *child, OTIOErrorStatus *error_status); -OTIO_API OptionalTimeRange Composition_trimmed_range_of_child( - Composition *self, - Composable *child, - OTIOErrorStatus *error_status); -OTIO_API OptionalTimeRange Composition_trim_child_range(Composition *self, - TimeRange child_range); -OTIO_API bool Composition_has_child(Composition *self, Composable *child); - -OTIO_API MapComposableTimeRange *Composition_range_of_all_children( - Composition *self, OTIOErrorStatus *error_status); - -OTIO_API bool Composition_visible(Composition *self); -OTIO_API bool Composition_overlapping(Composition *self); -OTIO_API OptionalTimeRange Composition_source_range(Composition *self); -OTIO_API void Composition_set_source_range(Composition *self, OptionalTimeRange source_range); -OTIO_API EffectRetainerVector *Composition_effects(Composition *self); -OTIO_API MarkerRetainerVector *Composition_markers(Composition *self); -OTIO_API RationalTime -Composition_duration(Composition *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange Composition_available_range( - Composition *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange -Composition_trimmed_range(Composition *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange -Composition_visible_range(Composition *self, OTIOErrorStatus *error_status); -OTIO_API OptionalTimeRange Composition_trimmed_range_in_parent( - Composition *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange Composition_range_in_parent( - Composition *self, OTIOErrorStatus *error_status); -OTIO_API RationalTime Composition_transformed_time( - Composition *self, - RationalTime time, - Item *to_item, - OTIOErrorStatus *error_status); -OTIO_API TimeRange Composition_transformed_time_range( - Composition *self, - TimeRange time_range, - Item *to_item, - OTIOErrorStatus *error_status); -OTIO_API Composition *Composition_parent(Composition *self); -OTIO_API const char *Composition_name(Composition *self); -OTIO_API AnyDictionary *Composition_metadata(Composition *self); -OTIO_API void Composition_set_name(Composition *self, const char *name); -OTIO_API bool Composition_to_json_file( - Composition *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); -OTIO_API const char *Composition_to_json_string( - Composition *self, OTIOErrorStatus *error_status, int indent); -OTIO_API bool -Composition_is_equivalent_to(Composition *self, OTIOSerializableObject *other); -OTIO_API Composition * -Composition_clone(Composition *self, OTIOErrorStatus *error_status); -OTIO_API const char *Composition_schema_name(Composition *self); -OTIO_API int Composition_schema_version(Composition *self); diff --git a/src/copentimelineio/deserialization.h b/src/copentimelineio/deserialization.h deleted file mode 100644 index cf91915..0000000 --- a/src/copentimelineio/deserialization.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "any.h" -#include "errorStatus.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -OTIO_API bool deserialize_json_from_string( - const char *input, Any *destination, OTIOErrorStatus *error_status); - -OTIO_API bool deserialize_json_from_file( - const char *file_name, Any *destination, OTIOErrorStatus *error_status); diff --git a/src/copentimelineio/effect.h b/src/copentimelineio/effect.h deleted file mode 100644 index fa81cc8..0000000 --- a/src/copentimelineio/effect.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -#include "serializableObject.h" - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct RetainerEffect RetainerEffect; -typedef struct Effect Effect; - -OTIO_API RetainerEffect *RetainerEffect_create(Effect *obj); - -OTIO_API Effect *RetainerEffect_take_value(RetainerEffect *self); - -OTIO_API Effect *RetainerEffect_value(RetainerEffect *self); - -OTIO_API void RetainerEffect_managed_destroy(RetainerEffect *self); - -OTIO_API Effect *Effect_create( - const char *name, const char *effect_name, AnyDictionary *metadata); - -OTIO_API const char *Effect_effect_name(Effect *self); - -OTIO_API void Effect_set_effect_name(Effect *self, const char *effect_name); - -OTIO_API const char *Effect_name(Effect *self); - -OTIO_API void Effect_set_name(Effect *self, const char *name); - -OTIO_API AnyDictionary *Effect_metadata(Effect *self); - -OTIO_API bool Effect_to_json_file( - Effect *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); - -OTIO_API const char *Effect_to_json_string( - Effect *self, OTIOErrorStatus *error_status, int indent); - -OTIO_API bool Effect_is_equivalent_to(Effect *self, OTIOSerializableObject *other); - -OTIO_API Effect *Effect_clone(Effect *self, OTIOErrorStatus *error_status); - -OTIO_API const char *Effect_schema_name(Effect *self); - -OTIO_API int Effect_schema_version(Effect *self); diff --git a/src/copentimelineio/effectRetainerVector.h b/src/copentimelineio/effectRetainerVector.h deleted file mode 100644 index 833263d..0000000 --- a/src/copentimelineio/effectRetainerVector.h +++ /dev/null @@ -1,84 +0,0 @@ -#pragma once - -#include "effect.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct EffectRetainerVectorIterator EffectRetainerVectorIterator; -typedef struct EffectRetainerVector EffectRetainerVector; - -OTIO_API EffectRetainerVector *EffectRetainerVector_create(); - -OTIO_API void EffectRetainerVector_destroy(EffectRetainerVector *self); - -OTIO_API EffectRetainerVectorIterator * -EffectRetainerVector_begin(EffectRetainerVector *self); - -OTIO_API EffectRetainerVectorIterator * -EffectRetainerVector_end(EffectRetainerVector *self); - -OTIO_API int EffectRetainerVector_size(EffectRetainerVector *self); - -OTIO_API int EffectRetainerVector_max_size(EffectRetainerVector *self); - -OTIO_API int EffectRetainerVector_capacity(EffectRetainerVector *self); - -OTIO_API void EffectRetainerVector_resize(EffectRetainerVector *self, int n); - -OTIO_API bool EffectRetainerVector_empty(EffectRetainerVector *self); - -OTIO_API void EffectRetainerVector_shrink_to_fit(EffectRetainerVector *self); - -OTIO_API void EffectRetainerVector_reserve(EffectRetainerVector *self, int n); - -OTIO_API void EffectRetainerVector_swap( - EffectRetainerVector *self, EffectRetainerVector *other); - -OTIO_API RetainerEffect * -EffectRetainerVector_at(EffectRetainerVector *self, int pos); - -OTIO_API void EffectRetainerVector_push_back( - EffectRetainerVector *self, RetainerEffect *value); - -OTIO_API void EffectRetainerVector_pop_back(EffectRetainerVector *self); - -OTIO_API EffectRetainerVectorIterator *EffectRetainerVector_insert( - EffectRetainerVector *self, - EffectRetainerVectorIterator *pos, - RetainerEffect *val); - -OTIO_API void EffectRetainerVector_clear(EffectRetainerVector *self); - -OTIO_API EffectRetainerVectorIterator *EffectRetainerVector_erase( - EffectRetainerVector *self, EffectRetainerVectorIterator *pos); - -OTIO_API EffectRetainerVectorIterator *EffectRetainerVector_erase_range( - EffectRetainerVector *self, - EffectRetainerVectorIterator *first, - EffectRetainerVectorIterator *last); - -OTIO_API void EffectRetainerVectorIterator_advance( - EffectRetainerVectorIterator *iter, int dist); - -OTIO_API EffectRetainerVectorIterator *EffectRetainerVectorIterator_next( - EffectRetainerVectorIterator *iter, int dist); - -OTIO_API EffectRetainerVectorIterator *EffectRetainerVectorIterator_prev( - EffectRetainerVectorIterator *iter, int dist); - -OTIO_API RetainerEffect * -EffectRetainerVectorIterator_value(EffectRetainerVectorIterator *iter); - -OTIO_API bool EffectRetainerVectorIterator_equal( - EffectRetainerVectorIterator *lhs, EffectRetainerVectorIterator *rhs); - -OTIO_API bool EffectRetainerVectorIterator_not_equal( - EffectRetainerVectorIterator *lhs, EffectRetainerVectorIterator *rhs); - -OTIO_API void -EffectRetainerVectorIterator_destroy(EffectRetainerVectorIterator *self); diff --git a/src/copentimelineio/effectVector.h b/src/copentimelineio/effectVector.h deleted file mode 100644 index 6965a62..0000000 --- a/src/copentimelineio/effectVector.h +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once - -#include "effect.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif -typedef struct EffectVectorIterator EffectVectorIterator; -typedef struct EffectVector EffectVector; - -OTIO_API EffectVector *EffectVector_create(); - -OTIO_API void EffectVector_destroy(EffectVector *self); - -OTIO_API EffectVectorIterator *EffectVector_begin(EffectVector *self); - -OTIO_API EffectVectorIterator *EffectVector_end(EffectVector *self); - -OTIO_API int EffectVector_size(EffectVector *self); - -OTIO_API int EffectVector_max_size(EffectVector *self); - -OTIO_API int EffectVector_capacity(EffectVector *self); - -OTIO_API void EffectVector_resize(EffectVector *self, int n); - -OTIO_API bool EffectVector_empty(EffectVector *self); - -OTIO_API void EffectVector_shrink_to_fit(EffectVector *self); - -OTIO_API void EffectVector_reserve(EffectVector *self, int n); - -OTIO_API void EffectVector_swap(EffectVector *self, EffectVector *other); - -OTIO_API Effect *EffectVector_at(EffectVector *self, int pos); - -OTIO_API void EffectVector_push_back(EffectVector *self, Effect *value); - -OTIO_API void EffectVector_pop_back(EffectVector *self); - -OTIO_API EffectVectorIterator *EffectVector_insert( - EffectVector *self, EffectVectorIterator *pos, Effect *val); - -OTIO_API void EffectVector_clear(EffectVector *self); - -OTIO_API EffectVectorIterator * -EffectVector_erase(EffectVector *self, EffectVectorIterator *pos); - -OTIO_API EffectVectorIterator *EffectVector_erase_range( - EffectVector *self, - EffectVectorIterator *first, - EffectVectorIterator *last); - -OTIO_API void EffectVectorIterator_advance(EffectVectorIterator *iter, int dist); - -OTIO_API EffectVectorIterator * -EffectVectorIterator_next(EffectVectorIterator *iter, int dist); - -OTIO_API EffectVectorIterator * -EffectVectorIterator_prev(EffectVectorIterator *iter, int dist); - -OTIO_API Effect *EffectVectorIterator_value(EffectVectorIterator *iter); - -OTIO_API bool EffectVectorIterator_equal( - EffectVectorIterator *lhs, EffectVectorIterator *rhs); - -OTIO_API bool EffectVectorIterator_not_equal( - EffectVectorIterator *lhs, EffectVectorIterator *rhs); - -OTIO_API void EffectVectorIterator_destroy(EffectVectorIterator *self); diff --git a/src/copentimelineio/errorStatus.h b/src/copentimelineio/errorStatus.h deleted file mode 100644 index 59a902f..0000000 --- a/src/copentimelineio/errorStatus.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#include "serializableObject.h" - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -struct OTIOErrorStatus; -typedef struct OTIOErrorStatus OTIOErrorStatus; -typedef struct OTIOSerializableObject OTIOSerializableObject; - -typedef enum -{ - OTIO_ErrorStatus_Outcome_OK = 0, - OTIO_ErrorStatus_Outcome_NOT_IMPLEMENTED = 1, - OTIO_ErrorStatus_Outcome_UNRESOLVED_OBJECT_REFERENCE = 2, - OTIO_ErrorStatus_Outcome_DUPLICATE_OBJECT_REFERENCE = 3, - OTIO_ErrorStatus_Outcome_MALFORMED_SCHEMA = 4, - OTIO_ErrorStatus_Outcome_JSON_PARSE_ERROR = 5, - OTIO_ErrorStatus_Outcome_CHILD_ALREADY_PARENTED = 6, - OTIO_ErrorStatus_Outcome_FILE_OPEN_FAILED = 7, - OTIO_ErrorStatus_Outcome_FILE_WRITE_FAILED = 8, - OTIO_ErrorStatus_Outcome_SCHEMA_ALREADY_REGISTERED = 9, - OTIO_ErrorStatus_Outcome_SCHEMA_NOT_REGISTERED = 10, - OTIO_ErrorStatus_Outcome_SCHEMA_VERSION_UNSUPPORTED = 11, - OTIO_ErrorStatus_Outcome_KEY_NOT_FOUND = 12, - OTIO_ErrorStatus_Outcome_ILLEGAL_INDEX = 13, - OTIO_ErrorStatus_Outcome_TYPE_MISMATCH = 14, - OTIO_ErrorStatus_Outcome_INTERNAL_ERROR = 15, - OTIO_ErrorStatus_Outcome_NOT_AN_ITEM = 16, - OTIO_ErrorStatus_Outcome_NOT_A_CHILD_OF = 17, - OTIO_ErrorStatus_Outcome_NOT_A_CHILD = 18, - OTIO_ErrorStatus_Outcome_NOT_DESCENDED_FROM = 19, - OTIO_ErrorStatus_Outcome_CANNOT_COMPUTE_AVAILABLE_RANGE = 20, - OTIO_ErrorStatus_Outcome_INVALID_TIME_RANGE = 21, - OTIO_ErrorStatus_Outcome_OBJECT_WITHOUT_DURATION = 22, - OTIO_ErrorStatus_Outcome_CANNOT_TRIM_TRANSITION = 23, -} OTIO_ErrorStatus_Outcome_; - -typedef int OTIO_ErrorStatus_Outcome; -OTIO_API OTIOErrorStatus* OTIOErrorStatus_create(); -OTIO_API OTIOErrorStatus* OTIOErrorStatus_create_with_outcome(OTIO_ErrorStatus_Outcome in_outcome); -OTIO_API OTIOErrorStatus* OTIOErrorStatus_create_with_outcome_details_serializable_object( - OTIO_ErrorStatus_Outcome in_outcome, - const char* in_details, - OTIOSerializableObject* object); - -OTIO_API const char* OTIOErrorStatus_outcome_to_string(OTIO_ErrorStatus_Outcome var1); -OTIO_API OTIO_ErrorStatus_Outcome OTIOErrorStatus_get_outcome(OTIOErrorStatus* self); -OTIO_API void OTIOErrorStatus_destroy(OTIOErrorStatus* self); diff --git a/src/copentimelineio/externalReference.h b/src/copentimelineio/externalReference.h deleted file mode 100644 index bdbb21b..0000000 --- a/src/copentimelineio/externalReference.h +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once - -#include "copentime/timeRange.h" -#include "copentime/optionalOpenTime.h" -#include "anyDictionary.h" -#include "errorStatus.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct ExternalReference ExternalReference; - -OTIO_API ExternalReference *ExternalReference_create( - const char *target_url, - OptionalTimeRange available_range, - AnyDictionary *metadata); - -OTIO_API const char *ExternalReference_target_url(ExternalReference *self); - -OTIO_API void ExternalReference_set_target_url( - ExternalReference *self, const char *target_url); - -OTIO_API OptionalTimeRange ExternalReference_available_range(ExternalReference *self); - -OTIO_API void ExternalReference_set_available_range( - ExternalReference *self, OptionalTimeRange available_range); - -OTIO_API bool ExternalReference_is_missing_reference(ExternalReference *self); - -OTIO_API const char *ExternalReference_name(ExternalReference *self); - -OTIO_API void ExternalReference_set_name(ExternalReference *self, const char *name); - -OTIO_API AnyDictionary *ExternalReference_metadata(ExternalReference *self); - -OTIO_API bool ExternalReference_to_json_file( - ExternalReference *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); - -OTIO_API const char *ExternalReference_to_json_string( - ExternalReference *self, OTIOErrorStatus *error_status, int indent); - -OTIO_API bool ExternalReference_is_equivalent_to( - ExternalReference *self, OTIOSerializableObject *other); - -OTIO_API ExternalReference *ExternalReference_clone( - ExternalReference *self, OTIOErrorStatus *error_status); - -OTIO_API const char *ExternalReference_schema_name(ExternalReference *self); - -OTIO_API int ExternalReference_schema_version(ExternalReference *self); diff --git a/src/copentimelineio/freezeFrame.h b/src/copentimelineio/freezeFrame.h deleted file mode 100644 index 29e0357..0000000 --- a/src/copentimelineio/freezeFrame.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -#include "errorStatus.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct FreezeFrame FreezeFrame; - -OTIO_API FreezeFrame *FreezeFrame_create(const char *name, AnyDictionary *metadata); - -OTIO_API double FreezeFrame_time_scalar(FreezeFrame *self); - -OTIO_API void FreezeFrame_set_time_scalar(FreezeFrame *self, double time_scalar); - -OTIO_API const char *FreezeFrame_effect_name(FreezeFrame *self); - -OTIO_API void -FreezeFrame_set_effect_name(FreezeFrame *self, const char *effect_name); - -OTIO_API const char *FreezeFrame_name(FreezeFrame *self); - -OTIO_API void FreezeFrame_set_name(FreezeFrame *self, const char *name); - -OTIO_API AnyDictionary *FreezeFrame_metadata(FreezeFrame *self); - -OTIO_API bool FreezeFrame_to_json_file( - FreezeFrame *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); - -OTIO_API const char *FreezeFrame_to_json_string( - FreezeFrame *self, OTIOErrorStatus *error_status, int indent); - -OTIO_API bool -FreezeFrame_is_equivalent_to(FreezeFrame *self, OTIOSerializableObject *other); - -OTIO_API FreezeFrame * -FreezeFrame_clone(FreezeFrame *self, OTIOErrorStatus *error_status); - -OTIO_API const char *FreezeFrame_schema_name(FreezeFrame *self); - -OTIO_API int FreezeFrame_schema_version(FreezeFrame *self); diff --git a/src/copentimelineio/gap.h b/src/copentimelineio/gap.h deleted file mode 100644 index fdb9566..0000000 --- a/src/copentimelineio/gap.h +++ /dev/null @@ -1,96 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -#include "composition.h" -#include "copentime/rationalTime.h" -#include "copentime/timeRange.h" -#include "effectRetainerVector.h" -#include "effectVector.h" -#include "item.h" -#include "markerRetainerVector.h" -#include "markerVector.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct Gap Gap; - -OTIO_API Gap *Gap_create_with_source_range( - OptionalTimeRange source_range, - const char *name, - EffectVector *effects, - MarkerVector *markers, - AnyDictionary *metadata); - -OTIO_API Gap *Gap_create_with_duration( - OptionalRationalTime duration, - const char *name, - EffectVector *effects, - MarkerVector *markers, - AnyDictionary *metadata); - -OTIO_API bool Gap_visible(Gap *self); - -OTIO_API bool Gap_overlapping(Gap *self); - -OTIO_API OptionalTimeRange Gap_source_range(Gap *self); - -OTIO_API void Gap_set_source_range(Gap *self, OptionalTimeRange source_range); - -OTIO_API EffectRetainerVector *Gap_effects(Gap *self); - -OTIO_API MarkerRetainerVector *Gap_markers(Gap *self); - -OTIO_API RationalTime Gap_duration(Gap *self, OTIOErrorStatus *error_status); - -OTIO_API TimeRange Gap_available_range(Gap *self, OTIOErrorStatus *error_status); - -OTIO_API TimeRange Gap_trimmed_range(Gap *self, OTIOErrorStatus *error_status); - -OTIO_API TimeRange Gap_visible_range(Gap *self, OTIOErrorStatus *error_status); - -OTIO_API OptionalTimeRange Gap_trimmed_range_in_parent(Gap *self, - OTIOErrorStatus *error_status); - -OTIO_API TimeRange Gap_range_in_parent(Gap *self, OTIOErrorStatus *error_status); - -OTIO_API RationalTime Gap_transformed_time( - Gap *self, - RationalTime time, - Item *to_item, - OTIOErrorStatus *error_status); - -OTIO_API TimeRange Gap_transformed_time_range( - Gap *self, - TimeRange time_range, - Item *to_item, - OTIOErrorStatus *error_status); - -OTIO_API Composition *Gap_parent(Gap *self); - -OTIO_API const char *Gap_name(Gap *self); - -OTIO_API AnyDictionary *Gap_metadata(Gap *self); - -OTIO_API void Gap_set_name(Gap *self, const char *name); - -OTIO_API bool Gap_to_json_file( - Gap *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); - -OTIO_API const char * -Gap_to_json_string(Gap *self, OTIOErrorStatus *error_status, int indent); - -OTIO_API bool Gap_is_equivalent_to(Gap *self, OTIOSerializableObject *other); - -OTIO_API Gap *Gap_clone(Gap *self, OTIOErrorStatus *error_status); - -OTIO_API const char *Gap_schema_name(Gap *self); - -OTIO_API int Gap_schema_version(Gap *self); diff --git a/src/copentimelineio/generatorReference.h b/src/copentimelineio/generatorReference.h deleted file mode 100644 index c75e71e..0000000 --- a/src/copentimelineio/generatorReference.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include "copentime/timeRange.h" -#include "copentime/optionalOpenTime.h" -#include "anyDictionary.h" -#include "errorStatus.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct GeneratorReference GeneratorReference; - -OTIO_API GeneratorReference *GeneratorReference_create( - const char *name, - const char *generator_kind, - OptionalTimeRange available_range, - AnyDictionary *parameters, - AnyDictionary *metadata); -OTIO_API const char *GeneratorReference_generator_kind(GeneratorReference *self); -OTIO_API void GeneratorReference_set_generator_kind( - GeneratorReference *self, const char *generator_kind); -OTIO_API AnyDictionary *GeneratorReference_parameters(GeneratorReference *self); -OTIO_API OptionalTimeRange GeneratorReference_available_range(GeneratorReference *self); -OTIO_API void GeneratorReference_set_available_range( - GeneratorReference *self, OptionalTimeRange available_range); -OTIO_API bool GeneratorReference_is_missing_reference(GeneratorReference *self); -OTIO_API const char *GeneratorReference_name(GeneratorReference *self); -OTIO_API void -GeneratorReference_set_name(GeneratorReference *self, const char *name); -OTIO_API AnyDictionary *GeneratorReference_metadata(GeneratorReference *self); -OTIO_API bool GeneratorReference_to_json_file( - GeneratorReference *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); -OTIO_API const char *GeneratorReference_to_json_string( - GeneratorReference *self, OTIOErrorStatus *error_status, int indent); -OTIO_API bool GeneratorReference_is_equivalent_to( - GeneratorReference *self, OTIOSerializableObject *other); -OTIO_API GeneratorReference *GeneratorReference_clone( - GeneratorReference *self, OTIOErrorStatus *error_status); -OTIO_API const char *GeneratorReference_schema_name(GeneratorReference *self); -OTIO_API int GeneratorReference_schema_version(GeneratorReference *self); diff --git a/src/copentimelineio/item.h b/src/copentimelineio/item.h deleted file mode 100644 index 5fda432..0000000 --- a/src/copentimelineio/item.h +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -#include "composition.h" -#include "copentime/rationalTime.h" -#include "copentime/timeRange.h" -#include "copentime/optionalOpenTime.h" -#include "effectRetainerVector.h" -#include "effectVector.h" -#include "errorStatus.h" -#include "markerRetainerVector.h" -#include "markerVector.h" - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct Item Item; -typedef struct Effect Effect; -typedef struct Marker Marker; - -OTIO_API Item * -Item_create( - const char *name, - OptionalTimeRange source_range, - AnyDictionary *metadata, - EffectVector *effects, - MarkerVector *markers); -OTIO_API bool Item_visible(Item *self); -OTIO_API bool Item_overlapping(Item *self); -OTIO_API OptionalTimeRange Item_source_range(Item *self); -OTIO_API void Item_set_source_range(Item *self, OptionalTimeRange source_range); -OTIO_API EffectRetainerVector *Item_effects(Item *self); -OTIO_API MarkerRetainerVector *Item_markers(Item *self); -OTIO_API RationalTime Item_duration(Item *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange Item_available_range(Item *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange Item_trimmed_range(Item *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange Item_visible_range(Item *self, OTIOErrorStatus *error_status); -OTIO_API OptionalTimeRange Item_trimmed_range_in_parent(Item *self, - OTIOErrorStatus *error_status); -OTIO_API TimeRange Item_range_in_parent(Item *self, OTIOErrorStatus *error_status); -OTIO_API RationalTime Item_transformed_time( - Item *self, - RationalTime time, - Item *to_item, - OTIOErrorStatus *error_status); -OTIO_API TimeRange Item_transformed_time_range( - Item *self, - TimeRange time_range, - Item *to_item, - OTIOErrorStatus *error_status); -OTIO_API Composition *Item_parent(Item *self); -OTIO_API const char *Item_name(Item *self); -OTIO_API AnyDictionary *Item_metadata(Item *self); -OTIO_API void Item_set_name(Item *self, const char *name); -OTIO_API bool Item_to_json_file( - Item *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); -OTIO_API const char * -Item_to_json_string(Item *self, OTIOErrorStatus *error_status, int indent); -OTIO_API bool Item_is_equivalent_to(Item *self, OTIOSerializableObject *other); -OTIO_API Item *Item_clone(Item *self, OTIOErrorStatus *error_status); -OTIO_API const char *Item_schema_name(Item *self); -OTIO_API int Item_schema_version(Item *self); diff --git a/src/copentimelineio/linearTimeWarp.h b/src/copentimelineio/linearTimeWarp.h deleted file mode 100644 index 76bd4eb..0000000 --- a/src/copentimelineio/linearTimeWarp.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -#include "errorStatus.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct LinearTimeWarp LinearTimeWarp; - -OTIO_API LinearTimeWarp *LinearTimeWarp_create( - const char *name, - const char *effect_name, - double time_scalar, - AnyDictionary *metadata); - -OTIO_API double LinearTimeWarp_time_scalar(LinearTimeWarp *self); - -OTIO_API void -LinearTimeWarp_set_time_scalar(LinearTimeWarp *self, double time_scalar); - -OTIO_API const char *LinearTimeWarp_effect_name(LinearTimeWarp *self); - -OTIO_API void LinearTimeWarp_set_effect_name( - LinearTimeWarp *self, const char *effect_name); - -OTIO_API const char *LinearTimeWarp_name(LinearTimeWarp *self); - -OTIO_API void LinearTimeWarp_set_name(LinearTimeWarp *self, const char *name); - -OTIO_API AnyDictionary *LinearTimeWarp_metadata(LinearTimeWarp *self); - -OTIO_API bool LinearTimeWarp_to_json_file( - LinearTimeWarp *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); - -OTIO_API const char *LinearTimeWarp_to_json_string( - LinearTimeWarp *self, OTIOErrorStatus *error_status, int indent); - -OTIO_API bool LinearTimeWarp_is_equivalent_to( - LinearTimeWarp *self, OTIOSerializableObject *other); - -OTIO_API LinearTimeWarp * -LinearTimeWarp_clone(LinearTimeWarp *self, OTIOErrorStatus *error_status); - -OTIO_API const char *LinearTimeWarp_schema_name(LinearTimeWarp *self); - -OTIO_API int LinearTimeWarp_schema_version(LinearTimeWarp *self); diff --git a/src/copentimelineio/mapComposableTimeRange.h b/src/copentimelineio/mapComposableTimeRange.h deleted file mode 100644 index e2f6b92..0000000 --- a/src/copentimelineio/mapComposableTimeRange.h +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once - -#include "composable.h" -#include "copentime/timeRange.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -struct MapComposableTimeRangeIterator; -typedef struct MapComposableTimeRangeIterator - MapComposableTimeRangeIterator; -struct MapComposableTimeRange; -typedef struct MapComposableTimeRange MapComposableTimeRange; - -OTIO_API MapComposableTimeRange *MapComposableTimeRange_create(); - -OTIO_API void MapComposableTimeRange_destroy(MapComposableTimeRange *self); - -OTIO_API void MapComposableTimeRange_clear(MapComposableTimeRange *self); - -OTIO_API MapComposableTimeRangeIterator * -MapComposableTimeRange_begin(MapComposableTimeRange *self); - -OTIO_API MapComposableTimeRangeIterator * -MapComposableTimeRange_end(MapComposableTimeRange *self); - -OTIO_API void MapComposableTimeRange_swap( - MapComposableTimeRange *self, MapComposableTimeRange *other); - -OTIO_API MapComposableTimeRangeIterator *MapComposableTimeRange_erase( - MapComposableTimeRange *self, MapComposableTimeRangeIterator *pos); - -OTIO_API MapComposableTimeRangeIterator *MapComposableTimeRange_erase_range( - MapComposableTimeRange *self, - MapComposableTimeRangeIterator *first, - MapComposableTimeRangeIterator *last); - -OTIO_API int MapComposableTimeRange_erase_key( - MapComposableTimeRange *self, Composable *key); - -OTIO_API int MapComposableTimeRange_size(MapComposableTimeRange *self); - -OTIO_API int MapComposableTimeRange_max_size(MapComposableTimeRange *self); - -OTIO_API bool MapComposableTimeRange_empty(MapComposableTimeRange *self); - -OTIO_API MapComposableTimeRangeIterator * -MapComposableTimeRange_find(MapComposableTimeRange *self, Composable *key); - -OTIO_API MapComposableTimeRangeIterator *MapComposableTimeRange_insert( - MapComposableTimeRange *self, Composable *key, TimeRange anyObj); - -OTIO_API void MapComposableTimeRangeIterator_advance( - MapComposableTimeRangeIterator *iter, int dist); - -OTIO_API MapComposableTimeRangeIterator *MapComposableTimeRangeIterator_next( - MapComposableTimeRangeIterator *iter, int dist); - -OTIO_API MapComposableTimeRangeIterator *MapComposableTimeRangeIterator_prev( - MapComposableTimeRangeIterator *iter, int dist); - -OTIO_API TimeRange -MapComposableTimeRangeIterator_value(MapComposableTimeRangeIterator *iter); - -OTIO_API bool MapComposableTimeRangeIterator_equal( - MapComposableTimeRangeIterator *lhs, - MapComposableTimeRangeIterator *rhs); - -OTIO_API bool MapComposableTimeRangeIterator_not_equal( - MapComposableTimeRangeIterator *lhs, - MapComposableTimeRangeIterator *rhs); - -OTIO_API void MapComposableTimeRangeIterator_destroy( - MapComposableTimeRangeIterator *self); diff --git a/src/copentimelineio/marker.h b/src/copentimelineio/marker.h deleted file mode 100644 index abb6a00..0000000 --- a/src/copentimelineio/marker.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include "copentime/timeRange.h" -#include "copentime/optionalOpenTime.h" -#include "anyDictionary.h" -#include "errorStatus.h" - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -OTIO_API const char *MarkerColor_pink; -OTIO_API const char *MarkerColor_red; -OTIO_API const char *MarkerColor_orange; -OTIO_API const char *MarkerColor_yellow; -OTIO_API const char *MarkerColor_green; -OTIO_API const char *MarkerColor_cyan; -OTIO_API const char *MarkerColor_blue; -OTIO_API const char *MarkerColor_purple; -OTIO_API const char *MarkerColor_magenta; -OTIO_API const char *MarkerColor_black; -OTIO_API const char *MarkerColor_white; -typedef struct RetainerMarker RetainerMarker; -typedef struct Marker Marker; - -OTIO_API RetainerMarker *RetainerMarker_create(Marker *obj); -OTIO_API Marker *RetainerMarker_take_value(RetainerMarker *self); -OTIO_API Marker *RetainerMarker_value(RetainerMarker *self); -OTIO_API void RetainerMarker_managed_destroy(RetainerMarker *self); - -OTIO_API Marker *Marker_create( - const char *name, - OptionalTimeRange marked_range, - const char *color, - AnyDictionary *metadata); -OTIO_API const char *Marker_color(Marker *self); -OTIO_API void Marker_set_color(Marker *self, const char *color); -OTIO_API TimeRange Marker_marked_range(Marker *self); -OTIO_API void Marker_set_marked_range(Marker *self, TimeRange marked_range); -OTIO_API const char *Marker_name(Marker *self); -OTIO_API void Marker_set_name(Marker *self, const char *name); -OTIO_API AnyDictionary *Marker_metadata(Marker *self); -OTIO_API bool Marker_to_json_file( - Marker *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); -OTIO_API const char *Marker_to_json_string( - Marker *self, OTIOErrorStatus *error_status, int indent); -OTIO_API bool Marker_is_equivalent_to(Marker *self, OTIOSerializableObject *other); -OTIO_API Marker *Marker_clone(Marker *self, OTIOErrorStatus *error_status); -OTIO_API const char *Marker_schema_name(Marker *self); -OTIO_API int Marker_schema_version(Marker *self); diff --git a/src/copentimelineio/markerRetainerVector.h b/src/copentimelineio/markerRetainerVector.h deleted file mode 100644 index 77f2d8b..0000000 --- a/src/copentimelineio/markerRetainerVector.h +++ /dev/null @@ -1,83 +0,0 @@ -#pragma once - -#include "marker.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif -typedef struct MarkerRetainerVectorIterator MarkerRetainerVectorIterator; -typedef struct MarkerRetainerVector MarkerRetainerVector; - -OTIO_API MarkerRetainerVector *MarkerRetainerVector_create(); - -OTIO_API void MarkerRetainerVector_destroy(MarkerRetainerVector *self); - -OTIO_API MarkerRetainerVectorIterator * -MarkerRetainerVector_begin(MarkerRetainerVector *self); - -OTIO_API MarkerRetainerVectorIterator * -MarkerRetainerVector_end(MarkerRetainerVector *self); - -OTIO_API int MarkerRetainerVector_size(MarkerRetainerVector *self); - -OTIO_API int MarkerRetainerVector_max_size(MarkerRetainerVector *self); - -OTIO_API int MarkerRetainerVector_capacity(MarkerRetainerVector *self); - -OTIO_API void MarkerRetainerVector_resize(MarkerRetainerVector *self, int n); - -OTIO_API bool MarkerRetainerVector_empty(MarkerRetainerVector *self); - -OTIO_API void MarkerRetainerVector_shrink_to_fit(MarkerRetainerVector *self); - -OTIO_API void MarkerRetainerVector_reserve(MarkerRetainerVector *self, int n); - -OTIO_API void MarkerRetainerVector_swap( - MarkerRetainerVector *self, MarkerRetainerVector *other); - -OTIO_API RetainerMarker * -MarkerRetainerVector_at(MarkerRetainerVector *self, int pos); - -OTIO_API void MarkerRetainerVector_push_back( - MarkerRetainerVector *self, RetainerMarker *value); - -OTIO_API void MarkerRetainerVector_pop_back(MarkerRetainerVector *self); - -OTIO_API MarkerRetainerVectorIterator *MarkerRetainerVector_insert( - MarkerRetainerVector *self, - MarkerRetainerVectorIterator *pos, - RetainerMarker *val); - -OTIO_API void MarkerRetainerVector_clear(MarkerRetainerVector *self); - -OTIO_API MarkerRetainerVectorIterator *MarkerRetainerVector_erase( - MarkerRetainerVector *self, MarkerRetainerVectorIterator *pos); - -OTIO_API MarkerRetainerVectorIterator *MarkerRetainerVector_erase_range( - MarkerRetainerVector *self, - MarkerRetainerVectorIterator *first, - MarkerRetainerVectorIterator *last); - -OTIO_API void MarkerRetainerVectorIterator_advance( - MarkerRetainerVectorIterator *iter, int dist); - -OTIO_API MarkerRetainerVectorIterator *MarkerRetainerVectorIterator_next( - MarkerRetainerVectorIterator *iter, int dist); - -OTIO_API MarkerRetainerVectorIterator *MarkerRetainerVectorIterator_prev( - MarkerRetainerVectorIterator *iter, int dist); - -OTIO_API RetainerMarker * -MarkerRetainerVectorIterator_value(MarkerRetainerVectorIterator *iter); - -OTIO_API bool MarkerRetainerVectorIterator_equal( - MarkerRetainerVectorIterator *lhs, MarkerRetainerVectorIterator *rhs); - -OTIO_API bool MarkerRetainerVectorIterator_not_equal( - MarkerRetainerVectorIterator *lhs, MarkerRetainerVectorIterator *rhs); - -OTIO_API void -MarkerRetainerVectorIterator_destroy(MarkerRetainerVectorIterator *self); diff --git a/src/copentimelineio/markerVector.h b/src/copentimelineio/markerVector.h deleted file mode 100644 index dd29d49..0000000 --- a/src/copentimelineio/markerVector.h +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once - -#include "marker.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif -typedef struct MarkerVectorIterator MarkerVectorIterator; -typedef struct MarkerVector MarkerVector; - -OTIO_API MarkerVector *MarkerVector_create(); - -OTIO_API void MarkerVector_destroy(MarkerVector *self); - -OTIO_API MarkerVectorIterator *MarkerVector_begin(MarkerVector *self); - -OTIO_API MarkerVectorIterator *MarkerVector_end(MarkerVector *self); - -OTIO_API int MarkerVector_size(MarkerVector *self); - -OTIO_API int MarkerVector_max_size(MarkerVector *self); - -OTIO_API int MarkerVector_capacity(MarkerVector *self); - -OTIO_API void MarkerVector_resize(MarkerVector *self, int n); - -OTIO_API bool MarkerVector_empty(MarkerVector *self); - -OTIO_API void MarkerVector_shrink_to_fit(MarkerVector *self); - -OTIO_API void MarkerVector_reserve(MarkerVector *self, int n); - -OTIO_API void MarkerVector_swap(MarkerVector *self, MarkerVector *other); - -OTIO_API Marker *MarkerVector_at(MarkerVector *self, int pos); - -OTIO_API void MarkerVector_push_back(MarkerVector *self, Marker *value); - -OTIO_API void MarkerVector_pop_back(MarkerVector *self); - -OTIO_API MarkerVectorIterator *MarkerVector_insert( - MarkerVector *self, MarkerVectorIterator *pos, Marker *val); - -OTIO_API void MarkerVector_clear(MarkerVector *self); - -OTIO_API MarkerVectorIterator * -MarkerVector_erase(MarkerVector *self, MarkerVectorIterator *pos); - -OTIO_API MarkerVectorIterator *MarkerVector_erase_range( - MarkerVector *self, - MarkerVectorIterator *first, - MarkerVectorIterator *last); - -OTIO_API void MarkerVectorIterator_advance(MarkerVectorIterator *iter, int dist); - -OTIO_API MarkerVectorIterator * -MarkerVectorIterator_next(MarkerVectorIterator *iter, int dist); - -OTIO_API MarkerVectorIterator * -MarkerVectorIterator_prev(MarkerVectorIterator *iter, int dist); - -OTIO_API Marker *MarkerVectorIterator_value(MarkerVectorIterator *iter); - -OTIO_API bool MarkerVectorIterator_equal( - MarkerVectorIterator *lhs, MarkerVectorIterator *rhs); - -OTIO_API bool MarkerVectorIterator_not_equal( - MarkerVectorIterator *lhs, MarkerVectorIterator *rhs); - -OTIO_API void MarkerVectorIterator_destroy(MarkerVectorIterator *self); diff --git a/src/copentimelineio/mediaReference.h b/src/copentimelineio/mediaReference.h deleted file mode 100644 index 79675fa..0000000 --- a/src/copentimelineio/mediaReference.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include "copentime/timeRange.h" -#include "copentime/optionalOpenTime.h" -#include "anyDictionary.h" -#include "errorStatus.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -struct MediaReference; -typedef struct MediaReference MediaReference; - -OTIO_API MediaReference *MediaReference_create( - const char *name, OptionalTimeRange available_range, AnyDictionary *metadata); -OTIO_API OptionalTimeRange MediaReference_available_range(MediaReference *self); -OTIO_API void MediaReference_set_available_range( - MediaReference *self, OptionalTimeRange available_range); -OTIO_API bool MediaReference_is_missing_reference(MediaReference *self); -OTIO_API const char *MediaReference_name(MediaReference *self); -OTIO_API void MediaReference_set_name(MediaReference *self, const char *name); -OTIO_API AnyDictionary *MediaReference_metadata(MediaReference *self); -OTIO_API bool MediaReference_to_json_file( - MediaReference *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); -OTIO_API const char *MediaReference_to_json_string( - MediaReference *self, OTIOErrorStatus *error_status, int indent); -OTIO_API bool MediaReference_is_equivalent_to( - MediaReference *self, OTIOSerializableObject *other); -OTIO_API MediaReference * -MediaReference_clone(MediaReference *self, OTIOErrorStatus *error_status); -OTIO_API const char *MediaReference_schema_name(MediaReference *self); -OTIO_API int MediaReference_schema_version(MediaReference *self); diff --git a/src/copentimelineio/missingReference.h b/src/copentimelineio/missingReference.h deleted file mode 100644 index 5be2550..0000000 --- a/src/copentimelineio/missingReference.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include "copentime/timeRange.h" -#include "copentime/optionalOpenTime.h" -#include "anyDictionary.h" -#include "errorStatus.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -struct MissingReference; -typedef struct MissingReference MissingReference; - -OTIO_API MissingReference *MissingReference_create( - const char *name, OptionalTimeRange available_range, AnyDictionary *metadata); - -OTIO_API bool MissingReference_is_missing_reference(MissingReference *self); - -OTIO_API OptionalTimeRange MissingReference_available_range(MissingReference *self); - -OTIO_API void MissingReference_set_available_range( - MissingReference *self, OptionalTimeRange available_range); - -OTIO_API const char *MissingReference_name(MissingReference *self); - -OTIO_API void MissingReference_set_name(MissingReference *self, const char *name); - -OTIO_API AnyDictionary *MissingReference_metadata(MissingReference *self); - -OTIO_API bool MissingReference_to_json_file( - MissingReference *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); - -OTIO_API const char *MissingReference_to_json_string( - MissingReference *self, OTIOErrorStatus *error_status, int indent); - -OTIO_API bool MissingReference_is_equivalent_to( - MissingReference *self, OTIOSerializableObject *other); - -OTIO_API MissingReference *MissingReference_clone( - MissingReference *self, OTIOErrorStatus *error_status); - -OTIO_API const char *MissingReference_schema_name(MissingReference *self); - -OTIO_API int MissingReference_schema_version(MissingReference *self); \ No newline at end of file diff --git a/src/copentimelineio/optionalPairRationalTime.h b/src/copentimelineio/optionalPairRationalTime.h deleted file mode 100644 index ab458cb..0000000 --- a/src/copentimelineio/optionalPairRationalTime.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include "copentime/optionalOpenTime.h" - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -struct OptionalPairRationalTime; -typedef struct OptionalPairRationalTime OptionalPairRationalTime; - -OTIO_API OptionalPairRationalTime * -OptionalPairRationalTime_create(OptionalRationalTime first, OptionalRationalTime second); - -OTIO_API OptionalRationalTime -OptionalPairRationalTime_first(OptionalPairRationalTime *self); - -OTIO_API OptionalRationalTime -OptionalPairRationalTime_second(OptionalPairRationalTime *self); - -OTIO_API void OptionalPairRationalTime_destroy(OptionalPairRationalTime *self); diff --git a/src/copentimelineio/retainerPairComposable.h b/src/copentimelineio/retainerPairComposable.h deleted file mode 100644 index 89ed360..0000000 --- a/src/copentimelineio/retainerPairComposable.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "composable.h" - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct RetainerPairComposable RetainerPairComposable; - -OTIO_API RetainerPairComposable *RetainerPairComposable_create( - RetainerComposable *first, RetainerComposable *second); - -OTIO_API RetainerComposable * -RetainerPairComposable_first(RetainerPairComposable *self); - -OTIO_API RetainerComposable * -RetainerPairComposable_second(RetainerPairComposable *self); - -OTIO_API void RetainerPairComposable_destroy(RetainerPairComposable *self); diff --git a/src/copentimelineio/safely_typed_any.h b/src/copentimelineio/safely_typed_any.h deleted file mode 100644 index 55da675..0000000 --- a/src/copentimelineio/safely_typed_any.h +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once - -#include "any.h" -#include "anyDictionary.h" -#include "anyVector.h" -#include "copentime/rationalTime.h" -#include "copentime/timeRange.h" -#include "copentime/timeTransform.h" -#include "serializableObject.h" -#include -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -OTIO_API Any *create_safely_typed_any_bool(bool boolValue); -OTIO_API Any *create_safely_typed_any_int(int intValue); -OTIO_API Any *create_safely_typed_any_int64(int64_t int64Value); -OTIO_API Any *create_safely_typed_any_double(double doubleValue); -OTIO_API Any *create_safely_typed_any_string(const char *stringValue); -OTIO_API Any *create_safely_typed_any_rational_time(RationalTime rationalTimeValue); -OTIO_API Any *create_safely_typed_any_time_range(TimeRange timeRangeValue); -OTIO_API Any * -create_safely_typed_any_time_transform(TimeTransform timeTransformValue); -OTIO_API Any *create_safely_typed_any_any_vector(AnyVector *anyVectorValue); -OTIO_API Any * -create_safely_typed_any_any_dictionary(AnyDictionary *anyDictionaryValue); -OTIO_API Any *create_safely_typed_any_serializable_object( - OTIOSerializableObject *serializableObjectValue); - -OTIO_API bool safely_cast_bool_any(Any *a); -OTIO_API int safely_cast_int_any(Any *a); -OTIO_API int64_t safely_cast_int64_any(Any *a); -OTIO_API double safely_cast_double_any(Any *a); -OTIO_API const char *safely_cast_string_any(Any *a); -OTIO_API RationalTime safely_cast_rational_time_any(Any *a); -OTIO_API TimeRange safely_cast_time_range_any(Any *a); -OTIO_API TimeTransform safely_cast_time_transform_any(Any *a); -OTIO_API OTIOSerializableObject *safely_cast_retainer_any(Any *a); - -OTIO_API AnyDictionary *safely_cast_any_dictionary_any(Any *a); -OTIO_API AnyVector *safely_cast_any_vector_any(Any *a); diff --git a/src/copentimelineio/serializableCollection.h b/src/copentimelineio/serializableCollection.h deleted file mode 100644 index 646068a..0000000 --- a/src/copentimelineio/serializableCollection.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -#include "errorStatus.h" -#include "serializableObjectRetainerVector.h" -#include "serializableObjectVector.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct SerializableCollection SerializableCollection; - -OTIO_API SerializableCollection* SerializableCollection_create( - const char* name, - SerializableObjectVector* children, - AnyDictionary* metadata); -OTIO_API SerializableObjectRetainerVector* - SerializableCollection_children(SerializableCollection* self); -OTIO_API void SerializableCollection_set_children( - SerializableCollection* self, SerializableObjectVector* children); -OTIO_API void SerializableCollection_clear_children(SerializableCollection* self); -OTIO_API void SerializableCollection_insert_child( - SerializableCollection* self, int index, OTIOSerializableObject* child); -OTIO_API bool SerializableCollection_set_child( - SerializableCollection* self, - int index, - OTIOSerializableObject* child, - OTIOErrorStatus* error_status); -OTIO_API bool SerializableCollection_remove_child( - SerializableCollection* self, int index, OTIOErrorStatus* error_status); -OTIO_API const char* SerializableCollection_name(SerializableCollection* self); -OTIO_API void SerializableCollection_set_name( - SerializableCollection* self, const char* name); -OTIO_API AnyDictionary* - SerializableCollection_metadata(SerializableCollection* self); -OTIO_API bool SerializableCollection_to_json_file( - SerializableCollection* self, - const char* file_name, - OTIOErrorStatus* error_status, - int indent); -OTIO_API const char* SerializableCollection_to_json_string( - SerializableCollection* self, - OTIOErrorStatus* error_status, - int indent); -OTIO_API bool SerializableCollection_is_equivalent_to( - SerializableCollection* self, OTIOSerializableObject* other); -OTIO_API SerializableCollection* SerializableCollection_clone( - SerializableCollection* self, OTIOErrorStatus* error_status); -OTIO_API const char* - SerializableCollection_schema_name(SerializableCollection* self); -OTIO_API int SerializableCollection_schema_version(SerializableCollection* self); diff --git a/src/copentimelineio/serializableObject.h b/src/copentimelineio/serializableObject.h deleted file mode 100644 index 30f668a..0000000 --- a/src/copentimelineio/serializableObject.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include "errorStatus.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct RetainerSerializableObject RetainerSerializableObject; -typedef struct OTIOSerializableObject OTIOSerializableObject; -typedef struct OTIOErrorStatus OTIOErrorStatus; - -OTIO_API RetainerSerializableObject* - RetainerSerializableObject_create(OTIOSerializableObject* obj); -OTIO_API OTIOSerializableObject* - RetainerSerializableObject_take_value(RetainerSerializableObject* self); -OTIO_API OTIOSerializableObject* - RetainerSerializableObject_value(RetainerSerializableObject* self); -OTIO_API void RetainerSerializableObject_managed_destroy( - RetainerSerializableObject* self); -OTIO_API OTIOSerializableObject* SerializableObject_create(); -OTIO_API bool SerializableObject_to_json_file( - OTIOSerializableObject* self, - const char* file_name, - OTIOErrorStatus* error_status, - int indent); -OTIO_API const char* SerializableObject_to_json_string( - OTIOSerializableObject* self, OTIOErrorStatus* error_status, int indent); -OTIO_API OTIOSerializableObject* SerializableObject_from_json_file( - const char* file_name, OTIOErrorStatus* error_status); -OTIO_API OTIOSerializableObject* SerializableObject_from_json_string( - const char* input, OTIOErrorStatus* error_status); -OTIO_API bool SerializableObject_is_equivalent_to( - OTIOSerializableObject* self, OTIOSerializableObject* other); -OTIO_API OTIOSerializableObject* SerializableObject_clone( - OTIOSerializableObject* self, OTIOErrorStatus* error_status); -/*AnyDictionary* SerializableObject_dynamic_fields(OTIOSerializableObject* self);*/ -OTIO_API bool SerializableObject_is_unknown_schema(OTIOSerializableObject* self); -OTIO_API const char* SerializableObject_schema_name(OTIOSerializableObject* self); -OTIO_API int SerializableObject_schema_version(OTIOSerializableObject* self); - -#define OTIO_RETAIN(X) RetainerSerializableObject* X##_r = RetainerSerializableObject_create((OTIOSerializableObject*) (X)) -#define OTIO_RELEASE(X) if (X##_r) { RetainerSerializableObject_managed_destroy(X##_r); X##_r = NULL; } diff --git a/src/copentimelineio/serializableObjectRetainerVector.h b/src/copentimelineio/serializableObjectRetainerVector.h deleted file mode 100644 index 9e03fce..0000000 --- a/src/copentimelineio/serializableObjectRetainerVector.h +++ /dev/null @@ -1,106 +0,0 @@ -#pragma once - -#include "serializableObject.h" - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif -typedef struct SerializableObjectRetainerVectorIterator - SerializableObjectRetainerVectorIterator; -typedef struct SerializableObjectRetainerVector - SerializableObjectRetainerVector; - -OTIO_API SerializableObjectRetainerVector *SerializableObjectRetainerVector_create(); - -OTIO_API void SerializableObjectRetainerVector_destroy( - SerializableObjectRetainerVector *self); - -OTIO_API SerializableObjectRetainerVectorIterator * -SerializableObjectRetainerVector_begin( - SerializableObjectRetainerVector *self); - -OTIO_API SerializableObjectRetainerVectorIterator * -SerializableObjectRetainerVector_end( - SerializableObjectRetainerVector *self); - -OTIO_API int SerializableObjectRetainerVector_size( - SerializableObjectRetainerVector *self); - -OTIO_API int SerializableObjectRetainerVector_max_size( - SerializableObjectRetainerVector *self); - -OTIO_API int SerializableObjectRetainerVector_capacity( - SerializableObjectRetainerVector *self); - -OTIO_API void SerializableObjectRetainerVector_resize( - SerializableObjectRetainerVector *self, int n); - -OTIO_API bool SerializableObjectRetainerVector_empty( - SerializableObjectRetainerVector *self); - -OTIO_API void SerializableObjectRetainerVector_shrink_to_fit( - SerializableObjectRetainerVector *self); - -OTIO_API void SerializableObjectRetainerVector_reserve( - SerializableObjectRetainerVector *self, int n); - -OTIO_API void SerializableObjectRetainerVector_swap( - SerializableObjectRetainerVector *self, - SerializableObjectRetainerVector *other); - -OTIO_API RetainerSerializableObject *SerializableObjectRetainerVector_at( - SerializableObjectRetainerVector *self, int pos); - -OTIO_API void SerializableObjectRetainerVector_push_back( - SerializableObjectRetainerVector *self, - RetainerSerializableObject *value); - -OTIO_API void SerializableObjectRetainerVector_pop_back( - SerializableObjectRetainerVector *self); - -OTIO_API SerializableObjectRetainerVectorIterator * -SerializableObjectRetainerVector_insert( - SerializableObjectRetainerVector *self, - SerializableObjectRetainerVectorIterator *pos, - RetainerSerializableObject *val); - -OTIO_API void SerializableObjectRetainerVector_clear( - SerializableObjectRetainerVector *self); - -OTIO_API SerializableObjectRetainerVectorIterator * -SerializableObjectRetainerVector_erase( - SerializableObjectRetainerVector *self, - SerializableObjectRetainerVectorIterator *pos); - -OTIO_API SerializableObjectRetainerVectorIterator * -SerializableObjectRetainerVector_erase_range( - SerializableObjectRetainerVector *self, - SerializableObjectRetainerVectorIterator *first, - SerializableObjectRetainerVectorIterator *last); - -OTIO_API void SerializableObjectRetainerVectorIterator_advance( - SerializableObjectRetainerVectorIterator *iter, int dist); - -OTIO_API SerializableObjectRetainerVectorIterator * -SerializableObjectRetainerVectorIterator_next( - SerializableObjectRetainerVectorIterator *iter, int dist); - -OTIO_API SerializableObjectRetainerVectorIterator * -SerializableObjectRetainerVectorIterator_prev( - SerializableObjectRetainerVectorIterator *iter, int dist); - -OTIO_API RetainerSerializableObject *SerializableObjectRetainerVectorIterator_value( - SerializableObjectRetainerVectorIterator *iter); - -OTIO_API bool SerializableObjectRetainerVectorIterator_equal( - SerializableObjectRetainerVectorIterator *lhs, - SerializableObjectRetainerVectorIterator *rhs); - -OTIO_API bool SerializableObjectRetainerVectorIterator_not_equal( - SerializableObjectRetainerVectorIterator *lhs, - SerializableObjectRetainerVectorIterator *rhs); - -OTIO_API void SerializableObjectRetainerVectorIterator_destroy( - SerializableObjectRetainerVectorIterator *self); diff --git a/src/copentimelineio/serializableObjectVector.h b/src/copentimelineio/serializableObjectVector.h deleted file mode 100644 index a53f2e4..0000000 --- a/src/copentimelineio/serializableObjectVector.h +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once - -#include "serializableObject.h" - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct SerializableObjectVectorIterator SerializableObjectVectorIterator; -typedef struct SerializableObjectVector SerializableObjectVector; - -OTIO_API SerializableObjectVector* SerializableObjectVector_create(); -OTIO_API void SerializableObjectVector_destroy(SerializableObjectVector* self); -OTIO_API SerializableObjectVectorIterator* - SerializableObjectVector_begin(SerializableObjectVector* self); -OTIO_API SerializableObjectVectorIterator* - SerializableObjectVector_end(SerializableObjectVector* self); -OTIO_API int SerializableObjectVector_size(SerializableObjectVector* self); -OTIO_API int SerializableObjectVector_max_size(SerializableObjectVector* self); -OTIO_API int SerializableObjectVector_capacity(SerializableObjectVector* self); -OTIO_API void SerializableObjectVector_resize(SerializableObjectVector* self, int n); -OTIO_API bool SerializableObjectVector_empty(SerializableObjectVector* self); -OTIO_API void SerializableObjectVector_shrink_to_fit(SerializableObjectVector* self); -OTIO_API void - SerializableObjectVector_reserve(SerializableObjectVector* self, int n); -OTIO_API void SerializableObjectVector_swap( - SerializableObjectVector* self, SerializableObjectVector* other); -OTIO_API OTIOSerializableObject* - SerializableObjectVector_at(SerializableObjectVector* self, int pos); -OTIO_API void SerializableObjectVector_push_back( - SerializableObjectVector* self, OTIOSerializableObject* value); -OTIO_API void SerializableObjectVector_pop_back(SerializableObjectVector* self); -OTIO_API SerializableObjectVectorIterator* SerializableObjectVector_insert( - SerializableObjectVector* self, - SerializableObjectVectorIterator* pos, - OTIOSerializableObject* val); -OTIO_API void SerializableObjectVector_clear(SerializableObjectVector* self); -OTIO_API SerializableObjectVectorIterator* SerializableObjectVector_erase( - SerializableObjectVector* self, SerializableObjectVectorIterator* pos); -OTIO_API SerializableObjectVectorIterator* SerializableObjectVector_erase_range( - SerializableObjectVector* self, - SerializableObjectVectorIterator* first, - SerializableObjectVectorIterator* last); -OTIO_API void SerializableObjectVectorIterator_advance( - SerializableObjectVectorIterator* iter, int dist); -OTIO_API SerializableObjectVectorIterator* SerializableObjectVectorIterator_next( - SerializableObjectVectorIterator* iter, int dist); -OTIO_API SerializableObjectVectorIterator* SerializableObjectVectorIterator_prev( - SerializableObjectVectorIterator* iter, int dist); -OTIO_API OTIOSerializableObject* SerializableObjectVectorIterator_value( - SerializableObjectVectorIterator* iter); -OTIO_API bool SerializableObjectVectorIterator_equal( - SerializableObjectVectorIterator* lhs, - SerializableObjectVectorIterator* rhs); -OTIO_API bool SerializableObjectVectorIterator_not_equal( - SerializableObjectVectorIterator* lhs, - SerializableObjectVectorIterator* rhs); -OTIO_API void SerializableObjectVectorIterator_destroy( - SerializableObjectVectorIterator* self); diff --git a/src/copentimelineio/serializableObjectWithMetadata.h b/src/copentimelineio/serializableObjectWithMetadata.h deleted file mode 100644 index b03679e..0000000 --- a/src/copentimelineio/serializableObjectWithMetadata.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -#include "errorStatus.h" -#include "serializableObject.h" - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -struct SerializableObjectWithMetadata; -typedef struct SerializableObjectWithMetadata - SerializableObjectWithMetadata; -OTIO_API SerializableObjectWithMetadata* -SerializableObjectWithMetadata_create(const char* name, AnyDictionary* metadata); -OTIO_API const char* -SerializableObjectWithMetadata_name(SerializableObjectWithMetadata* self); -OTIO_API void -SerializableObjectWithMetadata_set_name(SerializableObjectWithMetadata* self, const char* name); -OTIO_API AnyDictionary* -SerializableObjectWithMetadata_metadata(SerializableObjectWithMetadata* self); -OTIO_API bool -SerializableObjectWithMetadata_to_json_file( - SerializableObjectWithMetadata* self, - const char* file_name, - OTIOErrorStatus* error_status, - int indent); -OTIO_API const char* -SerializableObjectWithMetadata_to_json_string( - SerializableObjectWithMetadata* self, - OTIOErrorStatus* error_status, - int indent); -OTIO_API bool -SerializableObjectWithMetadata_is_equivalent_to( - SerializableObjectWithMetadata* self, OTIOSerializableObject* other); -OTIO_API SerializableObjectWithMetadata* -SerializableObjectWithMetadata_clone( - SerializableObjectWithMetadata* self, OTIOErrorStatus* error_status); -OTIO_API bool -SerializableObjectWithMetadata_is_unknown_schema(SerializableObjectWithMetadata* self); -OTIO_API const char* -SerializableObjectWithMetadata_schema_name(SerializableObjectWithMetadata* self); -OTIO_API int -SerializableObjectWithMetadata_schema_version(SerializableObjectWithMetadata* self); diff --git a/src/copentimelineio/serialization.h b/src/copentimelineio/serialization.h deleted file mode 100644 index d46c27d..0000000 --- a/src/copentimelineio/serialization.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "errorStatus.h" -#include "any.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -OTIO_API const char *serialize_json_to_string( - Any *value, OTIOErrorStatus *error_status, int indent); - -OTIO_API bool serialize_json_to_file( - Any *value, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); diff --git a/src/copentimelineio/stack.h b/src/copentimelineio/stack.h deleted file mode 100644 index 4515232..0000000 --- a/src/copentimelineio/stack.h +++ /dev/null @@ -1,107 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -#include "composableRetainerVector.h" -#include "composableVector.h" -#include "copentime/timeRange.h" -#include "effectRetainerVector.h" -#include "effectVector.h" -#include "errorStatus.h" -#include "item.h" -#include "mapComposableTimeRange.h" -#include "markerRetainerVector.h" -#include "markerVector.h" -#include "optionalPairRationalTime.h" -#include "copentime/optionalOpenTime.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct Stack Stack; - -OTIO_API Stack *Stack_create( - const char *name, - OptionalTimeRange source_range, - AnyDictionary *metadata, - EffectVector *effects, - MarkerVector *markers); -OTIO_API TimeRange Stack_range_of_child_at_index( - Stack *self, int index, OTIOErrorStatus *error_status); -OTIO_API TimeRange Stack_trimmed_range_of_child_at_index( - Stack *self, int index, OTIOErrorStatus *error_status); -OTIO_API TimeRange -Stack_available_range(Stack *self, OTIOErrorStatus *error_status); -OTIO_API MapComposableTimeRange * -Stack_range_of_all_children(Stack *self, OTIOErrorStatus *error_status); - -OTIO_API const char *Stack_composition_kind(Stack *self); -OTIO_API ComposableRetainerVector *Stack_children(Stack *self); -OTIO_API void Stack_clear_children(Stack *self); -OTIO_API bool Stack_set_children( - Stack *self, ComposableVector *children, OTIOErrorStatus *error_status); -OTIO_API bool Stack_insert_child( - Stack *self, - int index, - Composable *child, - OTIOErrorStatus *error_status); -OTIO_API bool Stack_set_child( - Stack *self, - int index, - Composable *child, - OTIOErrorStatus *error_status); -OTIO_API bool -Stack_remove_child(Stack *self, int index, OTIOErrorStatus *error_status); -OTIO_API bool Stack_append_child( - Stack *self, Composable *child, OTIOErrorStatus *error_status); -OTIO_API bool Stack_is_parent_of(Stack *self, Composable *other); -OTIO_API OptionalPairRationalTime *Stack_handles_of_child( - Stack *self, Composable *child, OTIOErrorStatus *error_status); -OTIO_API TimeRange Stack_range_of_child( - Stack *self, Composable *child, OTIOErrorStatus *error_status); -OTIO_API OptionalTimeRange Stack_trimmed_range_of_child( - Stack *self, Composable *child, OTIOErrorStatus *error_status); -OTIO_API OptionalTimeRange Stack_trim_child_range(Stack *self, TimeRange child_range); -OTIO_API bool Stack_has_child(Stack *self, Composable *child); - -OTIO_API bool Stack_visible(Stack *self); -OTIO_API bool Stack_overlapping(Stack *self); -OTIO_API OptionalTimeRange Stack_source_range(Stack *self); -OTIO_API void Stack_set_source_range(Stack *self, OptionalTimeRange source_range); -OTIO_API EffectRetainerVector *Stack_effects(Stack *self); -OTIO_API MarkerRetainerVector *Stack_markers(Stack *self); -OTIO_API RationalTime Stack_duration(Stack *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange Stack_trimmed_range(Stack *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange Stack_visible_range(Stack *self, OTIOErrorStatus *error_status); -OTIO_API OptionalTimeRange -Stack_trimmed_range_in_parent(Stack *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange -Stack_range_in_parent(Stack *self, OTIOErrorStatus *error_status); -OTIO_API RationalTime Stack_transformed_time( - Stack *self, - RationalTime time, - Item *to_item, - OTIOErrorStatus *error_status); -OTIO_API TimeRange Stack_transformed_time_range( - Stack *self, - TimeRange time_range, - Item *to_item, - OTIOErrorStatus *error_status); -OTIO_API Composition *Stack_parent(Stack *self); -OTIO_API const char *Stack_name(Stack *self); -OTIO_API AnyDictionary *Stack_metadata(Stack *self); -OTIO_API void Stack_set_name(Stack *self, const char *name); -OTIO_API bool Stack_to_json_file( - Stack *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); -OTIO_API const char *Stack_to_json_string( - Stack *self, OTIOErrorStatus *error_status, int indent); -OTIO_API bool Stack_is_equivalent_to(Stack *self, OTIOSerializableObject *other); -OTIO_API Stack *Stack_clone(Stack *self, OTIOErrorStatus *error_status); -OTIO_API const char *Stack_schema_name(Stack *self); -OTIO_API int Stack_schema_version(Stack *self); diff --git a/src/copentimelineio/stackAlgorithm.h b/src/copentimelineio/stackAlgorithm.h deleted file mode 100644 index ac3b743..0000000 --- a/src/copentimelineio/stackAlgorithm.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "errorStatus.h" -#include "stack.h" -#include "track.h" -#include "trackVector.h" - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -OTIO_API Track *flatten_stack(Stack *in_stack, OTIOErrorStatus *error_status); - -OTIO_API Track *flatten_stack_track_vector( - TrackVector *tracks, OTIOErrorStatus *error_status); diff --git a/src/copentimelineio/timeEffect.h b/src/copentimelineio/timeEffect.h deleted file mode 100644 index 50223fe..0000000 --- a/src/copentimelineio/timeEffect.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include "copentimelineio/anyDictionary.h" -#include "errorStatus.h" -#include "serializableObject.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif -typedef struct TimeEffect TimeEffect; - -OTIO_API TimeEffect* TimeEffect_create( - const char* name, const char* effect_name, AnyDictionary* metadata); -OTIO_API const char* TimeEffect_effect_name(TimeEffect* self); -OTIO_API void TimeEffect_set_effect_name(TimeEffect* self, const char* effect_name); -OTIO_API const char* TimeEffect_name(TimeEffect* self); -OTIO_API void TimeEffect_set_name(TimeEffect* self, const char* name); -OTIO_API AnyDictionary* TimeEffect_metadata(TimeEffect* self); -OTIO_API bool TimeEffect_to_json_file( - TimeEffect* self, - const char* file_name, - OTIOErrorStatus* error_status, - int indent); -OTIO_API const char* TimeEffect_to_json_string( - TimeEffect* self, OTIOErrorStatus* error_status, int indent); -OTIO_API bool - TimeEffect_is_equivalent_to(TimeEffect* self, OTIOSerializableObject* other); -OTIO_API TimeEffect* - TimeEffect_clone(TimeEffect* self, OTIOErrorStatus* error_status); -OTIO_API const char* TimeEffect_schema_name(TimeEffect* self); -OTIO_API int TimeEffect_schema_version(TimeEffect* self); diff --git a/src/copentimelineio/timeline.h b/src/copentimelineio/timeline.h deleted file mode 100644 index 3886310..0000000 --- a/src/copentimelineio/timeline.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -#include "copentime/optionalOpenTime.h" -#include "errorStatus.h" -#include "stack.h" -#include "trackVector.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct Timeline Timeline; - -OTIO_API Timeline *Timeline_create( - const char *name, - OptionalRationalTime global_start_time, - AnyDictionary *metadata); -OTIO_API Stack *Timeline_tracks(Timeline *self); -OTIO_API void Timeline_set_tracks(Timeline *self, Stack *stack); -OTIO_API OptionalRationalTime Timeline_global_start_time(Timeline *self); -OTIO_API void Timeline_set_global_start_time( - Timeline *self, OptionalRationalTime global_start_time); -OTIO_API RationalTime -Timeline_duration(Timeline *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange Timeline_range_of_child( - Timeline *self, Composable *child, OTIOErrorStatus *error_status); -OTIO_API TrackVector *Timeline_audio_tracks(Timeline *self); -OTIO_API TrackVector *Timeline_video_tracks(Timeline *self); -OTIO_API const char *Timeline_name(Timeline *self); -OTIO_API void Timeline_set_name(Timeline *self, const char *name); -OTIO_API AnyDictionary *Timeline_metadata(Timeline *self); -OTIO_API bool Timeline_to_json_file( - Timeline *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); -OTIO_API const char *Timeline_to_json_string( - Timeline *self, OTIOErrorStatus *error_status, int indent); -OTIO_API bool Timeline_is_equivalent_to(Timeline *self, OTIOSerializableObject *other); -OTIO_API Timeline *Timeline_clone(Timeline *self, OTIOErrorStatus *error_status); -OTIO_API bool Timeline_is_unknown_schema(Timeline *self); -OTIO_API const char *Timeline_schema_name(Timeline *self); -OTIO_API int Timeline_schema_version(Timeline *self); diff --git a/src/copentimelineio/track.h b/src/copentimelineio/track.h deleted file mode 100644 index 6391f6c..0000000 --- a/src/copentimelineio/track.h +++ /dev/null @@ -1,123 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -#include "composable.h" -#include "composableRetainerVector.h" -#include "composableVector.h" -#include "copentime/timeRange.h" -#include "effectRetainerVector.h" -#include "errorStatus.h" -#include "item.h" -#include "mapComposableTimeRange.h" -#include "markerRetainerVector.h" -#include "optionalPairRationalTime.h" -#include "retainerPairComposable.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct Track Track; - -typedef enum { - OTIO_Track_NeighbourGapPolicy_never = 0, - OTIO_Track_NeighbourGapPolicy_around_transitions = 1, -} OTIO_Track_NeighbourGapPolicy_; -typedef int OTIO_Track_NeighbourGapPolicy; - -OTIO_API const char *TrackKind_Video; -OTIO_API const char *TrackKind_Audio; - -OTIO_API Track *Track_create( - const char *name, - OptionalTimeRange source_range, - const char *kind, - AnyDictionary *metadata); -OTIO_API const char *Track_kind(Track *self); -OTIO_API void Track_set_kind(Track *self, const char *kind); -OTIO_API TimeRange Track_range_of_child_at_index( - Track *self, int index, OTIOErrorStatus *error_status); -OTIO_API TimeRange Track_trimmed_range_of_child_at_index( - Track *self, int index, OTIOErrorStatus *error_status); -OTIO_API TimeRange -Track_available_range(Track *self, OTIOErrorStatus *error_status); -OTIO_API OptionalPairRationalTime *Track_handles_of_child( - Track *self, Composable *child, OTIOErrorStatus *error_status); -OTIO_API RetainerPairComposable *Track_neighbors_of( - Track *self, - Composable *item, - OTIOErrorStatus *error_status, - OTIO_Track_NeighbourGapPolicy insert_gap); -OTIO_API ComposableVector *Track_each_clip(Track *self); -OTIO_API MapComposableTimeRange * -Track_range_of_all_children(Track *self, OTIOErrorStatus *error_status); - -OTIO_API const char *Track_composition_kind(Track *self); -OTIO_API ComposableRetainerVector *Track_children(Track *self); -OTIO_API void Track_clear_children(Track *self); -OTIO_API bool Track_set_children( - Track *self, ComposableVector *children, OTIOErrorStatus *error_status); -OTIO_API bool Track_insert_child( - Track *self, - int index, - Composable *child, - OTIOErrorStatus *error_status); -OTIO_API bool Track_set_child( - Track *self, - int index, - Composable *child, - OTIOErrorStatus *error_status); -OTIO_API bool -Track_remove_child(Track *self, int index, OTIOErrorStatus *error_status); -OTIO_API bool Track_append_child( - Track *self, Composable *child, OTIOErrorStatus *error_status); -OTIO_API bool Track_is_parent_of(Track *self, Composable *other); -OTIO_API TimeRange Track_range_of_child( - Track *self, Composable *child, OTIOErrorStatus *error_status); -OTIO_API OptionalTimeRange Track_trimmed_range_of_child( - Track *self, Composable *child, OTIOErrorStatus *error_status); -OTIO_API OptionalTimeRange Track_trim_child_range(Track *self, TimeRange child_range); -OTIO_API bool Track_has_child(Track *self, Composable *child); -OTIO_API bool Track_visible(Track *self); -OTIO_API bool Track_overlapping(Track *self); -OTIO_API OptionalTimeRange Track_source_range(Track *self); -OTIO_API void Track_set_source_range(Track *self, OptionalTimeRange source_range); -OTIO_API EffectRetainerVector *Track_effects(Track *self); -OTIO_API MarkerRetainerVector *Track_markers(Track *self); -OTIO_API RationalTime Track_duration(Track *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange -Track_available_range(Track *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange Track_trimmed_range(Track *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange Track_visible_range(Track *self, OTIOErrorStatus *error_status); -OTIO_API OptionalTimeRange -Track_trimmed_range_in_parent(Track *self, OTIOErrorStatus *error_status); -OTIO_API TimeRange -Track_range_in_parent(Track *self, OTIOErrorStatus *error_status); -OTIO_API RationalTime Track_transformed_time( - Track *self, - RationalTime time, - Item *to_item, - OTIOErrorStatus *error_status); -OTIO_API TimeRange Track_transformed_time_range( - Track *self, - TimeRange time_range, - Item *to_item, - OTIOErrorStatus *error_status); -OTIO_API Composition *Track_parent(Track *self); -OTIO_API const char *Track_name(Track *self); -OTIO_API AnyDictionary *Track_metadata(Track *self); -OTIO_API void Track_set_name(Track *self, const char *name); -OTIO_API bool Track_to_json_file( - Track *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); -OTIO_API const char *Track_to_json_string( - Track *self, OTIOErrorStatus *error_status, int indent); -OTIO_API bool Track_is_equivalent_to(Track *self, OTIOSerializableObject *other); -OTIO_API Track *Track_clone(Track *self, OTIOErrorStatus *error_status); -OTIO_API const char *Track_schema_name(Track *self); -OTIO_API int Track_schema_version(Track *self); diff --git a/src/copentimelineio/trackAlgorithm.h b/src/copentimelineio/trackAlgorithm.h deleted file mode 100644 index e1981af..0000000 --- a/src/copentimelineio/trackAlgorithm.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "copentime/timeRange.h" -#include "errorStatus.h" -#include "track.h" - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -OTIO_API Track *track_trimmed_to_range( - Track *in_track, TimeRange trim_range, OTIOErrorStatus *error_status); \ No newline at end of file diff --git a/src/copentimelineio/trackVector.h b/src/copentimelineio/trackVector.h deleted file mode 100644 index 5622e48..0000000 --- a/src/copentimelineio/trackVector.h +++ /dev/null @@ -1,74 +0,0 @@ -#pragma once - -#include "track.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct TrackVectorIterator TrackVectorIterator; -typedef struct TrackVector TrackVector; - -OTIO_API TrackVector *TrackVector_create(); - -OTIO_API void TrackVector_destroy(TrackVector *self); - -OTIO_API TrackVectorIterator *TrackVector_begin(TrackVector *self); - -OTIO_API TrackVectorIterator *TrackVector_end(TrackVector *self); - -OTIO_API int TrackVector_size(TrackVector *self); - -OTIO_API int TrackVector_max_size(TrackVector *self); - -OTIO_API int TrackVector_capacity(TrackVector *self); - -OTIO_API void TrackVector_resize(TrackVector *self, int n); - -OTIO_API bool TrackVector_empty(TrackVector *self); - -OTIO_API void TrackVector_shrink_to_fit(TrackVector *self); - -OTIO_API void TrackVector_reserve(TrackVector *self, int n); - -OTIO_API void TrackVector_swap(TrackVector *self, TrackVector *other); - -OTIO_API Track *TrackVector_at(TrackVector *self, int pos); - -OTIO_API void TrackVector_push_back(TrackVector *self, Track *value); - -OTIO_API void TrackVector_pop_back(TrackVector *self); - -OTIO_API TrackVectorIterator * -TrackVector_insert(TrackVector *self, TrackVectorIterator *pos, Track *val); - -OTIO_API void TrackVector_clear(TrackVector *self); - -OTIO_API TrackVectorIterator * -TrackVector_erase(TrackVector *self, TrackVectorIterator *pos); - -OTIO_API TrackVectorIterator *TrackVector_erase_range( - TrackVector *self, - TrackVectorIterator *first, - TrackVectorIterator *last); - -OTIO_API void TrackVectorIterator_advance(TrackVectorIterator *iter, int dist); - -OTIO_API TrackVectorIterator * -TrackVectorIterator_next(TrackVectorIterator *iter, int dist); - -OTIO_API TrackVectorIterator * -TrackVectorIterator_prev(TrackVectorIterator *iter, int dist); - -OTIO_API Track *TrackVectorIterator_value(TrackVectorIterator *iter); - -OTIO_API bool TrackVectorIterator_equal( - TrackVectorIterator *lhs, TrackVectorIterator *rhs); - -OTIO_API bool TrackVectorIterator_not_equal( - TrackVectorIterator *lhs, TrackVectorIterator *rhs); - -OTIO_API void TrackVectorIterator_destroy(TrackVectorIterator *self); diff --git a/src/copentimelineio/transition.h b/src/copentimelineio/transition.h deleted file mode 100644 index 5a99a0d..0000000 --- a/src/copentimelineio/transition.h +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -#include "composition.h" -#include "copentime/optionalOpenTime.h" -#include "errorStatus.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -extern const char *TransitionType_SMPTE_Dissolve; -extern const char *TransitionType_Custom; - -typedef struct Transition Transition; - -OTIO_API Transition *Transition_create( - const char *name, - const char *transition_type, - OptionalRationalTime in_offset, - OptionalRationalTime out_offset, - AnyDictionary *metadata); -OTIO_API bool Transition_overlapping(Transition *self); -OTIO_API const char *Transition_transition_type(Transition *self); -OTIO_API void Transition_set_transition_type( - Transition *self, const char *transition_type); -OTIO_API RationalTime Transition_in_offset(Transition *self); -OTIO_API void Transition_set_in_offset(Transition *self, RationalTime in_offset); -OTIO_API RationalTime Transition_out_offset(Transition *self); -OTIO_API void Transition_set_out_offset(Transition *self, RationalTime out_offset); -OTIO_API RationalTime -Transition_duration(Transition *self, OTIOErrorStatus *error_status); -OTIO_API OptionalTimeRange -Transition_range_in_parent(Transition *self, - OTIOErrorStatus *error_status); -OTIO_API OptionalTimeRange Transition_trimmed_range_in_parent( - Transition *self, - OTIOErrorStatus *error_status); -OTIO_API const char *Transition_name(Transition *self); -OTIO_API AnyDictionary *Transition_metadata(Transition *self); -OTIO_API Composition *Transition_parent(Transition *self); -OTIO_API bool Transition_visible(Transition *self); -OTIO_API void Transition_set_name(Transition *self, const char *name); -OTIO_API bool Transition_to_json_file( - Transition *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); -OTIO_API const char *Transition_to_json_string( - Transition *self, OTIOErrorStatus *error_status, int indent); -OTIO_API bool -Transition_is_equivalent_to(Transition *self, OTIOSerializableObject *other); -OTIO_API Transition * -Transition_clone(Transition *self, OTIOErrorStatus *error_status); -OTIO_API const char *Transition_schema_name(Transition *self); -OTIO_API int Transition_schema_version(Transition *self); diff --git a/src/copentimelineio/typeInfo.h b/src/copentimelineio/typeInfo.h deleted file mode 100644 index 5409fdd..0000000 --- a/src/copentimelineio/typeInfo.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include "errorStatus.h" -#include - -typedef struct TypeInfo TypeInfo; diff --git a/src/copentimelineio/typeRegistry.h b/src/copentimelineio/typeRegistry.h deleted file mode 100644 index eb07203..0000000 --- a/src/copentimelineio/typeRegistry.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#include "anyDictionary.h" -#include "errorStatus.h" -#include "serializableObject.h" -#include "typeInfo.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef OTIOSerializableObject* (*TypeRegistryCreateFunction)(); -typedef void (*TypeRegistryUpgradeFunction)(AnyDictionary*); -typedef struct TypeRegistry TypeRegistry; - -OTIO_API TypeRegistry* TypeRegistry_instance(); -/*bool TypeRegistry_register_type( - TypeRegistry* self, - const char* schema_name, - int schema_version, - TypeInfo* type, - TypeRegistryCreateFunction create, //unable to cast this function pointer to std::function because of the wrapped return type - const char* class_name);*/ -OTIO_API bool TypeRegistry_register_type_from_existing_type( - TypeRegistry* self, - const char* schema_name, - int schema_version, - const char* existing_schema_name, - OTIOErrorStatus* error_status); -/*OTIO_API bool TypeRegistry_register_upgrade_function( - TypeRegistry* self, - const char* schema_name, - int version_to_upgrade_to, - TypeRegistryUpgradeFunction upgrade_function);*/ -OTIO_API OTIOSerializableObject* TypeRegistry_instance_from_schema( - TypeRegistry* self, - const char* schema_name, - int schema_version, - AnyDictionary* dict, - OTIOErrorStatus* error_status); -OTIO_API bool TypeRegistry_set_type_record( - TypeRegistry* self, - OTIOSerializableObject* var1, - const char* schema_name, - OTIOErrorStatus* error_status); -OTIO_API void TypeRegistry_destroy(TypeRegistry* self); diff --git a/src/copentimelineio/unknownSchema.h b/src/copentimelineio/unknownSchema.h deleted file mode 100644 index 1014eb9..0000000 --- a/src/copentimelineio/unknownSchema.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include "errorStatus.h" -#include - -#ifdef __cplusplus -# define OTIO_API extern "C" -#else -# define OTIO_API -#endif - -typedef struct UnknownSchema UnknownSchema; - -OTIO_API UnknownSchema *UnknownSchema_create( - const char *original_schema_name, int original_schema_version); - -OTIO_API const char *UnknownSchema_original_schema_name(UnknownSchema *self); - -OTIO_API int UnknownSchema_original_schema_version(UnknownSchema *self); - -OTIO_API bool UnknownSchema_is_unknown_schema(UnknownSchema *self); - -OTIO_API bool UnknownSchema_to_json_file( - UnknownSchema *self, - const char *file_name, - OTIOErrorStatus *error_status, - int indent); - -OTIO_API const char *UnknownSchema_to_json_string( - UnknownSchema *self, OTIOErrorStatus *error_status, int indent); - -OTIO_API bool UnknownSchema_is_equivalent_to( - UnknownSchema *self, OTIOSerializableObject *other); - -OTIO_API UnknownSchema * -UnknownSchema_clone(UnknownSchema *self, OTIOErrorStatus *error_status); - -OTIO_API const char *UnknownSchema_schema_name(UnknownSchema *self); - -OTIO_API int UnknownSchema_schema_version(UnknownSchema *self); diff --git a/src/lib.h b/src/lib.h deleted file mode 100644 index 58d72b2..0000000 --- a/src/lib.h +++ /dev/null @@ -1,50 +0,0 @@ -#include "copentime/errorStatus.h" -#include "copentime/optionalOpenTime.h" -#include "copentime/rationalTime.h" -#include "copentime/timeRange.h" -#include "copentime/timeTransform.h" -#include "copentimelineio/any.h" -#include "copentimelineio/anyDictionary.h" -#include "copentimelineio/anyVector.h" -#include "copentimelineio/clip.h" -#include "copentimelineio/composable.h" -#include "copentimelineio/composableRetainerVector.h" -#include "copentimelineio/composableVector.h" -#include "copentimelineio/composition.h" -#include "copentimelineio/deserialization.h" -#include "copentimelineio/effect.h" -#include "copentimelineio/effectRetainerVector.h" -#include "copentimelineio/effectVector.h" -#include "copentimelineio/errorStatus.h" -#include "copentimelineio/externalReference.h" -#include "copentimelineio/freezeFrame.h" -#include "copentimelineio/gap.h" -#include "copentimelineio/generatorReference.h" -#include "copentimelineio/item.h" -#include "copentimelineio/linearTimeWarp.h" -#include "copentimelineio/mapComposableTimeRange.h" -#include "copentimelineio/marker.h" -#include "copentimelineio/markerRetainerVector.h" -#include "copentimelineio/markerVector.h" -#include "copentimelineio/mediaReference.h" -#include "copentimelineio/missingReference.h" -#include "copentimelineio/optionalPairRationalTime.h" -#include "copentimelineio/retainerPairComposable.h" -#include "copentimelineio/safely_typed_any.h" -#include "copentimelineio/serializableCollection.h" -#include "copentimelineio/serializableObject.h" -#include "copentimelineio/serializableObjectRetainerVector.h" -#include "copentimelineio/serializableObjectVector.h" -#include "copentimelineio/serializableObjectWithMetadata.h" -#include "copentimelineio/serialization.h" -#include "copentimelineio/stack.h" -#include "copentimelineio/stackAlgorithm.h" -#include "copentimelineio/timeEffect.h" -#include "copentimelineio/timeline.h" -#include "copentimelineio/track.h" -#include "copentimelineio/trackAlgorithm.h" -#include "copentimelineio/trackVector.h" -#include "copentimelineio/transition.h" -#include "copentimelineio/typeInfo.h" -#include "copentimelineio/typeRegistry.h" -#include "copentimelineio/unknownSchema.h" From 5e4e0c7d353cf158dd4e9ad54c271eef127fb98a Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Wed, 21 Sep 2022 21:03:08 -0700 Subject: [PATCH 2/3] finish implementing open time modules --- README.md | 1 + opentimelineio/src/opentime/mod.rs | 3 + .../src/opentime/optional_open_time.rs | 186 +++++++++++ opentimelineio/src/opentime/rational_time.rs | 9 + opentimelineio/src/opentime/time_range.rs | 303 ++++++++++++++++++ opentimelineio/src/opentime/time_transform.rs | 128 ++++++++ 6 files changed, 630 insertions(+) create mode 100644 opentimelineio/src/opentime/optional_open_time.rs create mode 100644 opentimelineio/src/opentime/time_range.rs create mode 100644 opentimelineio/src/opentime/time_transform.rs diff --git a/README.md b/README.md index ff25ba5..9740718 100644 --- a/README.md +++ b/README.md @@ -38,5 +38,6 @@ Testing ```bash clear && LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/otio/lib:/opt/otio/lib64 cargo llvm-cov --html +clear && LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/otio/lib:/opt/otio/lib64 cargo valgrind test ``` diff --git a/opentimelineio/src/opentime/mod.rs b/opentimelineio/src/opentime/mod.rs index 0bd9438..f57cf91 100644 --- a/opentimelineio/src/opentime/mod.rs +++ b/opentimelineio/src/opentime/mod.rs @@ -1,2 +1,5 @@ pub mod error_status; +pub mod optional_open_time; pub mod rational_time; +pub mod time_range; +pub mod time_transform; diff --git a/opentimelineio/src/opentime/optional_open_time.rs b/opentimelineio/src/opentime/optional_open_time.rs new file mode 100644 index 0000000..552f8a3 --- /dev/null +++ b/opentimelineio/src/opentime/optional_open_time.rs @@ -0,0 +1,186 @@ +use super::rational_time::RationalTime; +use super::time_range::TimeRange; +use opentimelineio_sys as sys; + +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum OptionalRationalTime { + Valid(RationalTime), + Invalid, +} + +impl std::convert::From for OptionalRationalTime { + fn from(optional_rational_time: sys::OptionalRationalTime) -> Self { + if optional_rational_time.valid { + Self::Valid(optional_rational_time.value.into()) + } else { + Self::Invalid + } + } +} + +impl std::convert::Into for OptionalRationalTime { + fn into(self) -> sys::OptionalRationalTime { + match self { + Self::Valid(rational_time) => unsafe { + sys::OptionalRationalTime_create(rational_time.into()) + }, + // SAFETY: The create_null's value field is unset, so accessing that + // is undefined. + Self::Invalid => unsafe { sys::OptionalRationalTime_create_null() }, + } + } +} + +impl std::default::Default for OptionalRationalTime { + fn default() -> Self { + Self::Invalid + } +} + +impl OptionalRationalTime { + pub fn new(rational_time: RationalTime) -> Self { + unsafe { sys::OptionalRationalTime_create(rational_time.into()) }.into() + } + + pub fn is_valid(&self) -> bool { + match self { + Self::Valid(_) => true, + Self::Invalid => false, + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum OptionalTimeRange { + Valid(TimeRange), + Invalid, +} + +impl std::convert::From for OptionalTimeRange { + fn from(optional_time_range: sys::OptionalTimeRange) -> Self { + if optional_time_range.valid { + Self::Valid(optional_time_range.value.into()) + } else { + Self::Invalid + } + } +} + +impl std::convert::Into for OptionalTimeRange { + fn into(self) -> sys::OptionalTimeRange { + match self { + Self::Valid(time_range) => sys::OptionalTimeRange { + value: time_range.into(), + valid: true, + }, + Self::Invalid => unsafe { sys::OptionalTimeRange_create_null() }, + } + } +} + +impl std::default::Default for OptionalTimeRange { + fn default() -> Self { + Self::Invalid + } +} + +impl OptionalTimeRange { + pub fn new(time_range: TimeRange) -> Self { + unsafe { sys::OptionalTimeRange_create(time_range.into()) }.into() + } + + pub fn is_valid(&self) -> bool { + match self { + Self::Valid(_) => true, + Self::Invalid => false, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_optional_rational_time_new_success() { + let optional_rational_time = OptionalRationalTime::new(RationalTime::new(0.0, 1.0)); + assert_eq!( + optional_rational_time, + OptionalRationalTime::Valid(RationalTime::new(0.0, 1.0)) + ); + assert!(optional_rational_time.is_valid()); + + let optional_rational_time = OptionalRationalTime::default(); + assert_eq!(optional_rational_time, OptionalRationalTime::Invalid); + assert!(!optional_rational_time.is_valid()); + } + + #[test] + fn test_optional_rational_time_into_sys() { + let optional_rational_time = OptionalRationalTime::new(RationalTime::new(0.0, 1.0)); + let sys_optional_rational_time: sys::OptionalRationalTime = optional_rational_time.into(); + + assert_eq!(sys_optional_rational_time.value.value, 0.0); + assert_eq!(sys_optional_rational_time.value.rate, 1.0); + assert_eq!(sys_optional_rational_time.valid, true); + + let optional_rational_time = OptionalRationalTime::default(); + let sys_optional_rational_time: sys::OptionalRationalTime = optional_rational_time.into(); + + assert_eq!(sys_optional_rational_time.valid, false); + } + + #[test] + fn test_optional_rational_time_from_invalid() { + let sys_optional_rational_time = unsafe { sys::OptionalRationalTime_create_null() }; + let optional_rational_time: OptionalRationalTime = sys_optional_rational_time.into(); + + assert_eq!(optional_rational_time, OptionalRationalTime::Invalid); + } + + #[test] + fn test_optional_time_range_new_success() { + let optional_time_range = OptionalTimeRange::new(TimeRange::new( + RationalTime::new(0.0, 1.0), + RationalTime::new(1.0, 1.0), + )); + assert_eq!( + optional_time_range, + OptionalTimeRange::Valid(TimeRange::new( + RationalTime::new(0.0, 1.0), + RationalTime::new(1.0, 1.0), + )) + ); + assert!(optional_time_range.is_valid()); + + let optional_time_range = OptionalTimeRange::default(); + assert_eq!(optional_time_range, OptionalTimeRange::Invalid); + assert!(!optional_time_range.is_valid()); + } + + #[test] + fn test_optional_time_range_into_sys() { + let optional_time_range = OptionalTimeRange::new(TimeRange::new( + RationalTime::new(0.0, 1.0), + RationalTime::new(1.0, 1.0), + )); + let sys_optional_time_range: sys::OptionalTimeRange = optional_time_range.into(); + assert_eq!(sys_optional_time_range.value.start_time.value, 0.0); + assert_eq!(sys_optional_time_range.value.start_time.rate, 1.0); + assert_eq!(sys_optional_time_range.value.duration.value, 1.0); + assert_eq!(sys_optional_time_range.value.duration.rate, 1.0); + assert_eq!(sys_optional_time_range.valid, true); + + let optional_time_range = OptionalTimeRange::default(); + let sys_optional_time_range: sys::OptionalTimeRange = optional_time_range.into(); + assert_eq!(sys_optional_time_range.valid, false); + } + + #[test] + fn test_optional_time_range_from_invalid() { + let sys_optional_time_range = unsafe { sys::OptionalTimeRange_create_null() }; + let optional_time_range: OptionalTimeRange = sys_optional_time_range.into(); + + assert_eq!(optional_time_range, OptionalTimeRange::Invalid); + } +} diff --git a/opentimelineio/src/opentime/rational_time.rs b/opentimelineio/src/opentime/rational_time.rs index c45d2b1..1274acd 100644 --- a/opentimelineio/src/opentime/rational_time.rs +++ b/opentimelineio/src/opentime/rational_time.rs @@ -58,6 +58,15 @@ impl std::convert::Into for RationalTime { } } +impl std::default::Default for RationalTime { + fn default() -> Self { + Self { + value: 0.0, + rate: 1.0, + } + } +} + // TODO: Most of the unsafe APIs can be replaced with native Rust. The only real // exceptions would be string -> RationalTime -> string conversions. impl RationalTime { diff --git a/opentimelineio/src/opentime/time_range.rs b/opentimelineio/src/opentime/time_range.rs new file mode 100644 index 0000000..960f8f5 --- /dev/null +++ b/opentimelineio/src/opentime/time_range.rs @@ -0,0 +1,303 @@ +use super::rational_time::RationalTime; +use opentimelineio_sys as sys; + +#[derive(Debug, Clone, Copy)] +pub struct TimeRange { + pub start_time: RationalTime, + pub duration: RationalTime, +} + +impl std::convert::From for TimeRange { + fn from(time_range: sys::TimeRange) -> Self { + Self { + start_time: time_range.start_time.into(), + duration: time_range.duration.into(), + } + } +} + +impl std::convert::Into for TimeRange { + fn into(self) -> sys::TimeRange { + sys::TimeRange { + start_time: self.start_time.into(), + duration: self.duration.into(), + } + } +} + +impl std::default::Default for TimeRange { + fn default() -> Self { + unsafe { sys::TimeRange_create() }.into() + } +} + +// TODO: Most of the unsafe APIs can be replaced with native Rust. +impl TimeRange { + pub fn new(start_time: RationalTime, duration: RationalTime) -> Self { + unsafe { + sys::TimeRange_create_with_start_time_and_duration(start_time.into(), duration.into()) + } + .into() + } + + pub fn with_start_time(start_time: RationalTime) -> Self { + unsafe { sys::TimeRange_create_with_start_time(start_time.into()) }.into() + } + + pub fn with_duration(duration: RationalTime) -> Self { + unsafe { sys::TimeRange_create_with_duration(duration.into()) }.into() + } + + pub fn from_start_and_end_time( + start_time: RationalTime, + end_time_exclusive: RationalTime, + ) -> Self { + unsafe { + sys::TimeRange_range_from_start_end_time(start_time.into(), end_time_exclusive.into()) + } + .into() + } + + pub fn end_time_inclusive(&self) -> RationalTime { + unsafe { sys::TimeRange_end_time_inclusive(self.to_owned().into()) }.into() + } + + pub fn end_time_exclusive(&self) -> RationalTime { + unsafe { sys::TimeRange_end_time_exclusive(self.to_owned().into()) }.into() + } + + pub fn duration_extended_by(&self, other: RationalTime) -> Self { + unsafe { sys::TimeRange_duration_extended_by(self.to_owned().into(), other.into()) }.into() + } + + pub fn extended_by(&self, other: Self) -> Self { + unsafe { sys::TimeRange_extended_by(self.to_owned().into(), other.into()) }.into() + } + + pub fn clamped_with_rational_time(&self, other: RationalTime) -> RationalTime { + unsafe { sys::TimeRange_clamped_with_rational_time(self.to_owned().into(), other.into()) } + .into() + } + + pub fn clamped_with_time_range(&self, other: Self) -> Self { + unsafe { sys::TimeRange_clamped_with_time_range(self.to_owned().into(), other.into()) } + .into() + } + + pub fn contains_rational_time(&self, other: RationalTime) -> bool { + unsafe { sys::TimeRange_contains_rational_time(self.to_owned().into(), other.into()) } + } + pub fn contains_time_range(&self, other: Self) -> bool { + unsafe { sys::TimeRange_contains_time_range(self.to_owned().into(), other.into()) } + } + + pub fn overlaps_rational_time(&self, other: RationalTime) -> bool { + unsafe { sys::TimeRange_overlaps_rational_time(self.to_owned().into(), other.into()) } + } + pub fn overlaps_time_range(&self, other: Self) -> bool { + unsafe { sys::TimeRange_overlaps_time_range(self.to_owned().into(), other.into()) } + } +} + +impl std::cmp::PartialEq for TimeRange { + fn eq(&self, other: &Self) -> bool { + unsafe { sys::TimeRange_equal(self.to_owned().into(), other.to_owned().into()) } + } + + fn ne(&self, other: &Self) -> bool { + unsafe { sys::TimeRange_not_equal(self.to_owned().into(), other.to_owned().into()) } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_time_range_default_success() { + let time_range = TimeRange::default(); + assert_eq!(time_range.start_time, RationalTime::default()); + assert_eq!(time_range.duration, RationalTime::default()); + } + + #[test] + fn test_time_range_new_success() { + let start_time = RationalTime::new(2.0, 1.0); + let duration = RationalTime::new(100.0, 1.0); + + let time_range = TimeRange::new(start_time, duration); + + assert_eq!(time_range.start_time, start_time); + assert_eq!(time_range.duration, duration); + } + + #[test] + fn test_time_range_with_start_time_success() { + let start_time = RationalTime::new(2.0, 1.0); + let time_range = TimeRange::with_start_time(start_time); + + assert_eq!(time_range.start_time, start_time); + assert_eq!(time_range.duration, RationalTime::new(0.0, 1.0)); + } + + #[test] + fn test_time_range_with_duration_success() { + let duration = RationalTime::new(2.0, 1.0); + let time_range = TimeRange::with_duration(duration); + + assert_eq!(time_range.start_time, RationalTime::new(0.0, 1.0)); + assert_eq!(time_range.duration, duration); + } + + #[test] + fn test_time_range_from_start_and_end_time_success() { + let start_time = RationalTime::new(0.0, 1.0); + let end_time = RationalTime::new(1.0, 1.0); + let time_range = TimeRange::from_start_and_end_time(start_time, end_time); + + assert_eq!(time_range.start_time, start_time); + assert_eq!(time_range.duration, RationalTime::new(1.0, 1.0)); + } + + #[test] + fn test_time_range_end_time_inclusive_success() { + let time_range = TimeRange::new(RationalTime::new(0.0, 1.0), RationalTime::new(1.0, 1.0)); + + assert_eq!(time_range.end_time_inclusive(), RationalTime::new(0.0, 1.0)); + } + + #[test] + fn test_time_range_end_time_exclusive_success() { + let time_range = TimeRange::new(RationalTime::new(0.0, 1.0), RationalTime::new(1.0, 1.0)); + + assert_eq!(time_range.end_time_exclusive(), RationalTime::new(1.0, 1.0)); + } + + #[test] + fn test_time_range_duration_extended_by_success() { + let time_range = TimeRange::new(RationalTime::new(0.0, 1.0), RationalTime::new(1.0, 1.0)); + let result = time_range.duration_extended_by(RationalTime::new(1.0, 1.0)); + + assert_eq!(result.start_time, time_range.start_time); + assert_eq!(result.duration, RationalTime::new(2.0, 1.0)); + } + + #[test] + fn test_time_range_extended_by_success() { + let time_range = TimeRange::new(RationalTime::new(0.0, 1.0), RationalTime::new(1.0, 1.0)); + let other = TimeRange::new(RationalTime::new(0.0, 1.0), RationalTime::new(2.0, 1.0)); + let result = time_range.extended_by(other); + + assert_eq!(result.start_time, time_range.start_time); + assert_eq!(result.duration, RationalTime::new(2.0, 1.0)); + } + + #[test] + fn test_time_range_clamped_with_rational_time_success() { + let time_range = TimeRange::new(RationalTime::new(1.0, 1.0), RationalTime::new(2.0, 1.0)); + let result = time_range.clamped_with_rational_time(RationalTime::new(1.5, 1.0)); + + assert_eq!(result.value, 1.5); + assert_eq!(result.rate, 1.0); + + let time_range = TimeRange::new(RationalTime::new(1.0, 1.0), RationalTime::new(2.0, 1.0)); + let result = time_range.clamped_with_rational_time(RationalTime::new(0.5, 1.0)); + + assert_eq!(result.value, 1.0); + assert_eq!(result.rate, 1.0); + } + + #[test] + fn test_time_range_clamped_with_time_range_success() { + let time_range = TimeRange::new(RationalTime::new(1.0, 1.0), RationalTime::new(2.0, 1.0)); + let result = time_range.clamped_with_time_range(TimeRange::new( + RationalTime::new(1.5, 1.0), + RationalTime::new(2.0, 1.0), + )); + + assert_eq!(result.start_time, RationalTime::new(1.5, 1.0)); + assert_eq!(result.duration, RationalTime::new(1.5, 1.0)); + + let time_range = TimeRange::new(RationalTime::new(1.0, 1.0), RationalTime::new(2.0, 1.0)); + let result = time_range.clamped_with_time_range(TimeRange::new( + RationalTime::new(0.5, 1.0), + RationalTime::new(2.0, 1.0), + )); + + assert_eq!(result.start_time, RationalTime::new(1.0, 1.0)); + assert_eq!(result.duration, RationalTime::new(2.0, 1.0)); + } + + #[test] + fn test_time_range_contains_rational_time_success() { + let time_range = TimeRange::new(RationalTime::new(0.0, 1.0), RationalTime::new(1.0, 1.0)); + let result = time_range.contains_rational_time(RationalTime::new(0.5, 1.0)); + + assert!(result); + + let time_range = TimeRange::new(RationalTime::new(0.0, 1.0), RationalTime::new(1.0, 1.0)); + let result = time_range.contains_rational_time(RationalTime::new(1.5, 1.0)); + + assert!(!result); + } + + #[test] + fn test_time_range_contains_time_range_success() { + let time_range = TimeRange::new(RationalTime::new(0.0, 1.0), RationalTime::new(1.0, 1.0)); + let result = time_range.contains_time_range(TimeRange::new( + RationalTime::new(0.5, 1.0), + RationalTime::new(0.1, 1.0), + )); + + assert!(result); + + let time_range = TimeRange::new(RationalTime::new(0.0, 1.0), RationalTime::new(1.0, 1.0)); + let result = time_range.contains_time_range(TimeRange::new( + RationalTime::new(2.0, 1.0), + RationalTime::new(1.0, 1.0), + )); + + assert!(!result); + } + + #[test] + fn test_time_range_overlaps_rational_time_success() { + let time_range = TimeRange::new(RationalTime::new(0.0, 1.0), RationalTime::new(1.0, 1.0)); + let result = time_range.overlaps_rational_time(RationalTime::new(0.5, 1.0)); + + assert!(result); + + let time_range = TimeRange::new(RationalTime::new(0.0, 1.0), RationalTime::new(1.0, 1.0)); + let result = time_range.overlaps_rational_time(RationalTime::new(1.5, 1.0)); + + assert!(!result); + } + + #[test] + fn test_time_range_overlaps_time_range_success() { + // TODO: This always returns false, no matter what values I put in. + let time_range = TimeRange::new(RationalTime::new(0.0, 1.0), RationalTime::new(1.0, 1.0)); + let result = time_range.overlaps_time_range(TimeRange::new( + RationalTime::new(0.0, 1.0), + RationalTime::new(1.0, 1.0), + )); + + assert!(!result); + + let time_range = TimeRange::new(RationalTime::new(0.0, 1.0), RationalTime::new(1.0, 1.0)); + let result = time_range.overlaps_time_range(TimeRange::new( + RationalTime::new(-1.0, 1.0), + RationalTime::new(2.0, 1.0), + )); + + assert!(!result); + + let time_range = TimeRange::new(RationalTime::new(0.0, 1.0), RationalTime::new(1.0, 1.0)); + let result = time_range.overlaps_time_range(TimeRange::new( + RationalTime::new(0.5, 1.0), + RationalTime::new(0.1, 1.0), + )); + + assert!(!result); + } +} diff --git a/opentimelineio/src/opentime/time_transform.rs b/opentimelineio/src/opentime/time_transform.rs new file mode 100644 index 0000000..21a1505 --- /dev/null +++ b/opentimelineio/src/opentime/time_transform.rs @@ -0,0 +1,128 @@ +use super::rational_time::RationalTime; +use super::time_range::TimeRange; +use opentimelineio_sys as sys; + +#[derive(Debug, Copy, Clone)] +pub struct TimeTransform { + pub offset: RationalTime, + pub scale: f64, + pub rate: f64, +} + +impl std::convert::From for TimeTransform { + fn from(time_transform: sys::TimeTransform) -> Self { + Self { + offset: time_transform.offset.into(), + scale: time_transform.scale, + rate: time_transform.rate, + } + } +} + +impl std::convert::Into for TimeTransform { + fn into(self) -> sys::TimeTransform { + sys::TimeTransform { + offset: self.offset.into(), + scale: self.scale, + rate: self.rate, + } + } +} + +impl std::default::Default for TimeTransform { + fn default() -> Self { + unsafe { sys::TimeTransform_create() }.into() + } +} + +impl std::cmp::PartialEq for TimeTransform { + fn eq(&self, other: &Self) -> bool { + unsafe { sys::TimeTransform_equal(self.to_owned().into(), other.to_owned().into()) } + } + + fn ne(&self, other: &Self) -> bool { + unsafe { sys::TimeTransform_not_equal(self.to_owned().into(), other.to_owned().into()) } + } +} + +impl TimeTransform { + pub fn new(offset: RationalTime, scale: f64, rate: f64) -> Self { + unsafe { sys::TimeTransform_create_with_offset_scale_rate(offset.into(), scale, rate) } + .into() + } + + pub fn applied_to_rational_time(&self, other: RationalTime) -> RationalTime { + unsafe { sys::TimeTransform_applied_to_rational_time(self.to_owned().into(), other.into()) } + .into() + } + + pub fn applied_to_time_range(&self, other: TimeRange) -> TimeRange { + unsafe { sys::TimeTransform_applied_to_time_range(self.to_owned().into(), other.into()) } + .into() + } + + pub fn applied_to_time_transform(&self, other: Self) -> Self { + unsafe { + sys::TimeTransform_applied_to_time_transform(self.to_owned().into(), other.into()) + } + .into() + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_time_transform_new_success() { + let time_transform = TimeTransform::new(RationalTime::new(2.0, 1.0), 2.0, 3.0); + assert_eq!(time_transform.offset, RationalTime::new(2.0, 1.0)); + assert_eq!(time_transform.scale, 2.0); + assert_eq!(time_transform.rate, 3.0); + } + + #[test] + fn test_time_transform_default_success() { + let time_transform = TimeTransform::default(); + assert_eq!(time_transform.offset, RationalTime::new(0.0, 1.0)); + assert_eq!(time_transform.scale, 1.0); + assert_eq!(time_transform.rate, -1.0); + } + + #[test] + fn test_time_transform_applied_to_rational_time_success() { + let time_transform = TimeTransform::new(RationalTime::new(2.0, 1.0), 2.0, 3.0); + let result = time_transform.applied_to_rational_time(RationalTime::new(0.0, 1.0)); + + assert_eq!(result, RationalTime::new(6.0, 3.0)); + } + + #[test] + fn test_time_transform_applied_to_time_range_success() { + let time_transform = TimeTransform::new(RationalTime::new(2.0, 1.0), 2.0, 3.0); + let result = time_transform.applied_to_time_range(TimeRange::new( + RationalTime::new(0.0, 1.0), + RationalTime::new(1.0, 1.0), + )); + + assert_eq!( + result, + TimeRange::new(RationalTime::new(6.0, 3.0), RationalTime::new(6.0, 3.0)) + ); + } + + #[test] + fn test_time_transform_applied_to_time_transform_success() { + let time_transform = TimeTransform::new(RationalTime::new(2.0, 1.0), 2.0, 3.0); + let result = time_transform.applied_to_time_transform(TimeTransform::new( + RationalTime::new(2.0, 1.0), + 2.0, + 3.0, + )); + + assert_eq!( + result, + TimeTransform::new(RationalTime::new(4.0, 1.0), 4.0, 3.0) + ); + } +} From 494ebec4b0c69afd0641b9aa1b39ce5db93e849a Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Fri, 23 Sep 2022 18:36:40 -0700 Subject: [PATCH 3/3] sort includes --- opentimelineio-sys/src/lib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opentimelineio-sys/src/lib.h b/opentimelineio-sys/src/lib.h index 22b9793..ecd2781 100644 --- a/opentimelineio-sys/src/lib.h +++ b/opentimelineio-sys/src/lib.h @@ -9,8 +9,8 @@ #include #include -#include #include +#include #include #include #include @@ -43,12 +43,12 @@ #include #include #include -#include #include +#include #include #include -#include #include +#include #include #include #include