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