4#include "AudioToolsConfig.h"
5#include "AudioSource.h"
6#include "AudioTools/Communication/HTTP/AbstractURLStream.h"
18 template <
typename T,
size_t N>
20 const char* mime,
int startPos = 0) {
22 this->actual_stream = &urlStream;
24 this->urlArray = urlArray;
26 this->pos = startPos - 1;
27 this->timeout_auto_next_value = 20000;
43 if (started) actual_stream->end();
52 LOGI(
"url array out of limits: %d -> %d", idx, pos);
56 LOGI(
"url array out of limits: %d -> %d", idx, pos);
58 LOGI(
"selectStream: %d/%d -> %s", pos, size() - 1, value(pos));
59 if (started) actual_stream->end();
60 actual_stream->begin(value(pos), mime);
68 if (pos < 0 || pos >= size()) {
71 LOGI(
"nextStream: %d/%d -> %s", pos, max - 1, value(pos));
78 if (pos < 0 || pos >= size()) {
81 LOGI(
"previousStream: %d/%d -> %s", pos, size() - 1, value(pos));
87 LOGI(
"selectStream: %s", path);
88 if (started) actual_stream->end();
89 actual_stream->begin(path, mime);
96 const char*
toStr() {
return value(pos); }
99 void setTimeout(
int millisec) { actual_stream->setTimeout(millisec); }
105 bool setMetadataCallback(
void (*fn)(
MetaDataType info,
const char* str,
109 return actual_stream->setMetadataCallback(fn);
113 AbstractURLStream* actual_stream =
nullptr;
114 const char** urlArray =
nullptr;
117 const char* mime =
nullptr;
118 bool started =
false;
123 virtual const char* value(
int pos) {
124 if (urlArray ==
nullptr)
return nullptr;
125 return urlArray[pos];
128 virtual int size() {
return max; }
141 template <
typename T,
size_t N>
143 const char* mime,
int startPos = 0) {
144 this->actual_stream = &urlStream;
146 this->pos = startPos - 1;
147 this->timeout_auto_next_value = 20000;
148 for (
int j = 0; j < N; j++) {
155 this->actual_stream = &urlStream;
157 this->pos = startPos - 1;
158 this->timeout_auto_next_value = 20000;
162 void addURL(
const char* url) { url_vector.push_back(url); }
164 void clear() { url_vector.clear(); }
167 Vector<Str> url_vector;
169 const char* value(
int pos)
override {
return url_vector[pos].c_str(); }
171 int size()
override {
return url_vector.size(); }