diff --git a/tools/cli-video/appl/main-tool-client-video.cpp b/tools/cli-video/appl/main-tool-client-video.cpp index 04b316a..cd568af 100644 --- a/tools/cli-video/appl/main-tool-client-video.cpp +++ b/tools/cli-video/appl/main-tool-client-video.cpp @@ -58,7 +58,8 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< && _path.rfind('.') != 0) { extention = etk::tolower(std::string(_path.begin()+_path.rfind('.')+1, _path.end())); } - // internal extention .... + std::string fileName = etk::split(_path, '/').back(); + // internal extention ... if (extention == "sha512") { return true; } @@ -67,10 +68,35 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< && extention != "mkv" && extention != "mov" && extention != "mp4" - && extention != "ts") { + && extention != "ts" + && fileName != "cover_1.jpg" + && fileName != "cover_1.png" + && fileName != "cover_1.till" + && fileName != "cover_1.bmp" + && fileName != "cover_1.tga") { APPL_ERROR("Sot send file : " << _path << " Not manage extention..."); return false; } + if ( fileName == "cover_1.jpg" + || fileName == "cover_1.png" + || fileName == "cover_1.till" + || fileName == "cover_1.bmp" + || fileName == "cover_1.tga") { + // find a cover... + APPL_INFO("Send cover for: " << _basicKey["series-name"] << " " << _basicKey["saison"]); + if (_basicKey["series-name"] == "") { + APPL_ERROR(" ==> can not asociate at a specific seri"); + return false; + } + std::string groupName = _basicKey["series-name"]; + if (_basicKey["saison"] != "") { + groupName += ":" + _basicKey["saison"]; + } + auto sending = _srv.setGroupCover(zeus::File::create(_path, ""), groupName); + sending.onSignal(progressCallback); + sending.waitFor(echrono::seconds(20000)); + return true; + } std::string storedSha512; if (etk::FSNodeExist(_path + ".sha512") == true) { uint64_t time_sha512 = etk::FSNodeGetTimeModified(_path + ".sha512"); @@ -123,9 +149,6 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< } // TODO: if the media have meta data ==> this mean that the media already added before ... - - // Parse file name: - std::string fileName = etk::split(_path, '/').back(); APPL_INFO("Find fileName : '" << fileName << "'"); // Remove Date (XXXX) or other title std::vector dates; diff --git a/tools/player-video/appl/widget/ListViewer.cpp b/tools/player-video/appl/widget/ListViewer.cpp index 307ef0c..1ececa5 100644 --- a/tools/player-video/appl/widget/ListViewer.cpp +++ b/tools/player-video/appl/widget/ListViewer.cpp @@ -336,7 +336,50 @@ bool appl::ElementProperty::LoadDataEnded() { std::unique_lock lock(m_mutex); return m_metadataUpdated == appl::statusLoadingData::done; } +void appl::ElementPropertyGroup::loadData() { + // Check progression status: + { + std::unique_lock lock(m_mutex); + if (m_metadataUpdated != appl::statusLoadingData::noData) { + return; + } + m_metadataUpdated = appl::statusLoadingData::inProgress; + } + auto tmpProperty = sharedFromThis(); + // Get the media + auto futMedia = m_remoteServiceVideo.getGroupCover(m_title, 128); + futMedia.andElse([=](const std::string& _error, const std::string& _help) mutable { + APPL_INFO(" [" << tmpProperty->m_id << "] get cover error on group: " << tmpProperty->m_title << ": " << _help); + { + std::unique_lock lock(tmpProperty->m_mutex); + tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; + } + m_widget->markToRedraw(); + return true; + }); + futMedia.andThen([=](zeus::ProxyFile _media) mutable { + APPL_INFO(" [" << tmpProperty->m_id << "] get cover on group: " << tmpProperty->m_title); + auto mineTypeFut = _media.getMineType(); + std::vector bufferData = zeus::storeInMemory(_media); + APPL_INFO(" [" << tmpProperty->m_id << "] get cover on group: " << tmpProperty->m_title << " store in memory " << bufferData.size()); + std::string mineType = mineTypeFut.wait().get(); + APPL_INFO(" [" << tmpProperty->m_id << "] get cover on group: " << tmpProperty->m_title << " mineType '" << mineType << "'"); + { + std::unique_lock lock(tmpProperty->m_mutex); + tmpProperty->m_thumb = egami::load(mineType, bufferData); + tmpProperty->m_thumbPresent = true; + } + APPL_WARNING("Get the Thumb ... " << tmpProperty->m_title << " ==> " << tmpProperty->m_thumb); + m_widget->markToRedraw(); + tmpProperty->m_metadataUpdated = appl::statusLoadingData::done; + return true; + }); +} +bool appl::ElementPropertyGroup::LoadDataEnded() { + std::unique_lock lock(m_mutex); + return m_metadataUpdated == appl::statusLoadingData::done; +} void appl::widget::ListViewer::backHistory() { if (m_history.size() == 0) { @@ -395,7 +438,7 @@ void appl::widget::ListViewer::searchElementsInternal(const std::string& _filter } for (auto &it : returnValues) { - auto elem = ememory::makeShared(); + auto elem = ememory::makeShared(remoteServiceVideo, ememory::staticPointerCast(sharedFromThis())); if (elem == nullptr) { APPL_ERROR("Can not allocate element... " << it); continue; @@ -540,6 +583,9 @@ void appl::widget::ListViewer::onRegenerateDisplay() { } if (offset + iii < m_listElementGroup.size()) { elem->m_propertyGroup = m_listElementGroup[offset + iii]; + if (elem->m_propertyGroup != nullptr) { + elem->m_propertyGroup->loadData(); + } } else { elem->m_propertyGroup.reset(); } @@ -678,9 +724,12 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) { textToDisplay += "" + m_property->m_description + ""; } } else { - std::unique_lock lock(m_propertyGroup->m_mutex); - //m_text.setClipping(drawClippingPos, drawClippingSize); - textToDisplay = "
" + m_propertyGroup->m_title + "
"; + if (m_propertyGroup->LoadDataEnded() == false) { + textToDisplay += "
" + m_propertyGroup->m_title + "
Loading in progress ..."; + } else { + //m_text.setClipping(drawClippingPos, drawClippingSize); + textToDisplay = "
" + m_propertyGroup->m_title + "
"; + } } m_text.printDecorated(textToDisplay); @@ -698,8 +747,16 @@ void appl::ElementDisplayed::generateDisplay(vec2 _startPos, vec2 _size) { m_image.setSource("DATA:Home.svg", 128); } } else { - std::unique_lock lock(m_propertyGroup->m_mutex); - m_image.setSource("DATA:Home.svg", 128); + if (m_propertyGroup->LoadDataEnded() == false) { + m_image.setSource("DATA:Home.svg", 128); + } else { + std::unique_lock lock(m_propertyGroup->m_mutex); + if (m_propertyGroup->m_thumbPresent == false) { + m_image.setSource("DATA:Home.svg", 128); + } else { + m_image.setSource(m_propertyGroup->m_thumb); + } + } } m_image.setPos(_startPos+vec2(10,10)); m_image.print(vec2(_size.y(), _size.y())-vec2(20,20)); diff --git a/tools/player-video/appl/widget/ListViewer.hpp b/tools/player-video/appl/widget/ListViewer.hpp index fa6faac..4164606 100644 --- a/tools/player-video/appl/widget/ListViewer.hpp +++ b/tools/player-video/appl/widget/ListViewer.hpp @@ -32,7 +32,8 @@ namespace appl { m_remoteServiceVideo(_remoteServiceVideo), m_widget(_widget), m_metadataUpdated(appl::statusLoadingData::noData), - m_nbElementLoaded(0) { + m_nbElementLoaded(0), + m_thumbPresent(false) { } public: @@ -44,6 +45,7 @@ namespace appl { uint64_t m_id; //!< Remote Id of the Media egami::Image m_thumb; //!< simple image describing the element + bool m_thumbPresent; //!< if true, the Image is loaded std::string m_title; //!< Title of the Element std::string m_description; //!< Description of the element std::string m_serie; //!< Name of the serie or empty @@ -57,12 +59,31 @@ namespace appl { // TODO: int64_t m_globalPersonalView; //!< number of time this media has been viewed void loadData(); }; - class ElementPropertyGroup { + class ElementPropertyGroup : public ememory::EnableSharedFromThis { + private: + zeus::service::ProxyVideo m_remoteServiceVideo; + ewol::WidgetShared m_widget; + enum appl::statusLoadingData m_metadataUpdated; //!< Check value to know when metadata is getted (like thumb ...) + uint32_t m_nbElementLoaded; //!< this cont the number of lement loaded to set tle media full loaded + public: + ElementPropertyGroup(zeus::service::ProxyVideo& _remoteServiceVideo, ewol::WidgetShared _widget): + m_remoteServiceVideo(_remoteServiceVideo), + m_widget(_widget), + m_metadataUpdated(appl::statusLoadingData::noData), + m_nbElementLoaded(0), + m_thumbPresent(false) { + + } + public: + bool LoadDataEnded(); public: std::mutex m_mutex; uint64_t m_id; //!< Remote Id of the Media std::string m_title; //!< Title of the Group std::string m_filter; //!< element to add in the filter + egami::Image m_thumb; //!< simple image describing the element + bool m_thumbPresent; //!< if true, the Image is loaded + void loadData(); }; class ElementDisplayed { public: diff --git a/tools/player-video/data/gui-player.xml b/tools/player-video/data/gui-player.xml index 9d030cb..ee52939 100644 --- a/tools/player-video/data/gui-player.xml +++ b/tools/player-video/data/gui-player.xml @@ -24,7 +24,7 @@ - +