EBML input from S3 support

This commit is contained in:
Thulinma 2023-04-05 14:27:20 +02:00
parent 55be798e46
commit 364441c435
7 changed files with 176 additions and 61 deletions

View file

@ -108,6 +108,18 @@ namespace HTTP{
size_t URIReader::getDataCallbackPos() const{return allData.size();}
bool URIReader::open(const int fd){
close();
myURI = HTTP::URL("file://-");
originalUrl = myURI;
downer.getSocket().open(-1, fd);
stateType = HTTP::Stream;
startPos = 0;
endPos = std::string::npos;
totalSize = std::string::npos;
return true;
}
bool URIReader::open(const HTTP::URL &uri){
close();
myURI = uri;
@ -317,15 +329,17 @@ namespace HTTP{
}else if (stateType == HTTP::HTTP){
downer.continueNonBlocking(cb);
}else{// streaming mode
int s;
if ((downer.getSocket() && downer.getSocket().spool())){// || downer.getSocket().Received().size() > 0){
s = downer.getSocket().Received().bytes(wantedLen);
std::string buf = downer.getSocket().Received().remove(s);
cb.dataCallback(buf.data(), s);
}else{
Util::sleep(50);
int s = downer.getSocket().Received().bytes(wantedLen);
if (!s){
if (downer.getSocket() && downer.getSocket().spool()){
s = downer.getSocket().Received().bytes(wantedLen);
}else{
Util::sleep(50);
return;
}
}
std::string buf = downer.getSocket().Received().remove(s);
cb.dataCallback(buf.data(), s);
}
}

View file

@ -20,6 +20,8 @@ namespace HTTP{
/// Calls open on the given relative uri during construction
/// URI is resolved relative to the current working directory
URIReader(const std::string &reluri);
/// Sets the internal URI to file://- and opens the given file descriptor in stream mode.
bool open(const int fd);
/// Sets the internal URI to the given URI and opens it, whatever that may mean for the given URI type.
bool open(const HTTP::URL &uri);
/// Links the internal URI to the given relative URI and opens it, whatever that may mean for the current URI type.