2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
4 * This file is part of CasparCG (www.casparcg.com).
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
19 * Author: Robert Nagy, ronag89@gmail.com
24 #include "frame_producer.h"
26 #include <common/memory.h>
32 #include <boost/noncopyable.hpp>
34 namespace caspar { namespace core {
39 static const unsigned int DEFAULT_LAYER = 9999;
41 virtual ~cg_proxy() {}
43 virtual void add(int layer, const std::wstring& template_name, bool play_on_load, const std::wstring& start_from_label = L"", const std::wstring& data = L"") = 0;
44 virtual void remove(int layer) = 0;
45 virtual void play(int layer) = 0;
46 virtual void stop(int layer, unsigned int mix_out_duration) = 0;
47 virtual void next(int layer) = 0;
48 virtual void update(int layer, const std::wstring& data) = 0;
49 virtual std::wstring invoke(int layer, const std::wstring& label) = 0;
50 virtual std::wstring description(int layer) = 0;
51 virtual std::wstring template_host_info() = 0;
53 static const spl::shared_ptr<cg_proxy>& empty();
56 typedef std::function<spl::shared_ptr<cg_proxy>(
57 const spl::shared_ptr<frame_producer>& producer
59 typedef std::function<spl::shared_ptr<frame_producer>(
60 const frame_producer_dependencies& dependencies,
61 const std::wstring& filename
62 )> cg_producer_factory;
63 typedef std::function<std::string(const std::wstring& filename)> meta_info_extractor;
65 class cg_producer_registry : boost::noncopyable
68 cg_producer_registry();
70 void register_cg_producer(
71 std::wstring cg_producer_name,
72 std::set<std::wstring> file_extensions,
73 meta_info_extractor info_extractor,
74 cg_proxy_factory proxy_factory,
75 cg_producer_factory producer_factory,
76 bool reusable_producer_instance);
78 spl::shared_ptr<frame_producer> create_producer(
79 const frame_producer_dependencies& dependencies,
80 const std::wstring& filename) const;
81 spl::shared_ptr<cg_proxy> get_proxy(
82 const spl::shared_ptr<frame_producer>& producer) const;
83 spl::shared_ptr<cg_proxy> get_proxy(
84 const spl::shared_ptr<video_channel>& video_channel,
85 int render_layer) const;
86 spl::shared_ptr<cg_proxy> get_or_create_proxy(
87 const spl::shared_ptr<video_channel>& video_channel,
88 const frame_producer_dependencies& dependencies,
90 const std::wstring& filename) const;
91 std::string read_meta_info(const std::wstring& filename) const;
92 bool is_cg_extension(const std::wstring& extension) const;
93 std::wstring get_cg_producer_name(const std::wstring& filename) const;
96 spl::shared_ptr<impl> impl_;