15 #ifndef ALEXA_CLIENT_SDK_PLAYLISTPARSER_TEST_PLAYLISTPARSER_MOCKCONTENTFETCHER_H_ 16 #define ALEXA_CLIENT_SDK_PLAYLISTPARSER_TEST_PLAYLISTPARSER_MOCKCONTENTFETCHER_H_ 20 #include <unordered_map> 25 namespace playlistParser {
28 using namespace avsCommon::sdkInterfaces;
37 "http://stream.radiotime.com/sample.mp3\n" 38 "http://live-mp3-128.kexp.org\n";
42 static const std::vector<std::chrono::milliseconds>
TEST_M3U_DURATIONS = {std::chrono::milliseconds{-1},
43 std::chrono::milliseconds{-1}};
46 "http://live-mp3-128.kexp.org"};
58 "http://sanjayisthecoolest.com/test2.aac"};
65 "#EXT-X-TARGETDURATION:10\n" 66 "#EXT-X-MEDIA-SEQUENCE:9684358\n" 68 "http://76.74.255.139/bismarck/live/bismarck.mov_9684358.aac\n" 69 "#EXTINF:10.0,RADIO\n" 70 "http://76.74.255.139/bismarck/live/bismarck.mov_9684359.aac\n" 72 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n" 73 "#EXTINF:10.34,RADIO\n" 74 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n" 75 "#EXTINF:10.344,RADIO\n" 76 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n" 77 "#EXTINF:10.3444,RADIO\n" 78 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n" 79 "#EXTINF:10.002,RADIO\n" 80 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n" 81 "#EXTINF:10.0022,RADIO\n" 82 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n" 83 "#EXTINF : 10.0022,RADIO\n" 84 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n" 85 "#EXTINF : -1,RADIO\n" 86 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n" 87 "#EXTINF:123ms,RADIO\n" 88 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n" 89 "#EXTINF:123 ms,RADIO\n" 90 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n" 91 "#EXTINF:123.0ms,RADIO\n" 92 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n" 94 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n" 96 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n" 102 "http://76.74.255.139/bismarck/live/bismarck.mov_9684358.aac",
103 "http://76.74.255.139/bismarck/live/bismarck.mov_9684359.aac",
104 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac",
105 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac",
106 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac",
107 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac",
108 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac",
109 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac",
110 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac",
111 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac",
112 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac",
113 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac",
114 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac",
115 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac",
116 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac"};
118 static const std::vector<std::chrono::milliseconds>
TEST_HLS_DURATIONS = {std::chrono::milliseconds{10000},
119 std::chrono::milliseconds{10000},
120 std::chrono::milliseconds{10000},
121 std::chrono::milliseconds{10340},
122 std::chrono::milliseconds{10344},
123 std::chrono::milliseconds{10344},
124 std::chrono::milliseconds{10002},
125 std::chrono::milliseconds{10002},
126 std::chrono::milliseconds{10002},
127 std::chrono::milliseconds{-1},
128 std::chrono::milliseconds{-1},
129 std::chrono::milliseconds{-1},
130 std::chrono::milliseconds{-1},
131 std::chrono::milliseconds{-1},
132 std::chrono::milliseconds{123000}};
139 "NumberOfEntries=2\n" 140 "File1=http://stream.radiotime.com/sample.mp3\n" 142 "File2=http://live-mp3-128.kexp.org\n" 148 "http://live-mp3-128.kexp.org"};
155 "#EXT-X-TARGETDURATION:10\n" 156 "#EXT-X-MEDIA-SEQUENCE:9684358\n" 158 "http://76.74.255.139/bismarck/live/bismarck.mov_9684358.aac\n" 159 "#EXTINF:10.0,RADIO\n" 160 "http://76.74.255.139/bismarck/live/bismarck.mov_9684359.aac\n" 162 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n";
166 "#EXT-X-TARGETDURATION:10\n" 167 "#EXT-X-MEDIA-SEQUENCE:9684360\n" 169 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac\n" 171 "http://sanjay.com/chunk.mp3\n" 173 "http://sanjay.com/anotherChunk.mp3\n" 179 "http://76.74.255.139/bismarck/live/bismarck.mov_9684358.aac",
180 "http://76.74.255.139/bismarck/live/bismarck.mov_9684359.aac",
181 "http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac",
182 "http://sanjay.com/chunk.mp3",
183 "http://sanjay.com/anotherChunk.mp3"};
186 std::chrono::milliseconds{10000},
187 std::chrono::milliseconds{10000},
188 std::chrono::milliseconds{10000},
189 std::chrono::milliseconds{10000}};
204 {
"http://stream.radiotime.com/sample.mp3",
"audio/mpeg"},
205 {
"http://live-mp3-128.kexp.org",
"audio/mpeg"},
206 {
"http://76.74.255.139/bismarck/live/bismarck.mov_9684358.aac",
"audio/mpeg"},
207 {
"http://76.74.255.139/bismarck/live/bismarck.mov_9684359.aac",
"audio/mpeg"},
208 {
"http://76.74.255.139/bismarck/live/bismarck.mov_9684360.aac",
"audio/mpeg"},
209 {
"http://stream.radiotime.com/sample.mp3",
"audio/mpeg"},
210 {
"http://live-mp3-128.kexp.org",
"audio/mpeg"},
211 {
"http://sanjayisthecoolest.com/../test.mp3",
"audio/mpeg"},
212 {
"http://sanjayisthecoolest.com/test2.aac",
"audio/mpeg"},
213 {
"http://sanjay.com/chunk.mp3",
"audio/mpeg"},
214 {
"http://sanjay.com/anotherChunk.mp3",
"audio/mpeg"}};
228 m_state{HTTPContentFetcherInterface::State::INITIALIZED} {
248 m_state = HTTPContentFetcherInterface::State::HEADER_DONE;
257 bool getBody(std::shared_ptr<avsCommon::avs::attachment::AttachmentWriter> writer)
override {
262 static bool liveStreamPlaylistRequested =
false;
264 if (!liveStreamPlaylistRequested) {
266 liveStreamPlaylistRequested =
true;
271 auto attachment = writeStringIntoAttachment(it2->second,
std::move(writer));
275 m_state = HTTPContentFetcherInterface::State::BODY_DONE;
285 std::unique_ptr<avsCommon::avs::attachment::AttachmentWriter> writer,
286 const std::vector<std::string>& customHeaders = std::vector<std::string>())
override {
291 std::shared_ptr<avsCommon::avs::attachment::InProcessAttachment> writeStringIntoAttachment(
293 std::shared_ptr<avsCommon::avs::attachment::AttachmentWriter> writer) {
295 std::shared_ptr<avsCommon::avs::attachment::InProcessAttachment> stream =
296 std::make_shared<avsCommon::avs::attachment::InProcessAttachment>(std::to_string(
id++));
302 writer = stream->createWriter();
305 writer->write(
string.data(),
string.size(), &writeStatus);
318 #endif // ALEXA_CLIENT_SDK_PLAYLISTPARSER_TEST_PLAYLISTPARSER_MOCKCONTENTFETCHER_H_ static const size_t TEST_M3U_RELATIVE_PLAYLIST_URL_EXPECTED_PARSES
Definition: MockContentFetcher.h:55
HTTPContentFetcherInterface::Header getHeader(std::atomic< bool > *shouldShutdown) override
Definition: MockContentFetcher.h:239
static const std::vector< std::string > TEST_M3U_RELATIVE_PLAYLIST_URLS
Definition: MockContentFetcher.h:57
static const std::vector< std::string > TEST_PLS_PLAYLIST_URLS
Definition: MockContentFetcher.h:147
Definition: HTTPContentFetcherInterface.h:32
static const std::string TEST_HLS_LIVE_STREAM_PLAYLIST_URL
A test playlist in HLS format.
Definition: MockContentFetcher.h:151
Definition: AmdMetricWrapperTest.cpp:24
::std::string string
Definition: gtest-port.h:1097
std::string getEffectiveUrl() const override
Definition: MockContentFetcher.h:235
static const size_t TEST_PLS_PLAYLIST_URL_EXPECTED_PARSES
Definition: MockContentFetcher.h:145
std::unique_ptr< avsCommon::utils::HTTPContent > getContent(FetchOptions fetchOption, std::unique_ptr< avsCommon::avs::attachment::AttachmentWriter > writer, const std::vector< std::string > &customHeaders=std::vector< std::string >()) override
Definition: MockContentFetcher.h:283
static const std::string TEST_HLS_PLAYLIST_URL
A test playlist in HLS format.
Definition: MockContentFetcher.h:61
bool getBody(std::shared_ptr< avsCommon::avs::attachment::AttachmentWriter > writer) override
Definition: MockContentFetcher.h:257
static const std::string TEST_HLS_LIVE_STREAM_PLAYLIST_CONTENT_2
Definition: MockContentFetcher.h:164
A mock content fetcher.
Definition: MockContentFetcher.h:224
static const std::string TEST_PLS_PLAYLIST_URL
A test playlist in PLS format.
Definition: MockContentFetcher.h:135
static const std::vector< std::string > TEST_M3U_PLAYLIST_URLS
Definition: MockContentFetcher.h:45
static const std::string TEST_PLS_CONTENT
Definition: MockContentFetcher.h:137
static const size_t TEST_M3U_PLAYLIST_URL_EXPECTED_PARSES
Definition: MockContentFetcher.h:40
static const std::vector< std::string > TEST_HLS_LIVE_STREAM_PLAYLIST_URLS
Definition: MockContentFetcher.h:178
HTTP Success with response payload.
Definition: HttpResponseCodes.h:31
static const std::string TEST_HLS_LIVE_STREAM_PLAYLIST_CONTENT_1
Definition: MockContentFetcher.h:153
static const std::string TEST_M3U_RELATIVE_PLAYLIST_CONTENT
Definition: MockContentFetcher.h:51
static const std::unordered_map< std::string, std::string > urlsToContentTypes
Definition: MockContentFetcher.h:195
static const std::string TEST_HLS_PLAYLIST_CONTENT
Definition: MockContentFetcher.h:63
static const size_t NUM_PARSES_EXPECTED_WHEN_NO_PARSING
Definition: MockContentFetcher.h:191
State
The state of payload fetching.
Definition: HTTPContentFetcherInterface.h:43
MockContentFetcher(const std::string &url)
Definition: MockContentFetcher.h:226
static const std::string TEST_M3U_PLAYLIST_URL
Test M3U url.
Definition: MockContentFetcher.h:34
static const std::string TEST_M3U_PLAYLIST_CONTENT
Definition: MockContentFetcher.h:36
static const std::vector< std::chrono::milliseconds > TEST_M3U_DURATIONS
Definition: MockContentFetcher.h:42
static const std::string TEST_M3U_RELATIVE_PLAYLIST_URL
Test M3U url with relative urls within.
Definition: MockContentFetcher.h:49
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::string getUrl() const override
Definition: MockContentFetcher.h:231
FetchOptions
Represents what HTTP content to fetch.
Definition: HTTPContentFetcherInterface.h:35
static const std::vector< std::chrono::milliseconds > TEST_HLS_LIVE_STREAM_DURATIONS
Definition: MockContentFetcher.h:185
HTTPContentFetcherInterface::State getState() override
Definition: MockContentFetcher.h:253
static const std::vector< std::chrono::milliseconds > TEST_HLS_DURATIONS
Definition: MockContentFetcher.h:118
static const auto SHORT_TIMEOUT
Short time out for when callbacks are expected not to occur.
Definition: MockContentFetcher.h:31
static std::unordered_map< std::string, std::string > urlsToContent
Definition: MockContentFetcher.h:216
static const size_t TEST_HLS_LIVE_STREAM_PLAYLIST_EXPECTED_PARSES
Definition: MockContentFetcher.h:176
static const size_t TEST_HLS_PLAYLIST_URL_EXPECTED_PARSES
Definition: MockContentFetcher.h:99
WriteStatus
Definition: AttachmentWriter.h:36
const T & move(const T &t)
Definition: gtest-port.h:1317
static const std::string TEST_MEDIA_URL
Definition: MockContentFetcher.h:193
static const std::vector< std::string > TEST_HLS_PLAYLIST_URLS
Definition: MockContentFetcher.h:101
void shutdown() override
Definition: MockContentFetcher.h:280