From 6f753738552ccba98438e3e2244c57d36949e75f Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 13 Apr 2017 00:16:24 +0200 Subject: [PATCH] [DEV/DEBUG] cli enterprete server name and correct the mpeg-ts mine type (not official) --- .../cli-video/appl/main-tool-client-video.cpp | 50 ++++++++++++++++--- .../player-video/appl/widget/VideoPlayer.cpp | 6 ++- zeus/mineType.cpp | 2 +- zeus/zeus-File.impl.cpp | 6 ++- 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/tools/cli-video/appl/main-tool-client-video.cpp b/tools/cli-video/appl/main-tool-client-video.cpp index 221cb85..d04a502 100644 --- a/tools/cli-video/appl/main-tool-client-video.cpp +++ b/tools/cli-video/appl/main-tool-client-video.cpp @@ -46,11 +46,16 @@ static std::string extractAndRemove(const std::string& _inputValue, const char _ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map _basicKey = std::map()) { APPL_INFO("Add media : '" << _path << "'"); - std::string extention = etk::tolower(std::string(_path.begin()+_path.size() -3, _path.end())); + std::string extention; + if ( _path.rfind('.') != std::string::npos + && _path.rfind('.') != 0) { + extention = etk::tolower(std::string(_path.begin()+_path.rfind('.'), _path.end())); + } if ( extention != "avi" && extention != "mkv" && extention != "mov" - && extention != "mp4") { + && extention != "mp4" + && extention != "ts") { APPL_ERROR("Sot send file : " << _path << " Not manage extention..."); return false; } @@ -90,7 +95,7 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< } // remove extention - fileName = std::string(fileName.begin(), fileName.begin() + fileName.size() - 4); + fileName = std::string(fileName.begin(), fileName.begin() + fileName.size() - (extention.size()+1)); std::vector listElementBase = etk::split(fileName, '-'); @@ -133,7 +138,11 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< std::string seriesName = listElement[0]; _basicKey.insert(std::pair("series-name", etk::to_string(seriesName))); - _basicKey.insert(std::pair("title", etk::to_string(listElement[3]))); + std::string fullEpisodeName = listElement[3]; + for (int32_t yyy=4; yyy("title", etk::to_string(fullEpisodeName))); if (std::string(&listElement[1][1]) == "XX") { // saison unknow ... ==> nothing to do ... } else { @@ -168,7 +177,7 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< episodePrint = etk::to_string(episode); _basicKey.insert(std::pair("episode", etk::to_string(episode))); } - APPL_INFO(" recontituated: '" << seriesName << "-s" << saisonPrint << "-e" << episodePrint << "-" << listElement[3] << "'"); + APPL_INFO(" recontituated: '" << seriesName << "-s" << saisonPrint << "-e" << episodePrint << "-" << fullEpisodeName << "'"); } } // send all meta data: @@ -276,13 +285,32 @@ int main(int _argc, const char *_argv[]) { zeus::init(_argc, _argv); zeus::Client client1; std::string login = "test1"; + std::string address = ""; + uint32_t port = 0; std::string pass = "coucou"; std::string requestAction = ""; std::vector args; for (int32_t iii=1; iii<_argc ; ++iii) { std::string data = _argv[iii]; if (etk::start_with(data, "--login=") == true) { - login = &data[8]; + // separate loggin and IP adress ... + std::vector listElem = etk::split(&data[8], '~'); + if (listElem.size() == 0) { + APPL_ERROR("Not enouth element in the login ... need use a XXX~SERVER.org:zzz"); + return -1; + } + login = listElem[0]; + if (listElem.size() == 1) { + // connnect on local host ... nothing to do + } else { + std::vector listElem2 = etk::split(listElem[1], ':'); + if (listElem2.size() >= 1) { + address = listElem2[0]; + } + if (listElem2.size() >= 2) { + port = etk::string_to_uint32_t(listElem2[1]); + } + } } else if (etk::start_with(data, "--pass=") == true) { pass = &data[7]; } else if ( data == "-h" @@ -308,7 +336,13 @@ int main(int _argc, const char *_argv[]) { APPL_INFO("=================================="); APPL_INFO("== ZEUS test client start =="); APPL_INFO("=================================="); - + // Generate IP and Port in the client interface + if (address != "") { + client1.propertyIp.set(address); + } + if (port != 0) { + client1.propertyPort.set(port); + } bool ret = client1.connect(login, pass); if (ret == false) { APPL_ERROR(" ==> NOT Authentify with '" << login << "'"); @@ -405,7 +439,7 @@ int main(int _argc, const char *_argv[]) { APPL_PRINT("============================================"); } else if (requestAction == "pushPath") { APPL_PRINT("============================================"); - APPL_PRINT("== push file: "); + APPL_PRINT("== push path: "); APPL_PRINT("============================================"); // Send a full path: // installVideoPath(remoteServiceVideo, "testVideo"); diff --git a/tools/player-video/appl/widget/VideoPlayer.cpp b/tools/player-video/appl/widget/VideoPlayer.cpp index 6ba7bef..ebeb6e7 100644 --- a/tools/player-video/appl/widget/VideoPlayer.cpp +++ b/tools/player-video/appl/widget/VideoPlayer.cpp @@ -52,7 +52,7 @@ void appl::widget::VideoDisplay::init() { m_resource->get().configure(ivec2(128,128), egami::colorType::RGB8); } // Create the River manager for tha application or part of the application. - m_audioManager = audio::river::Manager::create("river_sample_read"); + m_audioManager = audio::river::Manager::create("zeus-video-player"); } appl::widget::VideoDisplay::~VideoDisplay() { @@ -279,6 +279,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event) / audio::getFormatBytes(m_decoder->m_audioPool[idSlot].m_format) / m_decoder->m_audioPool[idSlot].m_map.size(); m_audioInterface->write(&m_decoder->m_audioPool[idSlot].m_buffer[0], nbSample); + APPL_WARNING("write samples ... "); } m_decoder->m_audioPool[idSlot].m_isUsed = false; getSomething = true; @@ -317,7 +318,8 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event) } // TODO : Chek if this is needed, the display configuration not change too much ... markToRedraw(); - if (m_haveDuration == true) { + if ( m_haveDuration == true + && m_decoder->getDuration() > echrono::milliseconds(10)) { if (m_currentTime >= m_decoder->getDuration() + echrono::milliseconds(200)) { APPL_WARNING("Finish playing"); signalFinish.emit(); diff --git a/zeus/mineType.cpp b/zeus/mineType.cpp index a0ceb35..25e694e 100644 --- a/zeus/mineType.cpp +++ b/zeus/mineType.cpp @@ -32,7 +32,7 @@ static std::vector> mineList = { { "m4v", "video/mp4"}, { "m4p", "video/mp4"}, { "mp4ps", "video/x-nerodigital-ps"}, - { "ts", "video/mpeg2"}, + { "ts", "video/mpeg2-ts"}, { "ogm", "video/mpeg"}, { "mkv", "video/x-matroska"}, { "rmvb", "video/mpeg"}, diff --git a/zeus/zeus-File.impl.cpp b/zeus/zeus-File.impl.cpp index 387ddb4..f3a3d4f 100644 --- a/zeus/zeus-File.impl.cpp +++ b/zeus/zeus-File.impl.cpp @@ -25,7 +25,11 @@ zeus::FileImpl::FileImpl(std::string _fileNameReal) : m_node(_fileNameReal) { m_size = m_node.fileSize(); m_node.fileOpenRead(); - std::string extention = std::string(_fileNameReal.begin()+_fileNameReal.size() -3, _fileNameReal.end()); + std::string extention; + if ( _fileNameReal.rfind('.') != std::string::npos + && _fileNameReal.rfind('.') != 0) { + extention = std::string(_fileNameReal.begin()+_fileNameReal.rfind('.'), _fileNameReal.end()); + } m_mineType = zeus::getMineType(extention); m_sha512 = algue::stringConvert(algue::sha512::encodeFromFile(_fileNameReal)); }