5G-MAG Reference Tools - MBMS Middleware
Middleware.h
Go to the documentation of this file.
1 // 5G-MAG Reference Tools
2 // MBMS Middleware Process
3 //
4 // Copyright (C) 2021 Klaus Kühnhammer (Österreichische Rundfunksender GmbH & Co KG)
5 //
6 // Licensed under the License terms and conditions for use, reproduction, and
7 // distribution of 5G-MAG software (the “License”). You may not use this file
8 // except in compliance with the License. You may obtain a copy of the License at
9 // https://www.5g-mag.com/reference-tools. Unless required by applicable law or
10 // agreed to in writing, software distributed under the License is distributed on
11 // an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 // or implied.
13 //
14 // See the License for the specific language governing permissions and limitations
15 // under the License.
16 //
17 #pragma once
18 
19 #include <string>
20 #include <filesystem>
21 #include <libconfig.h++>
22 #include <boost/asio.hpp>
23 #include "RpRestClient.h"
24 #include "Service.h"
25 #include "ServiceAnnouncement.h"
26 #include "File.h"
27 #include "RestHandler.h"
28 #include "CacheManagement.h"
29 #include "Service.h"
30 #include "on_demand/ControlSystemRestClient.h"
31 
32 namespace MBMS_RT {
33  class Middleware {
34  public:
35  Middleware( boost::asio::io_service& io_service, const libconfig::Config& cfg, const std::string& api_url, const std::string& iface);
36 
37  std::shared_ptr<Service> get_service(const std::string& service_id);
38  void set_service(const std::string& service_id, std::shared_ptr<Service> service) { _services[service_id] = service; };
39 
40  private:
41  void tick_handler();
42 
43  bool _seamless = false;
44 
45 
49 
50  bool _control_system = false;
51  MBMS_RT::ControlSystemRestClient _control;
52  boost::posix_time::seconds _control_tick_interval = boost::posix_time::seconds(10);
53  boost::asio::deadline_timer _control_timer;
54  void control_tick_handler();
55 
56  std::unique_ptr<MBMS_RT::ServiceAnnouncement> _service_announcement = {nullptr};
57  std::map<std::string, std::shared_ptr<Service>> _services;
58 
59  boost::posix_time::seconds _tick_interval;
60  boost::asio::deadline_timer _timer;
61 
62  const libconfig::Config& _cfg;
63  const std::string& _interface;
64  boost::asio::io_service& _io_service;
65 
67  };
68 };
const std::string & _interface
Definition: Middleware.h:63
std::unique_ptr< MBMS_RT::ServiceAnnouncement > _service_announcement
Definition: Middleware.h:56
boost::asio::io_service & _io_service
Definition: Middleware.h:64
std::map< std::string, std::shared_ptr< Service > > _services
Definition: Middleware.h:57
boost::posix_time::seconds _control_tick_interval
Definition: Middleware.h:52
Middleware(boost::asio::io_service &io_service, const libconfig::Config &cfg, const std::string &api_url, const std::string &iface)
Definition: Middleware.cpp:27
std::shared_ptr< Service > get_service(const std::string &service_id)
Definition: Middleware.cpp:149
MBMS_RT::CacheManagement _cache
Definition: Middleware.h:48
MBMS_RT::RpRestClient _rp
Definition: Middleware.h:46
boost::posix_time::seconds _tick_interval
Definition: Middleware.h:59
const libconfig::Config & _cfg
Definition: Middleware.h:62
MBMS_RT::RestHandler _api
Definition: Middleware.h:47
void set_service(const std::string &service_id, std::shared_ptr< Service > service)
Definition: Middleware.h:38
MBMS_RT::ControlSystemRestClient _control
Definition: Middleware.h:51
bool _handle_local_service_announcement()
Definition: Middleware.cpp:54
boost::asio::deadline_timer _control_timer
Definition: Middleware.h:53
boost::asio::deadline_timer _timer
Definition: Middleware.h:60
The RESTful API handler.
Definition: RestHandler.h:42
static Config cfg
Global configuration object.
Definition: main.cpp:111