Unified notification of source creation with Source info

New virtual function source::info used for notification after adding source
This commit is contained in:
Bruno Herbelin
2021-12-05 18:32:23 +01:00
parent bf3fc61ef7
commit 4675be7e2a
15 changed files with 111 additions and 18 deletions

View File

@@ -363,7 +363,6 @@ DeviceSource::~DeviceSource()
void DeviceSource::setDevice(const std::string &devicename)
{
device_ = devicename;
Log::Notify("Creating Source with device '%s'", device_.c_str());
int index = Device::manager().index(device_);
if (index > -1) {
@@ -589,6 +588,11 @@ glm::ivec2 DeviceSource::icon() const
return glm::ivec2(2, 14);
}
std::string DeviceSource::info() const
{
return std::string("device '") + device_ + "'";
}

View File

@@ -25,6 +25,7 @@ public:
inline std::string device() const { return device_; }
glm::ivec2 icon() const override;
std::string info() const override;
private:
std::string device_;

View File

@@ -46,7 +46,6 @@ MediaSource::~MediaSource()
void MediaSource::setPath(const std::string &p)
{
path_ = p;
Log::Notify("Creating Source with media '%s'", path_.c_str());
// open gstreamer
mediaplayer_->open(path_);
@@ -74,6 +73,11 @@ glm::ivec2 MediaSource::icon() const
return glm::ivec2(18, 13);
}
std::string MediaSource::info() const
{
return std::string("media '") + path_ + "'";
}
bool MediaSource::failed() const
{
return mediaplayer_->failed();

View File

@@ -30,6 +30,7 @@ public:
MediaPlayer *mediaplayer() const;
glm::ivec2 icon() const override;
std::string info() const override;
protected:

View File

@@ -258,10 +258,6 @@ Source * Mixer::createSourceFile(const std::string &path)
ms->setPath(path);
s = ms;
}
// remember in recent media
Settings::application.recentImport.push(path);
// propose a new name based on uri
s->setName(SystemToolkit::base_filename(path));
@@ -427,6 +423,12 @@ void Mixer::insertSource(Source *s, View::Mode m)
// new state in history manager
Action::manager().store(s->name() + std::string(": source inserted"));
// notify creation of source
Log::Notify("Added source '%s' with %s", s->name().c_str(), s->info().c_str());
MediaSource *ms = dynamic_cast<MediaSource *>(s);
if (ms)
Settings::application.recentImport.push(ms->path());
// if requested to show the source in a given view
// (known to work for View::MIXING et TRANSITION: other views untested)
if (m != View::INVALID) {
@@ -703,9 +705,10 @@ void Mixer::groupSelection()
info << sessiongroup->name() << " inserted: " << sessiongroup->session()->numSource() << " sources flatten.";
Action::manager().store(info.str());
Log::Notify("Added source '%s' with %s", sessiongroup->name().c_str(), sessiongroup->info().c_str());
// give the hand to the user
Mixer::manager().setCurrentSource(sessiongroup);
Log::Notify(info.str().c_str());
}
void Mixer::renameSource(Source *s, const std::string &newname)

View File

@@ -259,3 +259,14 @@ MultiFile *MultiFileSource::multifile () const
}
glm::ivec2 MultiFileSource::icon () const
{
return glm::ivec2(3, 9);
}
std::string MultiFileSource::info() const
{
return std::string("sequence '") + sequence_.location + "'";
}

View File

@@ -51,7 +51,8 @@ public:
// StreamSource interface
Stream *stream () const override { return stream_; }
glm::ivec2 icon () const override { return glm::ivec2(3, 9); }
glm::ivec2 icon() const override;
std::string info() const override;
// specific interface
void setFiles (const std::list<std::string> &list_files, uint framerate);

View File

@@ -310,7 +310,6 @@ NetworkStream *NetworkSource::networkStream() const
void NetworkSource::setConnection(const std::string &nameconnection)
{
connection_name_ = nameconnection;
Log::Notify("Network Source connecting to '%s'", connection_name_.c_str());
// open network stream
networkStream()->connect( connection_name_ );
@@ -333,5 +332,13 @@ void NetworkSource::accept(Visitor& v)
v.visit(*this);
}
glm::ivec2 NetworkSource::icon() const
{
return glm::ivec2(18, 11);
}
std::string NetworkSource::info() const
{
return std::string("connected to '") + connection_name_ + "'";
}

View File

@@ -74,7 +74,8 @@ public:
void setConnection(const std::string &nameconnection);
std::string connection() const;
glm::ivec2 icon() const override { return glm::ivec2(18, 11); }
glm::ivec2 icon() const override;
std::string info() const override;
};

View File

@@ -147,7 +147,6 @@ void PatternSource::setPattern(uint type, glm::ivec2 resolution)
// open gstreamer with pattern
if ( Pattern::get(type).available) {
pattern()->open( (uint) type, resolution );
Log::Notify("Creating Source with pattern '%s'", Pattern::get(type).label.c_str());
}
// revert to pattern Black if not available
else {
@@ -175,3 +174,12 @@ Pattern *PatternSource::pattern() const
}
glm::ivec2 PatternSource::icon() const
{
return glm::ivec2(11, 5);
}
std::string PatternSource::info() const
{
return std::string("pattern '") + Pattern::get(pattern()->type()).label + "'";
}

View File

@@ -47,7 +47,8 @@ public:
Pattern *pattern() const;
void setPattern(uint type, glm::ivec2 resolution);
glm::ivec2 icon() const override { return glm::ivec2(11, 5); }
glm::ivec2 icon() const override;
std::string info() const override;
};

View File

@@ -279,6 +279,16 @@ void SessionFileSource::accept(Visitor& v)
v.visit(*this);
}
glm::ivec2 SessionFileSource::icon() const
{
return glm::ivec2(19, 6);
}
std::string SessionFileSource::info() const
{
return std::string("session vimix '") + path_ + "'";
}
SessionGroupSource::SessionGroupSource(uint64_t id) : SessionSource(id), resolution_(glm::vec3(0.f))
{
@@ -335,7 +345,7 @@ void SessionGroupSource::init()
++View::need_deep_update_;
// done init
Log::Info("Source Group (%d x %d).", int(renderbuffer->resolution().x), int(renderbuffer->resolution().y) );
Log::Info("Source Group created (%d x %d).", int(renderbuffer->resolution().x), int(renderbuffer->resolution().y) );
}
}
@@ -360,6 +370,19 @@ void SessionGroupSource::accept(Visitor& v)
v.visit(*this);
}
glm::ivec2 SessionGroupSource::icon() const
{
return glm::ivec2(10, 6);
}
std::string SessionGroupSource::info() const
{
if (session_)
return std::string("group of ") + std::to_string(session_->numSource()) + " sources";
else
return std::string("undefined group.");
}
RenderSource::RenderSource(uint64_t id) : Source(id), session_(nullptr)
{
// set symbol
@@ -423,3 +446,13 @@ void RenderSource::accept(Visitor& v)
// if (!failed())
v.visit(*this);
}
glm::ivec2 RenderSource::icon() const
{
return glm::ivec2(0, 2);
}
std::string RenderSource::info() const
{
return std::string("Render loopback");
}

View File

@@ -46,7 +46,9 @@ public:
void load(const std::string &p = "", uint recursion = 0);
inline std::string path() const { return path_; }
glm::ivec2 icon() const override { return glm::ivec2(19, 6); }
glm::ivec2 icon() const override;
std::string info() const override;
protected:
@@ -72,7 +74,8 @@ public:
// import a source
bool import(Source *source);
glm::ivec2 icon() const override { return glm::ivec2(10, 6); }
glm::ivec2 icon() const override;
std::string info() const override;
protected:
@@ -99,7 +102,8 @@ public:
glm::vec3 resolution() const;
glm::ivec2 icon() const override { return glm::ivec2(0, 2); }
glm::ivec2 icon() const override;
std::string info() const override;
protected:

View File

@@ -733,7 +733,7 @@ FrameBuffer *Source::frame() const
return renderbuffer_;
}
else {
static FrameBuffer *black = new FrameBuffer(640,480);
static FrameBuffer *black = new FrameBuffer(320,180);
return black;
}
}
@@ -916,3 +916,13 @@ void CloneSource::accept(Visitor& v)
v.visit(*this);
}
glm::ivec2 CloneSource::icon() const
{
return glm::ivec2(9, 2);
}
std::string CloneSource::info() const
{
return std::string("clone of '") + origin_->name() + "'";
}

View File

@@ -230,6 +230,9 @@ public:
// class-dependent icon
virtual glm::ivec2 icon () const { return glm::ivec2(12, 11); }
// class-dependent notification
virtual std::string info () const { return "Undefined"; }
SourceLink processingshader_link_;
protected:
@@ -322,7 +325,8 @@ public:
inline void detach() { origin_ = nullptr; }
inline Source *origin() const { return origin_; }
glm::ivec2 icon() const override { return glm::ivec2(9, 2); }
glm::ivec2 icon() const override;
std::string info() const override;
protected:
// only Source class can create new CloneSource via clone();