From ee28a03a6c4cfb0db86191c39ed8cd4a29db4f90 Mon Sep 17 00:00:00 2001 From: Bruno Date: Thu, 6 May 2021 23:56:31 +0200 Subject: [PATCH] clean MultiFileSource --- MultiFileSource.cpp | 15 +++++++++++---- MultiFileSource.h | 4 +--- Stream.h | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/MultiFileSource.cpp b/MultiFileSource.cpp index 43ca8ce..954c67a 100644 --- a/MultiFileSource.cpp +++ b/MultiFileSource.cpp @@ -26,11 +26,11 @@ // splitfilesrc // gst-launch-1.0 splitfilesrc location="/home/bhbn/Videos/MOV01*.MOD" ! decodebin ! videoconvert ! autovideosink -MultiFileSequence::MultiFileSequence() : width(0), height(0), min(0), max(0), loop(1) +MultiFileSequence::MultiFileSequence() : width(0), height(0), min(0), max(0) { } -MultiFileSequence::MultiFileSequence(const std::list &list_files) : loop(1) +MultiFileSequence::MultiFileSequence(const std::list &list_files) { location = BaseToolkit::common_numbered_pattern(list_files, &min, &max); @@ -64,7 +64,6 @@ inline MultiFileSequence& MultiFileSequence::operator = (const MultiFileSequence this->height = b.height; this->min = b.min; this->max = b.max; - this->loop = b.loop; this->location = b.location; this->codec = b.codec; } @@ -75,7 +74,7 @@ inline MultiFileSequence& MultiFileSequence::operator = (const MultiFileSequence bool MultiFileSequence::operator != (const MultiFileSequence& b) { return ( location != b.location || codec != b.codec || width != b.width || - height != b.height || min != b.min || max != b.max || loop != b.loop ); + height != b.height || min != b.min || max != b.max ); } MultiFile::MultiFile() : Stream(), src_(nullptr) @@ -109,6 +108,14 @@ void MultiFile::open (const MultiFileSequence &sequence, uint framerate ) src_ = gst_bin_get_by_name (GST_BIN (pipeline_), "src"); } +void MultiFile::close () +{ + if (src_ != nullptr) { + gst_object_unref (src_); + src_ = nullptr; + } + Stream::close(); +} void MultiFile::setProperties (int begin, int end, int loop) { diff --git a/MultiFileSource.h b/MultiFileSource.h index 676e822..5435730 100644 --- a/MultiFileSource.h +++ b/MultiFileSource.h @@ -13,9 +13,6 @@ struct MultiFileSequence { uint height; int min; int max; - int begin; - int end; - int loop; MultiFileSequence (); MultiFileSequence (const std::list &list_files); @@ -29,6 +26,7 @@ class MultiFile : public Stream public: MultiFile (); void open (const MultiFileSequence &sequence, uint framerate = 30); + void close () override; // dynamic change of gstreamer multifile source properties void setProperties(int begin, int end, int loop); diff --git a/Stream.h b/Stream.h index fbcae96..f4c6a4b 100644 --- a/Stream.h +++ b/Stream.h @@ -49,7 +49,7 @@ public: /** * Close the Media * */ - void close(); + virtual void close(); /** * Update texture with latest frame * Must be called in rendering update loop