]> git.sesse.net Git - casparcg/blob - modules/ffmpeg/ffmpeg_pipeline.h
[executor] changed default to unbounded like in 2.0.7 and fixed a deadlock when capac...
[casparcg] / modules / ffmpeg / ffmpeg_pipeline.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: Helge Norberg, helge.norberg@svt.se
20 */
21
22 #pragma once
23
24 #include <common/memory.h>
25 #include <common/array.h>
26
27 #include <core/fwd.h>
28
29 #include <boost/rational.hpp>
30
31 #include <string>
32 #include <functional>
33 #include <cstdint>
34
35 FORWARD2(caspar, diagnostics, class graph);
36
37 namespace caspar { namespace ffmpeg {
38
39 struct ffmpeg_pipeline_backend;
40
41 class ffmpeg_pipeline
42 {
43 public:
44         ffmpeg_pipeline();
45
46         ffmpeg_pipeline                 graph(spl::shared_ptr<caspar::diagnostics::graph> g);
47
48         ffmpeg_pipeline                 from_file(std::string filename);
49         ffmpeg_pipeline                 from_memory_only_audio(int num_channels, int samplerate);
50         ffmpeg_pipeline                 from_memory_only_video(int width, int height, boost::rational<int> framerate);
51         ffmpeg_pipeline                 from_memory(int num_channels, int samplerate, int width, int height, boost::rational<int> framerate);
52
53         ffmpeg_pipeline                 start_frame(std::uint32_t frame);
54         std::uint32_t                   start_frame() const;
55         ffmpeg_pipeline                 length(std::uint32_t frames);
56         std::uint32_t                   length() const;
57         ffmpeg_pipeline                 seek(std::uint32_t frame);
58         ffmpeg_pipeline                 loop(bool value);
59         bool                                    loop() const;
60         std::string                             source_filename() const;
61
62         ffmpeg_pipeline                 vfilter(std::string filter);
63         ffmpeg_pipeline                 afilter(std::string filter);
64         int                                             width() const;
65         int                                             height() const;
66         boost::rational<int>    framerate() const;
67         bool                                    progressive() const;
68
69         ffmpeg_pipeline                 to_memory(spl::shared_ptr<core::frame_factory> factory, core::video_format_desc format);
70         ffmpeg_pipeline                 to_file(std::string filename);
71         ffmpeg_pipeline                 vcodec(std::string codec);
72         ffmpeg_pipeline                 acodec(std::string codec);
73         ffmpeg_pipeline                 format(std::string fmt);
74
75         ffmpeg_pipeline                 start();
76         bool                                    try_push_audio(caspar::array<const std::int32_t> data);
77         bool                                    try_push_video(caspar::array<const std::uint8_t> data);
78         core::draw_frame                try_pop_frame();
79         std::uint32_t                   last_frame() const;
80         bool                                    started() const;
81         void                                    stop();
82
83 private:
84         std::shared_ptr<ffmpeg_pipeline_backend> impl_;
85 };
86
87 }}