LCOV - code coverage report
Current view: top level - src/media/video - video_sender.h (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 1 1 100.0 %
Date: 2024-11-15 09:04:49 Functions: 2 2 100.0 %

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

Generated by: LCOV version 1.14