Multiple old changes.
This commit is contained in:
parent
fdf986a61e
commit
12a8391cd7
@ -16,8 +16,9 @@ public:
|
|||||||
virtual void seek(size_t position) = 0;
|
virtual void seek(size_t position) = 0;
|
||||||
virtual size_t size() = 0;
|
virtual size_t size() = 0;
|
||||||
virtual void close() = 0;
|
virtual void close() = 0;
|
||||||
virtual void skip_id3_tag() {};
|
|
||||||
virtual bool usable() = 0;
|
virtual bool usable() = 0;
|
||||||
|
virtual int peek(int offset) = 0;
|
||||||
|
void skip_id3_tag();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SDDataSource : public DataSource {
|
class SDDataSource : public DataSource {
|
||||||
@ -32,8 +33,8 @@ public:
|
|||||||
void seek(size_t position);
|
void seek(size_t position);
|
||||||
size_t size();
|
size_t size();
|
||||||
void close();
|
void close();
|
||||||
void skip_id3_tag();
|
|
||||||
bool usable();
|
bool usable();
|
||||||
|
int peek(int offset=0);
|
||||||
};
|
};
|
||||||
|
|
||||||
class HTTPSDataSource : public DataSource {
|
class HTTPSDataSource : public DataSource {
|
||||||
@ -54,5 +55,4 @@ public:
|
|||||||
void close();
|
void close();
|
||||||
bool usable();
|
bool usable();
|
||||||
int peek(int offset=0);
|
int peek(int offset=0);
|
||||||
void skip_id3_tag();
|
|
||||||
};
|
};
|
||||||
|
@ -11,21 +11,16 @@
|
|||||||
[platformio]
|
[platformio]
|
||||||
default_envs = esp32
|
default_envs = esp32
|
||||||
|
|
||||||
[extra]
|
[env]
|
||||||
lib_deps =
|
|
||||||
63 ; MFRC522
|
|
||||||
https://github.com/me-no-dev/ESPAsyncWebServer.git
|
|
||||||
ArduinoJSON
|
|
||||||
6691 ; TinyXML
|
|
||||||
|
|
||||||
[env:esp32]
|
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = esp-wrover-kit
|
board = esp-wrover-kit
|
||||||
framework = arduino
|
framework = arduino
|
||||||
upload_speed = 512000
|
upload_speed = 512000
|
||||||
build_flags=!./build_version.sh
|
lib_deps =
|
||||||
lib_deps = ${extra.lib_deps}
|
63 ; MFRC522
|
||||||
upload_port = /dev/cu.SLAB_USBtoUART
|
https://github.com/me-no-dev/ESPAsyncWebServer.git
|
||||||
|
64 ; ArduinoJSON
|
||||||
|
6691 ; TinyXML
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
board_build.embed_files =
|
board_build.embed_files =
|
||||||
src/webinterface/timezones.json.gz
|
src/webinterface/timezones.json.gz
|
||||||
@ -35,10 +30,8 @@ board_build.embed_files =
|
|||||||
extra_scripts =
|
extra_scripts =
|
||||||
post:tools/post_build.py
|
post:tools/post_build.py
|
||||||
|
|
||||||
|
[env:esp32]
|
||||||
|
build_flags=!./build_version.sh
|
||||||
|
upload_port = /dev/cu.SLAB_USBtoUART
|
||||||
|
|
||||||
[env:deploy]
|
[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,5 +1,29 @@
|
|||||||
#include "data_sources.h"
|
#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::SDDataSource(String file) { _file = SD.open(file, "r"); }
|
SDDataSource::SDDataSource(String file) { _file = SD.open(file, "r"); }
|
||||||
SDDataSource::~SDDataSource() { if (_file) _file.close(); }
|
SDDataSource::~SDDataSource() { if (_file) _file.close(); }
|
||||||
@ -10,31 +34,14 @@ void SDDataSource::seek(size_t position) { _file.seek(position); }
|
|||||||
size_t SDDataSource::size() { return _file.size(); }
|
size_t SDDataSource::size() { return _file.size(); }
|
||||||
void SDDataSource::close() { _file.close(); }
|
void SDDataSource::close() { _file.close(); }
|
||||||
bool SDDataSource::usable() { return _file; }
|
bool SDDataSource::usable() { return _file; }
|
||||||
|
int SDDataSource::peek(int offset) {
|
||||||
void SDDataSource::skip_id3_tag() {
|
if (offset==0) return _file.peek();
|
||||||
uint32_t original_position = _file.position();
|
size_t start_position = _file.position();
|
||||||
uint32_t offset = 0;
|
_file.seek(start_position + offset);
|
||||||
if (_file.read()=='I' && _file.read()=='D' && _file.read()=='3') {
|
int result = _file.peek();
|
||||||
DEBUG("ID3 tag found\n");
|
_file.seek(start_position);
|
||||||
// Skip ID3 tag version
|
return result;
|
||||||
_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 //////////////
|
////////////// HTTPSDataSource //////////////
|
||||||
@ -62,27 +69,3 @@ void HTTPSDataSource::seek(size_t position) { _http->close(); delete _http; _ini
|
|||||||
size_t HTTPSDataSource::size() { return _http->getSize(); }
|
size_t HTTPSDataSource::size() { return _http->getSize(); }
|
||||||
void HTTPSDataSource::close() { _http->close(); }
|
void HTTPSDataSource::close() { _http->close(); }
|
||||||
int HTTPSDataSource::peek(int offset) { return _http->peek(offset); }
|
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