mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-07 16:30:00 +01:00
Important change: sources keep their id all lifelong.
This simplifies a lot history and testing in session.
This commit is contained in:
@@ -197,8 +197,6 @@ void Action::restore(uint target)
|
||||
// attach created source
|
||||
Mixer::manager().attach( (*lsit).second );
|
||||
|
||||
// change the history to match the new id
|
||||
replaceSourceId( (*lsit).first, (*lsit).second->id());
|
||||
}
|
||||
|
||||
//
|
||||
@@ -224,24 +222,3 @@ void Action::restore(uint target)
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Action::replaceSourceId(uint64_t previousid, uint64_t newid)
|
||||
{
|
||||
// loop over every session history step
|
||||
XMLElement* historyNode = xmlDoc_.FirstChildElement("H1");
|
||||
for( ; historyNode ; historyNode = historyNode->NextSiblingElement())
|
||||
{
|
||||
// loop over every source in session history
|
||||
XMLElement* sourceNode = historyNode->FirstChildElement("Source");
|
||||
for( ; sourceNode ; sourceNode = sourceNode->NextSiblingElement())
|
||||
{
|
||||
// check if this source node has this id
|
||||
uint64_t id_source_ = 0;
|
||||
sourceNode->QueryUnsigned64Attribute("id", &id_source_);
|
||||
if ( id_source_ == previousid )
|
||||
// change to new id
|
||||
sourceNode->SetAttribute("id", newid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,8 +37,6 @@ public:
|
||||
private:
|
||||
|
||||
void restore(uint target);
|
||||
void replaceSourceId(uint64_t previousid, uint64_t newid);
|
||||
// void replaceSourceId(tinyxml2::XMLElement* parentnode, uint64_t previousid, uint64_t newid);
|
||||
|
||||
tinyxml2::XMLDocument xmlDoc_;
|
||||
uint step_;
|
||||
@@ -46,4 +44,5 @@ private:
|
||||
std::atomic<bool> locked_;
|
||||
};
|
||||
|
||||
|
||||
#endif // ACTIONMANAGER_H
|
||||
|
||||
@@ -325,7 +325,7 @@ int Device::index(const std::string &device) const
|
||||
return i;
|
||||
}
|
||||
|
||||
DeviceSource::DeviceSource() : StreamSource()
|
||||
DeviceSource::DeviceSource(uint64_t id) : StreamSource(id)
|
||||
{
|
||||
// create stream
|
||||
stream_ = new Stream;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
class DeviceSource : public StreamSource
|
||||
{
|
||||
public:
|
||||
DeviceSource();
|
||||
DeviceSource(uint64_t id = 0);
|
||||
~DeviceSource();
|
||||
|
||||
// Source interface
|
||||
|
||||
@@ -30,8 +30,8 @@ FrameGrabbing::~FrameGrabbing()
|
||||
// cleanup
|
||||
if (caps_)
|
||||
gst_caps_unref (caps_);
|
||||
if (pbo_[0])
|
||||
glDeleteBuffers(2, pbo_);
|
||||
// if (pbo_[0] > 0) // automatically deleted at shutdown
|
||||
// glDeleteBuffers(2, pbo_);
|
||||
}
|
||||
|
||||
void FrameGrabbing::add(FrameGrabber *rec)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "Visitor.h"
|
||||
#include "Log.h"
|
||||
|
||||
MediaSource::MediaSource() : Source(), path_("")
|
||||
MediaSource::MediaSource(uint64_t id) : Source(id), path_("")
|
||||
{
|
||||
// create media player
|
||||
mediaplayer_ = new MediaPlayer;
|
||||
|
||||
@@ -8,7 +8,7 @@ class MediaPlayer;
|
||||
class MediaSource : public Source
|
||||
{
|
||||
public:
|
||||
MediaSource();
|
||||
MediaSource(uint64_t id = 0);
|
||||
~MediaSource();
|
||||
|
||||
// implementation of source API
|
||||
|
||||
@@ -268,7 +268,7 @@ void NetworkStream::update()
|
||||
}
|
||||
|
||||
|
||||
NetworkSource::NetworkSource() : StreamSource()
|
||||
NetworkSource::NetworkSource(uint64_t id) : StreamSource(id)
|
||||
{
|
||||
// create stream
|
||||
stream_ = static_cast<Stream *>( new NetworkStream );
|
||||
|
||||
@@ -59,7 +59,7 @@ class NetworkSource : public StreamSource
|
||||
std::string connection_name_;
|
||||
|
||||
public:
|
||||
NetworkSource();
|
||||
NetworkSource(uint64_t id = 0);
|
||||
~NetworkSource();
|
||||
|
||||
// Source interface
|
||||
|
||||
@@ -131,7 +131,7 @@ void Pattern::open( uint pattern, glm::ivec2 res )
|
||||
Stream::open(gstreamer_pattern, res.x, res.y);
|
||||
}
|
||||
|
||||
PatternSource::PatternSource() : StreamSource()
|
||||
PatternSource::PatternSource(uint64_t id) : StreamSource(id)
|
||||
{
|
||||
// create stream
|
||||
stream_ = static_cast<Stream *>( new Pattern );
|
||||
|
||||
@@ -23,7 +23,7 @@ private:
|
||||
class PatternSource : public StreamSource
|
||||
{
|
||||
public:
|
||||
PatternSource();
|
||||
PatternSource(uint64_t id = 0);
|
||||
|
||||
// Source interface
|
||||
void accept (Visitor& v) override;
|
||||
|
||||
@@ -220,25 +220,25 @@ void SessionLoader::load(XMLElement *sessionNode)
|
||||
if (!pType)
|
||||
continue;
|
||||
if ( std::string(pType) == "MediaSource") {
|
||||
load_source = new MediaSource;
|
||||
load_source = new MediaSource(id_xml_);
|
||||
}
|
||||
else if ( std::string(pType) == "SessionSource") {
|
||||
load_source = new SessionFileSource;
|
||||
load_source = new SessionFileSource(id_xml_);
|
||||
}
|
||||
else if ( std::string(pType) == "GroupSource") {
|
||||
load_source = new SessionGroupSource;
|
||||
load_source = new SessionGroupSource(id_xml_);
|
||||
}
|
||||
else if ( std::string(pType) == "RenderSource") {
|
||||
load_source = new RenderSource;
|
||||
load_source = new RenderSource(id_xml_);
|
||||
}
|
||||
else if ( std::string(pType) == "PatternSource") {
|
||||
load_source = new PatternSource;
|
||||
load_source = new PatternSource(id_xml_);
|
||||
}
|
||||
else if ( std::string(pType) == "DeviceSource") {
|
||||
load_source = new DeviceSource;
|
||||
load_source = new DeviceSource(id_xml_);
|
||||
}
|
||||
else if ( std::string(pType) == "NetworkSource") {
|
||||
load_source = new NetworkSource;
|
||||
load_source = new NetworkSource(id_xml_);
|
||||
}
|
||||
|
||||
// skip failed (including clones)
|
||||
@@ -286,7 +286,7 @@ void SessionLoader::load(XMLElement *sessionNode)
|
||||
// found the orign source
|
||||
if (origin != session_->end()) {
|
||||
// create a new source of type Clone
|
||||
Source *clone_source = (*origin)->clone();
|
||||
Source *clone_source = (*origin)->clone(id_xml_);
|
||||
|
||||
// add source to session
|
||||
session_->addSource(clone_source);
|
||||
@@ -317,11 +317,12 @@ Source *SessionLoader::createSource(tinyxml2::XMLElement *sourceNode, Mode mode)
|
||||
Source *load_source = nullptr;
|
||||
bool is_clone = false;
|
||||
|
||||
SourceList::iterator sit = session_->end();
|
||||
uint64_t id__ = 0;
|
||||
xmlCurrent_->QueryUnsigned64Attribute("id", &id__);
|
||||
|
||||
// check if a source with the given id exists in the session
|
||||
SourceList::iterator sit = session_->end();
|
||||
if (mode == CLONE) {
|
||||
uint64_t id__ = 0;
|
||||
xmlCurrent_->QueryUnsigned64Attribute("id", &id__);
|
||||
sit = session_->find(id__);
|
||||
}
|
||||
|
||||
@@ -331,25 +332,25 @@ Source *SessionLoader::createSource(tinyxml2::XMLElement *sourceNode, Mode mode)
|
||||
const char *pType = xmlCurrent_->Attribute("type");
|
||||
if (pType) {
|
||||
if ( std::string(pType) == "MediaSource") {
|
||||
load_source = new MediaSource;
|
||||
load_source = new MediaSource(id__);
|
||||
}
|
||||
else if ( std::string(pType) == "SessionSource") {
|
||||
load_source = new SessionFileSource;
|
||||
load_source = new SessionFileSource(id__);
|
||||
}
|
||||
else if ( std::string(pType) == "GroupSource") {
|
||||
load_source = new SessionGroupSource;
|
||||
load_source = new SessionGroupSource(id__);
|
||||
}
|
||||
else if ( std::string(pType) == "RenderSource") {
|
||||
load_source = new RenderSource;
|
||||
load_source = new RenderSource(id__);
|
||||
}
|
||||
else if ( std::string(pType) == "PatternSource") {
|
||||
load_source = new PatternSource;
|
||||
load_source = new PatternSource(id__);
|
||||
}
|
||||
else if ( std::string(pType) == "DeviceSource") {
|
||||
load_source = new DeviceSource;
|
||||
load_source = new DeviceSource(id__);
|
||||
}
|
||||
else if ( std::string(pType) == "NetworkSource") {
|
||||
load_source = new NetworkSource;
|
||||
load_source = new NetworkSource(id__);
|
||||
}
|
||||
else if ( std::string(pType) == "CloneSource") {
|
||||
// clone from given origin
|
||||
@@ -359,7 +360,7 @@ Source *SessionLoader::createSource(tinyxml2::XMLElement *sourceNode, Mode mode)
|
||||
SourceList::iterator origin = session_->find(sourcename);
|
||||
// found the orign source
|
||||
if (origin != session_->end())
|
||||
load_source = (*origin)->clone();
|
||||
load_source = (*origin)->clone(id__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "Mixer.h"
|
||||
|
||||
|
||||
SessionSource::SessionSource() : Source(), failed_(false)
|
||||
SessionSource::SessionSource(uint64_t id) : Source(id), failed_(false)
|
||||
{
|
||||
session_ = new Session;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ void SessionSource::update(float dt)
|
||||
}
|
||||
|
||||
|
||||
SessionFileSource::SessionFileSource() : SessionSource(), path_("")
|
||||
SessionFileSource::SessionFileSource(uint64_t id) : SessionSource(id), path_("")
|
||||
{
|
||||
// specific node for transition view
|
||||
groups_[View::TRANSITION]->visible_ = false;
|
||||
@@ -235,7 +235,7 @@ void SessionFileSource::accept(Visitor& v)
|
||||
}
|
||||
|
||||
|
||||
SessionGroupSource::SessionGroupSource() : SessionSource(), resolution_(glm::vec3(0.f))
|
||||
SessionGroupSource::SessionGroupSource(uint64_t id) : SessionSource(id), resolution_(glm::vec3(0.f))
|
||||
{
|
||||
// // redo frame for layers view
|
||||
// frames_[View::LAYER]->clear();
|
||||
@@ -316,16 +316,13 @@ void SessionGroupSource::accept(Visitor& v)
|
||||
v.visit(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RenderSource::RenderSource() : Source(), session_(nullptr)
|
||||
RenderSource::RenderSource(uint64_t id) : Source(id), session_(nullptr)
|
||||
{
|
||||
// set symbol
|
||||
symbol_ = new Symbol(Symbol::RENDER, glm::vec3(0.75f, 0.75f, 0.01f));
|
||||
symbol_->scale_.y = 1.5f;
|
||||
}
|
||||
|
||||
|
||||
bool RenderSource::failed() const
|
||||
{
|
||||
if (initialized_ && session_!=nullptr)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
class SessionSource : public Source
|
||||
{
|
||||
public:
|
||||
SessionSource();
|
||||
SessionSource(uint64_t id = 0);
|
||||
virtual ~SessionSource();
|
||||
|
||||
// implementation of source API
|
||||
@@ -29,7 +29,7 @@ protected:
|
||||
class SessionFileSource : public SessionSource
|
||||
{
|
||||
public:
|
||||
SessionFileSource();
|
||||
SessionFileSource(uint64_t id = 0);
|
||||
|
||||
// implementation of source API
|
||||
void accept (Visitor& v) override;
|
||||
@@ -52,7 +52,7 @@ protected:
|
||||
class SessionGroupSource : public SessionSource
|
||||
{
|
||||
public:
|
||||
SessionGroupSource();
|
||||
SessionGroupSource(uint64_t id = 0);
|
||||
|
||||
// implementation of source API
|
||||
void accept (Visitor& v) override;
|
||||
@@ -75,7 +75,7 @@ protected:
|
||||
class RenderSource : public Source
|
||||
{
|
||||
public:
|
||||
RenderSource();
|
||||
RenderSource(uint64_t id = 0);
|
||||
|
||||
// implementation of source API
|
||||
bool failed () const override;
|
||||
|
||||
15
Source.cpp
15
Source.cpp
@@ -17,10 +17,11 @@
|
||||
|
||||
#include "Source.h"
|
||||
|
||||
Source::Source() : initialized_(false), symbol_(nullptr), active_(true), locked_(false), need_update_(true), workspace_(STAGE)
|
||||
Source::Source(uint64_t id) : id_(id), initialized_(false), symbol_(nullptr), active_(true), locked_(false), need_update_(true), workspace_(STAGE)
|
||||
{
|
||||
// create unique id
|
||||
id_ = GlmToolkit::uniqueId();
|
||||
if (id_ == 0)
|
||||
id_ = GlmToolkit::uniqueId();
|
||||
|
||||
sprintf(initials_, "__");
|
||||
name_ = "Source";
|
||||
@@ -762,9 +763,9 @@ void Source::clearMixingGroup()
|
||||
}
|
||||
|
||||
|
||||
CloneSource *Source::clone()
|
||||
CloneSource *Source::clone(uint64_t id)
|
||||
{
|
||||
CloneSource *s = new CloneSource(this);
|
||||
CloneSource *s = new CloneSource(this, id);
|
||||
|
||||
clones_.push_back(s);
|
||||
|
||||
@@ -772,7 +773,7 @@ CloneSource *Source::clone()
|
||||
}
|
||||
|
||||
|
||||
CloneSource::CloneSource(Source *origin) : Source(), origin_(origin)
|
||||
CloneSource::CloneSource(Source *origin, uint64_t id) : Source(id), origin_(origin)
|
||||
{
|
||||
// set symbol
|
||||
symbol_ = new Symbol(Symbol::CLONE, glm::vec3(0.75f, 0.75f, 0.01f));
|
||||
@@ -785,11 +786,11 @@ CloneSource::~CloneSource()
|
||||
origin_->clones_.remove(this);
|
||||
}
|
||||
|
||||
CloneSource *CloneSource::clone()
|
||||
CloneSource *CloneSource::clone(uint64_t id)
|
||||
{
|
||||
// do not clone a clone : clone the original instead
|
||||
if (origin_)
|
||||
return origin_->clone();
|
||||
return origin_->clone(id);
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
8
Source.h
8
Source.h
@@ -38,7 +38,7 @@ class Source
|
||||
public:
|
||||
// create a source and add it to the list
|
||||
// only subclasses of sources can actually be instanciated
|
||||
Source ();
|
||||
Source (uint64_t id = 0);
|
||||
virtual ~Source ();
|
||||
|
||||
// Get unique id
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
inline const char *initials () const { return initials_; }
|
||||
|
||||
// cloning mechanism
|
||||
virtual CloneSource *clone ();
|
||||
virtual CloneSource *clone (uint64_t id = 0);
|
||||
|
||||
// Display mode
|
||||
typedef enum {
|
||||
@@ -288,7 +288,7 @@ public:
|
||||
bool failed() const override { return origin_ == nullptr; }
|
||||
void accept (Visitor& v) override;
|
||||
|
||||
CloneSource *clone() override;
|
||||
CloneSource *clone(uint64_t id = 0) override;
|
||||
inline void detach() { origin_ = nullptr; }
|
||||
inline Source *origin() const { return origin_; }
|
||||
|
||||
@@ -296,7 +296,7 @@ public:
|
||||
|
||||
protected:
|
||||
// only Source class can create new CloneSource via clone();
|
||||
CloneSource(Source *origin);
|
||||
CloneSource(Source *origin, uint64_t id = 0);
|
||||
|
||||
void init() override;
|
||||
Source *origin_;
|
||||
|
||||
@@ -37,7 +37,7 @@ void GenericStreamSource::accept(Visitor& v)
|
||||
v.visit(*this);
|
||||
}
|
||||
|
||||
StreamSource::StreamSource() : Source(), stream_(nullptr)
|
||||
StreamSource::StreamSource(uint64_t id) : Source(id), stream_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
class StreamSource: public Source
|
||||
{
|
||||
public:
|
||||
StreamSource();
|
||||
StreamSource(uint64_t id = 0);
|
||||
virtual ~StreamSource();
|
||||
|
||||
// implementation of source API
|
||||
|
||||
@@ -3475,7 +3475,16 @@ void ShowSandbox(bool* p_open)
|
||||
}
|
||||
|
||||
ImGui::Text("Testing sandox");
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("Source list");
|
||||
Session *se = Mixer::manager().session();
|
||||
for (auto sit = se->begin(); sit != se->end(); ++sit) {
|
||||
|
||||
ImGui::Text("[%s] %s ", std::to_string((*sit)->id()).c_str(), (*sit)->name().c_str());
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
static char buf1[1280] = "videotestsrc pattern=smpte";
|
||||
ImGui::InputText("gstreamer pipeline", buf1, 1280);
|
||||
@@ -3489,106 +3498,6 @@ void ShowSandbox(bool* p_open)
|
||||
if ( ImGui::Button("Execute") )
|
||||
SystemToolkit::execute(str);
|
||||
|
||||
if (ImGui::Button("Message test")) {
|
||||
|
||||
for(int i=0; i<10; i++) {
|
||||
Log::Notify("Testing notification %d", i);
|
||||
}
|
||||
|
||||
for(int i=0; i<10; i++) {
|
||||
Log::Warning("Testing Warning %d", i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// const guint64 duration = GST_SECOND * 6;
|
||||
// const guint64 step = GST_MSECOND * 20;
|
||||
// static guint64 t = 0;
|
||||
|
||||
// static float *arr_lines = nullptr;
|
||||
// static float *arr_histo = nullptr;
|
||||
// static uint array_size = 200;
|
||||
|
||||
// if (arr_lines == nullptr) {
|
||||
|
||||
// arr_lines = (float *) malloc(array_size * sizeof(float));
|
||||
// arr_histo = (float *) malloc(array_size * sizeof(float));
|
||||
|
||||
// for (int i = 0; i < array_size; ++i) {
|
||||
// arr_lines[i] = 1.f;
|
||||
// arr_histo[i] = 0.f;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // scrolling sub-window
|
||||
// ImGui::BeginChild("##scrolling",
|
||||
// ImVec2(ImGui::GetContentRegionAvail().x, 250),
|
||||
// false, ImGuiWindowFlags_HorizontalScrollbar);
|
||||
|
||||
|
||||
// if (arr_lines != nullptr)
|
||||
// {
|
||||
|
||||
// ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(1, 1));
|
||||
// ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.f);
|
||||
|
||||
// ImVec2 size = ImGui::CalcItemSize(ImVec2(-FLT_MIN, 0.0f), ImGui::CalcItemWidth(), 40);
|
||||
// size.x *= 1.f;
|
||||
|
||||
//// // draw position when entering
|
||||
//// ImVec2 draw_pos = ImGui::GetCursorPos();
|
||||
|
||||
////// // capture user input
|
||||
////// uint press_index = array_size-1;
|
||||
////// float val = 0.f;
|
||||
////// bool pressed = false;
|
||||
|
||||
////// uint starting_index = press_index;
|
||||
////// pressed = ImGuiToolkit::InvisibleDoubleSliderFloat("test", &press_index, &val, 0, array_size-1, size);
|
||||
////// if (pressed)
|
||||
////// {
|
||||
////// for (int i = MIN(starting_index, press_index); i < MAX(starting_index, press_index); ++i)
|
||||
////// arr[i] = val;
|
||||
|
||||
//////// starting_index = press_index;
|
||||
////// }
|
||||
|
||||
//// float x = -1.f;
|
||||
//// float y = -1.f;
|
||||
//// bool clicked = ImGuiToolkit::InvisibleCoordinatesFloat("test", &x, &y, size);
|
||||
//// if (clicked) {
|
||||
//// Log::Info("clic %f %f in [%f %f]", x, y, size.x, size.y);
|
||||
//// }
|
||||
|
||||
|
||||
//// // back to
|
||||
//// ImGui::SetCursorPos(draw_pos);
|
||||
//// // plot lines
|
||||
//// ImGui::PlotLines("Lines", arr, array_size-1, 0, NULL, 0.0f, 1.0f, size);
|
||||
|
||||
////// size.y = 20;
|
||||
////// ImGui::PlotHistogram("Hisfd", arr, array_size-1, 0, NULL, 0.0f, 1.0f, size);
|
||||
// bool r = false;
|
||||
// ImGuiToolkit::EditPlotHistoLines("Alpha", arr_histo, arr_lines, array_size, 0.f, 1.f, &r, size);
|
||||
|
||||
// bool slider_pressed = ImGuiToolkit::TimelineSlider("timeline", &t, 0, duration, step, size.x);
|
||||
|
||||
// ImGui::PopStyleVar(2);
|
||||
|
||||
// ImGui::Text("Timeline t %" GST_STIME_FORMAT "\n", GST_STIME_ARGS(t));
|
||||
// ImGui::Text("Timeline Pressed %s", slider_pressed ? "on" : "off");
|
||||
|
||||
// static int w = 0;
|
||||
// ImGui::SetNextItemWidth(size.x);
|
||||
// ImGui::SliderInt("##int", &w, 0, array_size-1);
|
||||
|
||||
// }
|
||||
|
||||
// ImGui::EndChild();
|
||||
|
||||
|
||||
static char str0[128] = "àöäüèáû вторая строчка";
|
||||
ImGui::InputText("##inputtext", str0, IM_ARRAYSIZE(str0));
|
||||
std::string tra = SystemToolkit::transliterate(std::string(str0));
|
||||
|
||||
Reference in New Issue
Block a user