we also need a data_store[module] map

main
Tom Early 4 years ago
parent ecdfd4d26c
commit 1443fe4cc9

@ -194,25 +194,24 @@ void CController::ReadReflectorThread()
// This might complete the packet. If so, send it back to the reflector
void CController::AudiotoCodec2(std::shared_ptr<CTranscoderPacket> packet)
{
uint8_t m17data[8];
c2_32.codec2_encode(m17data, packet->GetAudio());
// the second half is silent in case this is frame is last.
uint8_t m17data[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0x00, 0x01, 0x43, 0x09, 0xe4, 0x9c, 0x08, 0x21 };
if (packet->IsSecond())
{
//move the c2_3200 data to the second half of the M17 packet
packet->SetM17Data(m17data, EAudioSection::secondhalf);
// get the first half from the store
memcpy(m17data, data_store[packet->GetModule()], 8);
// and then calculate the second half
c2_32.codec2_encode(m17data+8, packet->GetAudio());
}
else /* the packet is first */
{
// move it into the packet
packet->SetM17Data(m17data, EAudioSection::firsthalf);
if (packet->IsLast())
{
// we have an odd number of packets, so we have to finish up the m17 packet
const uint8_t silence[] = {0x00, 0x01, 0x43, 0x09, 0xe4, 0x9c, 0x08, 0x21 };
//put codec silence in the second half of the codec
packet->SetM17Data(silence, EAudioSection::secondhalf);
}
// calculate the first half...
c2_32.codec2_encode(m17data, packet->GetAudio());
// and then copy the calculated data to the data_store
memcpy(m17data, data_store[packet->GetModule()], 8);
}
// put the M17 data into the packet
packet->SetM17Data(m17data);
// we might be all done...
if (packet->AllCodecsAreSet())
{

@ -45,6 +45,7 @@ protected:
std::future<void> reflectorFuture, readambeFuture, feedambeFuture, c2Future;
std::vector<std::shared_ptr<CDV3003>> dmr_device, dstar_device;
std::map<char, int16_t[160]> audio_store;
std::map<char, uint8_t[8]> data_store;
CUnixDgramReader reader;
CUnixDgramWriter writer;
CCodec2 c2_16{false};

@ -35,7 +35,7 @@ CTranscoderPacket::CTranscoderPacket(const STCPacket &tcp) : dstar_set(false), d
break;
case ECodecType::c2_1600:
case ECodecType::c2_3200:
SetM17Data(tcp.m17, EAudioSection::all);
SetM17Data(tcp.m17);
break;
default:
std::cerr << "Trying to allocate CTranscoderPacket with an unknown codec type!" << std::endl;
@ -68,13 +68,10 @@ const STCPacket *CTranscoderPacket::GetTCPacket() const
return &tcpacket;
}
void CTranscoderPacket::SetM17Data(const uint8_t *data, EAudioSection section)
void CTranscoderPacket::SetM17Data(const uint8_t *data)
{
const unsigned int offset = (EAudioSection::secondhalf == section) ? 8 : 0;
const unsigned int size = (EAudioSection::all == section) ? 16 : 8;
memcpy(tcpacket.m17+offset, data, size);
if (EAudioSection::firsthalf != section)
m17_set = true;
memcpy(tcpacket.m17, data, 16);
m17_set = true;
}
void CTranscoderPacket::SetDStarData(const uint8_t *dstar)

@ -22,8 +22,6 @@
#include "TCPacketDef.h"
enum class EAudioSection { firsthalf, secondhalf, all };
class CTranscoderPacket
{
public:
@ -39,7 +37,7 @@ public:
const uint8_t *GetM17Data() const;
void SetDStarData(const uint8_t *dstar);
void SetDMRData(const uint8_t *dmr);
void SetM17Data(const uint8_t *m17, EAudioSection section);
void SetM17Data(const uint8_t *m17);
// audio
int16_t *GetAudio();

Loading…
Cancel
Save

Powered by TurnKey Linux.