From 4ad6f382dd131b46da9239e70b1c0ec05f01ce75 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 14 Apr 2017 21:19:19 +0200 Subject: [PATCH] [DEV] converge to use only object instead of single service API --- lutin_zeus.py | 9 + .../cli-video/appl/main-tool-client-video.cpp | 41 ++-- tools/player-video/appl/MediaDecoder.cpp | 15 +- tools/player-video/appl/MediaDecoder.hpp | 1 + .../player-video/appl/widget/VideoPlayer.cpp | 8 +- tools/player-video/appl/widget/VolumeBar.cpp | 10 +- tools/player-video/data/Light.svg | 7 + tools/player-video/data/Volume.svg | 13 ++ tools/player-video/data/gui-player.xml | 6 + .../service-video/appl/main-service-video.cpp | 198 +++++------------- .../appl/zeus-service-video.srv.zeus.idl | 56 +---- zeus/mineType.cpp | 4 +- zeus/zeus-File.impl.cpp | 8 +- zeus/zeus-File.impl.hpp | 11 +- zeus/zeus-Media.impl.cpp | 114 ++++++++++ zeus/zeus-Media.impl.hpp | 53 +++++ zeus/zeus-Media.obj.zeus.idl | 59 ++++++ 17 files changed, 392 insertions(+), 221 deletions(-) create mode 100644 tools/player-video/data/Light.svg create mode 100644 tools/player-video/data/Volume.svg create mode 100644 zeus/zeus-Media.impl.cpp create mode 100644 zeus/zeus-Media.impl.hpp create mode 100644 zeus/zeus-Media.obj.zeus.idl diff --git a/lutin_zeus.py b/lutin_zeus.py index 5ad0042..a3cc32f 100644 --- a/lutin_zeus.py +++ b/lutin_zeus.py @@ -125,6 +125,15 @@ def configure(target, my_module): 'zeus/zeus-File.impl.hpp', ]) + my_module.add_depend('ejson') + zeus_macro.parse_object_idl(my_module, 'zeus/zeus-Media.obj.zeus.idl') + my_module.add_src_file([ + 'zeus/zeus-Media.impl.cpp', + ]) + my_module.add_header_file([ + 'zeus/zeus-Media.impl.hpp', + ]) + if target.config["compilator"] == "clang": my_module.add_flag('c++', "-Wno-unsequenced", export=True) # build in C++ mode diff --git a/tools/cli-video/appl/main-tool-client-video.cpp b/tools/cli-video/appl/main-tool-client-video.cpp index 362ec21..b90bf9c 100644 --- a/tools/cli-video/appl/main-tool-client-video.cpp +++ b/tools/cli-video/appl/main-tool-client-video.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,7 @@ 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 << "'"); + APPL_PRINT("Add media : '" << _path << "'"); std::string extention; if ( _path.rfind('.') != std::string::npos && _path.rfind('.') != 0) { @@ -60,11 +61,19 @@ bool pushVideoFile(zeus::service::ProxyVideo& _srv, std::string _path, std::map< return false; } - uint32_t mediaId = _srv.mediaAdd(zeus::File::create(_path)).waitFor(echrono::seconds(20000)).get(); + uint32_t mediaId = _srv.add(zeus::File::create(_path)).waitFor(echrono::seconds(20000)).get(); if (mediaId == 0) { APPL_ERROR("Get media ID = 0 With no error"); return false; } + // Get the media + zeus::ProxyMedia media = _srv.get(mediaId).waitFor(echrono::seconds(2000)).get(); + if (media.exist() == false) { + APPL_ERROR("get media error"); + return false; + } + + // 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(); @@ -177,13 +186,13 @@ 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 << "-" << fullEpisodeName << "'"); + APPL_PRINT(" ==> '" << seriesName << "-s" << saisonPrint << "-e" << episodePrint << "-" << fullEpisodeName << "'"); } } // send all meta data: zeus::FutureGroup group; for (auto &itKey : _basicKey) { - group.add(_srv.mediaMetadataSetKey(mediaId, itKey.first, itKey.second)); + group.add(media.setMetadata(itKey.first, itKey.second)); } group.wait(); return true; @@ -380,16 +389,16 @@ int main(int _argc, const char *_argv[]) { // TODO : Do it : APPL_ERROR("NEED to add check in cmd line to execute it ..."); return -1; - uint32_t count = remoteServiceVideo.mediaIdCount().wait().get(); + uint32_t count = remoteServiceVideo.count().wait().get(); APPL_DEBUG("have " << count << " medias"); for (uint32_t iii=0; iii " << tmpMax); - std::vector list = remoteServiceVideo.mediaIdGet(iii,tmpMax).wait().get(); + std::vector list = remoteServiceVideo.getIds(iii,tmpMax).wait().get(); zeus::FutureGroup groupWait; for (auto& it : list) { APPL_PRINT("remove ELEMENT : " << it); - groupWait.add(remoteServiceVideo.mediaRemove(it)); + groupWait.add(remoteServiceVideo.remove(it)); } groupWait.waitFor(echrono::seconds(2000)); } @@ -400,17 +409,23 @@ int main(int _argc, const char *_argv[]) { APPL_PRINT("============================================"); APPL_PRINT("== list files: "); APPL_PRINT("============================================"); - uint32_t count = remoteServiceVideo.mediaIdCount().wait().get(); + uint32_t count = remoteServiceVideo.count().wait().get(); APPL_DEBUG("have " << count << " medias"); for (uint32_t iii=0; iii " << tmpMax); - std::vector list = remoteServiceVideo.mediaIdGet(iii, tmpMax).wait().get(); + std::vector list = remoteServiceVideo.getIds(iii, tmpMax).wait().get(); for (auto& it : list) { - std::string name = remoteServiceVideo.mediaMetadataGetKey(it, "title").wait().get(); - std::string serie = remoteServiceVideo.mediaMetadataGetKey(it, "series-name").wait().get(); - std::string episode = remoteServiceVideo.mediaMetadataGetKey(it, "episode").wait().get(); - std::string saison = remoteServiceVideo.mediaMetadataGetKey(it, "saison").wait().get(); + // Get the media + zeus::ProxyMedia media = remoteServiceVideo.get(it).waitFor(echrono::seconds(2000)).get(); + if (media.exist() == false) { + APPL_ERROR("get media error"); + return false; + } + std::string name = media.getMetadata("title").wait().get(); + std::string serie = media.getMetadata("series-name").wait().get(); + std::string episode = media.getMetadata("episode").wait().get(); + std::string saison = media.getMetadata("saison").wait().get(); std::string outputDesc = ""; if (serie != "") { outputDesc += serie + "-"; diff --git a/tools/player-video/appl/MediaDecoder.cpp b/tools/player-video/appl/MediaDecoder.cpp index 70fe6c7..716717f 100644 --- a/tools/player-video/appl/MediaDecoder.cpp +++ b/tools/player-video/appl/MediaDecoder.cpp @@ -157,7 +157,8 @@ void appl::MessageElementAudio::configure(audio::format _format, uint32_t _sampl } } -appl::MediaDecoder::MediaDecoder() { +appl::MediaDecoder::MediaDecoder() : + m_seekApply(-1) { init_ffmpeg(); m_IOContext = nullptr; m_formatContext = nullptr; @@ -236,6 +237,10 @@ int appl::MediaDecoder::decode_packet(int *_gotFrame, int _cached) { m_videoPool[slotId].m_duration = echrono::Duration(0, 1000000000.0/float(getFps(m_videoDecoderContext))); m_currentVideoTime += m_videoPool[slotId].m_duration; m_videoPool[slotId].m_isUsed = true; + if (m_fistFrameSended == false) { + m_seekApply = m_currentVideoTime; + m_fistFrameSended = true; + } } } } else if (m_packet.stream_index == m_audioStream_idx) { @@ -291,13 +296,17 @@ int appl::MediaDecoder::decode_packet(int *_gotFrame, int _cached) { // inject data in the buffer: memcpy(&m_audioPool[slotId].m_buffer[0], m_frame->extended_data[0], m_audioPool[slotId].m_buffer.size()); } - // We use the Time of the packet ==> better synchronisation when seeking - m_currentAudioTime = packetTime; + // TODO : We use the Time of the packet ==> better synchronisation when seeking + //m_currentAudioTime = packetTime; m_audioPool[slotId].m_id = m_audioFrameCount; m_audioPool[slotId].m_time = m_currentAudioTime; m_audioPool[slotId].m_duration = echrono::Duration(0,(1000000000.0*m_frame->nb_samples)/float(m_frame->sample_rate)); m_currentAudioTime += m_audioPool[slotId].m_duration; m_audioPool[slotId].m_isUsed = true; + if (m_fistFrameSended == false) { + m_seekApply = m_currentVideoTime; + m_fistFrameSended = true; + } } } } diff --git a/tools/player-video/appl/MediaDecoder.hpp b/tools/player-video/appl/MediaDecoder.hpp index 07ffe0e..1355aa7 100644 --- a/tools/player-video/appl/MediaDecoder.hpp +++ b/tools/player-video/appl/MediaDecoder.hpp @@ -86,6 +86,7 @@ namespace appl { class MediaDecoder : public gale::Thread { bool m_stopRequested; public: + bool m_fistFrameSended; echrono::Duration m_seekApply; private: echrono::Duration m_seek; diff --git a/tools/player-video/appl/widget/VideoPlayer.cpp b/tools/player-video/appl/widget/VideoPlayer.cpp index 52bbe59..e2833f8 100644 --- a/tools/player-video/appl/widget/VideoPlayer.cpp +++ b/tools/player-video/appl/widget/VideoPlayer.cpp @@ -272,9 +272,11 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event) if (m_decoder == nullptr) { return; } - if (m_decoder->m_seekApply >= echrono::Duration(0)) { + if (m_decoder->m_seekApply > echrono::Duration(-1)) { m_currentTime = m_decoder->m_seekApply; - APPL_ERROR("Apply new position : " << m_currentTime); + APPL_ERROR("=========================================================="); + APPL_ERROR("Apply seek position : " << m_currentTime); + APPL_ERROR("=========================================================="); m_decoder->m_seekApply = echrono::Duration(-1); if (m_audioInterface != nullptr) { m_audioInterface->clearInternalBuffer(); @@ -285,6 +287,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event) int32_t idSlot = m_decoder->audioGetOlderSlot(); if ( idSlot != -1 && m_currentTime > m_decoder->m_audioPool[idSlot].m_time) { + APPL_WARNING("Get Slot AUDIO " << m_currentTime << " > " << m_decoder->m_audioPool[idSlot].m_time); if (m_audioInterface == nullptr) { // start audio interface the first time we need it APPL_ERROR("=========================================================="); @@ -316,6 +319,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event) // check the slot is valid and check display time of the element: if ( idSlot != -1 && m_currentTime > m_decoder->m_videoPool[idSlot].m_time) { + APPL_WARNING("Get Slot VIDEO " << m_currentTime << " > " << m_decoder->m_audioPool[idSlot].m_time); m_resource->get().swap(m_decoder->m_videoPool[idSlot].m_image); m_imageSize = m_resource->get().getSize(); ivec2 tmpSize = m_decoder->m_videoPool[idSlot].m_imagerealSize; diff --git a/tools/player-video/appl/widget/VolumeBar.cpp b/tools/player-video/appl/widget/VolumeBar.cpp index 3ac94d8..2f920aa 100644 --- a/tools/player-video/appl/widget/VolumeBar.cpp +++ b/tools/player-video/appl/widget/VolumeBar.cpp @@ -8,7 +8,7 @@ #include -const int32_t dotRadius = 6; +const float dotRadius = 6.0f; appl::widget::VolumeBar::VolumeBar() : signalChange(this, "change", ""), @@ -61,18 +61,18 @@ void appl::widget::VolumeBar::onRegenerateDisplay() { m_draw.clear(); m_draw.setColor(m_textColorFg); // draw a line: - m_draw.setPos(vec3(dotRadius, 0, 0)); - m_draw.rectangleWidth(vec3(m_size.x(), m_size.y()-dotRadius*2.0, 0)); + m_draw.setPos(vec3(dotRadius, 0.0f, 0.0f)); + m_draw.rectangleWidth(vec3(m_size.x(), m_size.y()-dotRadius*2.0f, 0.0f)); // chaneg color whe soud became louder ... if (*propertyValue > 0.5f) { m_draw.setColor(m_textColorLoaded); } else { m_draw.setColor(m_textColorDone); } - m_draw.setPos(vec3(m_size.x()*0.1, dotRadius, 0)); + m_draw.setPos(vec3(m_size.x()*0.1f, dotRadius, 0.0f)); float offset = (*propertyValue-*propertyMinimum)/(*propertyMaximum-*propertyMinimum); - m_draw.rectangleWidth(vec3(m_size.x()*0.8, offset*(m_size.y()-2*dotRadius), 0) ); + m_draw.rectangleWidth(vec3(m_size.x()*0.8f, offset*(m_size.y()-2.0f*dotRadius), 0.0f) ); } diff --git a/tools/player-video/data/Light.svg b/tools/player-video/data/Light.svg new file mode 100644 index 0000000..2e1cbd7 --- /dev/null +++ b/tools/player-video/data/Light.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/tools/player-video/data/Volume.svg b/tools/player-video/data/Volume.svg new file mode 100644 index 0000000..181f34d --- /dev/null +++ b/tools/player-video/data/Volume.svg @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/tools/player-video/data/gui-player.xml b/tools/player-video/data/gui-player.xml index 989d1ac..abac7c1 100644 --- a/tools/player-video/data/gui-player.xml +++ b/tools/player-video/data/gui-player.xml @@ -30,11 +30,17 @@