Skip to content

Commit

Permalink
fix: video_channel ownership #1511 (#1513)
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian authored Dec 22, 2023
1 parent 746e3ea commit b1ce759
Show file tree
Hide file tree
Showing 27 changed files with 187 additions and 177 deletions.
14 changes: 7 additions & 7 deletions src/core/consumer/frame_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ class print_consumer_proxy : public frame_consumer
};

spl::shared_ptr<core::frame_consumer>
frame_consumer_registry::create_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<video_channel>> channels) const
frame_consumer_registry::create_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels) const
{
if (params.empty())
CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info("params cannot be empty"));
Expand All @@ -186,10 +186,10 @@ frame_consumer_registry::create_consumer(const std::vector<std::wstring>&
}

spl::shared_ptr<frame_consumer>
frame_consumer_registry::create_consumer(const std::wstring& element_name,
const boost::property_tree::wptree& element,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<video_channel>> channels) const
frame_consumer_registry::create_consumer(const std::wstring& element_name,
const boost::property_tree::wptree& element,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels) const
{
auto& preconfigured_consumer_factories = impl_->preconfigured_consumer_factories;
auto found = preconfigured_consumer_factories.find(element_name);
Expand Down
28 changes: 15 additions & 13 deletions src/core/consumer/frame_consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ class frame_consumer
};

using consumer_factory_t =
std::function<spl::shared_ptr<frame_consumer>(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<video_channel>> channels)>;
std::function<spl::shared_ptr<frame_consumer>(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels)>;
using preconfigured_consumer_factory_t =
std::function<spl::shared_ptr<frame_consumer>(const boost::property_tree::wptree& element,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<video_channel>> channels)>;
std::function<spl::shared_ptr<frame_consumer>(const boost::property_tree::wptree& element,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels)>;

class frame_consumer_registry
{
Expand All @@ -75,13 +75,15 @@ class frame_consumer_registry
void register_consumer_factory(const std::wstring& name, const consumer_factory_t& factory);
void register_preconfigured_consumer_factory(const std::wstring& element_name,
const preconfigured_consumer_factory_t& factory);
spl::shared_ptr<frame_consumer> create_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<video_channel>> channels) const;
spl::shared_ptr<frame_consumer> create_consumer(const std::wstring& element_name,
const boost::property_tree::wptree& element,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<video_channel>> channels) const;
spl::shared_ptr<frame_consumer>
create_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels) const;
spl::shared_ptr<frame_consumer>
create_consumer(const std::wstring& element_name,
const boost::property_tree::wptree& element,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels) const;

private:
struct impl;
Expand Down
2 changes: 0 additions & 2 deletions src/core/producer/frame_producer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include "cg_proxy.h"
#include "frame_producer.h"

#include "../frame/draw_frame.h"

#include "color/color_producer.h"
#include "route/route_producer.h"
#include "separated/separated_producer.h"
Expand Down
7 changes: 4 additions & 3 deletions src/core/producer/route/route_producer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <core/video_channel.h>

#include <boost/optional.hpp>
#include <boost/range/algorithm/find_if.hpp>
#include <boost/regex.hpp>
#include <boost/signals2.hpp>

Expand Down Expand Up @@ -188,8 +187,10 @@ spl::shared_ptr<core::frame_producer> create_route_producer(const core::frame_pr
mode = core::route_mode::next;
}

auto channel_it = boost::find_if(
dependencies.channels, [=](const spl::shared_ptr<core::video_channel>& ch) { return ch->index() == channel; });
auto channel_it =
std::find_if(dependencies.channels.begin(),
dependencies.channels.end(),
[=](const spl::shared_ptr<core::video_channel>& ch) { return ch->index() == channel; });

if (channel_it == dependencies.channels.end()) {
CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"No channel with id " + std::to_wstring(channel)));
Expand Down
6 changes: 3 additions & 3 deletions src/modules/artnet/consumer/artnet_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ std::vector<fixture> get_fixtures_ptree(const boost::property_tree::wptree& ptre
}

spl::shared_ptr<core::frame_consumer>
create_preconfigured_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels)
create_preconfigured_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels)
{
configuration config;

Expand Down
6 changes: 3 additions & 3 deletions src/modules/artnet/consumer/artnet_consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
namespace caspar { namespace artnet {

spl::shared_ptr<core::frame_consumer>
create_preconfigured_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels);
create_preconfigured_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels);
}} // namespace caspar::artnet
8 changes: 4 additions & 4 deletions src/modules/bluefish/consumer/bluefish_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ struct bluefish_consumer_proxy : public core::frame_consumer

spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels)
const std::vector<spl::shared_ptr<core::video_channel>>& channels)
{
if (params.size() < 1 || !boost::iequals(params.at(0), L"BLUEFISH")) {
return core::frame_consumer::empty();
Expand Down Expand Up @@ -937,9 +937,9 @@ spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wst
}

spl::shared_ptr<core::frame_consumer>
create_preconfigured_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels)
create_preconfigured_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels)
{
configuration config;
auto device_index = ptree.get(L"device", 1);
Expand Down
14 changes: 8 additions & 6 deletions src/modules/bluefish/consumer/bluefish_consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@
#include <boost/property_tree/ptree_fwd.hpp>
#include <common/memory.h>
#include <core/fwd.h>

#include <string>
#include <vector>

namespace caspar { namespace bluefish {

spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels);
spl::shared_ptr<core::frame_consumer>
create_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels);

spl::shared_ptr<core::frame_consumer>
create_preconfigured_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels);
create_preconfigured_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels);

}} // namespace caspar::bluefish
8 changes: 4 additions & 4 deletions src/modules/decklink/consumer/decklink_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ struct decklink_consumer_proxy : public core::frame_consumer

spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels)
const std::vector<spl::shared_ptr<core::video_channel>>& channels)
{
if (params.empty() || !boost::iequals(params.at(0), L"DECKLINK")) {
return core::frame_consumer::empty();
Expand All @@ -913,9 +913,9 @@ spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wst
}

spl::shared_ptr<core::frame_consumer>
create_preconfigured_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels)
create_preconfigured_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels)
{
configuration config = parse_xml_config(ptree, format_repository);

Expand Down
13 changes: 7 additions & 6 deletions src/modules/decklink/consumer/decklink_consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@

namespace caspar { namespace decklink {

spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels);
spl::shared_ptr<core::frame_consumer>
create_preconfigured_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels);
create_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels);
spl::shared_ptr<core::frame_consumer>
create_preconfigured_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels);

}} // namespace caspar::decklink
8 changes: 4 additions & 4 deletions src/modules/ffmpeg/consumer/ffmpeg_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ struct ffmpeg_consumer : public core::frame_consumer

spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels)
const std::vector<spl::shared_ptr<core::video_channel>>& channels)
{
if (params.size() < 2 || (!boost::iequals(params.at(0), L"STREAM") && !boost::iequals(params.at(0), L"FILE")))
return core::frame_consumer::empty();
Expand All @@ -729,9 +729,9 @@ spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wst
}

spl::shared_ptr<core::frame_consumer>
create_preconfigured_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels)
create_preconfigured_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels)
{
return spl::make_shared<ffmpeg_consumer>(u8(ptree.get<std::wstring>(L"path", L"")),
u8(ptree.get<std::wstring>(L"args", L"")),
Expand Down
11 changes: 6 additions & 5 deletions src/modules/ffmpeg/consumer/ffmpeg_consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@

namespace caspar { namespace ffmpeg {

spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels);
spl::shared_ptr<core::frame_consumer>
create_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels);
spl::shared_ptr<core::frame_consumer>
create_preconfigured_consumer(const boost::property_tree::wptree&,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels);
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels);

}} // namespace caspar::ffmpeg
13 changes: 7 additions & 6 deletions src/modules/newtek/consumer/newtek_ndi_consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,10 @@ struct newtek_ndi_consumer : public core::frame_consumer

std::atomic<int> newtek_ndi_consumer::instances_(0);

spl::shared_ptr<core::frame_consumer> create_ndi_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels)
spl::shared_ptr<core::frame_consumer>
create_ndi_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels)
{
if (params.size() < 1 || !boost::iequals(params.at(0), L"NDI"))
return core::frame_consumer::empty();
Expand All @@ -266,9 +267,9 @@ spl::shared_ptr<core::frame_consumer> create_ndi_consumer(const std::vector<std:
}

spl::shared_ptr<core::frame_consumer>
create_preconfigured_ndi_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels)
create_preconfigured_ndi_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels)
{
auto name = ptree.get(L"name", L"");
bool allow_fields = ptree.get(L"allow-fields", false);
Expand Down
13 changes: 7 additions & 6 deletions src/modules/newtek/consumer/newtek_ndi_consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@

namespace caspar { namespace newtek {

spl::shared_ptr<core::frame_consumer> create_ndi_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels);
spl::shared_ptr<core::frame_consumer>
create_preconfigured_ndi_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
std::vector<spl::shared_ptr<core::video_channel>> channels);
create_ndi_consumer(const std::vector<std::wstring>& params,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels);
spl::shared_ptr<core::frame_consumer>
create_preconfigured_ndi_consumer(const boost::property_tree::wptree& ptree,
const core::video_format_repository& format_repository,
const std::vector<spl::shared_ptr<core::video_channel>>& channels);

}} // namespace caspar::newtek
2 changes: 1 addition & 1 deletion src/protocol/amcp/AMCPCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

namespace caspar { namespace protocol { namespace amcp {

std::future<std::wstring> AMCPCommand::Execute(const std::vector<channel_context>& channels)
std::future<std::wstring> AMCPCommand::Execute(const spl::shared_ptr<std::vector<channel_context>>& channels)
{
return command_(ctx_, channels);
}
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/amcp/AMCPCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class AMCPCommand

using ptr_type = std::shared_ptr<AMCPCommand>;

std::future<std::wstring> Execute(const std::vector<channel_context>& channels);
std::future<std::wstring> Execute(const spl::shared_ptr<std::vector<channel_context>>& channels);

void SendReply(const std::wstring& str, bool reply_without_req_id) const;

Expand Down
Loading

0 comments on commit b1ce759

Please sign in to comment.