Ring Daemon 16.0.0
Loading...
Searching...
No Matches
video_base.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include "noncopyable.h"
20#include "observer.h"
21
22#pragma GCC diagnostic push
23#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
24#pragma GCC diagnostic ignored "-Wshadow"
25#include <yaml-cpp/yaml.h>
26#pragma GCC diagnostic pop
27
28#include <cstdlib>
29#include <cstdint>
30#include <memory>
31#include <set>
32#include <mutex>
33#include <ciso646> // fix windows compiler bug
34
35extern "C" {
36#include <libavutil/pixfmt.h>
37
38struct AVPacket;
39struct AVDictionary;
40
41#ifndef AVFORMAT_AVIO_H
42struct AVIOContext;
43#endif
44}
45
46namespace libjami {
47class MediaFrame;
48class VideoFrame;
49} // namespace libjami
50
51namespace jami {
54} // namespace jami
55
56namespace jami {
57namespace video {
58
59struct VideoFrameActiveWriter : Observable<std::shared_ptr<MediaFrame>>
60{};
61struct VideoFramePassiveReader : Observer<std::shared_ptr<MediaFrame>>
62{};
63
64/*=== VideoGenerator =========================================================*/
65
67{
68public:
70
71 virtual int getWidth() const = 0;
72 virtual int getHeight() const = 0;
73 virtual AVPixelFormat getPixelFormat() const = 0;
74
75 std::shared_ptr<VideoFrame> obtainLastFrame();
76
77public:
78 // getNewFrame and publishFrame must be called by the same thread only
80 void publishFrame();
81 void publishFrame(std::shared_ptr<VideoFrame>);
82 void flushFrames();
83
84private:
85 std::shared_ptr<VideoFrame> writableFrame_ = nullptr;
86 std::shared_ptr<VideoFrame> lastFrame_ = nullptr;
87 std::mutex mutex_ {}; // lock writableFrame_/lastFrame_ access
88};
89
91{
93 VideoSettings(const std::map<std::string, std::string>& settings);
94
95 std::map<std::string, std::string> to_map() const;
96
97 std::string unique_id {};
98 std::string input {};
99 std::string name {};
100 std::string channel {};
101 std::string video_size {};
102 std::string framerate {};
103};
104
105} // namespace video
106} // namespace jami
107
108namespace YAML {
109template<>
110struct convert<jami::video::VideoSettings>
111{
112 static Node encode(const jami::video::VideoSettings& rhs);
113 static bool decode(const Node& node, jami::video::VideoSettings& rhs);
114};
115
116Emitter& operator<<(Emitter& out, const jami::video::VideoSettings& v);
117
118} // namespace YAML
virtual int getWidth() const =0
virtual AVPixelFormat getPixelFormat() const =0
virtual int getHeight() const =0
std::shared_ptr< VideoFrame > obtainLastFrame()
Emitter & operator<<(Emitter &out, const jami::video::VideoSettings &v)
void emitSignal(Args... args)
Definition ring_signal.h:64
libjami::VideoFrame VideoFrame
Definition video_base.h:53
libjami::MediaFrame MediaFrame
Simple macro to hide class' copy constructor and assignment operator.
std::map< std::string, std::string > to_map() const