we also need a data_store[module] map

main
Tom Early 5 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 // This might complete the packet. If so, send it back to the reflector
void CController::AudiotoCodec2(std::shared_ptr<CTranscoderPacket> packet) void CController::AudiotoCodec2(std::shared_ptr<CTranscoderPacket> packet)
{ {
uint8_t m17data[8]; // the second half is silent in case this is frame is last.
c2_32.codec2_encode(m17data, packet->GetAudio()); uint8_t m17data[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0x00, 0x01, 0x43, 0x09, 0xe4, 0x9c, 0x08, 0x21 };
if (packet->IsSecond()) if (packet->IsSecond())
{ {
//move the c2_3200 data to the second half of the M17 packet // get the first half from the store
packet->SetM17Data(m17data, EAudioSection::secondhalf); 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 */ else /* the packet is first */
{ {
// move it into the packet // calculate the first half...
packet->SetM17Data(m17data, EAudioSection::firsthalf); c2_32.codec2_encode(m17data, packet->GetAudio());
if (packet->IsLast()) // and then copy the calculated data to the data_store
{ memcpy(m17data, data_store[packet->GetModule()], 8);
// 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);
}
} }
// put the M17 data into the packet
packet->SetM17Data(m17data);
// we might be all done... // we might be all done...
if (packet->AllCodecsAreSet()) if (packet->AllCodecsAreSet())
{ {

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

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

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

Loading…
Cancel
Save

Powered by TurnKey Linux.