]> git.sesse.net Git - casparcg/blob - core/producer/cg_proxy.h
* Enabled modules like flash and html (will be merged soon) to hook in CG functionali...
[casparcg] / core / producer / cg_proxy.h
1 /*
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
3 *
4 * This file is part of CasparCG (www.casparcg.com).
5 *
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.
10 *
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.
15 *
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/>.
18 *
19 * Author: Robert Nagy, ronag89@gmail.com
20 */
21
22 #pragma once
23
24 #include "frame_producer.h"
25
26 #include <common/memory.h>
27
28 #include <string>
29 #include <functional>
30 #include <set>
31
32 #include <boost/noncopyable.hpp>
33
34 namespace caspar { namespace core {
35                 
36 class cg_proxy
37 {
38 public:
39         static const unsigned int DEFAULT_LAYER = 9999;
40
41         virtual ~cg_proxy() {}
42
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;
52
53         static const spl::shared_ptr<cg_proxy>& empty();
54 };
55
56 typedef std::function<spl::shared_ptr<cg_proxy>(
57                 const spl::shared_ptr<frame_producer>& producer
58         )> cg_proxy_factory;
59 typedef std::function<spl::shared_ptr<frame_producer>(
60                 const spl::shared_ptr<class frame_factory>& factory,
61                 const video_format_desc& format_desc,
62                 const std::wstring& filename
63         )> cg_producer_factory;
64 typedef std::function<std::string(const std::wstring& filename)> meta_info_extractor;
65
66 class cg_producer_registry : boost::noncopyable
67 {
68 public:
69         cg_producer_registry();
70
71         void register_cg_producer(
72                         std::wstring cg_producer_name,
73                         std::set<std::wstring> file_extensions,
74                         meta_info_extractor info_extractor,
75                         cg_proxy_factory proxy_factory,
76                         cg_producer_factory producer_factory,
77                         bool reusable_producer_instance);
78
79         spl::shared_ptr<frame_producer> create_producer(
80                         const spl::shared_ptr<class video_channel>& video_channel,
81                         const std::wstring& filename) const;
82         spl::shared_ptr<cg_proxy> get_proxy(
83                         const spl::shared_ptr<frame_producer>& producer) const;
84         spl::shared_ptr<cg_proxy> get_proxy(
85                         const spl::shared_ptr<class video_channel>& video_channel,
86                         int render_layer) const;
87         spl::shared_ptr<cg_proxy> get_or_create_proxy(
88                         const spl::shared_ptr<class video_channel>& video_channel,
89                         int render_layer,
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 private:
94         struct impl;
95         spl::shared_ptr<impl> impl_;
96 };
97
98
99 }}