mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Work in progress: setting status of source on creation (automatic
activation or not?).
This commit is contained in:
@@ -348,11 +348,11 @@ void MediaPlayer::play(bool on)
|
||||
bool MediaPlayer::isPlaying(bool testpipeline) const
|
||||
{
|
||||
// image cannot play
|
||||
if (!enabled_ || isimage_)
|
||||
if (isimage_)
|
||||
return false;
|
||||
|
||||
// if not ready yet, answer with requested state
|
||||
if ( !testpipeline || pipeline_ == nullptr )
|
||||
if ( !testpipeline || pipeline_ == nullptr || !enabled_)
|
||||
return desired_state_ == GST_STATE_PLAYING;
|
||||
|
||||
// if ready, answer with actual state
|
||||
|
||||
@@ -93,6 +93,10 @@ void MediaSource::init()
|
||||
// done init
|
||||
initialized_ = true;
|
||||
Log::Info("Source Media linked to Media %s.", mediaplayer()->uri().c_str());
|
||||
|
||||
// force update of activation mode
|
||||
active_ = true;
|
||||
touch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +108,7 @@ void MediaSource::setActive (bool on)
|
||||
|
||||
Source::setActive(on);
|
||||
|
||||
// change status of media player (only if status changed)
|
||||
if ( active_ != was_active ) {
|
||||
mediaplayer()->enable(active_);
|
||||
}
|
||||
@@ -111,10 +116,10 @@ void MediaSource::setActive (bool on)
|
||||
|
||||
void MediaSource::update(float dt)
|
||||
{
|
||||
Source::update(dt);
|
||||
|
||||
// update video
|
||||
mediaplayer_->update();
|
||||
|
||||
Source::update(dt);
|
||||
}
|
||||
|
||||
void MediaSource::render()
|
||||
@@ -122,7 +127,6 @@ void MediaSource::render()
|
||||
if (!initialized_)
|
||||
init();
|
||||
else {
|
||||
|
||||
// render the media player into frame buffer
|
||||
static glm::mat4 projection = glm::ortho(-1.f, 1.f, 1.f, -1.f, -1.f, 1.f);
|
||||
renderbuffer_->begin();
|
||||
|
||||
@@ -314,6 +314,9 @@ void Mixer::insertSource(Source *s, bool makecurrent)
|
||||
layer_.scene.ws()->attach(s->group(View::LAYER));
|
||||
|
||||
if (makecurrent) {
|
||||
|
||||
s->group(View::MIXING)->translation_ = glm::vec3(-1.f, 1.f, 0.f);
|
||||
|
||||
// switch to Mixing view to show source created
|
||||
setView(View::MIXING);
|
||||
current_view_->update(0);
|
||||
|
||||
@@ -37,6 +37,13 @@ Session::~Session()
|
||||
|
||||
}
|
||||
|
||||
void Session::setActive (bool on)
|
||||
{
|
||||
for(auto it = sources_.begin(); it != sources_.end(); it++) {
|
||||
(*it)->setActive(on);
|
||||
}
|
||||
}
|
||||
|
||||
// update all sources
|
||||
void Session::update(float dt)
|
||||
{
|
||||
|
||||
@@ -35,6 +35,9 @@ public:
|
||||
// update all sources and mark sources which failed
|
||||
void update (float dt);
|
||||
|
||||
// update mode (active or not)
|
||||
void setActive (bool on);
|
||||
|
||||
// return the last source which failed
|
||||
Source *failedSource() { return failedSource_; }
|
||||
|
||||
|
||||
@@ -102,14 +102,18 @@ uint SessionSource::texture() const
|
||||
|
||||
void SessionSource::init()
|
||||
{
|
||||
Log::Info("SessionSource::init");
|
||||
|
||||
if ( loadFinished_ && !loadFailed_ && session_ != nullptr) {
|
||||
loadFinished_ = false;
|
||||
|
||||
// set resolution
|
||||
session_->setResolution( session_->config(View::RENDERING)->scale_ );
|
||||
|
||||
// update once
|
||||
// update once with update of the depth
|
||||
View::need_deep_update_ = true;
|
||||
session_->update(dt_);
|
||||
View::need_deep_update_ = false;
|
||||
|
||||
// get the texture index from framebuffer of session, apply it to the surface
|
||||
sessionsurface_->setTextureIndex( session_->frame()->texture() );
|
||||
@@ -126,23 +130,41 @@ void SessionSource::init()
|
||||
|
||||
// done init
|
||||
initialized_ = true;
|
||||
|
||||
Log::Info("Source Session %s loading %d sources.", path_.c_str(), session_->numSource());
|
||||
|
||||
// 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 ) {
|
||||
session_->setActive(active_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SessionSource::update(float dt)
|
||||
{
|
||||
// delete a source which failed
|
||||
if (session()->failedSource() != nullptr)
|
||||
session()->deleteSource(session()->failedSource());
|
||||
// Log::Info("SessionSource::update %f", dt);
|
||||
Source::update(dt);
|
||||
|
||||
// update video
|
||||
if (active_)
|
||||
session_->update(dt);
|
||||
|
||||
Source::update(dt);
|
||||
// delete a source which failed
|
||||
if (session()->failedSource() != nullptr)
|
||||
session()->deleteSource(session()->failedSource());
|
||||
}
|
||||
|
||||
void SessionSource::render()
|
||||
|
||||
@@ -12,6 +12,7 @@ public:
|
||||
|
||||
// implementation of source API
|
||||
void update (float dt) override;
|
||||
void setActive (bool on) override;
|
||||
void render() override;
|
||||
bool failed() const override;
|
||||
uint texture() const override;
|
||||
|
||||
@@ -33,7 +33,7 @@ Source::Source() : initialized_(false), active_(true), need_update_(true)
|
||||
groups_[View::MIXING] = new Group;
|
||||
groups_[View::MIXING]->visible_ = false;
|
||||
groups_[View::MIXING]->scale_ = glm::vec3(0.15f, 0.15f, 1.f);
|
||||
groups_[View::MIXING]->translation_ = glm::vec3(-1.f, 1.f, 0.f);
|
||||
// groups_[View::MIXING]->translation_ = glm::vec3(-1.f, 1.f, 0.f);
|
||||
|
||||
frames_[View::MIXING] = new Switch;
|
||||
Frame *frame = new Frame(Frame::ROUND, Frame::THIN, Frame::DROP);
|
||||
|
||||
Reference in New Issue
Block a user