Files
oak-editor/include/render/manager.h
T
Mike-Solar edbd3913af refactor(render): de-Qt oakrender and wrap it in a pure C ABI
- copy engine/render to src/render/src (sunk param types excluded),
  de-Qt in five parallel groups: core machinery (tickets/worker pool/
  jobs), caches, color/texture, preview/IPC, GPU backends
- replace Qt GL/Vulkan wrappers with native context abstractions
  (CGL/EGL/WGL, raw vulkan.h), QProcess with POSIX WorkerProcess,
  QJsonObject with a minimal NDJSON-compatible workerjson (wire
  protocol unchanged), QDataStream disk state with a byte-compatible
  BinaryStream
- signals become single std::function callbacks or facade-triggered
  calls per the documented signal/slot strategy
- pure C ABI in include/render + src/render/c_api (renderer/cache/
  color/manager families, OAKRENDER_E_* codes), 37 gtest cases
- bridge src/node/transition/render/* stubs to the real oakrender
  headers, closing the node<->render cycle: liboaknode links
  liboakrender, zero dangling symbols
- docs: M7 implementation status + oakrender semantic-change notes
2026-08-06 03:21:26 +08:00

158 lines
5.1 KiB
C

/***
Oak Video Editor - Non-Linear Video Editor
Copyright (C) 2026 Oak Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef OAK_EDITOR_RENDER_MANAGER_H
#define OAK_EDITOR_RENDER_MANAGER_H
#include <stdint.h>
// See cache.h for why these are same-dir relative includes.
#include "cache.h" /* OakCodecFrame */
#include "color.h" /* OakColorProcessor */
#include "error.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @file manager.h
* @brief C ABI for the oakrender render manager / preview auto-cacher /
* disk cache singletons (olive::RenderManager,
* olive::PreviewAutoCacher, olive::DiskManager), M7 §2.4.
*
* The render manager is a process-wide singleton gated by
* oakrender_manager_init() / oakrender_manager_shutdown(). Functions
* that need it return OAKRENDER_E_STATE when it is not up.
*
* The frame request callback is the asynchronous command return channel
* (M7 §2.2 note): it fires on a render worker thread, possibly after
* cancellation. The delivered OakCodecFrame is owned by the callback
* recipient (release with oakrender_codec_frame_free()); a NULL frame
* signals "no result" (cancelled or failed). Beyond this callback there
* are no event subscription interfaces.
*/
/**
* @brief Borrowed node handle (olive::Node) from the oaknode ABI,
* re-declared here so this header is self-contained.
*/
typedef struct OakNodeNode OakNodeNode;
/**
* @brief Create the RenderManager singleton (spawns render/audio
* threads, loads the configured backend).
*
* @return OAKRENDER_OK, OAKRENDER_E_STATE (already initialized), or
* OAKRENDER_E_FAILED.
*/
int oakrender_manager_init(void);
/**
* @brief Destroy the RenderManager singleton. No-op when not
* initialized.
*/
void oakrender_manager_shutdown(void);
/**
* @brief Completion callback of an asynchronous frame request.
*
* @param frame Owned frame handle, or NULL when the request finished
* without a result (cancelled/failed).
* @param ts The request's timestamp, passed back verbatim.
*/
typedef void (*oakrender_frame_ready_fn)(OakCodecFrame *frame, int64_t ts,
void *userdata);
/**
* @brief Asynchronously render one frame of `viewer` at `ts`
* (PreviewAutoCacher::get_single_frame()).
*
* `ts` is a frame number in the viewer node's video timebase (a whole
* second count when the viewer carries no valid timebase). The
* completion is delivered through `cb`; until then the request can be
* cancelled with oakrender_cancel_request().
*
* @return A positive request id, or a negative OAKRENDER_E_* code
* (OAKRENDER_E_INVALID for NULL viewer/callback,
* OAKRENDER_E_STATE when the manager is not initialized,
* OAKRENDER_E_FAILED when no ticket could be created).
*/
int64_t oakrender_request_frame(OakNodeNode *viewer, int64_t ts,
oakrender_frame_ready_fn cb, void *userdata);
/**
* @brief Cancel a pending frame request. The callback still fires with a
* NULL frame.
*
* @return OAKRENDER_OK, or OAKRENDER_E_NOT_FOUND for an unknown id.
*/
int oakrender_cancel_request(int64_t request_id);
/**
* @brief Set the multicam node on the manager's auto-cacher
* (PreviewAutoCacher::set_multicam_node()). `multicam_or_NULL` is a
* borrowed oaknode handle to a MultiCamNode (NULL to clear).
*
* @return OAKRENDER_OK or OAKRENDER_E_STATE.
*/
int oakrender_set_cacher_multicam(OakNodeNode *multicam_or_NULL);
/**
* @brief Set the display color processor on the manager's auto-cacher
* (PreviewAutoCacher::set_display_color_processor()). Borrowed handle,
* NULL to clear.
*
* @return OAKRENDER_OK or OAKRENDER_E_STATE.
*/
int oakrender_set_display_color_processor(OakColorProcessor *p_or_NULL);
/* ---- Disk cache (olive::DiskManager) -------------------------------------- */
/**
* @brief The default disk cache directory
* (DiskManager::get_default_disk_cache_path()). Two-stage string getter:
* returns the required buffer size including NUL; pass buf == NULL or
* too small a buffer to query the size. Does not require the manager.
*/
int oakrender_disk_cache_path(char *buf, int n);
/**
* @brief Bytes currently consumed by the default disk cache folder.
* Lazily creates the DiskManager singleton on first use.
*
* @return Consumption in bytes (>= 0), or OAKRENDER_E_FAILED.
*/
int64_t oakrender_disk_cache_size(void);
/**
* @brief Clear the default disk cache folder
* (DiskManager::clear_disk_cache()).
*
* @return OAKRENDER_OK or OAKRENDER_E_FAILED.
*/
int oakrender_disk_cache_clear(void);
#ifdef __cplusplus
}
#endif
#endif //OAK_EDITOR_RENDER_MANAGER_H