New CountVisitor to count the number of sources in session

Session size is the number of elements, use CountVisitor to count the total number of sources inside (recursively through SessionSources).
This commit is contained in:
Bruno Herbelin
2022-04-09 00:35:20 +02:00
parent f2db10d29a
commit 8fef0052a3
15 changed files with 353 additions and 148 deletions

146
CountVisitor.cpp Normal file
View File

@@ -0,0 +1,146 @@
/*
* This file is part of vimix - video live mixer
*
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
#include "Scene.h"
#include "Primitives.h"
#include "MediaSource.h"
#include "CloneSource.h"
#include "RenderSource.h"
#include "SessionSource.h"
#include "PatternSource.h"
#include "DeviceSource.h"
#include "NetworkSource.h"
#include "SrtReceiverSource.h"
#include "MultiFileSource.h"
#include "Session.h"
#include "CountVisitor.h"
CountVisitor::CountVisitor() : num_source_(0), num_playable_(0)
{
}
void CountVisitor::visit(Node &n)
{
}
void CountVisitor::visit(Group &)
{
}
void CountVisitor::visit(Switch &)
{
}
void CountVisitor::visit(Scene &)
{
}
void CountVisitor::visit(Primitive &)
{
}
void CountVisitor::visit(MediaPlayer &mp)
{
}
void CountVisitor::visit(Stream &n)
{
}
void CountVisitor::visit (MediaSource& s)
{
++num_source_;
if (s.playable())
++num_playable_;
}
void CountVisitor::visit (SessionFileSource& s)
{
num_source_ += s.session()->numSources();
if (s.playable())
++num_playable_;
}
void CountVisitor::visit (SessionGroupSource& s)
{
num_source_ += s.session()->numSources();
if (s.playable())
++num_playable_;
}
void CountVisitor::visit (RenderSource& s)
{
++num_source_;
++num_playable_;
}
void CountVisitor::visit (CloneSource& s)
{
++num_source_;
++num_playable_;
}
void CountVisitor::visit (PatternSource& s)
{
++num_source_;
if (s.playable())
++num_playable_;
}
void CountVisitor::visit (DeviceSource& s)
{
++num_source_;
if (s.playable())
++num_playable_;
}
void CountVisitor::visit (NetworkSource& s)
{
++num_source_;
if (s.playable())
++num_playable_;
}
void CountVisitor::visit (MultiFileSource& s)
{
++num_source_;
if (s.playable())
++num_playable_;
}
void CountVisitor::visit (GenericStreamSource& s)
{
++num_source_;
if (s.playable())
++num_playable_;
}
void CountVisitor::visit (SrtReceiverSource& s)
{
++num_source_;
if (s.playable())
++num_playable_;
}