Ring Daemon
Loading...
Searching...
No Matches
video_base.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2026 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 "observer.h"
20
21#pragma GCC diagnostic push
22#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
23#pragma GCC diagnostic ignored "-Wshadow"
24#include <yaml-cpp/yaml.h>
25#pragma GCC diagnostic pop
26
27#include <cstdlib>
28#include <memory>
29#include <mutex>
30
31extern "C" {
32#include <libavutil/pixfmt.h>
33
34struct AVPacket;
35struct AVDictionary;
36
37#ifndef AVFORMAT_AVIO_H
38struct AVIOContext;
39#endif
40}
41
42namespace libjami {
43class MediaFrame;
44class VideoFrame;
45} // namespace libjami
46
47namespace jami {
50} // namespace jami
51
52namespace jami {
53namespace video {
54
55struct VideoFrameActiveWriter : Observable<std::shared_ptr<MediaFrame>>
56{};
57struct VideoFramePassiveReader : Observer<std::shared_ptr<MediaFrame>>
58{};
59
60/*=== VideoGenerator =========================================================*/
61
63{
64public:
66
67 virtual int getWidth() const = 0;
68 virtual int getHeight() const = 0;
69 virtual AVPixelFormat getPixelFormat() const = 0;
70
71 std::shared_ptr<VideoFrame> obtainLastFrame();
72
73public:
74 // getNewFrame and publishFrame must be called by the same thread only
76 void publishFrame();
77 void publishFrame(std::shared_ptr<VideoFrame>);
78 void flushFrames();
79
80private:
81 std::shared_ptr<VideoFrame> writableFrame_ = nullptr;
82 std::shared_ptr<VideoFrame> lastFrame_ = nullptr;
83 std::mutex mutex_ {}; // lock writableFrame_/lastFrame_ access
84};
85
87{
89 VideoSettings(const std::map<std::string, std::string>& settings);
90
91 std::map<std::string, std::string> to_map() const;
92
93 std::string unique_id {};
94 std::string input {};
95 std::string name {};
96 std::string channel {};
97 std::string video_size {};
98 std::string framerate {};
99};
100
101} // namespace video
102} // namespace jami
103
104namespace YAML {
105template<>
106struct convert<jami::video::VideoSettings>
107{
108 static Node encode(const jami::video::VideoSettings& rhs);
109 static bool decode(const Node& node, jami::video::VideoSettings& rhs);
110};
111
112Emitter& operator<<(Emitter& out, const jami::video::VideoSettings& v);
113
114} // 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 jami_signal.h:64
libjami::VideoFrame VideoFrame
Definition video_base.h:49
libjami::MediaFrame MediaFrame
std::map< std::string, std::string > to_map() const