[DEBUG] correct cli-player and cli-video interface

This commit is contained in:
Edouard DUPIN 2017-04-14 23:48:31 +02:00
parent 4ad6f382dd
commit 88af61bc85
5 changed files with 28 additions and 13 deletions

View File

@ -379,7 +379,13 @@ void appl::MediaDecoder::init(ememory::SharedPtr<ClientProperty> _property, uint
m_remote->m_bufferReadPosition = 0; m_remote->m_bufferReadPosition = 0;
m_remote->m_property = _property; m_remote->m_property = _property;
m_remote->m_mediaId = _mediaId; m_remote->m_mediaId = _mediaId;
remoteServiceVideo.mediaGet(_mediaId).andThen( // Get the media
zeus::ProxyMedia media = remoteServiceVideo.get(_mediaId).waitFor(echrono::seconds(2000)).get();
if (media.exist() == false) {
APPL_ERROR("get media error");
return;
}
media.getFile().andThen(
[=](zeus::Future<zeus::ProxyFile> _fut) mutable { [=](zeus::Future<zeus::ProxyFile> _fut) mutable {
APPL_INFO("Receive ProxyFile"); APPL_INFO("Receive ProxyFile");
m_remote->m_fileHandle = _fut.get(); m_remote->m_fileHandle = _fut.get();

View File

@ -23,6 +23,7 @@
#include <echrono/Steady.hpp> #include <echrono/Steady.hpp>
#include <zeus/FutureGroup.hpp> #include <zeus/FutureGroup.hpp>
#include <etk/stdTools.hpp> #include <etk/stdTools.hpp>
#include <zeus/ProxyMedia.hpp>
#include <ejson/ejson.hpp> #include <ejson/ejson.hpp>
appl::widget::ListViewer::ListViewer() : appl::widget::ListViewer::ListViewer() :
@ -87,7 +88,7 @@ void appl::widget::ListViewer::searchElements(std::string _filter) {
APPL_ERROR(" ==> Service does not exist : 'video'"); APPL_ERROR(" ==> Service does not exist : 'video'");
return; return;
} }
zeus::Future<std::vector<uint32_t>> listElem = remoteServiceVideo.getMediaWhere(_filter).wait(); zeus::Future<std::vector<uint32_t>> listElem = remoteServiceVideo.getSQL(_filter).wait();
if (listElem.hasError() == true) { if (listElem.hasError() == true) {
APPL_ERROR(" ==> Can not get element from video service <with fileter ! '" << _filter << "' : " << listElem.getErrorType() << " : " << listElem.getErrorHelp()); APPL_ERROR(" ==> Can not get element from video service <with fileter ! '" << _filter << "' : " << listElem.getErrorType() << " : " << listElem.getErrorHelp());
return; return;
@ -104,8 +105,16 @@ void appl::widget::ListViewer::searchElements(std::string _filter) {
elem->m_metadataUpdated = false; elem->m_metadataUpdated = false;
// TODO : Type the "andThen" to simplify user experience // TODO : Type the "andThen" to simplify user experience
// TODO : Add the reference on the typed future in the function andTrn ... ==> then we can add later the cancel // TODO : Add the reference on the typed future in the function andTrn ... ==> then we can add later the cancel
// Get the media
zeus::ProxyMedia media = remoteServiceVideo.get(it).waitFor(echrono::seconds(2000)).get();
if (media.exist() == false) {
APPL_ERROR("get media error");
continue;
}
appl::widget::ListViewerShared tmpWidget = ememory::staticPointerCast<appl::widget::ListViewer>(sharedFromThis()); appl::widget::ListViewerShared tmpWidget = ememory::staticPointerCast<appl::widget::ListViewer>(sharedFromThis());
remoteServiceVideo.mediaMetadataGetKey(it, "title") media.getMetadata("title")
.andThen([=](zeus::Future<std::string> _fut) mutable { .andThen([=](zeus::Future<std::string> _fut) mutable {
APPL_INFO(" [" << elem->m_id << "] get title: " << _fut.get()); APPL_INFO(" [" << elem->m_id << "] get title: " << _fut.get());
{ {
@ -115,7 +124,7 @@ void appl::widget::ListViewer::searchElements(std::string _filter) {
tmpWidget->markToRedraw(); tmpWidget->markToRedraw();
return true; return true;
}); });
remoteServiceVideo.mediaMetadataGetKey(it, "series-name") media.getMetadata("series-name")
.andThen([=](zeus::Future<std::string> _fut) mutable { .andThen([=](zeus::Future<std::string> _fut) mutable {
APPL_ERROR(" [" << elem->m_id << "] get serie: " << _fut.get()); APPL_ERROR(" [" << elem->m_id << "] get serie: " << _fut.get());
{ {
@ -125,7 +134,7 @@ void appl::widget::ListViewer::searchElements(std::string _filter) {
tmpWidget->markToRedraw(); tmpWidget->markToRedraw();
return true; return true;
}); });
remoteServiceVideo.mediaMetadataGetKey(it, "saison") media.getMetadata("saison")
.andThen([=](zeus::Future<std::string> _fut) mutable { .andThen([=](zeus::Future<std::string> _fut) mutable {
APPL_INFO(" [" << elem->m_id << "] get saison: " << _fut.get()); APPL_INFO(" [" << elem->m_id << "] get saison: " << _fut.get());
{ {
@ -135,7 +144,7 @@ void appl::widget::ListViewer::searchElements(std::string _filter) {
tmpWidget->markToRedraw(); tmpWidget->markToRedraw();
return true; return true;
}); });
remoteServiceVideo.mediaMetadataGetKey(it, "episode") media.getMetadata("episode")
.andThen([=](zeus::Future<std::string> _fut) mutable { .andThen([=](zeus::Future<std::string> _fut) mutable {
APPL_INFO(" [" << elem->m_id << "] get episode: " << _fut.get()); APPL_INFO(" [" << elem->m_id << "] get episode: " << _fut.get());
{ {
@ -145,7 +154,7 @@ void appl::widget::ListViewer::searchElements(std::string _filter) {
tmpWidget->markToRedraw(); tmpWidget->markToRedraw();
return true; return true;
}); });
remoteServiceVideo.mediaMetadataGetKey(it, "description") media.getMetadata("description")
.andThen([=](zeus::Future<std::string> _fut) mutable { .andThen([=](zeus::Future<std::string> _fut) mutable {
APPL_INFO(" [" << elem->m_id << "] get description: " << _fut.get()); APPL_INFO(" [" << elem->m_id << "] get description: " << _fut.get());
{ {
@ -155,7 +164,7 @@ void appl::widget::ListViewer::searchElements(std::string _filter) {
tmpWidget->markToRedraw(); tmpWidget->markToRedraw();
return true; return true;
}); });
remoteServiceVideo.mediaMetadataGetKey(it, "production-methode") media.getMetadata("production-methode")
.andThen([=](zeus::Future<std::string> _fut) mutable { .andThen([=](zeus::Future<std::string> _fut) mutable {
APPL_INFO(" [" << elem->m_id << "] get production-methode: " << _fut.get()); APPL_INFO(" [" << elem->m_id << "] get production-methode: " << _fut.get());
{ {
@ -165,7 +174,7 @@ void appl::widget::ListViewer::searchElements(std::string _filter) {
tmpWidget->markToRedraw(); tmpWidget->markToRedraw();
return true; return true;
}); });
remoteServiceVideo.mediaMetadataGetKey(it, "type") media.getMetadata("type")
.andThen([=](zeus::Future<std::string> _fut) mutable { .andThen([=](zeus::Future<std::string> _fut) mutable {
APPL_INFO(" [" << elem->m_id << "] get type: " << _fut.get()); APPL_INFO(" [" << elem->m_id << "] get type: " << _fut.get());
{ {
@ -175,7 +184,7 @@ void appl::widget::ListViewer::searchElements(std::string _filter) {
tmpWidget->markToRedraw(); tmpWidget->markToRedraw();
return true; return true;
}); });
remoteServiceVideo.mediaMineTypeGet(it) media.getMineType()
.andThen([=](zeus::Future<std::string> _fut) mutable { .andThen([=](zeus::Future<std::string> _fut) mutable {
APPL_INFO(" [" << elem->m_id << "] get mine-type: " << _fut.get()); APPL_INFO(" [" << elem->m_id << "] get mine-type: " << _fut.get());
{ {

View File

@ -76,7 +76,7 @@ std::string zeus::MediaImpl::getMineType() {
return m_mineType; return m_mineType;
} }
ememory::SharedPtr<zeus::File> zeus::MediaImpl::GetFile() { ememory::SharedPtr<zeus::File> zeus::MediaImpl::getFile() {
return zeus::File::create(m_basePath + m_fileName + "." + zeus::getExtention(m_mineType), "", m_mineType); return zeus::File::create(m_basePath + m_fileName + "." + zeus::getExtention(m_mineType), "", m_mineType);
} }

View File

@ -35,7 +35,7 @@ namespace zeus {
~MediaImpl(); ~MediaImpl();
uint64_t getUniqueId() override; uint64_t getUniqueId() override;
std::string getMineType() override; std::string getMineType() override;
ememory::SharedPtr<zeus::File> GetFile() override; ememory::SharedPtr<zeus::File> getFile() override;
std::vector<std::string> getMetadataKeys() override; std::vector<std::string> getMetadataKeys() override;
std::string getMetadata(std::string _key) override; std::string getMetadata(std::string _key) override;
void setMetadata(std::string _key, std::string _value) override; void setMetadata(std::string _key, std::string _value) override;

View File

@ -24,7 +24,7 @@ string getMineType()
#brief:Get a media #brief:Get a media
#return:A file reference on the media (transmission is async) #return:A file reference on the media (transmission is async)
obj:zeus-File GetFile() obj:zeus-File getFile()
/* /*
#brief:Get a media in STREAM mode (usefull for video) #brief:Get a media in STREAM mode (usefull for video)
#return:A stream reference on the media (transmission is async) #return:A stream reference on the media (transmission is async)