2019-01-27 21:43:49 +00:00
|
|
|
/*
|
|
|
|
* Modern effects for a modern Streamer
|
|
|
|
* Copyright (C) 2017-2018 Michael Fabian Dirks
|
|
|
|
*
|
|
|
|
* 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 2 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-04-02 15:02:01 +00:00
|
|
|
#include "common.hpp"
|
2019-01-27 21:43:49 +00:00
|
|
|
#include <functional>
|
|
|
|
#include <map>
|
2020-07-26 16:38:49 +00:00
|
|
|
#include <mutex>
|
2019-01-27 21:43:49 +00:00
|
|
|
|
2021-06-08 02:36:30 +00:00
|
|
|
namespace streamfx::obs {
|
2019-01-27 21:43:49 +00:00
|
|
|
class source_tracker {
|
2020-07-26 16:38:49 +00:00
|
|
|
std::map<std::string, std::shared_ptr<obs_weak_source_t>> _sources;
|
|
|
|
std::mutex _lock;
|
2019-01-27 21:43:49 +00:00
|
|
|
|
2019-09-05 16:42:28 +00:00
|
|
|
static void source_create_handler(void* ptr, calldata_t* data) noexcept;
|
|
|
|
static void source_destroy_handler(void* ptr, calldata_t* data) noexcept;
|
|
|
|
static void source_rename_handler(void* ptr, calldata_t* data) noexcept;
|
2019-01-27 21:43:49 +00:00
|
|
|
|
|
|
|
public: // Singleton
|
2021-06-08 02:36:30 +00:00
|
|
|
static void initialize();
|
|
|
|
static void finalize();
|
|
|
|
static std::shared_ptr<streamfx::obs::source_tracker> get();
|
2019-01-27 21:43:49 +00:00
|
|
|
|
2019-04-19 12:18:29 +00:00
|
|
|
public:
|
2019-01-27 21:43:49 +00:00
|
|
|
source_tracker();
|
|
|
|
~source_tracker();
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Callback function for enumerating sources.
|
|
|
|
//
|
|
|
|
// @param std::string Name of the Source
|
|
|
|
// @param obs_source_t* Source
|
|
|
|
// @return true to abort enumeration, false to keep going.
|
|
|
|
typedef std::function<bool(std::string, obs_source_t*)> enumerate_cb_t;
|
|
|
|
|
|
|
|
// Filter function for enumerating sources.
|
|
|
|
//
|
|
|
|
// @param std::string Name of the Source
|
|
|
|
// @param obs_source_t* Source
|
|
|
|
// @return true to skip, false to pass along.
|
|
|
|
typedef std::function<bool(std::string, obs_source_t*)> filter_cb_t;
|
|
|
|
|
|
|
|
//! Enumerate all tracked sources
|
|
|
|
//
|
|
|
|
// @param enumerate_cb The function called for each tracked source.
|
|
|
|
// @param filter_cb Filter function to narrow down results.
|
|
|
|
void enumerate(enumerate_cb_t enumerate_cb, filter_cb_t filter_cb = nullptr);
|
|
|
|
|
|
|
|
public:
|
|
|
|
static bool filter_sources(std::string name, obs_source_t* source);
|
|
|
|
static bool filter_audio_sources(std::string name, obs_source_t* source);
|
|
|
|
static bool filter_video_sources(std::string name, obs_source_t* source);
|
|
|
|
static bool filter_transitions(std::string name, obs_source_t* source);
|
|
|
|
static bool filter_scenes(std::string name, obs_source_t* source);
|
|
|
|
};
|
2021-06-08 02:36:30 +00:00
|
|
|
} // namespace streamfx::obs
|