diff --git a/Controller.cpp b/Controller.cpp index 4e81db3..c988c75 100644 --- a/Controller.cpp +++ b/Controller.cpp @@ -217,6 +217,12 @@ void CController::AudiotoCodec2(std::shared_ptr packet) { SendToReflector(packet); } +#ifdef DEBUG + if (packet->IsSecond()) + { + AppendM17(packet); + } +#endif } // The original incoming coded was M17, so we will calculate the audio and then @@ -272,19 +278,10 @@ void CController::ProcessC2Thread() while (keep_running) { c2_mux.lock(); - auto c2_queue_is_empty = codec2_queue.empty(); // is there a packet avaiable + auto packet = codec2_queue.pop(); c2_mux.unlock(); - if (c2_queue_is_empty) + if (packet) { - // no packet available, sleep for a little while - std::this_thread::sleep_for(std::chrono::milliseconds(5)); - } - else - { - // a packet is available, so get it - c2_mux.lock(); - auto packet = codec2_queue.pop(); - c2_mux.unlock(); switch (packet->GetCodecIn()) { case ECodecType::c2_1600: @@ -300,6 +297,8 @@ void CController::ProcessC2Thread() break; } } + else + std::this_thread::sleep_for(std::chrono::milliseconds(5)); } } @@ -420,10 +419,10 @@ void CController::ReadAmbesThread() // Finally if the packet is complete, it can be sent back to the reflector. void CController::ReadDevice(std::shared_ptr device, EAmbeType type) { - //save the dmr/dstar type + // save the dmr/dstar type const char *device_type = (EAmbeType::dstar==type) ? "D-Star" : "DMR"; - //read the response from the vocoder + // read the response from the vocoder SDV3003_Packet devpacket; if (device->GetResponse(devpacket)) { @@ -537,6 +536,21 @@ void CController::AppendWave(const std::shared_ptr packet) co std::cerr << "could not open pcm file " << sstr.str(); } +void CController::AppendM17(const std::shared_ptr packet) const +{ + std::stringstream sstr; + sstr << std::hex << ntohs(packet->GetStreamId()) << ".m17"; + std::ofstream m17file(sstr.str(), std::ofstream::app | std::ofstream::binary); + if (m17file.good()) + { + m17file.write(reinterpret_cast(packet->GetM17Data()), 16); + + m17file.close(); + } + else + std::cerr << "could not open M17 data file " << sstr.str(); +} + void CController::Dump(const std::shared_ptr p, const std::string &title) const { std::string codec; diff --git a/Controller.h b/Controller.h index 92ce6d7..a1cfa04 100644 --- a/Controller.h +++ b/Controller.h @@ -68,6 +68,7 @@ protected: void AddFDSet(int &max, int newfd, fd_set *set) const; #ifdef DEBUG void AppendWave(const std::shared_ptr packet) const; + void AppendM17(const std::shared_ptr packet) const; void Dump(const std::shared_ptr packet, const std::string &title) const; #endif }; diff --git a/DV3003.cpp b/DV3003.cpp index 27492ab..efb7790 100644 --- a/DV3003.cpp +++ b/DV3003.cpp @@ -287,7 +287,7 @@ bool CDV3003::ConfigureVocoder(uint8_t pkt_ch, Encoding type) return true; }; #ifdef DEBUG - std::cout << devicepath << " channel " << (unsigned int)pkt_ch << " is now configured for " << ((Encoding::dstar == type) ? "D-Star" : "DMR") << std::endl; + std::cout << devicepath << " channel " << (unsigned int)(pkt_ch - PKT_CHANNEL0) << " is now configured for " << ((Encoding::dstar == type) ? "D-Star" : "DMR") << std::endl; #endif return false; } diff --git a/Main.cpp b/Main.cpp index b2c4032..e82528c 100644 --- a/Main.cpp +++ b/Main.cpp @@ -25,7 +25,7 @@ int main() if (controller.Start()) return EXIT_FAILURE; - std::cout << "Hybrid Transcoder Version #211219 Successfully started" << std::endl; + std::cout << "Hybrid Transcoder Version #211220 Successfully started" << std::endl; pause();