/* * libdatachannel streamer example * Copyright (c) 2020 Filip Klembara (in2core) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; If not, see . */ #ifndef helpers_hpp #define helpers_hpp #include "rtc/rtc.hpp" struct ClientTrackData { std::shared_ptr track; std::shared_ptr sender; ClientTrackData(std::shared_ptr track, std::shared_ptr sender); }; struct Client { enum class State { Waiting, WaitingForVideo, WaitingForAudio, Ready }; const std::shared_ptr & peerConnection = _peerConnection; Client(std::shared_ptr pc) { _peerConnection = pc; } std::optional> video; std::optional> audio; std::optional> dataChannel{}; void setState(State state); State getState(); private: std::shared_mutex _mutex; State state = State::Waiting; std::string id; std::shared_ptr _peerConnection; }; struct ClientTrack { std::string id; std::shared_ptr trackData; ClientTrack(std::string id, std::shared_ptr trackData); }; uint64_t currentTimeInMicroSeconds(); #endif /* helpers_hpp */