5G-MAG Reference Tools - MBMS Modem
MbsfnFrameProcessor.h
Go to the documentation of this file.
1 // 5G-MAG Reference Tools
2 // MBMS Modem Process
3 //
4 // Copyright (C) 2021 Klaus Kühnhammer (Österreichische Rundfunksender GmbH & Co KG)
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU Affero General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU Affero General Public License for more details.
15 //
16 // You should have received a copy of the GNU Affero General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 //
19 
20 #pragma once
21 
22 #include <cstdint>
23 #include <string>
24 #include <thread>
25 #include <vector>
26 #include <map>
27 #include "srsran/srsran.h"
28 #include "srsran/rlc/rlc.h"
29 #include "srsran/upper/pdcp.h"
30 #include "srsran/mac/pdu.h"
31 #include <libconfig.h++>
32 #include "Phy.h"
33 #include "RestHandler.h"
34 
40  public:
50  MbsfnFrameProcessor(const libconfig::Config& cfg, srsran::rlc& rlc, Phy& phy, srslog::basic_logger& log_h, RestHandler& rest, unsigned rx_channels )
51  : _cfg(cfg)
52  , _rlc(rlc)
53  , _phy(phy)
54  , _rest(rest)
55  , mch_mac_msg(20, log_h)
56  , _rx_channels(rx_channels)
57  {}
58 
62  virtual ~MbsfnFrameProcessor();
63 
68  bool init();
69 
76  int process(uint32_t tti);
77 
83  void set_cell(srsran_cell_t cell);
84 
93  cf_t** get_rx_buffer_and_lock() { _mutex.lock(); return _signal_buffer_rx; }
94 
99 
103  void configure_mbsfn(uint8_t area_id, srsran_scs_t subcarrier_spacing);
104 
109 
115  void unlock() { _mutex.unlock(); }
116 
120  const std::vector<uint8_t> mch_data() const;
121 
125  float cinr_db() { return _ue_dl.chest_res.snr_db; }
126 
127  private:
128  const libconfig::Config& _cfg;
129  srsran::rlc& _rlc;
131 
132  srsran_cell_t _cell;
133 
134  cf_t* _signal_buffer_rx[SRSRAN_MAX_PORTS] = {};
136 
137  static const uint32_t _payload_buffer_sz = SRSRAN_MAX_BUFFER_SIZE_BYTES;
139  srsran_softbuffer_rx_t _softbuffer;
140 
141  srsran_ue_dl_t _ue_dl = {};
142  srsran_ue_dl_cfg_t _ue_dl_cfg = {};
143  srsran_dl_sf_cfg_t _sf_cfg = {};
144  srsran_pmch_cfg_t _pmch_cfg = {};
145 
146  uint8_t _area_id = 1;
147  bool _mbsfn_configured = false;
148 
149  srsran::mch_pdu mch_mac_msg;
150  std::mutex _mutex;
151 
153 
154  unsigned _rx_channels;
155 
156  static std::mutex _sched_stop_mutex;
157  static std::map<uint8_t, uint16_t> _sched_stops;
158 
159  static std::mutex _rlc_mutex;
160  static int _current_mcs;
161 };
Frame processor for MBSFN subframes.
float cinr_db()
Get the CINR estimate (in dB)
static const uint32_t _payload_buffer_sz
void unlock()
Unlock the processor.
cf_t * _signal_buffer_rx[SRSRAN_MAX_PORTS]
srsran_softbuffer_rx_t _softbuffer
static std::map< uint8_t, uint16_t > _sched_stops
bool init()
Initialize signal- and softbuffers, init all underlying components.
cf_t ** get_rx_buffer_and_lock()
Get a handle of the signal buffer to store samples for processing in, and lock this processor.
void set_cell(srsran_cell_t cell)
Set the parameters for the cell (Nof PRB, etc).
srsran_ue_dl_cfg_t _ue_dl_cfg
uint32_t rx_buffer_size()
Size of the signal buffer.
srsran_dl_sf_cfg_t _sf_cfg
static std::mutex _rlc_mutex
virtual ~MbsfnFrameProcessor()
Default destructor.
int process(uint32_t tti)
Process the sample data in the signal buffer.
uint8_t _payload_buffer[_payload_buffer_sz]
static std::mutex _sched_stop_mutex
MbsfnFrameProcessor(const libconfig::Config &cfg, srsran::rlc &rlc, Phy &phy, srslog::basic_logger &log_h, RestHandler &rest, unsigned rx_channels)
Default constructor.
const std::vector< uint8_t > mch_data() const
Get the constellation diagram data (I/Q data of the subcarriers after CE)
srsran::mch_pdu mch_mac_msg
const libconfig::Config & _cfg
bool mbsfn_configured()
Returns tru if MBSFN params have already been configured.
srsran_pmch_cfg_t _pmch_cfg
void configure_mbsfn(uint8_t area_id, srsran_scs_t subcarrier_spacing)
Set MBSFN parameters: area ID and subcarrier spacing.
The PHY component.
Definition: Phy.h:42
The RESTful API handler.
Definition: RestHandler.h:44
static Config cfg
Global configuration object.
Definition: main.cpp:165