#pragma once
// tcd - a hybid transcoder using DVSI hardware and Codec2 software
// Copyright © 2021 Thomas A. Early N7TAE
// Copyright © 2021 Doug McLain AD8DP
// 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
#include
#include
#include "codec2.h"
#include "DV3000.h"
#include "DV3003.h"
#include "UnixDgramSocket.h"
#include "configure.h"
class CController
{
public:
std::mutex dstar_mux, dmrst_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, imbeFuture, usrpFuture;
std::unordered_map audio_store;
std::unordered_map data_store;
CUnixDgramReader reader;
CUnixDgramWriter writer;
std::unordered_map> c2_16, c2_32;
std::unique_ptr dstar_device, dmrsf_device;
CPacketQueue codec2_queue;
CPacketQueue imbe_queue;
CPacketQueue usrp_queue;
std::mutex send_mux;
int16_t ambe_gain;
int16_t usrp_rxgain;
int16_t usrp_txgain;
imbe_vocoder p25vocoder;
bool DiscoverFtdiDevices(std::list> &found);
bool InitVocoders();
// processing threads
void ReadReflectorThread();
void ProcessC2Thread();
void ProcessIMBEThread();
void ProcessUSRPThread();
void Codec2toAudio(std::shared_ptr packet);
void AudiotoCodec2(std::shared_ptr packet);
void IMBEtoAudio(std::shared_ptr packet);
void AudiotoIMBE(std::shared_ptr packet);
void USRPtoAudio(std::shared_ptr packet);
void AudiotoUSRP(std::shared_ptr packet);
void SendToReflector(std::shared_ptr packet);
#ifdef USE_SW_AMBE2
std::future swambe2Future;
CPacketQueue swambe2_queue;
void ProcessSWAMBE2Thread();
void SWAMBE2toAudio(std::shared_ptr packet);
void AudiotoSWAMBE2(std::shared_ptr packet);
#endif
};