mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 15:30:00 +01:00
Fixed initialization of source and of SessionSource; sources are ready
after full initialization and in standly. A new button allows playing the source (media or session) in the new source pannel.
This commit is contained in:
@@ -277,6 +277,9 @@ void ImGuiVisitor::visit (Source& s)
|
||||
// geometry direct control
|
||||
s.groupNode(View::GEOMETRY)->accept(*this);
|
||||
|
||||
if ( s.numClones() > 0 ) {
|
||||
ImGui::Text("Cloned %d time%s", s.numClones(), s.numClones() > 1 ? "s." : ".");
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit (MediaSource& s)
|
||||
|
||||
@@ -119,7 +119,8 @@ void MediaSource::update(float dt)
|
||||
Source::update(dt);
|
||||
|
||||
// update video
|
||||
mediaplayer_->update();
|
||||
if (active_)
|
||||
mediaplayer_->update();
|
||||
}
|
||||
|
||||
void MediaSource::render()
|
||||
|
||||
@@ -688,7 +688,7 @@ void Mixer::swap()
|
||||
// set resolution
|
||||
session_->setResolution( session_->config(View::RENDERING)->scale_ );
|
||||
|
||||
// request reordering in depth for views
|
||||
// request complete update for views
|
||||
View::need_deep_update_ = true;
|
||||
|
||||
// no current source
|
||||
|
||||
@@ -62,8 +62,7 @@ void Session::update(float dt)
|
||||
// render the source
|
||||
(*it)->render();
|
||||
// update the source
|
||||
if (active_)
|
||||
(*it)->update(dt);
|
||||
(*it)->update(dt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ SessionSource::SessionSource() : Source(), path_("")
|
||||
|
||||
loadFailed_ = false;
|
||||
loadFinished_ = false;
|
||||
wait_for_sources_ = false;
|
||||
|
||||
session_ = new Session;
|
||||
|
||||
@@ -127,7 +128,33 @@ uint SessionSource::texture() const
|
||||
|
||||
void SessionSource::init()
|
||||
{
|
||||
Log::Info("SessionSource::init");
|
||||
if (session_ == nullptr)
|
||||
return;
|
||||
|
||||
if (wait_for_sources_) {
|
||||
|
||||
// force update of of all sources
|
||||
active_ = true;
|
||||
touch();
|
||||
|
||||
// check that every source is ready..
|
||||
bool ready = true;
|
||||
for (SourceList::iterator iter = session_->begin(); iter != session_->end(); iter++)
|
||||
{
|
||||
// interrupt if any source is NOT ready
|
||||
if ( !(*iter)->ready() ){
|
||||
ready = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if all sources are ready, done with initialization!
|
||||
if (ready) {
|
||||
// done init
|
||||
wait_for_sources_ = false;
|
||||
initialized_ = true;
|
||||
Log::Info("Source Session %s loaded %d sources.", path_.c_str(), session_->numSource());
|
||||
}
|
||||
}
|
||||
|
||||
if ( loadFinished_ && !loadFailed_ && session_ != nullptr) {
|
||||
loadFinished_ = false;
|
||||
@@ -135,7 +162,7 @@ void SessionSource::init()
|
||||
// set resolution
|
||||
session_->setResolution( session_->config(View::RENDERING)->scale_ );
|
||||
|
||||
// update once with update of the depth
|
||||
// deep update once to draw framebuffer
|
||||
View::need_deep_update_ = true;
|
||||
session_->update(dt_);
|
||||
|
||||
@@ -152,41 +179,41 @@ void SessionSource::init()
|
||||
overlays_[View::MIXING]->attach( new Symbol(Symbol::SESSION, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||
overlays_[View::LAYER]->attach( new Symbol(Symbol::SESSION, glm::vec3(0.8f, 0.8f, 0.01f)) );
|
||||
|
||||
// done init
|
||||
initialized_ = true;
|
||||
Log::Info("Source Session %s loading %d sources.", path_.c_str(), session_->numSource());
|
||||
// wait for all sources to init
|
||||
wait_for_sources_ = true;
|
||||
|
||||
// force update of activation mode
|
||||
active_ = true;
|
||||
touch();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SessionSource::setActive (bool on)
|
||||
{
|
||||
// Log::Info("SessionSource::setActive %d", on);
|
||||
|
||||
bool was_active = active_;
|
||||
|
||||
Source::setActive(on);
|
||||
|
||||
// change status of media player (only if status changed)
|
||||
if ( active_ != was_active ) {
|
||||
// change status of session (recursive change of internal sources)
|
||||
if (session_ != nullptr)
|
||||
session_->setActive(active_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SessionSource::update(float dt)
|
||||
{
|
||||
Source::update(dt);
|
||||
if (session_ == nullptr)
|
||||
loadFailed_ = true;
|
||||
|
||||
// update content
|
||||
session_->update(dt);
|
||||
if (active_)
|
||||
session_->update(dt);
|
||||
|
||||
// delete a source which failed
|
||||
if (session()->failedSource() != nullptr)
|
||||
session()->deleteSource(session()->failedSource());
|
||||
if (session_->failedSource() != nullptr) {
|
||||
session_->deleteSource(session_->failedSource());
|
||||
// fail session if all sources failed
|
||||
if ( session_->numSource() < 1)
|
||||
loadFailed_ = true;
|
||||
}
|
||||
|
||||
Source::update(dt);
|
||||
}
|
||||
|
||||
void SessionSource::render()
|
||||
@@ -230,13 +257,14 @@ uint RenderSource::texture() const
|
||||
{
|
||||
if (session_ == nullptr)
|
||||
return Resource::getTextureBlack();
|
||||
return session_->frame()->texture();
|
||||
else
|
||||
return session_->frame()->texture();
|
||||
}
|
||||
|
||||
void RenderSource::init()
|
||||
{
|
||||
if (session_ == nullptr)
|
||||
session_ = Mixer::manager().session();
|
||||
return;
|
||||
|
||||
if (session_ && session_->frame()->texture() != Resource::getTextureBlack()) {
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ protected:
|
||||
|
||||
std::atomic<bool> loadFailed_;
|
||||
std::atomic<bool> loadFinished_;
|
||||
std::atomic<bool> wait_for_sources_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
19
Source.cpp
19
Source.cpp
@@ -359,12 +359,15 @@ CloneSource::~CloneSource()
|
||||
CloneSource *CloneSource::clone()
|
||||
{
|
||||
// do not clone a clone : clone the original instead
|
||||
return origin_->clone();
|
||||
if (origin_)
|
||||
return origin_->clone();
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CloneSource::init()
|
||||
{
|
||||
if (origin_ && origin_->texture() != Resource::getTextureBlack()) {
|
||||
if (origin_ && origin_->ready()) {
|
||||
|
||||
// get the texture index from framebuffer of view, apply it to the surface
|
||||
clonesurface_->setTextureIndex( origin_->texture() );
|
||||
@@ -394,7 +397,17 @@ void CloneSource::setActive (bool on)
|
||||
groups_[View::GEOMETRY]->visible_ = active_;
|
||||
groups_[View::LAYER]->visible_ = active_;
|
||||
|
||||
origin_->touch();
|
||||
if (origin_)
|
||||
origin_->touch();
|
||||
}
|
||||
|
||||
|
||||
uint CloneSource::texture() const
|
||||
{
|
||||
if (origin_)
|
||||
return origin_->texture();
|
||||
else
|
||||
return Resource::getTextureBlack();
|
||||
}
|
||||
|
||||
void CloneSource::render()
|
||||
|
||||
12
Source.h
12
Source.h
@@ -43,6 +43,7 @@ public:
|
||||
|
||||
// cloning mechanism
|
||||
virtual CloneSource *clone ();
|
||||
inline size_t numClones() const { return clones_.size(); }
|
||||
|
||||
// Display mode
|
||||
typedef enum {
|
||||
@@ -54,7 +55,6 @@ public:
|
||||
Mode mode () const;
|
||||
void setMode (Mode m);
|
||||
|
||||
|
||||
// get handle on the nodes used to manipulate the source in a view
|
||||
inline Group *group (View::Mode m) const { return groups_.at(m); }
|
||||
inline Node *groupNode (View::Mode m) const { return static_cast<Node*>(groups_.at(m)); }
|
||||
@@ -74,6 +74,9 @@ public:
|
||||
// touch to request update
|
||||
inline void touch () { need_update_ = true; }
|
||||
|
||||
// informs if its ready (i.e. initialized)
|
||||
inline bool ready() const { return initialized_; }
|
||||
|
||||
// a Source shall be updated before displayed (Mixing, Geometry and Layer)
|
||||
virtual void update (float dt);
|
||||
|
||||
@@ -81,9 +84,6 @@ public:
|
||||
virtual void setActive (bool on);
|
||||
inline bool active () { return active_; }
|
||||
|
||||
// accept all kind of visitors
|
||||
virtual void accept (Visitor& v);
|
||||
|
||||
// a Source shall informs if the source failed (i.e. shall be deleted)
|
||||
virtual bool failed() const = 0;
|
||||
|
||||
@@ -93,6 +93,8 @@ public:
|
||||
// a Source shall define how to render into the frame buffer
|
||||
virtual void render() = 0;
|
||||
|
||||
// accept all kind of visitors
|
||||
virtual void accept (Visitor& v);
|
||||
|
||||
struct hasNode: public std::unary_function<Source*, bool>
|
||||
{
|
||||
@@ -170,7 +172,7 @@ public:
|
||||
// implementation of source API
|
||||
void setActive (bool on) override;
|
||||
void render() override;
|
||||
uint texture() const override { return origin_->texture(); }
|
||||
uint texture() const override;
|
||||
bool failed() const override { return origin_ == nullptr; }
|
||||
void accept (Visitor& v) override;
|
||||
|
||||
|
||||
@@ -1514,14 +1514,21 @@ void SourcePreview::draw(float width)
|
||||
setSource();
|
||||
else
|
||||
{
|
||||
bool active = source_->active();
|
||||
// update source
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
source_->update( 1.f / io.Framerate);
|
||||
source_->update( Mixer::manager().dt());
|
||||
// render framebuffer
|
||||
source_->render();
|
||||
|
||||
// draw preview
|
||||
ImVec2 preview_size(width, width / source_->frame()->aspectRatio());
|
||||
ImGui::Image((void*)(uintptr_t) source_->frame()->texture(), preview_size);
|
||||
|
||||
ImVec2 pos = ImGui::GetCursorPos();
|
||||
ImGui::SameLine();
|
||||
if (ImGuiToolkit::IconToggle(9,7,1,8, &active))
|
||||
source_->setActive(active);
|
||||
ImGui::SetCursorPos(pos);
|
||||
ImGui::Text("%s ", label_.c_str());
|
||||
}
|
||||
}
|
||||
@@ -2036,13 +2043,9 @@ void ShowAboutOpengl(bool* p_open)
|
||||
|
||||
void ShowAboutGStreamer(bool* p_open)
|
||||
{
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(430, 20), ImGuiCond_FirstUseEver);
|
||||
if (!ImGui::Begin("About Gstreamer", p_open, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize))
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
ImGui::SetNextWindowPos(ImVec2(430, 20), ImGuiCond_Appearing);
|
||||
ImGui::SetNextWindowSize(ImVec2(600, 200), ImGuiCond_Appearing);
|
||||
ImGui::Begin("About Gstreamer", p_open, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings);
|
||||
|
||||
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_BOLD);
|
||||
ImGui::Text("GStreamer %s", GstToolkit::gst_version().c_str());
|
||||
@@ -2079,6 +2082,7 @@ void ShowAboutGStreamer(bool* p_open)
|
||||
ImGui::Text("GStreamer %s", GstToolkit::gst_version().c_str());
|
||||
ImGui::Text("Plugins & features (runtime) :");
|
||||
|
||||
std::list<std::string> filteredlist;
|
||||
static std::list<std::string> pluginslist;
|
||||
static std::map<std::string, std::list<std::string> > featureslist;
|
||||
if (pluginslist.empty()) {
|
||||
@@ -2089,22 +2093,19 @@ void ShowAboutGStreamer(bool* p_open)
|
||||
}
|
||||
}
|
||||
|
||||
std::list<std::string> filteredlist;
|
||||
|
||||
// filter
|
||||
// filter list
|
||||
if ( filter.empty() )
|
||||
filteredlist = pluginslist;
|
||||
else {
|
||||
std::list<std::string> plist = pluginslist;
|
||||
for (auto const& i: plist) {
|
||||
// add plugin if plugin name match
|
||||
for (auto const& i: pluginslist) {
|
||||
// add plugin if plugin name matches
|
||||
if ( i.find(filter) != std::string::npos )
|
||||
filteredlist.push_back( i.c_str() );
|
||||
filteredlist.push_back( i );
|
||||
// check in features
|
||||
for (auto const& j: featureslist[i]) {
|
||||
// add plugin if feature name matches
|
||||
if ( j.find(filter) != std::string::npos )
|
||||
filteredlist.push_back( i.c_str() );
|
||||
filteredlist.push_back( i );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2128,5 +2129,6 @@ void ShowAboutGStreamer(bool* p_open)
|
||||
|
||||
ImGui::EndChildFrame();
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
16
View.cpp
16
View.cpp
@@ -469,7 +469,7 @@ void GeometryView::update(float dt)
|
||||
{
|
||||
View::update(dt);
|
||||
|
||||
// reorder depth if needed
|
||||
// a more complete update is requested
|
||||
if (View::need_deep_update_) {
|
||||
|
||||
// update rendering of render frame
|
||||
@@ -725,7 +725,7 @@ void LayerView::update(float dt)
|
||||
{
|
||||
View::update(dt);
|
||||
|
||||
// reorder depth if needed
|
||||
// a more complete update is requested
|
||||
if (View::need_deep_update_) {
|
||||
|
||||
// update rendering of render frame
|
||||
@@ -777,12 +777,12 @@ float LayerView::setDepth(Source *s, float d)
|
||||
// change depth
|
||||
sourceNode->translation_.z = -sourceNode->translation_.x;
|
||||
|
||||
// request update
|
||||
s->touch();
|
||||
|
||||
// request reordering
|
||||
// request reordering of scene at next update
|
||||
View::need_deep_update_ = true;
|
||||
|
||||
// request update of source
|
||||
s->touch();
|
||||
|
||||
return sourceNode->translation_.z;
|
||||
}
|
||||
|
||||
@@ -930,8 +930,8 @@ void TransitionView::update(float dt)
|
||||
// update scene
|
||||
View::update(dt);
|
||||
|
||||
// reorder depth if needed
|
||||
if (View::need_deep_update_) {
|
||||
// a more complete update is requested
|
||||
if (View::need_deep_update_) {
|
||||
|
||||
// update rendering of render frame
|
||||
FrameBuffer *output = Mixer::manager().session()->frame();
|
||||
|
||||
Reference in New Issue
Block a user