From c7bc0bb2292c2057acdaebd6b367ba07ce5f05e6 Mon Sep 17 00:00:00 2001 From: Jason McHuff Date: Sun, 2 Apr 2023 00:48:20 -0700 Subject: [PATCH] adding since_last_update functionality can be used to keep calls open while voice channel is active are changes to p25_recorder_impl.h and p25_frame_assembler_impl.h correct? --- .../include/op25_repeater/p25_frame_assembler.h | 3 ++- lib/op25_repeater/lib/p25_frame_assembler_impl.cc | 5 +++++ lib/op25_repeater/lib/p25_frame_assembler_impl.h | 1 + trunk-recorder/main.cc | 8 ++++---- trunk-recorder/recorders/p25_recorder.h | 1 + trunk-recorder/recorders/p25_recorder_decode.cc | 4 ++++ trunk-recorder/recorders/p25_recorder_decode.h | 1 + trunk-recorder/recorders/p25_recorder_impl.cc | 8 ++++++++ trunk-recorder/recorders/p25_recorder_impl.h | 1 + trunk-recorder/recorders/recorder.h | 1 + 10 files changed, 28 insertions(+), 5 deletions(-) diff --git a/lib/op25_repeater/include/op25_repeater/p25_frame_assembler.h b/lib/op25_repeater/include/op25_repeater/p25_frame_assembler.h index 781764410..5de90b8e1 100644 --- a/lib/op25_repeater/include/op25_repeater/p25_frame_assembler.h +++ b/lib/op25_repeater/include/op25_repeater/p25_frame_assembler.h @@ -61,7 +61,8 @@ namespace gr { virtual void reset_timer() {} virtual void set_phase2_tdma(bool p) {} virtual void clear() {}; - virtual void clear_silence_frame_count() {}; + virtual void clear_silence_frame_count() {}; + virtual double since_last_update() = 0; }; } // namespace op25_repeater diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc index 93bf4854e..fc3f9648f 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc @@ -37,6 +37,11 @@ namespace gr { namespace op25_repeater { + double p25_frame_assembler_impl::since_last_update() { + time_t now = time(NULL); + return now - p1fdma.get_rx_status().last_update; + } + /* This is for the TPS Analog decoder */ void p25_frame_assembler_impl::p25p2_queue_msg(int duid) { static const unsigned char wbuf[2] = {0xff, 0xff}; // dummy NAC diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.h b/lib/op25_repeater/lib/p25_frame_assembler_impl.h index 964425b0f..730519332 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.h +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.h @@ -90,6 +90,7 @@ namespace gr { void clear_silence_frame_count(); void clear(); + double since_last_update(); }; } // namespace op25_repeater diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 8d40c3e79..8c7f78870 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -852,7 +852,7 @@ void manage_calls() { // Handle Trunked Calls if ((call->since_last_update() > 1.0 /*config.call_timeout*/) && ((state == RECORDING) || (state == MONITORING))) { - if (state == RECORDING) { + /* if (state == RECORDING) { ended_call = true; call->set_record_more_transmissions(false); call->set_state(INACTIVE); @@ -860,7 +860,7 @@ void manage_calls() { // If the call is being recorded and the wav_sink is already hit a termination flag, the call state is set to COMPLETED // call->stop_call(); - } + } */ // we do not need to stop Monitoring Calls, we can just delete them if (state == MONITORING) { ended_call = true; @@ -888,12 +888,12 @@ void manage_calls() { } // We are checking to make sure a Call hasn't gotten stuck. If it is in the INACTIVE state - if (state == INACTIVE) { + if ((state == INACTIVE) || (state == RECORDING)) { Recorder *recorder = call->get_recorder(); if (recorder != NULL) { // if the recorder has simply been going for a while and a call is inactive, end things - if (call->since_last_update() > config.call_timeout) { + if (recorder->since_last_update() > config.call_timeout) { // BOOST_LOG_TRIVIAL(info) << "Recorder state: " << recorder->get_state(); BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Removing call that has been inactive for more than " << config.call_timeout << " Sec \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << recorder->get_state(); diff --git a/trunk-recorder/recorders/p25_recorder.h b/trunk-recorder/recorders/p25_recorder.h index 6289aef74..bfc00ad77 100644 --- a/trunk-recorder/recorders/p25_recorder.h +++ b/trunk-recorder/recorders/p25_recorder.h @@ -48,6 +48,7 @@ class p25_recorder : virtual public gr::hier_block2, virtual public Recorder { virtual void set_record_more_transmissions(bool more) = 0; virtual void set_source(long src) = 0; virtual double since_last_write() = 0; + virtual double since_last_update() = 0; virtual double get_current_length() = 0; virtual bool is_active() = 0; virtual bool is_idle() = 0; diff --git a/trunk-recorder/recorders/p25_recorder_decode.cc b/trunk-recorder/recorders/p25_recorder_decode.cc index ca740418a..f8fee0da1 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.cc +++ b/trunk-recorder/recorders/p25_recorder_decode.cc @@ -63,6 +63,10 @@ double p25_recorder_decode::since_last_write() { return now - wav_sink->get_stop_time(); } +double p25_recorder_decode::since_last_update() { + return op25_frame_assembler->since_last_update(); +} + void p25_recorder_decode::switch_tdma(bool phase2_tdma) { op25_frame_assembler->set_phase2_tdma(phase2_tdma); } diff --git a/trunk-recorder/recorders/p25_recorder_decode.h b/trunk-recorder/recorders/p25_recorder_decode.h index d46461210..7483cc49f 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.h +++ b/trunk-recorder/recorders/p25_recorder_decode.h @@ -62,6 +62,7 @@ class p25_recorder_decode : public gr::hier_block2 { void switch_tdma(bool phase2_tdma); void start(Call *call); double since_last_write(); + double since_last_update(); void stop(); int tdma_slot; bool delay_open; diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index 07a3547df..44f402394 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -307,6 +307,14 @@ double p25_recorder_impl::since_last_write() { } } +double p25_recorder_impl::since_last_update() { + if (qpsk_mod) { + return qpsk_p25_decode->since_last_update(); + } else { + return fsk4_p25_decode->since_last_update(); + } +} + State p25_recorder_impl::get_state() { if (qpsk_mod) { return qpsk_p25_decode->get_state(); diff --git a/trunk-recorder/recorders/p25_recorder_impl.h b/trunk-recorder/recorders/p25_recorder_impl.h index f968899b6..5fe0ce4ef 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.h +++ b/trunk-recorder/recorders/p25_recorder_impl.h @@ -90,6 +90,7 @@ class p25_recorder_impl : public p25_recorder { void set_record_more_transmissions(bool more); void set_source(long src); double since_last_write(); + double since_last_update(); void generate_arb_taps(); double get_current_length(); bool is_active(); diff --git a/trunk-recorder/recorders/recorder.h b/trunk-recorder/recorders/recorder.h index 13c3f56d0..2d064dba6 100644 --- a/trunk-recorder/recorders/recorder.h +++ b/trunk-recorder/recorders/recorder.h @@ -95,6 +95,7 @@ class Recorder { virtual bool is_squelched() { return true; }; virtual double get_current_length() { return 0; }; virtual double since_last_write() { return 0; }; + virtual double since_last_update() { return 0; }; virtual void clear(){}; int rec_num; static int rec_counter;