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