mirror of https://github.com/n7tae/tcd.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.0 KiB
62 lines
2.0 KiB
#pragma once
|
|
|
|
// tcd - a hybid transcoder using DVSI hardware and Codec2 software
|
|
// Copyright © 2022 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 <https://www.gnu.org/licenses/>.
|
|
|
|
#include <netinet/in.h>
|
|
#include <string>
|
|
#include <sstream>
|
|
#include <future>
|
|
#include <atomic>
|
|
|
|
#include "PacketQueue.h"
|
|
#include "ftd2xx.h"
|
|
#include "DVSIPacket.h"
|
|
|
|
class CDVDevice
|
|
{
|
|
public:
|
|
CDVDevice(Encoding t);
|
|
virtual ~CDVDevice();
|
|
|
|
bool OpenDevice(const std::string &serialno, const std::string &desc, Edvtype dvtype);
|
|
void Start();
|
|
void CloseDevice();
|
|
void AddPacket(const std::shared_ptr<CTranscoderPacket> packet);
|
|
|
|
protected:
|
|
const Encoding type;
|
|
FT_HANDLE ftHandle;
|
|
std::atomic<unsigned int> buffer_depth;
|
|
std::atomic<bool> keep_running;
|
|
CPacketQueue input_queue;
|
|
std::future<void> feedFuture, readFuture;
|
|
std::string description;
|
|
|
|
bool DiscoverFtdiDevices();
|
|
void FTDI_Error(const char *where, FT_STATUS status) const;
|
|
bool InitDevice();
|
|
bool ConfigureVocoder(uint8_t pkt_ch, Encoding type);
|
|
bool checkResponse(SDV_Packet &responsePacket, uint8_t response) const;
|
|
bool GetResponse(SDV_Packet &packet);
|
|
void dump(const char *title, void *data, int length) const;
|
|
// pure virtual methods unique to the device type
|
|
virtual void FeedDevice() = 0;
|
|
virtual void ReadDevice() = 0;
|
|
virtual bool SendAudio(const uint8_t channel, const int16_t *audio) const = 0;
|
|
virtual bool SendData(const uint8_t channel, const uint8_t *data) const = 0;
|
|
};
|