LCOV - code coverage report
Current view: top level - src/client - videomanager.h (source / functions) Coverage Total Hit
Test: jami-coverage-filtered.info Lines: 0.0 % 3 0
Test Date: 2026-08-23 08:52:56 Functions: 0.0 % 1 0

            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              : #ifdef HAVE_CONFIG_H
      20              : #include "config.h"
      21              : #endif
      22              : 
      23              : #include <memory> // for weak/shared_ptr
      24              : #include <map>
      25              : #include <mutex>
      26              : #include <condition_variable>
      27              : #include <cstdint>
      28              : #include <string>
      29              : 
      30              : #include "media/audio/audio_input.h"
      31              : #ifdef ENABLE_VIDEO
      32              : #include "media/video/video_device_monitor.h"
      33              : #include "media/video/video_input.h"
      34              : #endif
      35              : #include "media/media_player.h"
      36              : 
      37              : namespace jami {
      38              : 
      39              : struct VideoManager
      40              : {
      41              : public:
      42              :     // Client-managed video inputs and players
      43              :     std::map<std::string, std::shared_ptr<MediaPlayer>> mediaPlayers;
      44              :     std::mutex mediaPlayersMutex;
      45              : 
      46              :     // Client-managed audio preview
      47              :     std::shared_ptr<AudioInput> audioPreview;
      48              : 
      49              : #ifdef ENABLE_VIDEO
      50              :     std::map<std::string, std::shared_ptr<video::VideoInput>> clientVideoInputs;
      51              :     void setDeviceOrientation(const std::string& deviceId, int angle);
      52              :     // device monitor
      53              :     video::VideoDeviceMonitor videoDeviceMonitor;
      54              :     // A registered VideoInput. The generation uniquely identifies the instance
      55              :     // that registered the entry, so that the deleter of an instance which
      56              :     // outlived its registration cannot unregister a later one.
      57              :     struct VideoInputEntry
      58              :     {
      59              :         std::weak_ptr<video::VideoInput> input;
      60              :         uint64_t generation {0};
      61              :     };
      62            0 :     std::shared_ptr<video::VideoInput> getVideoInput(std::string_view id) const
      63              :     {
      64            0 :         auto input = videoInputs.find(id);
      65            0 :         return input == videoInputs.end() ? nullptr : input->second.input.lock();
      66              :     }
      67              :     std::mutex videoMutex;
      68              :     std::map<std::string, VideoInputEntry, std::less<>> videoInputs;
      69              :     uint64_t nextVideoInputGeneration {0};
      70              :     // Notified once a VideoInput has been fully destroyed and unregistered from
      71              :     // videoInputs, so that a new one can be created for the same sink.
      72              :     std::condition_variable videoInputsCv;
      73              : #endif
      74              : 
      75              :     /**
      76              :      * Cache of the active Audio/Video input(s).
      77              :      */
      78              :     std::map<std::string, std::weak_ptr<AudioInput>, std::less<>> audioInputs;
      79              :     std::mutex audioMutex;
      80              :     bool hasRunningPlayers();
      81              : };
      82              : 
      83              : #ifdef ENABLE_VIDEO
      84              : video::VideoDeviceMonitor* getVideoDeviceMonitor();
      85              : std::shared_ptr<video::VideoInput> getVideoInput(const std::string& resource,
      86              :                                                  video::VideoInputMode inputMode = video::VideoInputMode::Undefined,
      87              :                                                  const std::string& sink = "");
      88              : #endif
      89              : std::shared_ptr<AudioInput> getAudioInput(const std::string& device);
      90              : std::string createMediaPlayer(const std::string& path);
      91              : std::shared_ptr<MediaPlayer> getMediaPlayer(const std::string& id);
      92              : bool pausePlayer(const std::string& id, bool pause);
      93              : bool closeMediaPlayer(const std::string& id);
      94              : bool mutePlayerAudio(const std::string& id, bool mute);
      95              : bool playerSeekToTime(const std::string& id, int time);
      96              : int64_t getPlayerPosition(const std::string& id);
      97              : int64_t getPlayerDuration(const std::string& id);
      98              : void setAutoRestart(const std::string& id, bool restart);
      99              : 
     100              : } // namespace jami
        

Generated by: LCOV version 2.0-1