5G-MAG Reference Tools - MBMS Middleware
Public Member Functions | Private Attributes | List of all members
MBMS_RT::Service Class Reference

#include <Service.h>

Collaboration diagram for MBMS_RT::Service:
Collaboration graph

Public Member Functions

 Service (CacheManagement &cache)
 
virtual ~Service ()=default
 
void add_name (const std::string &name, const std::string &lang)
 
void add_and_start_content_stream (std::shared_ptr< ContentStream > s)
 
void read_master_manifest (const std::string &manifest, const std::string &base_path)
 
const std::map< std::string, std::string > & names () const
 
const std::map< std::string, std::shared_ptr< ContentStream > > & content_streams () const
 
DeliveryProtocol delivery_protocol () const
 
std::string delivery_protocol_string () const
 
void set_delivery_protocol_from_mime_type (const std::string &mime_type)
 
const std::string & manifest_path () const
 

Private Attributes

CacheManagement_cache
 
DeliveryProtocol _delivery_protocol
 
std::map< std::string, std::shared_ptr< ContentStream > > _content_streams
 
std::map< std::string, std::string > _names
 
HlsPrimaryPlaylist _hls_primary_playlist
 
DashManifest _dash_manifest
 
std::string _manifest
 
std::string _manifest_path
 

Detailed Description

Definition at line 30 of file Service.h.

Constructor & Destructor Documentation

◆ Service()

MBMS_RT::Service::Service ( CacheManagement cache)
inline

Definition at line 32 of file Service.h.

33  : _cache(cache) {};
CacheManagement & _cache
Definition: Service.h:48

◆ ~Service()

virtual MBMS_RT::Service::~Service ( )
virtualdefault

Member Function Documentation

◆ add_and_start_content_stream()

auto MBMS_RT::Service::add_and_start_content_stream ( std::shared_ptr< ContentStream s)

Definition at line 56 of file Service.cpp.

57 {
58  spdlog::debug("adding stream with playlist path {}", s->playlist_path());
60  for (const auto &stream: _hls_primary_playlist.streams()) {
61  if (stream.uri == s->playlist_path()) {
62  spdlog::debug("matched hls entry with uri {}", stream.uri);
63  s->set_resolution(stream.resolution);
64  s->set_codecs(stream.codecs);
65  s->set_bandwidth(stream.bandwidth);
66  s->set_frame_rate(stream.frame_rate);
67  }
68  }
69  }
70  _content_streams[s->playlist_path()] = s;
71  s->start();
72 
74  // recreate the manifest
75  HlsPrimaryPlaylist pl;
76  for (const auto &stream: _content_streams) {
77  HlsPrimaryPlaylist::Stream s{
78  "/" + stream.second->playlist_path(),
79  stream.second->resolution(),
80  stream.second->codecs(),
81  stream.second->bandwidth(),
82  stream.second->frame_rate()
83  };
84  pl.add_stream(s);
85  }
86  _manifest = pl.to_string();
89  }
90 }
const std::vector< Stream > & streams() const
std::map< std::string, std::shared_ptr< ContentStream > > _content_streams
Definition: Service.h:53
DashManifest _dash_manifest
Definition: Service.h:57
DeliveryProtocol _delivery_protocol
Definition: Service.h:52
HlsPrimaryPlaylist _hls_primary_playlist
Definition: Service.h:56
std::string _manifest
Definition: Service.h:58

◆ add_name()

auto MBMS_RT::Service::add_name ( const std::string &  name,
const std::string &  lang 
)

Definition at line 31 of file Service.cpp.

31  {
32  spdlog::debug("Service name added: {} ({})", name, lang);
33  _names[lang] = name;
34 }
std::map< std::string, std::string > _names
Definition: Service.h:54

◆ content_streams()

const std::map<std::string, std::shared_ptr<ContentStream> >& MBMS_RT::Service::content_streams ( ) const
inline

Definition at line 41 of file Service.h.

41 { return _content_streams; };

◆ delivery_protocol()

DeliveryProtocol MBMS_RT::Service::delivery_protocol ( ) const
inline

Definition at line 43 of file Service.h.

43 { return _delivery_protocol; };

◆ delivery_protocol_string()

std::string MBMS_RT::Service::delivery_protocol_string ( ) const
inline

Definition at line 44 of file Service.h.

44  { return _delivery_protocol == DeliveryProtocol::HLS ? "HLS" :
45  (_delivery_protocol == DeliveryProtocol::DASH ? "DASH" : "RTP"); };

◆ manifest_path()

const std::string& MBMS_RT::Service::manifest_path ( ) const
inline

Definition at line 48 of file Service.h.

48 { return _manifest_path; };
std::string _manifest_path
Definition: Service.h:59

◆ names()

const std::map<std::string, std::string>& MBMS_RT::Service::names ( ) const
inline

Definition at line 40 of file Service.h.

40 { return _names; };

◆ read_master_manifest()

auto MBMS_RT::Service::read_master_manifest ( const std::string &  manifest,
const std::string &  base_path 
)

Definition at line 36 of file Service.cpp.

36  {
37  spdlog::debug("service: master manifest contents:\n{}, base path {}", manifest, base_path);
39  _hls_primary_playlist = HlsPrimaryPlaylist(manifest, base_path);
41  _dash_manifest = DashManifest(manifest, base_path);
42  }
43 
45  _delivery_protocol == DeliveryProtocol::HLS ? base_path + "manifest.m3u8" : base_path + "manifest.mpd",
46  _cache.add_item(std::make_shared<CachedPlaylist>(
48  0,
49  [&]() -> const std::string & {
50  spdlog::debug("Service: master manifest requested");
51  return _manifest;
52  }
53  ));
54 }
void add_item(std::shared_ptr< CacheItem > item)

◆ set_delivery_protocol_from_mime_type()

auto MBMS_RT::Service::set_delivery_protocol_from_mime_type ( const std::string &  mime_type)

Definition at line 92 of file Service.cpp.

92  {
93  // Need to remove potential profile from mimeType, example:application/dash+xml;profiles=urn:3GPP:PSS:profile:DASH10
94  std::vector<std::string> strs;
95  boost::split(strs, mime_type, boost::is_any_of(";"));
96  std::string adjusted_mime_type = strs.front();
98  (adjusted_mime_type == ContentTypeConstants::HLS ? DeliveryProtocol::HLS :
100  spdlog::info("Setting delivery type {} from MIME type {}", _delivery_protocol == DeliveryProtocol::HLS ? "HLS" : (
101  _delivery_protocol == DeliveryProtocol::DASH ? "DASH" : "RTP"), mime_type);
102 };
const std::string DASH
Definition: Constants.h:25
const std::string HLS
Definition: Constants.h:24

Member Data Documentation

◆ _cache

CacheManagement& MBMS_RT::Service::_cache
private

Definition at line 51 of file Service.h.

◆ _content_streams

std::map<std::string, std::shared_ptr<ContentStream> > MBMS_RT::Service::_content_streams
private

Definition at line 53 of file Service.h.

◆ _dash_manifest

DashManifest MBMS_RT::Service::_dash_manifest
private

Definition at line 57 of file Service.h.

◆ _delivery_protocol

DeliveryProtocol MBMS_RT::Service::_delivery_protocol
private

Definition at line 52 of file Service.h.

◆ _hls_primary_playlist

HlsPrimaryPlaylist MBMS_RT::Service::_hls_primary_playlist
private

Definition at line 56 of file Service.h.

◆ _manifest

std::string MBMS_RT::Service::_manifest
private

Definition at line 58 of file Service.h.

◆ _manifest_path

std::string MBMS_RT::Service::_manifest_path
private

Definition at line 59 of file Service.h.

◆ _names

std::map<std::string, std::string> MBMS_RT::Service::_names
private

Definition at line 54 of file Service.h.


The documentation for this class was generated from the following files: