libcyberradio 22.01.24
VitaIqSource.h
1/* -*- c++ -*- */
2/***************************************************************************
3 * \file VitaIqSource.h
4 *
5 * \brief Generic VITA 49-compatible I/Q data source block.
6 *
7 * \author DA
8 * \copyright 2015 CyberRadio Solutions, Inc.
9 */
10
11
12#ifndef INCLUDED_LIBCYBERRADIO_VITAIQSOURCE_H_
13#define INCLUDED_LIBCYBERRADIO_VITAIQSOURCE_H_
14
15#include "LibCyberRadio/Common/Debuggable.h"
16#include "LibCyberRadio/Common/Vita49Packet.h"
17#include "LibCyberRadio/Common/VitaIqUdpPort.h"
18#include <boost/thread.hpp>
19#include <string>
20#include <vector>
21
22
26namespace LibCyberRadio
27{
28 typedef std::vector<Vita49Packet> Vita49PacketVector;
29
44 class VitaIqSource : public Debuggable
45 {
46 public:
47
71 VitaIqSource(const std::string& name = "VitaIqSource",
72 int vita_type = 0,
73 size_t payload_size = 8192,
74 size_t vita_header_size = 0,
75 size_t vita_tail_size = 0,
76 bool byte_swapped = false,
77 bool iq_swapped = false,
78 const std::string& host = "0.0.0.0",
79 unsigned short port = 0,
80 bool debug = false);
84 virtual ~VitaIqSource();
93 virtual int getPackets(int noutput_items, Vita49PacketVector& output_items);
99 virtual int getPacketSize() const;
108 virtual int getPacketsPayloadData(int noutput_items, void * buff);
114 bool isByteSwapped() const;
120 bool isIqSwapped() const;
126 size_t getPayloadSize() const;
132 size_t getVitaHeaderSize() const;
138 size_t getVitaTailSize() const;
147 int getVitaType() const;
148
149 protected:
150 // Packet size recalculator
151 void recalc_packet_size();
152 // Connect UDP port
153 void connect_udp_port();
154 // Disconnect UDP port
155 void disconnect_udp_port();
156
157 private:
158 std::string d_name;
159 int d_vita_type;
160 size_t d_payload_size; // maximum transmission unit (packet length)
161 size_t d_vita_header_size;
162 size_t d_vita_tail_size;
163 bool d_byte_swapped;
164 bool d_iq_swapped;
165 std::string d_host;
166 unsigned short d_port;
167 size_t d_packet_size;
168 VitaIqUdpPort* d_udp_port;
169 boost::mutex d_udp_port_mtx;
170 };
171
172} // namespace LibCyberRadio
173
174#endif /* INCLUDED_LIBCYBERRADIO_VITAIQSOURCE_H_ */
175
virtual int debug(const char *format,...)
Outputs debug information.
Debuggable(bool debug=false, const std::string &debug_name="", FILE *debug_fp=DEBUG_FP, const std::string &debug_timefmt=DEBUG_TIME_FMT)
Constructs a Debuggable object.
size_t getPayloadSize() const
Gets the payload size.
virtual ~VitaIqSource()
Destroys a vita_iq_source object.
size_t getVitaHeaderSize() const
Gets the VITA 49 frame header size.
bool isIqSwapped() const
Gets the I/Q-swapping state.
virtual int getPacketsPayloadData(int noutput_items, void *buff)
Gets VITA 49 or I/Q data packets.
virtual int getPackets(int noutput_items, Vita49PacketVector &output_items)
Gets VITA 49 or I/Q data packets.
VitaIqSource(const std::string &name="VitaIqSource", int vita_type=0, size_t payload_size=8192, size_t vita_header_size=0, size_t vita_tail_size=0, bool byte_swapped=false, bool iq_swapped=false, const std::string &host="0.0.0.0", unsigned short port=0, bool debug=false)
Creates a VitaIqSource object.
virtual int getPacketSize() const
Gets the VITA 49 or I/Q packet size.
size_t getVitaTailSize() const
Gets the VITA 49 frame trailer size.
int getVitaType() const
Gets the VITA type.
bool isByteSwapped() const
Gets the byte-swapping state.
Defines functionality for LibCyberRadio applications.
Definition App.h:24