refactor(task): de-Qt oaktask base + project tasks, wire codec task submitter
- Task base: Qt signals become lifecycle listeners (the async-command callback exception), cancellation uses oakrender's OakCancelAtom C handle; TaskManager runs std::thread workers, no signals - ConformTask/ProxyTask implement oakcodec's submit-callback contract (synchronous interim); register_codec_task_submitter() closes the conform/proxy loop - conform of demo.mp4 produces pcm caches in tests - ProjectImportTask/ProjectLoadTask/ProjectSaveTask over the oaknode C ABI; image-sequence confirmation becomes a facade callback (default: not a sequence) - C API additions needed by oaktask: oaknode serializer file-level save/load (auto-initializing), footage video-params/cancel-atom/ as-node, folder add-child command factory; oakcodec decoder conform_audio + image-sequence helpers; oakrender cancelatom get_native - fix double-ownership: submitting a task to the manager transfers ownership, freeing its handle only releases the wrapper - C ABI in include/task (task/manager/project, OakTaskTask opaque handle + lifecycle subscribe), every function tested (103 cases in build-oaktask incl. regressions) - RenderTask family and OTIO tasks follow in separate commits
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "node/folder.h"
|
||||
|
||||
#include "../../undo/c_api/commandhandle.h"
|
||||
|
||||
#include <new>
|
||||
|
||||
#include "../src/project.h"
|
||||
@@ -230,3 +232,30 @@ OakNodeFolder *oaknode_folder_parent_of(const OakNodeNode *node)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
OakNodeNode *oaknode_folder_as_node(OakNodeFolder *folder)
|
||||
{
|
||||
return reinterpret_cast<OakNodeNode *>(folder);
|
||||
}
|
||||
|
||||
OakUndoCommand *oaknode_command_create_folder_add_child(
|
||||
OakNodeFolder *folder, OakNodeNode *child)
|
||||
{
|
||||
if (!folder || !child) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
try {
|
||||
OakUndoCommand *handle =
|
||||
new (std::nothrow) OakUndoCommand{ nullptr, true };
|
||||
if (!handle) {
|
||||
return NULL;
|
||||
}
|
||||
handle->command = new olive::FolderAddChild(
|
||||
reinterpret_cast<olive::Folder *>(folder),
|
||||
reinterpret_cast<olive::Node *>(child));
|
||||
return handle;
|
||||
} catch (...) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
|
||||
#include "node/footage.h"
|
||||
|
||||
#include "common/videoparams.h"
|
||||
#include "../../../include/render/cancelatom.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <new>
|
||||
#include <string>
|
||||
@@ -320,3 +323,78 @@ int oaknode_footage_clear_proxy(OakNodeFootage *footage)
|
||||
return OAKNODE_E_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
int oaknode_footage_get_video_params(OakNodeFootage *footage, int index,
|
||||
OakVideoParams *out)
|
||||
{
|
||||
olive::Footage *f = to_cpp(footage);
|
||||
if (!f || !out || index < 0) {
|
||||
return OAKNODE_E_INVALID;
|
||||
}
|
||||
|
||||
try {
|
||||
olive::VideoParams vp = f->get_video_params(index);
|
||||
if (!vp.is_valid() && index >= f->input_array_size(
|
||||
olive::ViewerOutput::k_video_params_input)) {
|
||||
return OAKNODE_E_NOT_FOUND;
|
||||
}
|
||||
*out = oakcommon_videoparams_init_from_native(&vp);
|
||||
return out->ctx ? OAKNODE_OK : OAKNODE_E_NOMEM;
|
||||
} catch (...) {
|
||||
return OAKNODE_E_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
int oaknode_footage_set_video_params(OakNodeFootage *footage, int index,
|
||||
const OakVideoParams *params)
|
||||
{
|
||||
olive::Footage *f = to_cpp(footage);
|
||||
if (!f || !params || !params->ctx) {
|
||||
return OAKNODE_E_INVALID;
|
||||
}
|
||||
|
||||
const olive::VideoParams *native =
|
||||
oakcommon_videoparams_get_native(*params);
|
||||
if (!native) {
|
||||
return OAKNODE_E_INVALID;
|
||||
}
|
||||
|
||||
try {
|
||||
f->set_video_params(*native, index);
|
||||
return OAKNODE_OK;
|
||||
} catch (...) {
|
||||
return OAKNODE_E_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
int oaknode_footage_get_video_length(OakNodeFootage *footage,
|
||||
int64_t *out_num, int64_t *out_den)
|
||||
{
|
||||
olive::Footage *f = to_cpp(footage);
|
||||
if (!f || !out_num || !out_den) {
|
||||
return OAKNODE_E_INVALID;
|
||||
}
|
||||
|
||||
olive::core::Rational len = f->get_video_length();
|
||||
*out_num = len.numerator();
|
||||
*out_den = len.denominator();
|
||||
return OAKNODE_OK;
|
||||
}
|
||||
|
||||
int oaknode_footage_set_cancel_atom(OakNodeFootage *footage,
|
||||
OakCancelAtom atom)
|
||||
{
|
||||
olive::Footage *f = to_cpp(footage);
|
||||
if (!f) {
|
||||
return OAKNODE_E_INVALID;
|
||||
}
|
||||
|
||||
f->set_cancel_pointer(
|
||||
atom.ctx ? oakrender_cancelatom_get_native(atom) : nullptr);
|
||||
return OAKNODE_OK;
|
||||
}
|
||||
|
||||
OakNodeNode *oaknode_footage_as_node(OakNodeFootage *footage)
|
||||
{
|
||||
return reinterpret_cast<OakNodeNode *>(footage);
|
||||
}
|
||||
|
||||
@@ -355,3 +355,78 @@ int oaknode_serializer_loaddata_connection_at(
|
||||
return OAKNODE_E_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
int report_serializer_result(const olive::ProjectSerializer::Result &result,
|
||||
int *out_code, char *details, int details_size)
|
||||
{
|
||||
if (out_code) {
|
||||
*out_code = int(result.code());
|
||||
}
|
||||
|
||||
int needed = 0;
|
||||
if (details || details_size > 0) {
|
||||
std::string d = result.get_details();
|
||||
needed = int(d.size()) + 1;
|
||||
if (details && details_size >= needed) {
|
||||
memcpy(details, d.c_str(), needed);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.code() == olive::ProjectSerializer::k_success) {
|
||||
return OAKNODE_OK;
|
||||
}
|
||||
return (details && details_size > 0) ? needed : OAKNODE_E_FAILED;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int oaknode_serializer_save_to_file(OakNodeProject *project,
|
||||
const char *filename, int use_compression, int *out_code,
|
||||
char *details, int details_size)
|
||||
{
|
||||
if (!project || !filename) {
|
||||
return OAKNODE_E_INVALID;
|
||||
}
|
||||
|
||||
try {
|
||||
oaknode_serializer_initialize();
|
||||
|
||||
olive::ProjectSerializer::SaveData data(
|
||||
olive::ProjectSerializer::k_project,
|
||||
reinterpret_cast<olive::Project *>(project), filename);
|
||||
|
||||
olive::ProjectSerializer::Result result =
|
||||
olive::ProjectSerializer::save(data, use_compression != 0);
|
||||
|
||||
return report_serializer_result(result, out_code, details,
|
||||
details_size);
|
||||
} catch (...) {
|
||||
return OAKNODE_E_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
int oaknode_serializer_load_from_file(OakNodeProject *project,
|
||||
const char *filename, int *out_code, char *details,
|
||||
int details_size)
|
||||
{
|
||||
if (!project || !filename) {
|
||||
return OAKNODE_E_INVALID;
|
||||
}
|
||||
|
||||
try {
|
||||
oaknode_serializer_initialize();
|
||||
|
||||
olive::ProjectSerializer::Result result =
|
||||
olive::ProjectSerializer::load(
|
||||
reinterpret_cast<olive::Project *>(project), filename,
|
||||
olive::ProjectSerializer::k_project);
|
||||
|
||||
return report_serializer_result(result, out_code, details,
|
||||
details_size);
|
||||
} catch (...) {
|
||||
return OAKNODE_E_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user