]> git.sesse.net Git - casparcg/blobdiff - core/producer/stage.h
[ffmpeg_producer] Don't assume interlaced material based on resolution.
[casparcg] / core / producer / stage.h
index bdd39d6a74d122da4dc56b29ad910c5bf30e1d3c..69925892ec05babee4b27d6112e6b623b832ed00 100644 (file)
-/*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG (www.casparcg.com).\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-* Author: Robert Nagy, ronag89@gmail.com\r
-*/\r
-\r
-#pragma once\r
-\r
-#include "frame_producer.h"\r
-\r
-#include <common/memory/safe_ptr.h>\r
-#include <common/concurrency/target.h>\r
-#include <common/diagnostics/graph.h>\r
-\r
-#include <boost/noncopyable.hpp>\r
-#include <boost/property_tree/ptree_fwd.hpp>\r
-#include <boost/thread/future.hpp>\r
-\r
-#include <functional>\r
-\r
-namespace caspar { namespace core {\r
-\r
-struct video_format_desc;\r
-struct frame_transform;\r
-\r
-class stage : boost::noncopyable\r
-{\r
-public:\r
-       typedef target<std::pair<std::map<int, safe_ptr<basic_frame>>, std::shared_ptr<void>>> target_t;\r
-\r
-       explicit stage(const safe_ptr<diagnostics::graph>& graph, const safe_ptr<target_t>& target, const video_format_desc& format_desc);\r
-       \r
-       // stage\r
-       \r
-       void set_frame_transform(int index, const frame_transform& transform, unsigned int mix_duration = 0, const std::wstring& tween = L"linear");\r
-       void apply_frame_transform(int index, const std::function<frame_transform(frame_transform)>& transform, unsigned int mix_duration = 0, const std::wstring& tween = L"linear");\r
-       void clear_transforms(int index);\r
-       void clear_transforms();\r
-\r
-       void spawn_token();\r
-                       \r
-       void load(int index, const safe_ptr<frame_producer>& producer, bool preview = false, int auto_play_delta = -1);\r
-       void pause(int index);\r
-       void play(int index);\r
-       void stop(int index);\r
-       void clear(int index);\r
-       void clear();   \r
-       void swap_layers(const safe_ptr<stage>& other);\r
-       void swap_layer(int index, int other_index);\r
-       void swap_layer(int index, int other_index, const safe_ptr<stage>& other);\r
-       \r
-       boost::unique_future<std::wstring>                              call(int index, bool foreground, const std::wstring& param);\r
-       boost::unique_future<safe_ptr<frame_producer>>  foreground(int index);\r
-       boost::unique_future<safe_ptr<frame_producer>>  background(int index);\r
-\r
-       boost::unique_future<boost::property_tree::wptree> info() const;\r
-       boost::unique_future<boost::property_tree::wptree> info(int layer) const;\r
-       \r
-       void set_video_format_desc(const video_format_desc& format_desc);\r
-\r
-private:\r
-       struct implementation;\r
-       safe_ptr<implementation> impl_;\r
-};\r
-\r
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG 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 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG 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 CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Robert Nagy, ronag89@gmail.com
+*/
+
+#pragma once
+
+#include "../fwd.h"
+#include "../monitor/monitor.h"
+#include "../interaction/interaction_sink.h"
+
+#include <common/forward.h>
+#include <common/future_fwd.h>
+#include <common/memory.h>
+#include <common/tweener.h>
+
+#include <boost/optional.hpp>
+#include <boost/property_tree/ptree_fwd.hpp>
+
+#include <functional>
+#include <map>
+#include <tuple>
+#include <vector>
+
+FORWARD2(caspar, diagnostics, class graph);
+
+namespace caspar { namespace core {
+
+//typedef reactive::observable<std::map<int, class draw_frame>> frame_observable;
+       
+class stage final : public interaction_sink
+{
+       stage(const stage&);
+       stage& operator=(const stage&);
+public:
+
+       // Static Members
+       
+       typedef std::function<struct frame_transform(struct frame_transform)> transform_func_t;
+       typedef std::tuple<int, transform_func_t, unsigned int, tweener> transform_tuple_t;
+
+       // Constructors
+
+       explicit stage(int channel_index, spl::shared_ptr<caspar::diagnostics::graph> graph);
+       
+       // Methods
+
+       std::map<int, draw_frame>               operator()(const video_format_desc& format_desc);
+
+       std::future<void>                               apply_transforms(const std::vector<transform_tuple_t>& transforms);
+       std::future<void>                               apply_transform(int index, const transform_func_t& transform, unsigned int mix_duration, const tweener& tween);
+       std::future<void>                               clear_transforms(int index);
+       std::future<void>                               clear_transforms();
+       std::future<frame_transform>    get_current_transform(int index);
+       std::future<void>                               load(int index, const spl::shared_ptr<frame_producer>& producer, bool preview = false, const boost::optional<int32_t>& auto_play_delta = boost::optional<int32_t>());
+       std::future<void>                               pause(int index);
+       std::future<void>                               resume(int index);
+       std::future<void>                               play(int index);
+       std::future<void>                               stop(int index);
+       std::future<std::wstring>               call(int index, const std::vector<std::wstring>& params);
+       std::future<void>                               clear(int index);
+       std::future<void>                               clear();
+       std::future<void>                               swap_layers(stage& other, bool swap_transforms);
+       std::future<void>                               swap_layer(int index, int other_index, bool swap_transforms);
+       std::future<void>                               swap_layer(int index, int other_index, stage& other, bool swap_transforms);
+
+       void                                                    add_layer_consumer(void* token, int layer, const spl::shared_ptr<write_frame_consumer>& layer_consumer);
+       void                                                    remove_layer_consumer(void* token, int layer);
+
+       monitor::subject& monitor_output();     
+
+       // frame_observable
+       //void subscribe(const frame_observable::observer_ptr& o) override;
+       //void unsubscribe(const frame_observable::observer_ptr& o) override;
+
+       // interaction_sink
+
+       void on_interaction(const interaction_event::ptr& event) override;
+
+       // Properties
+
+       std::future<std::shared_ptr<frame_producer>>    foreground(int index);
+       std::future<std::shared_ptr<frame_producer>>    background(int index);
+
+       std::future<boost::property_tree::wptree>               info() const;
+       std::future<boost::property_tree::wptree>               info(int index) const;
+
+       std::future<boost::property_tree::wptree>               delay_info() const;
+       std::future<boost::property_tree::wptree>               delay_info(int layer) const;
+private:
+       struct impl;
+       spl::shared_ptr<impl> impl_;
+};
+
 }}
\ No newline at end of file