From d136aa51fbf3072beae38b3d3c01a05a798140d9 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 15 Nov 2016 23:51:33 +0100 Subject: [PATCH] [DEV] set multithread decoding... --- tools/player-video/appl/Main.cpp | 9 ++++++- tools/player-video/appl/Windows.cpp | 25 +++++++++++++------ tools/player-video/appl/Windows.hpp | 3 +++ .../player-video/appl/widget/VideoPlayer.cpp | 1 + 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/tools/player-video/appl/Main.cpp b/tools/player-video/appl/Main.cpp index 5c333e2..8a1dea8 100644 --- a/tools/player-video/appl/Main.cpp +++ b/tools/player-video/appl/Main.cpp @@ -68,9 +68,16 @@ namespace appl { // set application widget: appl::widget::VideoDisplay::createManagerWidget(_context.getWidgetManager()); // Create the windows - ewol::widget::WindowsShared basicWindows = appl::Windows::create(); + ememory::SharedPtr basicWindows = appl::Windows::create(); // configure the ewol context to use the new windows _context.setWindows(basicWindows); + for (int32_t iii=0 ; iii<_context.getCmd().size(); iii++) { + std::string tmpppp = _context.getCmd().get(iii); + if (etk::start_with(tmpppp, "-") == true) { + continue; + } + basicWindows->addFile(tmpppp); + } } }; } diff --git a/tools/player-video/appl/Windows.cpp b/tools/player-video/appl/Windows.cpp index 74c6bdc..f183eb4 100644 --- a/tools/player-video/appl/Windows.cpp +++ b/tools/player-video/appl/Windows.cpp @@ -11,7 +11,8 @@ #include #include -appl::Windows::Windows() { +appl::Windows::Windows(): + m_id(0) { addObjectType("appl::Windows"); propertyTitle.setDirectCheck(std::string("sample ") + PROJECT_NAME); } @@ -57,27 +58,35 @@ void appl::Windows::init() { void appl::Windows::onCallbackPrevious() { - ememory::SharedPtr tmpDisp = ememory::dynamicPointerCast(getSubObjectNamed("displayer")); - if (tmpDisp != nullptr) { - // TODO : tmpDisp->... + m_id--; + if (m_id < 0) { + m_id = m_list.size()-1; } + onCallbackPlay(); } void appl::Windows::onCallbackPlay() { ememory::SharedPtr tmpDisp = ememory::dynamicPointerCast(getSubObjectNamed("displayer")); if (tmpDisp != nullptr) { - tmpDisp->setFile("/home/heero/Downloads/Mademoiselle Zazie-e18-Myrtille.mp4"); + tmpDisp->setFile(m_list[m_id]); } } void appl::Windows::onCallbackNext() { - ememory::SharedPtr tmpDisp = ememory::dynamicPointerCast(getSubObjectNamed("displayer")); - if (tmpDisp != nullptr) { - // TODO : tmpDisp->... + m_id++; + if (m_id >= m_list.size()) { + m_id = 0; } + onCallbackPlay(); } void appl::Windows::onCallbackFPS(const int32_t& _fps) { APPL_PRINT("FPS = " << _fps); + propertySetOnWidgetNamed("lb-fps", "value", "FPS=" + etk::to_string(_fps) + ""); +} + +void appl::Windows::addFile(const std::string& _file) { + APPL_PRINT("Add file : " << _file); + m_list.push_back(_file); } \ No newline at end of file diff --git a/tools/player-video/appl/Windows.hpp b/tools/player-video/appl/Windows.hpp index fef93fd..907623f 100644 --- a/tools/player-video/appl/Windows.hpp +++ b/tools/player-video/appl/Windows.hpp @@ -17,6 +17,8 @@ namespace appl { Windows(); void init(); ewol::widget::ComposerShared m_composer; + std::vector m_list; + int32_t m_id; public: DECLARE_FACTORY(Windows); public: // callback functions @@ -24,6 +26,7 @@ namespace appl { void onCallbackPlay(); void onCallbackNext(); void onCallbackFPS(const int32_t& _fps); + void addFile(const std::string& _file); }; } diff --git a/tools/player-video/appl/widget/VideoPlayer.cpp b/tools/player-video/appl/widget/VideoPlayer.cpp index 98a58e9..f9cae53 100644 --- a/tools/player-video/appl/widget/VideoPlayer.cpp +++ b/tools/player-video/appl/widget/VideoPlayer.cpp @@ -137,6 +137,7 @@ int appl::Decoder::open_codec_context(int *_streamId, AVFormatContext *_formatCo } // Init the decoders, with or without reference counting av_dict_set(&opts, "refcounted_frames", m_refCount ? "1" : "0", 0); + av_dict_set(&opts, "threads", "auto", 0); if ((ret = avcodec_open2(dec_ctx, dec, &opts)) < 0) { APPL_ERROR("Failed to open " << av_get_media_type_string(_type) << " codec"); return ret;