#include <HlsPrimaryPlaylist.h>
|
std::vector< std::pair< std::string, std::string > > | parse_parameters (const std::string &line) const |
|
Definition at line 24 of file HlsPrimaryPlaylist.h.
◆ HlsPrimaryPlaylist() [1/2]
MBMS_RT::HlsPrimaryPlaylist::HlsPrimaryPlaylist |
( |
const std::string & |
content, |
|
|
const std::string & |
base_path |
|
) |
| |
Definition at line 25 of file HlsPrimaryPlaylist.cpp.
27 spdlog::debug(
"Parsing HLS primary playlist: {}", content);
29 std::istringstream iss(content);
31 std::string resolution =
"";
32 std::string codecs =
"";
33 unsigned long bandwidth = 0;
34 double frame_rate = 0;
35 for (std::string line; std::getline(iss, line); idx++ )
38 boost::algorithm::trim(line);
41 if ( line !=
"#EXTM3U") {
42 throw(
"HLS playlist parsing failed: first line is not #EXTM3U");
48 size_t cpos = line.rfind(
':');
50 if (line.rfind(
"#EXT-X-VERSION", 0) == 0) {
52 throw(
"HLS playlist parsing failed: duplicate #EXT-X-VERSION");
54 if (cpos != std::string::npos) {
55 _version = atoi(line.substr(cpos+1).c_str());
57 }
else if (line.rfind(
"#EXT-X-STREAM-INF", 0) == 0) {
58 if (cpos != std::string::npos) {
59 std::string info = line.substr(cpos+1);
61 for (
const auto& param : params) {
62 if (param.first ==
"BANDWIDTH") {
63 bandwidth = std::atoi(param.second.c_str());
65 else if (param.first ==
"FRAME-RATE") {
66 frame_rate = std::atof(param.second.c_str());
68 else if (param.first ==
"RESOLUTION") {
69 resolution = param.second;
71 else if (param.first ==
"CODECS") {
72 codecs = param.second;
76 }
else if (line.rfind(
'#', 0) == 0) {
77 spdlog::debug(
"HLS playlist parser ignoring unhandled line {}", line);
78 }
else if (line.size() > 0) {
79 std::string uri = base_path + line;
80 _streams.push_back({uri, resolution, codecs, bandwidth, frame_rate});
81 resolution =
""; codecs =
""; bandwidth = 0; frame_rate = 0;
std::vector< std::pair< std::string, std::string > > parse_parameters(const std::string &line) const
std::vector< Stream > _streams
◆ HlsPrimaryPlaylist() [2/2]
MBMS_RT::HlsPrimaryPlaylist::HlsPrimaryPlaylist |
( |
| ) |
|
|
default |
◆ ~HlsPrimaryPlaylist()
MBMS_RT::HlsPrimaryPlaylist::~HlsPrimaryPlaylist |
( |
| ) |
|
|
default |
◆ add_stream()
void MBMS_RT::HlsPrimaryPlaylist::add_stream |
( |
Stream |
stream | ) |
|
|
inline |
◆ parse_parameters()
auto MBMS_RT::HlsPrimaryPlaylist::parse_parameters |
( |
const std::string & |
line | ) |
const |
|
private |
Definition at line 86 of file HlsPrimaryPlaylist.cpp.
88 std::vector<std::pair<std::string, std::string>> result;
91 std::stringstream key;
92 std::stringstream value;
93 for(
const char& c : line) {
96 }
else if (c ==
',' && !quoted) {
97 result.emplace_back(std::make_pair(key.str(), value.str()));
98 key.str(
""); key.clear();
99 value.str(
""); value.clear();
101 }
else if (c ==
'=') {
111 result.emplace_back(std::make_pair(key.str(), value.str()));
◆ streams()
const std::vector<Stream>& MBMS_RT::HlsPrimaryPlaylist::streams |
( |
| ) |
const |
|
inline |
◆ to_string()
auto MBMS_RT::HlsPrimaryPlaylist::to_string |
( |
| ) |
const |
Definition at line 115 of file HlsPrimaryPlaylist.cpp.
117 std::stringstream pl;
119 pl <<
"#EXTM3U" << std::endl;
120 pl <<
"#EXT-X-VERSION:3" << std::endl;
123 pl <<
"#EXT-X-STREAM-INF:BANDWITH=" << s.bandwidth <<
124 ",RESOLUTION=" << s.resolution <<
125 ",FRAME-RATE=" << std::fixed << std::setprecision(3) << s.frame_rate <<
126 ",CODECS=\"" << s.codecs <<
"\"" << std::endl;
127 pl << s.uri << std::endl;
129 return std::move(pl.str());
◆ _streams
std::vector<Stream> MBMS_RT::HlsPrimaryPlaylist::_streams = {} |
|
private |
◆ _version
int MBMS_RT::HlsPrimaryPlaylist::_version = -1 |
|
private |
The documentation for this class was generated from the following files: