Display mixing source original texture when inactive

Re-using activesurface_ for manipulation and display of the source's input texture in the Mixer icon when inactive.
This commit is contained in:
Bruno
2021-08-02 22:27:06 +02:00
parent e8acfc1c26
commit fc4e40fba3
6 changed files with 57 additions and 17 deletions

View File

@@ -519,7 +519,7 @@ void MediaPlayer::enable(bool on)
if ( enabled_ != on ) {
// option to automatically rewind each time the player is disabled
if (!on && rewind_on_disable_ )
if (!on && rewind_on_disable_ && desired_state_ == GST_STATE_PLAYING)
rewind(true);
// apply change
@@ -529,9 +529,8 @@ void MediaPlayer::enable(bool on)
GstState requested_state = GST_STATE_PAUSED;
// unpause only if enabled
if (enabled_) {
if (enabled_)
requested_state = desired_state_;
}
// apply state change
GstStateChangeReturn ret = gst_element_set_state (pipeline_, requested_state);

View File

@@ -66,8 +66,17 @@ void SessionSource::setActive (bool on)
Source::setActive(on);
// change status of session (recursive change of internal sources)
if (session_)
if (session_) {
session_->setActive(active_);
// change visibility of active surface (show preview of session when inactive)
if (activesurface_) {
if (active_)
activesurface_->setTextureIndex(Resource::getTextureTransparent());
else
activesurface_->setTextureIndex(session_->frame()->texture());
}
}
}
void SessionSource::update(float dt)
@@ -101,7 +110,6 @@ void SessionSource::replay ()
}
}
SessionFileSource::SessionFileSource(uint64_t id) : SessionSource(id), path_(""), initialized_(false), wait_for_sources_(false)
{
// specific node for transition view

View File

@@ -268,7 +268,7 @@ Source::Source(uint64_t id) : SourceCore(), id_(id), ready_(false), symbol_(null
// for drawing in mixing view
mixingshader_ = new ImageShader;
mixingshader_->stipple = 1.0;
mixingshader_->stipple = 1.0f;
mixinggroup_ = nullptr;
// create media surface:
@@ -281,6 +281,7 @@ Source::Source(uint64_t id) : SourceCore(), id_(id), ready_(false), symbol_(null
renderbuffer_ = nullptr;
rendersurface_ = nullptr;
mixingsurface_ = nullptr;
activesurface_ = nullptr;
maskbuffer_ = nullptr;
maskimage_ = nullptr;
mask_need_update_ = false;
@@ -454,11 +455,11 @@ void Source::attach(FrameBuffer *renderbuffer)
groups_[View::LAYER]->attach(mixingsurface_);
// for views showing a scaled mixing surface, a dedicated transparent surface allows grabbing
Surface *surfacetmp = new Surface();
surfacetmp->setTextureIndex(Resource::getTextureTransparent());
groups_[View::TEXTURE]->attach(surfacetmp);
groups_[View::MIXING]->attach(surfacetmp);
groups_[View::LAYER]->attach(surfacetmp);
activesurface_ = new Surface();
activesurface_->setTextureIndex(Resource::getTextureTransparent());
groups_[View::TEXTURE]->attach(activesurface_);
groups_[View::MIXING]->attach(activesurface_);
groups_[View::LAYER]->attach(activesurface_);
// Transition group node is optionnal
if (groups_[View::TRANSITION]->numChildren() > 0)
@@ -866,8 +867,18 @@ void CloneSource::setActive (bool on)
groups_[View::GEOMETRY]->visible_ = active_;
groups_[View::LAYER]->visible_ = active_;
if ( mode_ > Source::UNINITIALIZED && origin_ != nullptr)
origin_->touch();
if (origin_) {
if ( mode_ > Source::UNINITIALIZED)
origin_->touch();
// change visibility of active surface (show preview of origin when inactive)
if (activesurface_) {
if (active_)
activesurface_->setTextureIndex(Resource::getTextureTransparent());
else
activesurface_->setTextureIndex(origin_->texture());
}
}
}
uint CloneSource::texture() const

View File

@@ -250,7 +250,11 @@ protected:
// the rendersurface draws the renderbuffer in the scene
// It is associated to the rendershader for mixing effects
FrameBufferSurface *rendersurface_;
// for the mixer, we have a surface with stippling to show
// the rendering, and a preview of the original texture
FrameBufferSurface *mixingsurface_;
Surface *activesurface_;
// blendingshader provides mixing controls
ImageShader *blendingshader_;

View File

@@ -105,10 +105,19 @@ void StreamSource::setActive (bool on)
// try to activate (may fail if source is cloned)
Source::setActive(on);
// change status of stream (only if status changed)
if ( stream_ && active_ != was_active )
stream_->enable(active_);
if (stream_) {
// change status of stream (only if status changed)
if (active_ != was_active)
stream_->enable(active_);
// change visibility of active surface (show preview of stream when inactive)
if (activesurface_) {
if (active_)
activesurface_->setTextureIndex(Resource::getTextureTransparent());
else
activesurface_->setTextureIndex(stream_->texture());
}
}
}

View File

@@ -72,7 +72,7 @@ TextEditor editor;
#define PLOT_ARRAY_SIZE 180
#define LABEL_AUTO_MEDIA_PLAYER ICON_FA_CARET_SQUARE_RIGHT " Dynamic selection"
#define LABEL_STORE_SELECTION " Store selection"
#define LABEL_EDIT_FADING ICON_FA_RANDOM " Edit Fading"
#define LABEL_EDIT_FADING ICON_FA_RANDOM " Edit timeline fading"
// utility functions
void ShowAboutGStreamer(bool* p_open);
@@ -2867,6 +2867,15 @@ void SourceController::RenderSingleSource(Source *s)
ImGui::Text("%s %s", SourcePlayIcon(s), GstToolkit::time_to_string(s->playtime()).c_str() );
ImGui::PopFont();
// if ( ms != nullptr ) {
// // ok, get the media player of the media source
// MediaPlayer *mp = ms->mediaplayer();
// const double width_ratio = static_cast<double>(rendersize.x) / static_cast<double>(mp->timeline()->sectionsDuration());
// DrawTimeline("##timeline_mediaplayers", mp->timeline(), mp->position(), width_ratio, 60);
// }
///
/// Play button bar
///