Centralize legacy video export bridge

This commit is contained in:
2026-06-04 14:11:24 +02:00
parent 78003923ca
commit ca5b94b044
8 changed files with 259 additions and 16 deletions

View File

@@ -4,6 +4,9 @@
#include "app.h"
#include <string>
#include <thread>
namespace pp::panopainter {
namespace {
@@ -105,6 +108,65 @@ private:
App& app_;
};
class LegacyDocumentVideoExportServices final : public pp::app::DocumentVideoExportServices {
public:
LegacyDocumentVideoExportServices(App& app, bool asynchronous) noexcept
: app_(app)
, asynchronous_(asynchronous)
{
}
void export_animation_mp4(std::string_view path) override
{
auto* app = &app_;
auto path_string = std::string(path);
if (asynchronous_) {
Canvas::I->export_anim_mp4(path_string, [app, path_string] {
app->message_box("Export Animation", "Animation exported to: " + path_string);
});
return;
}
Canvas::I->export_anim_mp4(path_string, [app] {
app->message_box("Export Animation", "Animation exported successfully.");
});
}
void export_timelapse_mp4(std::string_view path) override
{
auto* app = &app_;
auto path_string = std::string(path);
if (asynchronous_) {
std::thread([app, path_string] {
BT_SetTerminate();
app->rec_export(path_string);
app->message_box("Export Timelapse", "Timelapse exported to: " + path_string);
}).detach();
return;
}
app->rec_export(path_string);
}
void show_animation_export_success(std::string_view path) override
{
(void)path;
}
void show_timelapse_export_success(std::string_view path) override
{
if (asynchronous_) {
(void)path;
} else {
app_.message_box("Export Timelapse", "Timelapse exported successfully.");
}
}
private:
App& app_;
bool asynchronous_ = false;
};
} // namespace
pp::foundation::Status execute_legacy_document_export_file(
@@ -149,4 +211,14 @@ pp::foundation::Status execute_legacy_document_export_cube_faces(
return pp::app::execute_document_export_cube_faces(document_name, services);
}
pp::foundation::Status execute_legacy_document_video_export(
App& app,
pp::app::DocumentVideoExportKind kind,
std::string_view path,
bool asynchronous)
{
LegacyDocumentVideoExportServices services(app, asynchronous);
return pp::app::execute_document_video_export(kind, path, services);
}
} // namespace pp::panopainter