+/**
+ * Callbacks provided by the user of the mp4 parsing API.
+ *
+ * A pointer to this structure is passed to the two public open functions. If
+ * the file is opened in read-only mode, the ->write() and ->truncate() methods
+ * won't be called and may thus be NULL. The ->read() and ->seek() methods
+ * must be supplied for either open type.
+ *
+ * All methods are supposed to work like their corresponding system calls.
+ * That is, they should return non-negative for success and -1 on failure. In
+ * the error case errno is expected to be set accordingly.
+ *
+ * \sa \ref mp4_open(), \ref mp4_open_meta().
+ */
+struct mp4_callback {
+ /** This pointer is propagated to each call of all methods. */
+ void *user_data;
+ /**
+ * This should return the number of bytes read on success. Short reads
+ * are OK: the function may return less than length.
+ */
+ ssize_t (*read)(void *user_data, void *buffer, size_t length);
+ /**
+ * This method is assumed to succeed. The implementation should simply
+ * abort on errors. Note that offsets beyond EOF must not be regarded
+ * as invalid arguments.
+ */
+ off_t (*seek)(void *user_data, off_t offset, int whence);
+ /**
+ * Like the write() system call, this should return the number of bytes
+ * written. Short writes are OK: the function may return less than
+ * count.
+ */
+ ssize_t (*write)(void *user_data, void *buffer, size_t count);
+ /**
+ * Unlike the truncate system call, this function does not receive an
+ * offset. The method is expected to truncate the file to the offset
+ * given by the current file position instead.
+ */
+ int (*truncate)(void *user_data);