From 748a44f64ba05c1fdbee8b4b82a07f8df2c212f2 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Tue, 4 May 2021 22:19:04 -0400 Subject: [PATCH 1/2] Update call.cc fixes start time --- trunk-recorder/call.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/trunk-recorder/call.cc b/trunk-recorder/call.cc index 63dae1b6b..5ac5d2bf9 100644 --- a/trunk-recorder/call.cc +++ b/trunk-recorder/call.cc @@ -121,8 +121,10 @@ void Call::end_call() { BOOST_LOG_TRIVIAL(error) << "Call::end_call() State is recording, but no recorder assigned!"; } BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\tTG: " << this->get_talkgroup_display() << "\tFreq: " << FormatFreq(get_freq()) << "\tEnding Recorded Call - Last Update: " << this->since_last_update() << "s\tCall Elapsed: " << this->elapsed(); - + final_length = recorder->get_current_length(); + // Fixes https://github.com/robotastic/trunk-recorder/issues/103#issuecomment-284825841 + start_time = stop_time - final_length; if (freq_count > 0) { Rx_Status rx_status = recorder->get_rx_status(); From 8f4ba3497734e6536dd332e0b259da698d594994 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sat, 15 May 2021 09:22:00 -0400 Subject: [PATCH 2/2] Updated so the start_time fix only applies to Conventional Calls --- trunk-recorder/call.cc | 12 +++++------- trunk-recorder/call.h | 3 ++- trunk-recorder/call_conventional.cc | 5 +++++ trunk-recorder/call_conventional.h | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/trunk-recorder/call.cc b/trunk-recorder/call.cc index 5ac5d2bf9..14124e757 100644 --- a/trunk-recorder/call.cc +++ b/trunk-recorder/call.cc @@ -111,6 +111,7 @@ Call::~Call() { void Call::restart_call() { } + void Call::end_call() { std::stringstream shell_command; std::string shell_command_string; @@ -123,8 +124,9 @@ void Call::end_call() { BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\tTG: " << this->get_talkgroup_display() << "\tFreq: " << FormatFreq(get_freq()) << "\tEnding Recorded Call - Last Update: " << this->since_last_update() << "s\tCall Elapsed: " << this->elapsed(); final_length = recorder->get_current_length(); - // Fixes https://github.com/robotastic/trunk-recorder/issues/103#issuecomment-284825841 - start_time = stop_time - final_length; + + + if (freq_count > 0) { Rx_Status rx_status = recorder->get_rx_status(); @@ -138,7 +140,7 @@ void Call::end_call() { if (myfile.is_open()) { myfile << "{\n"; myfile << "\"freq\": " << this->curr_freq << ",\n"; - myfile << "\"start_time\": " << this->start_time << ",\n"; + myfile << "\"start_time\": " << this->get_start_time() << ",\n"; myfile << "\"stop_time\": " << this->stop_time << ",\n"; myfile << "\"emergency\": " << this->emergency << ",\n"; //myfile << "\"source\": \"" << this->get_recorder()->get_source()->get_device() << "\",\n"; @@ -481,10 +483,6 @@ long Call::get_stop_time() { return stop_time; } -long Call::get_start_time() { - return start_time; -} - char *Call::get_converted_filename() { return converted_filename; } diff --git a/trunk-recorder/call.h b/trunk-recorder/call.h index 3a3cafe03..1681098b6 100644 --- a/trunk-recorder/call.h +++ b/trunk-recorder/call.h @@ -82,7 +82,7 @@ class Call { int since_last_update(); long stopping_elapsed(); long elapsed(); - long get_start_time(); + double get_current_length(); long get_stop_time(); void set_debug_recording(bool m); @@ -96,6 +96,7 @@ class Call { void set_tdma_slot(int s); int get_tdma_slot(); const char *get_xor_mask(); + virtual time_t get_start_time() {return start_time;} virtual bool is_conventional() { return false; } void set_encrypted(bool m); bool get_encrypted(); diff --git a/trunk-recorder/call_conventional.cc b/trunk-recorder/call_conventional.cc index 3ffacf6f7..1ec212517 100644 --- a/trunk-recorder/call_conventional.cc +++ b/trunk-recorder/call_conventional.cc @@ -30,6 +30,11 @@ void Call_conventional::restart_call() { recorder->start(this); } +time_t Call_conventional::get_start_time() { + // Fixes https://github.com/robotastic/trunk-recorder/issues/103#issuecomment-284825841 + return start_time = stop_time - final_length; +} + void Call_conventional::set_recorder(Recorder *r) { recorder = r; BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\tTG: " << this->get_talkgroup_display() << "\tFreq: " << FormatFreq(this->get_freq()); diff --git a/trunk-recorder/call_conventional.h b/trunk-recorder/call_conventional.h index 5f3f22ca7..7428c53d3 100644 --- a/trunk-recorder/call_conventional.h +++ b/trunk-recorder/call_conventional.h @@ -11,7 +11,7 @@ class Call_conventional : public Call { public: Call_conventional(long t, double f, System *s, Config c); ~Call_conventional(); - + time_t get_start_time(); virtual bool is_conventional() { return true; } void restart_call(); void set_recorder(Recorder *r);