Compare commits
No commits in common. "1bb358c961e313c9ff49b50a31007f81d363401e" and "b6dc04920a6101a51d1a3e530a27c348fd72b228" have entirely different histories.
1bb358c961
...
b6dc04920a
@ -16,9 +16,8 @@ public:
|
||||
virtual void seek(size_t position) = 0;
|
||||
virtual size_t size() = 0;
|
||||
virtual void close() = 0;
|
||||
virtual void skip_id3_tag() {};
|
||||
virtual bool usable() = 0;
|
||||
virtual int peek(int offset) = 0;
|
||||
void skip_id3_tag();
|
||||
};
|
||||
|
||||
class SDDataSource : public DataSource {
|
||||
@ -33,8 +32,8 @@ public:
|
||||
void seek(size_t position);
|
||||
size_t size();
|
||||
void close();
|
||||
void skip_id3_tag();
|
||||
bool usable();
|
||||
int peek(int offset=0);
|
||||
};
|
||||
|
||||
class HTTPSDataSource : public DataSource {
|
||||
@ -55,4 +54,5 @@ public:
|
||||
void close();
|
||||
bool usable();
|
||||
int peek(int offset=0);
|
||||
void skip_id3_tag();
|
||||
};
|
||||
|
@ -11,16 +11,21 @@
|
||||
[platformio]
|
||||
default_envs = esp32
|
||||
|
||||
[env]
|
||||
[extra]
|
||||
lib_deps =
|
||||
63 ; MFRC522
|
||||
https://github.com/me-no-dev/ESPAsyncWebServer.git
|
||||
ArduinoJSON
|
||||
6691 ; TinyXML
|
||||
|
||||
[env:esp32]
|
||||
platform = espressif32
|
||||
board = esp-wrover-kit
|
||||
framework = arduino
|
||||
upload_speed = 512000
|
||||
lib_deps =
|
||||
63 ; MFRC522
|
||||
https://github.com/me-no-dev/ESPAsyncWebServer.git
|
||||
64 ; ArduinoJSON
|
||||
6691 ; TinyXML
|
||||
build_flags=!./build_version.sh
|
||||
lib_deps = ${extra.lib_deps}
|
||||
upload_port = /dev/cu.SLAB_USBtoUART
|
||||
monitor_speed = 115200
|
||||
board_build.embed_files =
|
||||
src/webinterface/timezones.json.gz
|
||||
@ -30,8 +35,10 @@ board_build.embed_files =
|
||||
extra_scripts =
|
||||
post:tools/post_build.py
|
||||
|
||||
[env:esp32]
|
||||
build_flags=!./build_version.sh
|
||||
upload_port = /dev/cu.SLAB_USBtoUART
|
||||
|
||||
[env:deploy]
|
||||
platform = espressif32
|
||||
board = esp-wrover-kit
|
||||
framework = arduino
|
||||
lib_deps = ${extra.lib_deps}
|
||||
board_build.embed_txtfiles = src/index.html
|
||||
board_build.partitions = partitions.csv
|
||||
|
@ -1,29 +1,5 @@
|
||||
#include "data_sources.h"
|
||||
|
||||
void DataSource::skip_id3_tag() {
|
||||
if (peek(0)=='I' && peek(1)=='D' && peek(2)=='3') {
|
||||
DEBUG("ID3 tag found\n");
|
||||
// Skip ID3 tag marker
|
||||
read(); read(); read();
|
||||
// Skip ID3 tag version
|
||||
read(); read();
|
||||
byte tags = read();
|
||||
bool footer_present = tags & 0x10;
|
||||
DEBUG("ID3 footer found: %d\n", footer_present);
|
||||
uint32_t offset = 0;
|
||||
for (byte i=0; i<4; i++) {
|
||||
offset <<= 7;
|
||||
offset |= (0x7F & read());
|
||||
}
|
||||
offset += 10;
|
||||
if (footer_present) offset += 10;
|
||||
DEBUG("ID3 tag length is %d bytes.\n", offset);
|
||||
seek(offset);
|
||||
} else {
|
||||
DEBUG("No ID3 tag found\n");
|
||||
}
|
||||
}
|
||||
|
||||
////////////// SDDataSource //////////////
|
||||
SDDataSource::SDDataSource(String file) { _file = SD.open(file, "r"); }
|
||||
SDDataSource::~SDDataSource() { if (_file) _file.close(); }
|
||||
@ -34,14 +10,31 @@ void SDDataSource::seek(size_t position) { _file.seek(position); }
|
||||
size_t SDDataSource::size() { return _file.size(); }
|
||||
void SDDataSource::close() { _file.close(); }
|
||||
bool SDDataSource::usable() { return _file; }
|
||||
int SDDataSource::peek(int offset) {
|
||||
if (offset==0) return _file.peek();
|
||||
size_t start_position = _file.position();
|
||||
_file.seek(start_position + offset);
|
||||
int result = _file.peek();
|
||||
_file.seek(start_position);
|
||||
return result;
|
||||
|
||||
void SDDataSource::skip_id3_tag() {
|
||||
uint32_t original_position = _file.position();
|
||||
uint32_t offset = 0;
|
||||
if (_file.read()=='I' && _file.read()=='D' && _file.read()=='3') {
|
||||
DEBUG("ID3 tag found\n");
|
||||
// Skip ID3 tag version
|
||||
_file.read(); _file.read();
|
||||
byte tags = _file.read();
|
||||
bool footer_present = tags & 0x10;
|
||||
DEBUG("ID3 footer found: %d\n", footer_present);
|
||||
for (byte i=0; i<4; i++) {
|
||||
offset <<= 7;
|
||||
offset |= (0x7F & _file.read());
|
||||
}
|
||||
offset += 10;
|
||||
if (footer_present) offset += 10;
|
||||
DEBUG("ID3 tag length is %d bytes.\n", offset);
|
||||
_file.seek(offset);
|
||||
} else {
|
||||
DEBUG("No ID3 tag found\n");
|
||||
_file.seek(original_position);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////// HTTPSDataSource //////////////
|
||||
@ -69,3 +62,27 @@ void HTTPSDataSource::seek(size_t position) { _http->close(); delete _http; _ini
|
||||
size_t HTTPSDataSource::size() { return _http->getSize(); }
|
||||
void HTTPSDataSource::close() { _http->close(); }
|
||||
int HTTPSDataSource::peek(int offset) { return _http->peek(offset); }
|
||||
|
||||
void HTTPSDataSource::skip_id3_tag() {
|
||||
uint32_t offset = 0;
|
||||
if (_http->peek(0)=='I' && _http->peek(1)=='D' && _http->peek(2)=='3') {
|
||||
DEBUG("ID3 tag found\n");
|
||||
// Skip ID3 tag marker
|
||||
_http->read(); _http->read(); _http->read();
|
||||
// Skip ID3 tag version
|
||||
_http->read(); _http->read();
|
||||
byte tags = _http->read();
|
||||
bool footer_present = tags & 0x10;
|
||||
DEBUG("ID3 footer found: %d\n", footer_present);
|
||||
for (byte i=0; i<4; i++) {
|
||||
offset <<= 7;
|
||||
offset |= (0x7F & _http->read());
|
||||
}
|
||||
offset += 10;
|
||||
if (footer_present) offset += 10;
|
||||
DEBUG("ID3 tag length is %d bytes.\n", offset);
|
||||
seek(offset);
|
||||
} else {
|
||||
DEBUG("No ID3 tag found\n");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user