4#include "AudioToolsConfig.h"
5#include "AudioSource.h"
6#include "AudioTools/CoreAudio/AudioHttp/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;
42 LOGI(
"url array out of limits: %d -> %d", idx, pos);
46 LOGI(
"url array out of limits: %d -> %d", idx, pos);
48 LOGI(
"selectStream: %d/%d -> %s", pos, size() - 1, value(pos));
49 if (started) actual_stream->end();
50 actual_stream->begin(value(pos), mime);
58 if (pos < 0 || pos >= size()) {
61 LOGI(
"nextStream: %d/%d -> %s", pos, max - 1, value(pos));
68 if (pos < 0 || pos >= size()) {
71 LOGI(
"previousStream: %d/%d -> %s", pos, size() - 1, value(pos));
77 LOGI(
"selectStream: %s", path);
78 if (started) actual_stream->end();
79 actual_stream->begin(path, mime);
86 const char*
toStr() {
return value(pos); }
89 void setTimeout(
int millisec) { actual_stream->setTimeout(millisec); }
95 bool setMetadataCallback(
void (*fn)(
MetaDataType info,
const char* str,
99 return actual_stream->setMetadataCallback(fn);
103 AbstractURLStream* actual_stream =
nullptr;
104 const char** urlArray =
nullptr;
107 const char* mime =
nullptr;
108 bool started =
false;
113 virtual const char* value(
int pos) {
114 if (urlArray ==
nullptr)
return nullptr;
115 return urlArray[pos];
118 virtual int size() {
return max; }
131 template <
typename T,
size_t N>
133 const char* mime,
int startPos = 0) {
134 this->actual_stream = &urlStream;
136 this->pos = startPos - 1;
137 this->timeout_auto_next_value = 20000;
138 for (
int j = 0; j < N; j++) {
145 this->actual_stream = &urlStream;
147 this->pos = startPos - 1;
148 this->timeout_auto_next_value = 20000;
152 void addURL(
const char* url) { url_vector.push_back(url); }
154 void clear() { url_vector.clear(); }
157 Vector<Str> url_vector;
159 const char* value(
int pos)
override {
return url_vector[pos].c_str(); }
161 int size()
override {
return url_vector.size(); }