Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public Plugin API #681

Merged
merged 3 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wno-narrowing -fvisibility=hid

list(APPEND trunk_recorder_sources
trunk-recorder/recorders/recorder.cc
trunk-recorder/call.cc
trunk-recorder/call_impl.cc
trunk-recorder/formatter.cc
trunk-recorder/source.cc
trunk-recorder/call_conventional.cc
Expand All @@ -227,7 +227,7 @@ list(APPEND trunk_recorder_sources
trunk-recorder/systems/smartnet_parser.cc
trunk-recorder/systems/p25_parser.cc
trunk-recorder/systems/smartnet_decode.cc
trunk-recorder/systems/system.cc
trunk-recorder/systems/system_impl.cc
trunk-recorder/recorders/debug_recorder.cc
trunk-recorder/recorders/sigmf_recorder.cc
trunk-recorder/recorders/analog_recorder.cc
Expand Down
2 changes: 1 addition & 1 deletion plugins/stat_socket/stat_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class Stat_Socket : public Plugin_Api {
}
sys_node.add_child("channels", channels_node);

if (sys->system_type == "smartnet") {
if (sys->get_system_type() == "smartnet") {
sys_node.put("bandplan", sys->get_bandplan());
sys_node.put("bandfreq", sys->get_bandfreq());
sys_node.put("bandplan_base", sys->get_bandplan_base());
Expand Down
191 changes: 69 additions & 122 deletions trunk-recorder/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@


#include "./global_structs.h"
#include "gr_blocks/decoder_wrapper.h"
#include <boost/log/trivial.hpp>
#include <boost/program_options.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include <string>
#include <sys/time.h>
#include <vector>
Expand All @@ -15,135 +17,80 @@ class Recorder;
class System;

#include "state.h"
#include "systems/parser.h"
#include "systems/system.h"
#include <op25_repeater/include/op25_repeater/rx_status.h>
//enum CallState { MONITORING=0, recording=1, stopping=2};
#include "systems/parser.h"




class Call {
public:
Call(long t, double f, System *s, Config c);
Call(TrunkMessage message, System *s, Config c);
long get_call_num();
virtual ~Call();
virtual void restart_call();
void set_record_more_transmissions(bool more);
void inactive_call();
void stop_call();
void conclude_call();
void set_sigmf_recorder(Recorder *r);
Recorder *get_sigmf_recorder();
void set_debug_recorder(Recorder *r);
Recorder *get_debug_recorder();
virtual void set_recorder(Recorder *r);
Recorder *get_recorder();
double get_freq();
int get_sys_num();
std::string get_short_name();
std::string get_capture_dir();
void set_error(Rx_Status rx_status);
void set_freq(double f);
long get_talkgroup();
Call_Freq *get_freq_list();
Call_Error *get_error_list();
long get_error_list_count();
long get_freq_count();
bool update(TrunkMessage message);
int get_idle_count();
void increase_idle_count();
void reset_idle_count();
int since_last_update();
long stopping_elapsed();
long elapsed();

double get_current_length();
long get_stop_time();
void set_debug_recording(bool m);
bool get_debug_recording();
void set_sigmf_recording(bool m);
bool get_sigmf_recording();
void set_state(State s);
State get_state();
void set_phase2_tdma(bool m);
bool get_phase2_tdma();
void set_tdma_slot(int s);
int get_tdma_slot();
bool get_is_analog();
void set_is_analog( bool a );
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();
void set_emergency(bool m);
bool get_emergency();
std::string get_talkgroup_display();
void set_talkgroup_display_format(std::string format);
void set_talkgroup_tag(std::string tag);
void clear_transmission_list();
boost::property_tree::ptree get_stats();
State add_transmission(Transmission t);

bool add_signal_source(long src, const char *signaling_type, gr::blocks::SignalType signal);

std::string get_talkgroup_tag();
std::string get_system_type();
double get_final_length();
long get_current_source_id();
bool get_conversation_mode();
System *get_system();
std::vector<Transmission> transmission_list;
protected:
State state;
static long call_counter;
long call_num;
long talkgroup;
double curr_freq;
System *sys;
std::string short_name;
long curr_src_id;
Call_Error error_list[50];

Call_Freq freq_list[50];
long error_list_count;
long freq_count;
time_t last_update;
int idle_count;
time_t stop_time;
time_t start_time;
bool debug_recording;
bool sigmf_recording;
bool encrypted;
bool emergency;
bool mode;
bool duplex;
bool is_analog;
long priority;
char filename[255];
char transmission_filename[255];
char converted_filename[255];
char status_filename[255];
char debug_filename[255];
char sigmf_filename[255];
char path[255];
bool phase2_tdma;
int tdma_slot;
double final_length;

Config config;
Recorder *recorder;
Recorder *debug_recorder;
Recorder *sigmf_recorder;
bool add_source(long src);
std::string talkgroup_display;
std::string talkgroup_tag;
void update_talkgroup_display();
};
//static Call * make(long t, double f, System *s, Config c);
static Call * make(TrunkMessage message, System *s, Config c);
virtual ~Call() {};
virtual long get_call_num() = 0;
virtual void restart_call() = 0;
virtual void set_record_more_transmissions(bool more) = 0;
virtual void inactive_call() = 0;
virtual void stop_call() = 0;
virtual void conclude_call() = 0;
virtual void set_sigmf_recorder(Recorder *r) = 0;
virtual Recorder *get_sigmf_recorder() = 0;
virtual void set_debug_recorder(Recorder *r) = 0;
virtual Recorder *get_debug_recorder() = 0;
virtual void set_recorder(Recorder *r) = 0;
virtual Recorder *get_recorder() = 0;
virtual double get_freq() = 0;
virtual int get_sys_num() = 0;
virtual std::string get_short_name() = 0;
virtual std::string get_capture_dir() = 0;
virtual void set_freq(double f) = 0;
virtual long get_talkgroup() = 0;


virtual bool update(TrunkMessage message) = 0;
virtual int get_idle_count() = 0;
virtual void increase_idle_count() = 0;
virtual void reset_idle_count() = 0;
virtual int since_last_update() = 0;
virtual long elapsed() = 0;

virtual double get_current_length() = 0;
virtual long get_stop_time() = 0;
virtual void set_debug_recording(bool m) = 0;
virtual bool get_debug_recording() = 0;
virtual void set_sigmf_recording(bool m) = 0;
virtual bool get_sigmf_recording() = 0;
virtual void set_state(State s) = 0;
virtual State get_state() = 0;
virtual void set_phase2_tdma(bool m) = 0;
virtual bool get_phase2_tdma() = 0;
virtual void set_tdma_slot(int s) = 0;
virtual int get_tdma_slot() = 0;
virtual bool get_is_analog() = 0;
virtual void set_is_analog( bool a ) = 0;
virtual const char *get_xor_mask() = 0;
virtual time_t get_start_time() = 0;
virtual bool is_conventional() =0;
virtual void set_encrypted(bool m) = 0;
virtual bool get_encrypted() = 0;
virtual void set_emergency(bool m) = 0;
virtual bool get_emergency() = 0;
virtual std::string get_talkgroup_display() = 0;
virtual void set_talkgroup_tag(std::string tag) = 0;
virtual void clear_transmission_list() = 0;
virtual boost::property_tree::ptree get_stats() = 0;

virtual std::string get_talkgroup_tag() = 0;
virtual std::string get_system_type() = 0;
virtual double get_final_length() = 0;
virtual long get_current_source_id() = 0;
virtual bool get_conversation_mode() = 0;
virtual System *get_system() = 0;
virtual std::vector<Transmission> get_transmissions() = 0;

};

int plugman_signal(long unitId, const char *signaling_type, gr::blocks::SignalType sig_type, Call *call, System *system, Recorder *recorder);


#endif
2 changes: 1 addition & 1 deletion trunk-recorder/call_concluder/call_concluder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ Call_Data_t Call_Concluder::create_call_data(Call *call, System *sys, Config con
call_info.emergency = call->get_emergency();
call_info.tdma_slot = call->get_tdma_slot();
call_info.phase2_tdma = call->get_phase2_tdma();
call_info.transmission_list = call->transmission_list;
call_info.transmission_list = call->get_transmissions();
call_info.short_name = sys->get_short_name();
call_info.upload_script = sys->get_upload_script();
call_info.audio_archive = sys->get_audio_archive();
Expand Down
42 changes: 1 addition & 41 deletions trunk-recorder/call_concluder/call_concluder.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "../global_structs.h"
#include "../formatter.h"
#include "../systems/system.h"
#include "../systems/system_impl.h"
/*
class Uploader;
#include "../uploaders/uploader.h"
Expand All @@ -20,49 +21,8 @@ class Uploader;
#include "../uploaders/openmhz_uploader.h"*/


enum Call_Data_Status { INITIAL, SUCCESS, RETRY, FAILED };
struct Call_Data_t {
long talkgroup;
std::vector<unsigned long> patched_talkgroups;
std::string talkgroup_tag;
std::string talkgroup_alpha_tag;
std::string talkgroup_description;
std::string talkgroup_group;
long call_num;
double freq;
long start_time;
long stop_time;
long error_count;
long spike_count;
bool encrypted;
bool emergency;
bool audio_archive;
bool transmission_archive;
bool call_log;
bool compress_wav;
char filename[300];
char status_filename[300];
char converted[300];



std::string short_name;
std::string upload_script;
std::string audio_type;

int tdma_slot;
double length;
bool phase2_tdma;

std::vector<Call_Source> transmission_source_list;
std::vector<Call_Error> transmission_error_list;
std::vector<Transmission> transmission_list;

Call_Data_Status status;
time_t process_call_time;
int retry_attempt;
};

Call_Data_t upload_call_worker(Call_Data_t call_info);

class Call_Concluder {
Expand Down
7 changes: 2 additions & 5 deletions trunk-recorder/call_conventional.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
#include "recorders/recorder.h"
#include <boost/algorithm/string.hpp>

Call_conventional::Call_conventional(long t, double f, System *s, Config c) : Call(t, f, s, c) {
Call_conventional::Call_conventional(long t, double f, System *s, Config c) : Call_impl(t, f, s, c) {
}

Call_conventional::~Call_conventional() {
}


void Call_conventional::restart_call() {
idle_count = 0;
freq_count = 0;
error_list_count = 0;
curr_src_id = -1;
start_time = time(NULL);
stop_time = time(NULL);
Expand Down
4 changes: 2 additions & 2 deletions trunk-recorder/call_conventional.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ class System;
class Recorder;

#include "call.h"
#include "call_impl.h"
#include <string>

class Call_conventional : public Call {
class Call_conventional : public Call_impl {
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();
Expand Down
Loading