OBECA Receive Process
MbsfnFrameProcessor.h
1 // OBECA - Open Broadcast Edge Cache Appliance
2 // Receive 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 "Phy.h"
28 #include "RestHandler.h"
29 #include <libconfig.h++>
30 #include "srslte/srslte.h"
31 #include "srslte/upper/rlc.h"
32 #include "srslte/upper/pdcp.h"
33 #include "srslte/mac/pdu.h"
34 
40  public:
50  MbsfnFrameProcessor(const libconfig::Config& cfg, srslte::rlc& rlc, Phy& phy, srslte::log_ref log_h, RestHandler& rest )
51  : _cfg(cfg)
52  , _rlc(rlc)
53  , _phy(phy)
54  , _rest(rest)
55  , mch_mac_msg(20, log_h) {}
56 
60  virtual ~MbsfnFrameProcessor();
61 
66  bool init();
67 
74  int process(uint32_t tti);
75 
81  void set_cell(srslte_cell_t cell);
82 
91  cf_t** get_rx_buffer_and_lock() { _mutex.lock(); return _signal_buffer_rx; }
92 
96  uint32_t rx_buffer_size() { return _signal_buffer_max_samples; }
97 
101  void configure_mbsfn(uint8_t area_id, srslte_scs_t subcarrier_spacing);
102 
106  bool mbsfn_configured() { return _mbsfn_configured; }
107 
113  void unlock() { _mutex.unlock(); }
114 
118  const std::vector<uint8_t> mch_data() const;
119 
123  float cinr_db() { return _ue_dl.chest_res.snr_db; }
124 
125  private:
126  const libconfig::Config& _cfg;
127  srslte::rlc& _rlc;
128  Phy& _phy;
129 
130  srslte_cell_t _cell;
131 
132  cf_t* _signal_buffer_rx[SRSLTE_MAX_PORTS] = {};
133  uint32_t _signal_buffer_max_samples = 0;
134 
135  static const uint32_t _payload_buffer_sz = SRSLTE_MAX_BUFFER_SIZE_BYTES;
136  uint8_t _payload_buffer[_payload_buffer_sz];
137  srslte_softbuffer_rx_t _softbuffer;
138 
139  srslte_ue_dl_t _ue_dl = {};
140  srslte_ue_dl_cfg_t _ue_dl_cfg = {};
141  srslte_dl_sf_cfg_t _sf_cfg = {};
142  srslte_pmch_cfg_t _pmch_cfg = {};
143 
144  uint8_t _area_id = 1;
145  bool _mbsfn_configured = false;
146 
147  srslte::mch_pdu mch_mac_msg;
148  std::mutex _mutex;
149 
150  RestHandler& _rest;
151 
152  static std::mutex _sched_stop_mutex;
153  static std::map<uint8_t, uint16_t> _sched_stops;
154 
155  static std::mutex _rlc_mutex;
156  static int _current_mcs;
157 };
MbsfnFrameProcessor::get_rx_buffer_and_lock
cf_t ** get_rx_buffer_and_lock()
Get a handle of the signal buffer to store samples for processing in, and lock this processor.
Definition: MbsfnFrameProcessor.h:91
MbsfnFrameProcessor::mch_data
const std::vector< uint8_t > mch_data() const
Get the constellation diagram data (I/Q data of the subcarriers after CE)
Definition: MbsfnFrameProcessor.cpp:249
Phy
The PHY component.
Definition: Phy.h:43
MbsfnFrameProcessor
Frame processor for MBSFN subframes.
Definition: MbsfnFrameProcessor.h:39
MbsfnFrameProcessor::set_cell
void set_cell(srslte_cell_t cell)
Set the parameters for the cell (Nof PRB, etc).
Definition: MbsfnFrameProcessor.cpp:77
MbsfnFrameProcessor::unlock
void unlock()
Unlock the processor.
Definition: MbsfnFrameProcessor.h:113
MbsfnFrameProcessor::init
bool init()
Initialize signal- and softbuffers, init all underlying components.
Definition: MbsfnFrameProcessor.cpp:29
MbsfnFrameProcessor::~MbsfnFrameProcessor
virtual ~MbsfnFrameProcessor()
Default destructor.
Definition: MbsfnFrameProcessor.cpp:72
RestHandler
The RESTful API handler.
Definition: RestHandler.h:47
MbsfnFrameProcessor::configure_mbsfn
void configure_mbsfn(uint8_t area_id, srslte_scs_t subcarrier_spacing)
Set MBSFN parameters: area ID and subcarrier spacing.
Definition: MbsfnFrameProcessor.cpp:241
MbsfnFrameProcessor::cinr_db
float cinr_db()
Get the CINR estimate (in dB)
Definition: MbsfnFrameProcessor.h:123
MbsfnFrameProcessor::MbsfnFrameProcessor
MbsfnFrameProcessor(const libconfig::Config &cfg, srslte::rlc &rlc, Phy &phy, srslte::log_ref log_h, RestHandler &rest)
Default constructor.
Definition: MbsfnFrameProcessor.h:50
MbsfnFrameProcessor::process
int process(uint32_t tti)
Process the sample data in the signal buffer.
Definition: MbsfnFrameProcessor.cpp:82
MbsfnFrameProcessor::rx_buffer_size
uint32_t rx_buffer_size()
Size of the signal buffer.
Definition: MbsfnFrameProcessor.h:96
MbsfnFrameProcessor::mbsfn_configured
bool mbsfn_configured()
Returns tru if MBSFN params have already been configured.
Definition: MbsfnFrameProcessor.h:106