libcyberradio 22.01.24
Packetizer.h
1#ifndef INCLUDED_LIBCYBERRADIO_NDR651_PACKETIZER_H
2#define INCLUDED_LIBCYBERRADIO_NDR651_PACKETIZER_H
3
4#define DAC_RATE 102400000
5
6#include <sys/socket.h>
7#include <netinet/in.h>
8#include <linux/if_ether.h>
9#include <netinet/ip.h>
10#include <netinet/udp.h>
11#include <arpa/inet.h>
12#include <linux/filter.h>
13#include "LibCyberRadio/NDR651/TransmitSocket.h"
14#include <netpacket/packet.h>
15#include <net/ethernet.h>
16#include <net/if.h>
17#include <sys/types.h>
18#include <sys/ioctl.h>
19#include <stdio.h>
20#include <unistd.h>
21#include <ifaddrs.h>
22#include <sys/types.h>
23#include <sys/uio.h>
24#include <unistd.h>
25
26#include "LibCyberRadio/Common/Debuggable.h"
27#include "LibCyberRadio/NDR651/PacketTypes.h"
28
29namespace LibCyberRadio
30{
31 namespace NDR651
32 {
33
34 class Packetizer : public Debuggable
35 {
36
37 private:
38 std::string txInterfaceName;
39 unsigned short txUdpPort;
40 unsigned int samplesPerFrame;
41 unsigned long long sampleRate;
42 int txSocket;
43 struct iovec txVec[3]; // Will hold Vita Header, Payload of Samples, Vita Footer
44 uint32_t fracTimestampIncrement;
45
46 /* Instance methods */
47 void setVitaHeader(unsigned short streamId);
48 void incrementVitaHeader();
49 void initBroadcastTxSocket(const std::string &txInterfaceName, unsigned short port);
50 unsigned long long calculateSampleRate(unsigned int ducRateIndex);
51
52
53 public:
54 Packetizer(const std::string &txInterfaceName, unsigned short port, unsigned int ducRateIndex, bool debug = false);
55 ~Packetizer();
56
57 int getSocketFd();
58 void start();
59 void sendFrame(short * samples);
60 void setSamplesPerFrame(unsigned int samplesPerFrame);
61
62
63 };
64 }
65}
66
67#endif /* INCLUDED_LIBCYBERRADIO_NDR651_PACKETIZER_H */
virtual int debug(const char *format,...)
Outputs debug information.
Provides programming elements for controlling the CyberRadio Solutions NDR651 radio.
Defines functionality for LibCyberRadio applications.
Definition App.h:24