]> git.sesse.net Git - casparcg/blob - core/producer/cg_proxy.h
93be32c0eee85a1c0de79672b537ad3b8964e37a
[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 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;
64
65 class cg_producer_registry : boost::noncopyable
66 {
67 public:
68         cg_producer_registry();
69
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);
77
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,
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         std::wstring get_cg_producer_name(const std::wstring& filename) const;
94 private:
95         struct impl;
96         spl::shared_ptr<impl> impl_;
97 };
98
99
100 }}