Ring Daemon 16.0.0
Loading...
Searching...
No Matches
video_sender.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 "media_encoder.h"
21#include "media_io_handle.h"
22
23#include <map>
24#include <string>
25#include <memory>
26#include <atomic>
27
28// Forward declarations
29namespace jami {
30class SocketPair;
31struct DeviceParams;
32} // namespace jami
33
34namespace jami {
35namespace video {
36
38{
39public:
40 VideoSender(const std::string& dest,
41 const MediaStream& opts,
44 const uint16_t seqVal,
46 bool allowHwAccel = true);
47
49
50 void forceKeyFrame();
51
52 // as VideoFramePassiveReader
53 void update(Observable<std::shared_ptr<MediaFrame>>* obs,
54 const std::shared_ptr<MediaFrame>& frame_p) override;
55
57
58 void setChangeOrientationCallback(std::function<void(int)> cb);
60
61private:
62 static constexpr int KEYFRAMES_AT_START {1}; // Number of keyframes to enforce at stream startup
63 static constexpr unsigned KEY_FRAME_PERIOD {0}; // seconds before forcing a keyframe
64
65 NON_COPYABLE(VideoSender);
66
67 void encodeAndSendVideo(const std::shared_ptr<VideoFrame>&);
68
69 // encoder MUST be deleted before muxContext
70 std::unique_ptr<MediaIOHandle> muxContext_ = nullptr;
71 std::unique_ptr<MediaEncoder> videoEncoder_ = nullptr;
72
73 std::atomic<int> forceKeyFrame_ {KEYFRAMES_AT_START};
74 int keyFrameFreq_ {0}; // Set keyframe rate, 0 to disable auto-keyframe. Computed in constructor
75 int64_t frameNumber_ = 0;
76
77 int rotation_ = -1;
78 std::function<void(int)> changeOrientationCallback_;
79};
80} // namespace video
81} // namespace jami
void update(Observable< std::shared_ptr< MediaFrame > > *obs, const std::shared_ptr< MediaFrame > &frame_p) override
void setChangeOrientationCallback(std::function< void(int)> cb)
int setBitrate(uint64_t br)
void emitSignal(Args... args)
Definition ring_signal.h:64
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
Definition noncopyable.h:30
MediaDescription Negotiated RTP media slot.