LCOV - code coverage report
Current view: top level - src/media/video - video_sender.h (source / functions) Coverage Total Hit
Test: jami-coverage-filtered.info Lines: 100.0 % 1 1
Test Date: 2026-06-13 09:18:46 Functions: 100.0 % 2 2

            Line data    Source code
       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
      28              : namespace jami {
      29              : class SocketPair;
      30              : struct DeviceParams;
      31              : } // namespace jami
      32              : 
      33              : namespace jami {
      34              : namespace video {
      35              : 
      36              : class VideoSender : public VideoFramePassiveReader
      37              : {
      38              : public:
      39              :     VideoSender(const std::string& dest,
      40              :                 const MediaStream& opts,
      41              :                 const MediaDescription& args,
      42              :                 SocketPair& socketPair,
      43              :                 const uint16_t seqVal,
      44              :                 uint16_t mtu,
      45              :                 bool allowHwAccel = true);
      46              : 
      47          280 :     ~VideoSender() {};
      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              : 
      54              :     uint16_t getLastSeqValue();
      55              : 
      56              :     void setChangeOrientationCallback(std::function<void(int)> cb);
      57              :     int setBitrate(uint64_t br);
      58              : 
      59              : private:
      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
        

Generated by: LCOV version 2.0-1