#include "Helpers.h"
#include <mutex>
#include <sys/time.h>

Client::Client(std::shared_ptr<rtc::PeerConnection> pc) {
    m_peerConnection = pc;
}

Client::State Client::state() const {
    std::shared_lock lock(m_mutex);
    return m_state;
}

void Client::setState(State state) {
    std::unique_lock lock(m_mutex);
    m_state = state;
}

std::shared_ptr<rtc::PeerConnection> Client::peerConnection() const {
    return m_peerConnection;
}

ClientTrack::ClientTrack(std::string id, std::shared_ptr<ClientTrackData> trackData) {
    this->id = id;
    this->trackData = trackData;
}

uint64_t currentTimeInMicroSeconds() {
    struct timeval time;
    gettimeofday(&time, NULL);
    return uint64_t(time.tv_sec) * 1000 * 1000 + time.tv_usec;
}
