diff --git a/src/PatternSource.cpp b/src/PatternSource.cpp index dc8a996..5f67207 100644 --- a/src/PatternSource.cpp +++ b/src/PatternSource.cpp @@ -157,6 +157,11 @@ void PatternSource::setPattern(uint type, glm::ivec2 resolution) // play gstreamer stream_->play(true); + // delete and reset render buffer to enforce re-init of StreamSource + if (renderbuffer_) + delete renderbuffer_; + renderbuffer_ = nullptr; + // will be ready after init and one frame rendered ready_ = false; } diff --git a/src/SrtReceiverSource.cpp b/src/SrtReceiverSource.cpp index 6f64080..f916d35 100644 --- a/src/SrtReceiverSource.cpp +++ b/src/SrtReceiverSource.cpp @@ -43,6 +43,11 @@ void SrtReceiverSource::setConnection(const std::string &ip, const std::string & stream_->open(description); stream_->play(true); + // delete and reset render buffer to enforce re-init of StreamSource + if (renderbuffer_) + delete renderbuffer_; + renderbuffer_ = nullptr; + // will be ready after init and one frame rendered ready_ = false; } diff --git a/src/Stream.cpp b/src/Stream.cpp index 427e8c3..f988ab4 100644 --- a/src/Stream.cpp +++ b/src/Stream.cpp @@ -106,7 +106,7 @@ std::string Stream::decoderName() guint Stream::texture() const { - if (!textureindex_) + if (!textureindex_ || !textureinitialized_) return Resource::getTextureBlack(); return textureindex_; @@ -202,9 +202,6 @@ StreamInfo StreamDiscoverer(const std::string &description, guint w, guint h) void Stream::open(const std::string &gstreamer_description, guint w, guint h) { - if ( w != width_ || h != height_ ) - textureinitialized_ = false; - // set gstreamer pipeline source description_ = gstreamer_description; @@ -238,6 +235,7 @@ void Stream::execute_open() { // reset opened_ = false; + textureinitialized_ = false; // Add custom app sink to the gstreamer pipeline std::string description = description_; @@ -369,7 +367,6 @@ void Stream::close() // un-ready opened_ = false; - textureinitialized_ = false; // clean up GST if (pipeline_ != nullptr) { diff --git a/src/StreamSource.cpp b/src/StreamSource.cpp index 88fd5ee..e745372 100644 --- a/src/StreamSource.cpp +++ b/src/StreamSource.cpp @@ -51,6 +51,11 @@ void GenericStreamSource::setDescription(const std::string &desc) stream_->open(gst_description_ + " ! queue max-size-buffers=10 ! videoconvert" ); stream_->play(true); + // delete and reset render buffer to enforce re-init of StreamSource + if (renderbuffer_) + delete renderbuffer_; + renderbuffer_ = nullptr; + // will be ready after init and one frame rendered ready_ = false; }