add: add 3 functions. Provide the way to get current audio and video params.

This commit is contained in:
2025-09-14 20:43:56 +08:00
parent a6bff4f610
commit c71b20bb95
7 changed files with 190 additions and 83 deletions
+3 -1
View File
@@ -26,7 +26,6 @@ set(OLIVE_SOURCES
add_subdirectory(audio)
add_subdirectory(cli)
add_subdirectory(codec)
add_subdirectory(common)
add_subdirectory(config)
add_subdirectory(dialog)
add_subdirectory(node)
@@ -73,7 +72,10 @@ add_library(libolive-editor
${OLIVE_SOURCES}
${OLIVE_RESOURCES}
)
add_subdirectory(common)
add_subdirectory(pluginSupport)
target_compile_features(libolive-editor PUBLIC cxx_std_23)
include_directories(../third_party/openfx/include
../third_party/openfx/HostSupport/include)
+39 -39
View File
@@ -14,43 +14,43 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
common/cancelableobject.h
common/channellayout.h
common/commandlineparser.cpp
common/commandlineparser.h
common/crashpadinterface.cpp
common/crashpadinterface.h
common/crashpadutils.h
common/debug.cpp
common/debug.h
common/decibel.h
common/define.h
common/ffmpegutils.cpp
common/ffmpegutils.h
common/filefunctions.cpp
common/filefunctions.h
common/html.cpp
common/html.h
common/jobtime.cpp
common/jobtime.h
common/lerp.h
common/memorypool.h
common/ocioutils.cpp
common/ocioutils.h
common/oiioutils.cpp
common/oiioutils.h
common/otioutils.h
common/qtutils.cpp
common/qtutils.h
common/range.h
common/ratiodialog.cpp
common/ratiodialog.h
common/threadsafemap.h
common/tohex.h
common/util.h
common/xmlutils.cpp
common/xmlutils.h
PARENT_SCOPE
target_sources(libolive-editor PRIVATE
cancelableobject.h
channellayout.h
commandlineparser.cpp
commandlineparser.h
crashpadinterface.cpp
crashpadinterface.h
crashpadutils.h
Current.cpp
Current.h
debug.cpp
debug.h
decibel.h
define.h
ffmpegutils.cpp
ffmpegutils.h
filefunctions.cpp
filefunctions.h
html.cpp
html.h
jobtime.cpp
jobtime.h
lerp.h
memorypool.h
ocioutils.cpp
ocioutils.h
oiioutils.cpp
oiioutils.h
otioutils.h
qtutils.cpp
qtutils.h
range.h
ratiodialog.cpp
ratiodialog.h
threadsafemap.h
tohex.h
util.h
xmlutils.cpp
xmlutils.h
)
+22
View File
@@ -0,0 +1,22 @@
/*
* Olive Community Edition - Non-Linear Video Editor
* Copyright (C) 2025 Olive CE 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/>.
*
*/
#include "Current.h"
Current Current::current;
+62
View File
@@ -0,0 +1,62 @@
/*
* Olive Community Edition - Non-Linear Video Editor
* Copyright (C) 2025 Olive CE 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 CURRENT_H
#define CURRENT_H
#include "render/videoparams.h"
class Current {
public:
static Current& getInstance()
{
return current;
}
olive::VideoParams& currentVideoParams()
{
return currentVideoParams_;
}
olive::AudioParams& currentAudioParams()
{
return currentAudioParams_;
}
void setCurrentVideoParams(olive::VideoParams& params)
{
currentVideoParams_ = params;
}
void setCurrentAudioParams(olive::AudioParams& params)
{
currentAudioParams_ = params;
}
void setCurrentVideoParams(olive::VideoParams&& params)
{
currentVideoParams_ = params;
}
void setCurrentAudioParams(olive::AudioParams&& params)
{
currentAudioParams_ = params;
}
private:
static Current current;
olive::VideoParams currentVideoParams_;
olive::AudioParams currentAudioParams_;
};
#endif //CURRENT_H
+54 -41
View File
@@ -18,90 +18,103 @@
#include "OliveInstance.h"
#include "ofxCore.h"
#include "ofxMessage.h"
#include "common/Current.h"
#include <cstdio>
#include <QMessageBox>
#include <qmessagebox.h>
#include <qobject.h>
#include <string.h>
#include <QString>
namespace olive{
namespace plugin {
OfxStatus OliveInstance::vmessage(const char* type,
const char* id,
const char* format,
va_list args){
namespace olive
{
namespace plugin
{
OfxStatus OliveInstance::vmessage(const char *type, const char *id,
const char *format, va_list args)
{
char *buffer = new char[1024];
char *buffer=new char[1024];
memset(buffer, 0, 1024*sizeof(char));
memset(buffer, 0, 1024 * sizeof(char));
vsprintf(buffer, format, args);
QString message(buffer);
delete [] buffer;
delete[] buffer;
if(strncmp(type, kOfxMessageQuestion, strlen(kOfxMessageQuestion))){
if (strncmp(type, kOfxMessageQuestion, strlen(kOfxMessageQuestion))) {
auto ret = QMessageBox::information(
nullptr, "", message, QMessageBox::Ok, QMessageBox::Cancel);
auto ret= QMessageBox::information(nullptr,
"", message,
QMessageBox::Ok, QMessageBox::Cancel);
if(ret==QMessageBox::Ok){
if (ret == QMessageBox::Ok) {
return kOfxStatReplyYes;
}
else {
} else {
return kOfxStatReplyNo;
}
}
}
else{
QMessageBox::information(nullptr,
"", message);
} else {
QMessageBox::information(nullptr, "", message);
return kOfxStatOK;
}
}
OfxStatus OliveInstance::setPersistentMessage(const char* type,
const char* id,
const char* format,
va_list args){
char *buffer=new char[1024];
OfxStatus OliveInstance::setPersistentMessage(const char *type, const char *id,
const char *format, va_list args)
{
char *buffer = new char[1024];
memset(buffer, 0, 1024*sizeof(char));
int ret=vsprintf(buffer, format, args);
if(ret<0){
memset(buffer, 0, 1024 * sizeof(char));
int ret = vsprintf(buffer, format, args);
if (ret < 0) {
return kOfxStatFailed;
}
QString message(buffer);
delete [] buffer;
delete[] buffer;
// If This is a error message
if(strncmp(type, kOfxMessageError, strlen(kOfxMessageError))==0){
persistentErrors_.append({ErrorType::Error, message});
if (strncmp(type, kOfxMessageError, strlen(kOfxMessageError)) == 0) {
persistentErrors_.append({ ErrorType::Error, message });
QMessageBox::critical(nullptr, "", message);
// TODO: tell the shell to show the error
}
// A warning
else if(strncmp(type, kOfxMessageWarning, strlen(kOfxMessageError))==0){
persistentErrors_.append({ErrorType::Warning, message});
else if (strncmp(type, kOfxMessageWarning, strlen(kOfxMessageError)) == 0) {
persistentErrors_.append({ ErrorType::Warning, message });
QMessageBox::warning(nullptr, "", message);
// TODO: tell the shell to show the warning
}
// A simple information
else if(strncmp(type, kOfxMessageMessage, strlen(kOfxMessageError))==0){
persistentErrors_.append({ErrorType::Message, message});
else if (strncmp(type, kOfxMessageMessage, strlen(kOfxMessageError)) == 0) {
persistentErrors_.append({ ErrorType::Message, message });
QMessageBox::information(nullptr, "", message);
}
else{
} else {
return kOfxStatFailed;
}
return kOfxStatOK;
}
OfxStatus OliveInstance::clearPersistentMessage(){
OfxStatus OliveInstance::clearPersistentMessage()
{
persistentErrors_.clear();
// TODO: tell the shell to remove message.
return kOfxStatOK;
}
void OliveInstance::getProjectSize(double &xSize, double &ySize) const
{
xSize = Current::getInstance().currentVideoParams().width();
ySize = Current::getInstance().currentVideoParams().height();
}
void OliveInstance::getProjectOffset(double &xOffset, double &yOffset) const
{
xOffset = Current::getInstance().currentVideoParams().x();
yOffset = Current::getInstance().currentVideoParams().y();
}
void OliveInstance::getProjectExtent(double &xSize, double &ySize) const
{
xSize = Current::getInstance().currentVideoParams().width();
ySize = Current::getInstance().currentVideoParams().height();
// TODO: Ensure this project does not support this.
}
}
}
+7 -1
View File
@@ -64,7 +64,13 @@ public:
const char* format,
va_list args) override;
OfxStatus clearPersistentMessage() override;
OfxStatus clearPersistentMessage() override;
void getProjectSize(double& xSize, double& ySize) const override;
void getProjectOffset(double& xOffset, double& yOffset) const override;
void getProjectExtent(double& xSize, double& ySize) const override;
private:
QList<PersistentErrors> persistentErrors_;
+3 -1
View File
@@ -24,6 +24,7 @@
#include "common/range.h"
#include "config/config.h"
#include "core.h"
#include "common/Current.h"
#include "dialog/markerproperties/markerpropertiesdialog.h"
#include "node/project/sequence/sequence.h"
#include "timeline/timelineundoworkarea.h"
@@ -90,7 +91,8 @@ void TimeBasedWidget::ConnectViewerNode(ViewerOutput *node)
// Set viewer node
ViewerOutput *old = viewer_node_;
viewer_node_ = node;
Current::getInstance().setCurrentVideoParams(viewer_node_->GetVideoParams());
Current::getInstance().setCurrentAudioParams(viewer_node_->GetAudioParams());
if (old) {
// Call potential derivative functions for disconnecting the viewer node
DisconnectNodeEvent(old);