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

Conventional recorder info for MQTT and status-server plugins #744

Merged
merged 4 commits into from
Dec 12, 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
2 changes: 1 addition & 1 deletion plugins/streamer/streamer_proto_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ streamer::RecorderInfo* ToRecorderInfo(Recorder *recorder) {

streamer::RecorderInfo* ri;
ri->set_recorder_num(recorder->get_num());
ri->set_recorder_type(recorder->get_type());
ri->set_recorder_type(recorder->get_type_string());
ri->set_source_num(recorder->get_source()->get_num());
ri->set_id(boost::lexical_cast<std::string>(recorder->get_source()->get_num()) + "_" + boost::lexical_cast<std::string>(recorder->get_num()));
ri->set_recorder_count(recorder->get_recording_count());
Expand Down
9 changes: 9 additions & 0 deletions trunk-recorder/global_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ enum Call_Data_Status { INITIAL,
SUCCESS,
RETRY,
FAILED };

enum Recorder_Type { DEBUG,
SIGMF,
ANALOG,
ANALOGC,
P25,
P25C,
DMR };

struct Call_Data_t {
long talkgroup;
std::vector<unsigned long> patched_talkgroups;
Expand Down
18 changes: 9 additions & 9 deletions trunk-recorder/recorders/analog_recorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ std::vector<float> design_filter(double interpolation, double deci) {
return result;
}

analog_recorder_sptr make_analog_recorder(Source *src) {
return gnuradio::get_initial_sptr(new analog_recorder(src));
analog_recorder_sptr make_analog_recorder(Source *src, Recorder_Type type) {
return gnuradio::get_initial_sptr(new analog_recorder(src, type));
}

/*! \brief Calculate taps for FM de-emph IIR filter. */
Expand Down Expand Up @@ -66,11 +66,11 @@ void analog_recorder::calculate_iir_taps(double tau) {
d_fbtaps[1] = -p1;
}

analog_recorder::analog_recorder(Source *src)
analog_recorder::analog_recorder(Source *src, Recorder_Type type)
: gr::hier_block2("analog_recorder",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(0, 0, sizeof(float))),
Recorder("A") {
Recorder(type) {
// int nchars;

source = src;
Expand Down Expand Up @@ -152,7 +152,7 @@ analog_recorder::analog_recorder(Source *src)
arb_taps = gr::filter::firdes::low_pass_2(arb_size, arb_size, bw, tb, arb_atten, gr::fft::window::WIN_BLACKMAN_HARRIS);
#endif
double tap_total = inital_lpf_taps.size() + channel_lpf_taps.size() + arb_taps.size();
BOOST_LOG_TRIVIAL(info) << "Analog Recorder Taps - initial: " << inital_lpf_taps.size() << " channel: " << channel_lpf_taps.size() << " ARB: " << arb_taps.size() << " Total: " << tap_total;
BOOST_LOG_TRIVIAL(info) << "\t Analog Recorder Taps - initial: " << inital_lpf_taps.size() << " channel: " << channel_lpf_taps.size() << " ARB: " << arb_taps.size() << " Total: " << tap_total;
} else {
BOOST_LOG_TRIVIAL(error) << "Something is probably wrong! Resampling rate too low";
exit(1);
Expand Down Expand Up @@ -201,14 +201,14 @@ analog_recorder::analog_recorder(Source *src)
wav_sink = gr::blocks::transmission_sink::make(1, wav_sample_rate, 16); // Configurable

if (use_streaming) {
BOOST_LOG_TRIVIAL(info) << "Creating plugin sink..." << std::endl;
BOOST_LOG_TRIVIAL(info) << "\t Creating plugin sink..." << std::endl;
plugin_sink = gr::blocks::plugin_wrapper_impl::make(std::bind(&analog_recorder::plugin_callback_handler, this, std::placeholders::_1, std::placeholders::_2));
BOOST_LOG_TRIVIAL(info) << "Plugin sink created!" << std::endl;
BOOST_LOG_TRIVIAL(info) << "\t Plugin sink created!" << std::endl;
}

BOOST_LOG_TRIVIAL(info) << "Creating decoder sink..." << std::endl;
BOOST_LOG_TRIVIAL(info) << "\t Creating decoder sink..." << std::endl;
decoder_sink = gr::blocks::decoder_wrapper_impl::make(wav_sample_rate, src->get_num(), std::bind(&analog_recorder::decoder_callback_handler, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
BOOST_LOG_TRIVIAL(info) << "Decoder sink created!" << std::endl;
BOOST_LOG_TRIVIAL(info) << "\t Decoder sink created!" << std::endl;

// Analog audio band pass from 300 to 3000 Hz
// can't use gnuradio.filter.firdes.band_pass since we have different transition widths
Expand Down
6 changes: 3 additions & 3 deletions trunk-recorder/recorders/analog_recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ typedef std::shared_ptr<analog_recorder> analog_recorder_sptr;

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

analog_recorder_sptr make_analog_recorder(Source *src);
analog_recorder_sptr make_analog_recorder(Source *src, Recorder_Type type);

class analog_recorder : public gr::hier_block2, public Recorder {
friend analog_recorder_sptr make_analog_recorder(Source *src);
friend analog_recorder_sptr make_analog_recorder(Source *src, Recorder_Type type);

protected:
analog_recorder(Source *src);
analog_recorder(Source *src, Recorder_Type type);

public:
~analog_recorder();
Expand Down
2 changes: 1 addition & 1 deletion trunk-recorder/recorders/debug_recorder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ debug_recorder_impl::debug_recorder_impl(Source *src, std::string address, int p
: gr::hier_block2("debug_recorder",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(0, 0, sizeof(float))),
Recorder("D") {
Recorder(DEBUG) {
source = src;
chan_freq = source->get_center();
center_freq = source->get_center();
Expand Down
2 changes: 1 addition & 1 deletion trunk-recorder/recorders/dmr_recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef boost::shared_ptr<dmr_recorder> dmr_recorder_sptr;
typedef std::shared_ptr<dmr_recorder> dmr_recorder_sptr;
#endif

dmr_recorder_sptr make_dmr_recorder(Source *src);
dmr_recorder_sptr make_dmr_recorder(Source *src, Recorder_Type type);

class dmr_recorder : virtual public gr::hier_block2, virtual public Recorder {

Expand Down
8 changes: 4 additions & 4 deletions trunk-recorder/recorders/dmr_recorder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "../plugin_manager/plugin_manager.h"
#include <boost/log/trivial.hpp>

dmr_recorder_sptr make_dmr_recorder(Source *src) {
dmr_recorder *recorder = new dmr_recorder_impl(src);
dmr_recorder_sptr make_dmr_recorder(Source *src, Recorder_Type type) {
dmr_recorder *recorder = new dmr_recorder_impl(src, type);

return gnuradio::get_initial_sptr(recorder);
}
Expand Down Expand Up @@ -46,11 +46,11 @@ void dmr_recorder_impl::generate_arb_taps() {
}
}

dmr_recorder_impl::dmr_recorder_impl(Source *src)
dmr_recorder_impl::dmr_recorder_impl(Source *src, Recorder_Type type)
: gr::hier_block2("dmr_recorder",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(0, 0, sizeof(float))),
Recorder("DMR") {
Recorder(type) {
initialize(src);
}

Expand Down
2 changes: 1 addition & 1 deletion trunk-recorder/recorders/dmr_recorder_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class dmr_recorder_impl : public dmr_recorder {
void initialize(Source *src);

public:
dmr_recorder_impl(Source *src);
dmr_recorder_impl(Source *src, Recorder_Type type);
DecimSettings get_decim(long speed);
void initialize_prefilter();
void tune_offset(double f);
Expand Down
2 changes: 1 addition & 1 deletion trunk-recorder/recorders/p25_recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ typedef boost::shared_ptr<p25_recorder> p25_recorder_sptr;
typedef std::shared_ptr<p25_recorder> p25_recorder_sptr;
#endif

p25_recorder_sptr make_p25_recorder(Source *src);
p25_recorder_sptr make_p25_recorder(Source *src, Recorder_Type type);
#include "../source.h"

class p25_recorder : virtual public gr::hier_block2, virtual public Recorder {
Expand Down
8 changes: 4 additions & 4 deletions trunk-recorder/recorders/p25_recorder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include "p25_recorder.h"
#include <boost/log/trivial.hpp>

p25_recorder_sptr make_p25_recorder(Source *src) {
p25_recorder *recorder = new p25_recorder_impl(src);
p25_recorder_sptr make_p25_recorder(Source *src, Recorder_Type type) {
p25_recorder *recorder = new p25_recorder_impl(src, type);

return gnuradio::get_initial_sptr(recorder);
}
Expand Down Expand Up @@ -44,11 +44,11 @@ void p25_recorder_impl::generate_arb_taps() {
}
}

p25_recorder_impl::p25_recorder_impl(Source *src)
p25_recorder_impl::p25_recorder_impl(Source *src, Recorder_Type type)
: gr::hier_block2("p25_recorder",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(0, 0, sizeof(float))),
Recorder("P25") {
Recorder(type) {
initialize(src);
}

Expand Down
2 changes: 1 addition & 1 deletion trunk-recorder/recorders/p25_recorder_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class p25_recorder_impl : public p25_recorder {
void initialize(Source *src);

public:
p25_recorder_impl(Source *src);
p25_recorder_impl(Source *src, Recorder_Type type);
DecimSettings get_decim(long speed);
void initialize_prefilter();
void initialize_qpsk();
Expand Down
23 changes: 22 additions & 1 deletion trunk-recorder/recorders/recorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "../source.h"
#include <boost/algorithm/string.hpp>

Recorder::Recorder(std::string type) {
Recorder::Recorder(Recorder_Type type) {
this->type = type;
}

Expand All @@ -16,4 +16,25 @@ boost::property_tree::ptree Recorder::get_stats() {
node.put("duration", recording_duration);
node.put("state", get_state());
return node;
}

std::string Recorder::get_type_string() {
switch(type) {
case DEBUG:
return "Debug";
case SIGMF:
return "SIGMF";
case ANALOGC:
return "AnalogC";
case ANALOG:
return "Analog";
case P25:
return "P25";
case P25C:
return "P25C";
case DMR:
return "DMR";
default:
return "Unknown";
}
}
7 changes: 4 additions & 3 deletions trunk-recorder/recorders/recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Recorder {
long decim2;
};

Recorder(std::string type);
Recorder(Recorder_Type type);
virtual void tune_offset(double f){};
virtual void tune_freq(double f){};
virtual bool start(Call *call) { return false; };
Expand All @@ -87,7 +87,8 @@ class Recorder {
virtual long get_talkgroup() { return 0; };
virtual void set_record_more_transmissions(bool more){};
virtual State get_state() { return INACTIVE; };
virtual std::string get_type() { return type; }
std::string get_type_string();
Recorder_Type get_type() { return type; }
virtual bool is_active() { return false; };
virtual bool is_analog() { return false; };
virtual bool is_idle() { return true; };
Expand All @@ -110,7 +111,7 @@ class Recorder {
int recording_count;
bool d_enable_audio_streaming;
double recording_duration;
std::string type;
Recorder_Type type;
};

#endif
2 changes: 1 addition & 1 deletion trunk-recorder/recorders/sigmf_recorder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sigmf_recorder_impl::sigmf_recorder_impl(Source *src)
: gr::hier_block2("sigmf_recorder",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(0, 0, sizeof(float))),
Recorder("D") {
Recorder(SIGMF) {
source = src;
freq = source->get_center();
center = source->get_center();
Expand Down
Loading