#pragma once
// tcd - a hybid transcoder using DVSI hardware and Codec2 software
// Copyright © 2021 Thomas A. Early N7TAE
// 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 3 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 .
#include
#include
#include
#include
#include
#include "codec2.h"
#include "DV3003.h"
#include "UnixDgramSocket.h"
#include "configure.h"
enum class EAmbeType { dstar, dmr };
class CController
{
public:
std::mutex dstar_mux, dmr_mux;
CController();
bool Start();
void Stop();
void RouteDstPacket(std::shared_ptr packet);
void RouteDmrPacket(std::shared_ptr packet);
void Dump(const std::shared_ptr packet, const std::string &title) const;
protected:
std::atomic keep_running;
std::future reflectorFuture, c2Future;
std::unordered_map audio_store;
std::unordered_map data_store;
CUnixDgramReader reader;
CUnixDgramWriter writer;
std::unordered_map> c2_16, c2_32;
CDV3003 dstar_device{Encoding::dstar};
CDV3003 dmr_device{Encoding::dmr};
CPacketQueue codec2_queue;
std::mutex send_mux;
bool InitDevices();
// processing threads
void ReadReflectorThread();
void ProcessC2Thread();
bool CheckTCModules() const;
void Codec2toAudio(std::shared_ptr packet);
void AudiotoCodec2(std::shared_ptr packet);
void SendToReflector(std::shared_ptr packet);
#ifdef DEBUG
void AppendWave(const std::shared_ptr packet) const;
void AppendM17(const std::shared_ptr packet) const;
#endif
};