[DEV] add support of metadata
This commit is contained in:
parent
325c740290
commit
4b961dbc84
@ -50,7 +50,8 @@ void installPath(zeus::service::ProxyPicture& _srv, std::string _path, uint32_t
|
||||
|| extention == "mkv"
|
||||
|| extention == "mka"
|
||||
|| extention == "tga"
|
||||
|| extention == "mp2") {
|
||||
|| extention == "mp2"
|
||||
|| extention == "mov") {
|
||||
uint32_t mediaId = _srv.mediaAdd(zeus::File::create(itFile)).wait().get();
|
||||
if (mediaId == 0) {
|
||||
APPL_ERROR("Get media ID = 0 With no error");
|
||||
@ -221,33 +222,6 @@ int main(int _argc, const char *_argv[]) {
|
||||
} else {
|
||||
APPL_INFO(" - " << it);
|
||||
}
|
||||
#if 0
|
||||
std::vector<std::string> retCall2 = remoteServicePicture.getSubAlbums(it).wait().get();
|
||||
for (auto &it2 : retCall2) {
|
||||
uint32_t retCount2 = remoteServicePicture.getAlbumCount(it2).wait().get();
|
||||
if (retCount2 != 0) {
|
||||
APPL_INFO(" - " << it2 << " / " << retCount2.get() << " images");
|
||||
std::vector<std::string> retListImage = remoteServicePicture.getAlbumListPicture(it2).wait().get();
|
||||
for (auto &it3 : retListImage) {
|
||||
APPL_INFO(" - " << it3);
|
||||
zeus::ProxyFile tmpFile = zeus::ObjectRemote(remoteServicePicture.getAlbumListPicture(it3).wait().get());
|
||||
APPL_INFO(" mine-type: " << tmpFile.getMineType().wait().get());
|
||||
APPL_INFO(" size: " << tmpFile.getSize().wait().get());
|
||||
APPL_INFO(" receive in =" << int64_t(retListImage.getTransmitionTime().count()/1000)/1000.0 << " ms");
|
||||
std::string tmpFileName = std::string("./out/") + it + "_" + it2 + "_" + it3 + "." + zeus::getExtention(tmpFile.getMineType().wait().get());
|
||||
APPL_INFO(" store in: " << tmpFileName);
|
||||
/*
|
||||
etk::FSNode node(tmpFileName);
|
||||
node.fileOpenWrite();
|
||||
node.fileWrite(&tmpFile.getData()[0], 1, tmpFile.getData().size());
|
||||
node.fileClose();
|
||||
*/
|
||||
}
|
||||
} else {
|
||||
APPL_INFO(" - " << it2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if 1
|
||||
@ -266,7 +240,6 @@ int main(int _argc, const char *_argv[]) {
|
||||
APPL_WARNING(" speed=" << int64_t(megaParSec/1024.0)/1024.0 << " Mo/s");
|
||||
}
|
||||
#endif
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
}
|
||||
}
|
||||
int32_t iii=0;
|
||||
|
@ -34,6 +34,7 @@ class FileProperty {
|
||||
std::string m_name;
|
||||
std::string m_mineType;
|
||||
echrono::Time m_creationData;
|
||||
std::map<std::string, std::string> m_metadata;
|
||||
};
|
||||
static std::vector<FileProperty> m_listFile;
|
||||
|
||||
@ -186,13 +187,42 @@ namespace appl {
|
||||
|
||||
std::vector<std::string> mediaMetadataGetKeys(uint32_t _mediaId) override {
|
||||
std::vector<std::string> out;
|
||||
return out;
|
||||
for (auto &it : m_listFile) {
|
||||
if (it.m_id == _mediaId) {
|
||||
for (auto &itM : it.m_metadata) {
|
||||
out.push_back(itM.first);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
throw std::invalid_argument("Wrong Album ID ...");
|
||||
}
|
||||
std::string mediaMetadataGetKey(uint32_t _mediaId, std::string _key) override {
|
||||
return "";
|
||||
std::vector<std::string> out;
|
||||
for (auto &it : m_listFile) {
|
||||
if (it.m_id == _mediaId) {
|
||||
auto itM = it.m_metadata.find(_key);
|
||||
if (itM != it.m_metadata.end()) {
|
||||
return itM->second;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
throw std::invalid_argument("Wrong Album ID ...");
|
||||
}
|
||||
void mediaMetadataSetKey(uint32_t _mediaId, std::string _key, std::string _value) override {
|
||||
|
||||
for (auto &it : m_listFile) {
|
||||
if (it.m_id == _mediaId) {
|
||||
auto itM = it.m_metadata.find(_key);
|
||||
if (itM != it.m_metadata.end()) {
|
||||
itM->second = _value;
|
||||
} else {
|
||||
it.m_metadata.insert(std::make_pair(_key, _value));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw std::invalid_argument("Wrong Album ID ...");
|
||||
}
|
||||
uint32_t albumCreate(std::string _albumName) override {
|
||||
std::unique_lock<std::mutex> lock(g_mutex);
|
||||
@ -378,6 +408,13 @@ static void store_db() {
|
||||
fileElement.add("name", ejson::String(it.m_name));
|
||||
fileElement.add("mine-type", ejson::String(it.m_mineType));
|
||||
fileElement.add("add-date", ejson::Number(it.m_creationData.count()));
|
||||
if (it.m_metadata.size() != 0) {
|
||||
ejson::Object listMetadata;
|
||||
fileElement.add("meta", listMetadata);
|
||||
for (auto &itM : it.m_metadata) {
|
||||
listMetadata.add(itM.first, ejson::String(itM.second));
|
||||
}
|
||||
}
|
||||
}
|
||||
ejson::Array listAlbumArray;
|
||||
database.add("list-album", listAlbumArray);
|
||||
@ -417,6 +454,14 @@ static void load_db() {
|
||||
if (m_lastMaxId < property.m_id) {
|
||||
m_lastMaxId = property.m_id+1;
|
||||
}
|
||||
ejson::Object tmpObj = fileElement["meta"].toObject();
|
||||
if (tmpObj.exist() == true) {
|
||||
for (auto itValue = tmpObj.begin();
|
||||
itValue != tmpObj.end();
|
||||
++itValue) {
|
||||
property.m_metadata.insert(std::make_pair(itValue.getKey(), (*itValue).toString().get()));
|
||||
}
|
||||
}
|
||||
if (property.m_fileName == "") {
|
||||
APPL_ERROR("Can not access on the file : ... No name ");
|
||||
} else {
|
||||
@ -446,46 +491,6 @@ ETK_EXPORT_API bool SERVICE_IO_init(int _argc, const char *_argv[], std::string
|
||||
std::unique_lock<std::mutex> lock(g_mutex);
|
||||
APPL_WARNING("Load USER: " << g_basePath);
|
||||
load_db();
|
||||
|
||||
/*
|
||||
|
||||
|
||||
// Load all files (image and video ...)
|
||||
etk::FSNode node(g_basePath);
|
||||
std::vector<etk::FSNode*> tmpList = node.folderGetSubList(false, false, true, false);
|
||||
APPL_WARNING("Find " << tmpList.size() << " files");
|
||||
for (auto &it : tmpList) {
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if ( etk::end_with(it->getNameFile(), ".svg", false) == true
|
||||
|| etk::end_with(it->getNameFile(), ".bmp", false) == true
|
||||
|| etk::end_with(it->getNameFile(), ".png", false) == true
|
||||
|| etk::end_with(it->getNameFile(), ".jpg", false) == true
|
||||
|| etk::end_with(it->getNameFile(), ".tga", false) == true
|
||||
|| etk::end_with(it->getNameFile(), ".mp4", false) == true
|
||||
|| etk::end_with(it->getNameFile(), ".avi", false) == true
|
||||
|| etk::end_with(it->getNameFile(), ".mov", false) == true
|
||||
|| etk::end_with(it->getNameFile(), ".mkv", false) == true) {
|
||||
// TODO : Do it better (proto ..)
|
||||
std::string idString = it->getNameFile();
|
||||
idString.resize(idString.size()-4);
|
||||
uint64_t id = 0;
|
||||
std::stringstream ss;
|
||||
ss << std::hex << idString;
|
||||
ss >> id;
|
||||
if (id <= 1024) {
|
||||
APPL_WARNING(" ==> REJECTED file " << it->getNameFile() << " with ID = " << id);
|
||||
} else {
|
||||
//m_listFile.insert(std::make_pair(id, it->getNameFile()));
|
||||
m_lastMaxId = std::max(m_lastMaxId,id);
|
||||
APPL_WARNING(" ==> load file " << it->getNameFile() << " with ID = " << id);
|
||||
}
|
||||
} else {
|
||||
APPL_WARNING(" ==> REJECT file " << it->getNameFile());
|
||||
}
|
||||
}
|
||||
*/
|
||||
APPL_WARNING("new USER: [STOP]");
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user