]> git.sesse.net Git - casparcg/blob - modules/ffmpeg/producer/util/util.h
Made the server more portable
[casparcg] / modules / ffmpeg / producer / util / util.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 <common/forward.h>
25 #include <common/memory.h>
26
27 #include <core/video_format.h>
28 #include <core/frame/pixel_format.h>
29 #include <core/mixer/audio/audio_mixer.h>
30
31 #include <array>
32
33 #include <libavutil/avutil.h>
34
35 struct AVFrame;
36 struct AVFormatContext;
37 struct AVPacket;
38 struct AVRational;
39 struct AVCodecContext;
40
41 FORWARD2(caspar, core, struct pixel_format_desc);
42 FORWARD2(caspar, core, class mutable_frame);
43 FORWARD2(caspar, core, class frame_factory);
44
45 namespace caspar { namespace ffmpeg {
46                 
47 // Utils
48
49 core::field_mode                                        get_mode(const AVFrame& frame);
50 core::mutable_frame                                     make_frame(const void* tag, const spl::shared_ptr<AVFrame>& decoded_frame, double fps, core::frame_factory& frame_factory);
51 spl::shared_ptr<AVFrame>                        make_av_frame(core::mutable_frame& frame);
52 spl::shared_ptr<AVFrame>                        make_av_frame(core::const_frame& frame);
53 spl::shared_ptr<AVFrame>                        make_av_frame(std::array<uint8_t*, 4> data, const core::pixel_format_desc& pix_desc);
54
55 core::pixel_format_desc                         pixel_format_desc(PixelFormat pix_fmt, int width, int height);
56
57 spl::shared_ptr<AVPacket> create_packet();
58 spl::shared_ptr<AVFrame>  create_frame();
59
60 spl::shared_ptr<AVCodecContext> open_codec(AVFormatContext& context, AVMediaType type, int& index);
61 spl::shared_ptr<AVFormatContext> open_input(const std::wstring& filename);
62
63 bool is_sane_fps(AVRational time_base);
64 AVRational fix_time_base(AVRational time_base);
65
66 double read_fps(AVFormatContext& context, double fail_value);
67
68 std::wstring print_mode(int width, int height, double fps, bool interlaced);
69
70 std::wstring probe_stem(const std::wstring& stem);
71 bool is_valid_file(const std::wstring& filename);
72
73 }}