AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
M3UParser.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_PLAYLISTPARSER_INCLUDE_PLAYLISTPARSER_M3UPARSER_H_
17 #define ALEXA_CLIENT_SDK_PLAYLISTPARSER_INCLUDE_PLAYLISTPARSER_M3UPARSER_H_
18 
19 #include <chrono>
20 #include <string>
21 #include <vector>
22 
24 
25 namespace alexaClientSDK {
26 namespace playlistParser {
27 
29 static constexpr long INVALID_MEDIA_SEQUENCE = -1;
30 
35 struct PlayItem {
42 
49 
56  enum class Type { PLAYLIST_URL, MEDIA_INFO } type;
57 
60 
64 };
65 
67 struct M3UContent {
73  M3UContent(const std::vector<std::string>& variantURLs);
74 
82  M3UContent(
83  const std::vector<avsCommon::utils::playlistParser::PlaylistEntry>& entries,
84  bool isLive,
85  long mediaSequence = INVALID_MEDIA_SEQUENCE);
86 
92  bool isMasterPlaylist() const;
93 
99  bool hasMediaSequence() const;
100 
104  bool empty() const;
105 
107  const std::vector<std::string> variantURLs;
108 
110  const std::vector<avsCommon::utils::playlistParser::PlaylistEntry> entries;
111 
113  const bool isLive;
114 
119  const long mediaSequence;
120 };
121 
128 bool isPlaylistExtendedM3U(const std::string& playlistContent);
129 
139 
148  const std::string& line,
149  const std::string& baseURL);
150 
158 long parsePlaylistMediaSequence(const std::string& line);
159 
167 
176 
177 } // namespace playlistParser
178 } // namespace alexaClientSDK
179 
180 #endif // ALEXA_CLIENT_SDK_PLAYLISTPARSER_INCLUDE_PLAYLISTPARSER_M3UPARSER_H_
Definition: PlaylistEntry.h:111
const std::vector< std::string > variantURLs
If this is a master playlist, variantURLs has list of media playlists.
Definition: M3UParser.h:107
::std::string string
Definition: gtest-port.h:1097
M3UContent parseM3UContent(const std::string &playlistURL, const std::string &content)
std::tuple< long, long > ByteRange
Alias for holding start and end offsets of byte range of an URL to download.
Definition: PlaylistEntry.h:33
enum alexaClientSDK::playlistParser::PlayItem::Type type
const bool isLive
If EXT-X-ENDLIST tag exists, isLive is set to false.
Definition: M3UParser.h:113
static constexpr long INVALID_MEDIA_SEQUENCE
An invalid media sequence number.
Definition: M3UParser.h:29
const long mediaSequence
Definition: M3UParser.h:119
avsCommon::utils::playlistParser::PlaylistEntry parseHLSMapLine(const std::string &line, const std::string &baseURL)
A struct used to encapsulate information retrieved from an M3U playlist.
Definition: M3UParser.h:67
static PlaylistEntry createErrorEntry(const std::string &url)
Definition: PlaylistEntry.h:199
bool isPlaylistExtendedM3U(const std::string &playlistContent)
avsCommon::utils::playlistParser::EncryptionInfo parseHLSEncryptionLine(const std::string &line, const std::string &baseURL)
const std::string playlistURL
If type == PLAYLIST_URL, url to parse next playlist.
Definition: M3UParser.h:59
const avsCommon::utils::playlistParser::PlaylistEntry playlistEntry
If type == MEDIA_INFO, holds information about next PlaylistEntry.
Definition: M3UParser.h:62
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
long parsePlaylistMediaSequence(const std::string &line)
const std::vector< avsCommon::utils::playlistParser::PlaylistEntry > entries
If this is a media playlist, entries has list of parsed entries.
Definition: M3UParser.h:110
avsCommon::utils::playlistParser::ByteRange parseHLSByteRangeLine(const std::string &line)

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0