1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- /**
- * libdatachannel streamer example
- * Copyright (c) 2020 Filip Klembara (in2core)
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
- */
- #ifndef helpers_hpp
- #define helpers_hpp
- #include "rtc/rtc.hpp"
- #include <shared_mutex>
- struct ClientTrackData {
- std::shared_ptr<rtc::Track> track;
- std::shared_ptr<rtc::RtcpSrReporter> sender;
- ClientTrackData(std::shared_ptr<rtc::Track> track, std::shared_ptr<rtc::RtcpSrReporter> sender);
- };
- struct Client {
- enum class State {
- Waiting,
- WaitingForVideo,
- WaitingForAudio,
- Ready
- };
- const std::shared_ptr<rtc::PeerConnection> & peerConnection = _peerConnection;
- Client(std::shared_ptr<rtc::PeerConnection> pc) {
- _peerConnection = pc;
- }
- std::optional<std::shared_ptr<ClientTrackData>> video;
- std::optional<std::shared_ptr<ClientTrackData>> audio;
- std::optional<std::shared_ptr<rtc::DataChannel>> dataChannel;
- void setState(State state);
- State getState();
- uint32_t rtpStartTimestamp = 0;
- private:
- std::shared_mutex _mutex;
- State state = State::Waiting;
- std::string id;
- std::shared_ptr<rtc::PeerConnection> _peerConnection;
- };
- struct ClientTrack {
- std::string id;
- std::shared_ptr<ClientTrackData> trackData;
- ClientTrack(std::string id, std::shared_ptr<ClientTrackData> trackData);
- };
- uint64_t currentTimeInMicroSeconds();
- #endif /* helpers_hpp */
|