[DEV] add viewer of the download of the remote file
This commit is contained in:
parent
6091275c64
commit
7cc209a13e
@ -17,6 +17,7 @@
|
||||
#include <appl/widget/VideoPlayer.hpp>
|
||||
#include <appl/widget/ListViewer.hpp>
|
||||
#include <appl/widget/Player.hpp>
|
||||
#include <appl/widget/ProgressBar.hpp>
|
||||
#include <zeus/zeus.hpp>
|
||||
|
||||
namespace appl {
|
||||
@ -72,6 +73,7 @@ namespace appl {
|
||||
appl::widget::VideoDisplay::createManagerWidget(_context.getWidgetManager());
|
||||
appl::widget::ListViewer::createManagerWidget(_context.getWidgetManager());
|
||||
appl::widget::Player::createManagerWidget(_context.getWidgetManager());
|
||||
appl::widget::ProgressBar::createManagerWidget(_context.getWidgetManager());
|
||||
// Create the windows
|
||||
ememory::SharedPtr<appl::Windows> basicWindows = appl::Windows::create();
|
||||
// configure the ewol context to use the new windows
|
||||
|
@ -353,6 +353,11 @@ void appl::MediaDecoder::init(ememory::SharedPtr<ClientProperty> _property, uint
|
||||
APPL_ERROR("Request play of not connected handle ==> 'not alive'");
|
||||
return;
|
||||
}
|
||||
bool retSrv = _property->connection.waitForService("video");
|
||||
if (retSrv == false) {
|
||||
APPL_ERROR(" ==> SERVICE not availlable or not started");
|
||||
return;
|
||||
}
|
||||
zeus::service::ProxyVideo remoteServiceVideo = _property->connection.getService("video");
|
||||
// remove all media (for test)
|
||||
if (remoteServiceVideo.exist() == false) {
|
||||
@ -463,6 +468,9 @@ int64_t appl::MediaDecoder::seekFunc(int64_t _offset, int _whence) {
|
||||
}
|
||||
|
||||
bool appl::StreamBuffering::addDataCallback(zeus::Future<zeus::Raw> _fut, int64_t _positionRequest) {
|
||||
#ifdef DEBUG
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
#endif
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
bool find = false;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <gale/Thread.hpp>
|
||||
#include <audio/channel.hpp>
|
||||
#include <audio/format.hpp>
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/ClientProperty.hpp>
|
||||
#include <zeus/ProxyFile.hpp>
|
||||
|
||||
@ -174,6 +175,22 @@ namespace appl {
|
||||
int writeFunc(uint8_t* _buf, int _bufSize);
|
||||
// @brief INTERNAL seek callback
|
||||
int64_t seekFunc(int64_t _offset, int _whence);
|
||||
|
||||
std::vector<std::pair<float,float>> getDownloadPart() {
|
||||
std::vector<std::pair<float,float>> out;
|
||||
if (m_remote == nullptr) {
|
||||
return out;
|
||||
}
|
||||
std::vector<std::pair<uint32_t,uint32_t>> vals = m_remote->getDownloadPart();
|
||||
echrono::Duration totalTime = getDuration();
|
||||
float size = totalTime.toSeconds()/float(m_remote->getSize());
|
||||
APPL_ERROR(" duration in sec : " << totalTime << " => " << totalTime.toSeconds());
|
||||
for (auto &it : vals) {
|
||||
out.push_back(std::pair<float,float>(float(it.first)*size, float(it.second)*size));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -75,6 +75,11 @@ void appl::widget::ListViewer::searchElements(std::string _filter) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool retSrv = m_clientProp->connection.waitForService("video");
|
||||
if (retSrv == false) {
|
||||
APPL_ERROR(" ==> SERVICE not availlable or not started");
|
||||
return;
|
||||
}
|
||||
// get all the data:
|
||||
zeus::service::ProxyVideo remoteServiceVideo = m_clientProp->connection.getService("video");
|
||||
// remove all media (for test)
|
||||
|
@ -47,6 +47,7 @@ void appl::widget::Player::init() {
|
||||
subBind(ewol::widget::Slider, "[" + etk::to_string(getId()) + "]appl-player-progress-bar", signalChange, sharedFromThis(), &appl::widget::Player::onCallbackSeekRequest);
|
||||
|
||||
m_display = ememory::dynamicPointerCast<appl::widget::VideoDisplay>(getSubObjectNamed("[" + etk::to_string(getId()) + "]appl-player-display"));
|
||||
m_progress = ememory::dynamicPointerCast<appl::widget::ProgressBar>(getSubObjectNamed("[" + etk::to_string(getId()) + "]appl-player-progress-bar"));
|
||||
propertyCanFocus.set(true);
|
||||
markToRedraw();
|
||||
}
|
||||
@ -77,14 +78,24 @@ void appl::widget::Player::playStream(ememory::SharedPtr<appl::ClientProperty> _
|
||||
|
||||
void appl::widget::Player::onCallbackDuration(const echrono::Duration& _time) {
|
||||
//APPL_ERROR("duration = " << _time);
|
||||
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-progress-bar", "value", "0");
|
||||
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-progress-bar", "max", etk::to_string(_time.toSeconds()));
|
||||
if (m_progress != nullptr) {
|
||||
m_progress->propertyValue.set(0);
|
||||
m_progress->propertyMaximum.set(_time.toSeconds());
|
||||
}
|
||||
}
|
||||
|
||||
void appl::widget::Player::onCallbackPosition(const echrono::Duration& _time) {
|
||||
APPL_ERROR("time = " << _time);
|
||||
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-time", "value", "<font color='green'>" + etk::to_string(_time) + "</font>");
|
||||
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-progress-bar", "value", etk::to_string(_time.toSeconds()));
|
||||
if (m_progress != nullptr) {
|
||||
m_progress->propertyValue.set(_time.toSeconds());
|
||||
}
|
||||
if (m_display != nullptr) {
|
||||
std::vector<std::pair<float,float>> tmp = m_display->getDownloadPart();
|
||||
if (m_progress != nullptr) {
|
||||
m_progress->setRangeAvaillable(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void appl::widget::Player::onCallbackSeekRequest(const float& _value) {
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
#include <appl/widget/VideoPlayer.hpp>
|
||||
#include <appl/widget/ProgressBar.hpp>
|
||||
#include <appl/ClientProperty.hpp>
|
||||
|
||||
namespace appl {
|
||||
@ -33,6 +34,7 @@ namespace appl {
|
||||
virtual ~Player();
|
||||
protected:
|
||||
ememory::SharedPtr<appl::widget::VideoDisplay> m_display; //!< Display widget
|
||||
ememory::SharedPtr<appl::widget::ProgressBar> m_progress; //!< Display widget
|
||||
public:
|
||||
void playStream(ememory::SharedPtr<appl::ClientProperty> _property, uint32_t _mediaId);
|
||||
void suspend();
|
||||
|
124
tools/player-video/appl/widget/ProgressBar.cpp
Normal file
124
tools/player-video/appl/widget/ProgressBar.cpp
Normal file
@ -0,0 +1,124 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <appl/widget/ProgressBar.hpp>
|
||||
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
const int32_t dotRadius = 6;
|
||||
|
||||
appl::widget::ProgressBar::ProgressBar() :
|
||||
signalChange(this, "change", ""),
|
||||
propertyValue(this, "value",
|
||||
0.0f,
|
||||
"Value of the ProgressBar",
|
||||
&appl::widget::ProgressBar::onChangePropertyValue),
|
||||
propertyMaximum(this, "max",
|
||||
10.0f,
|
||||
"Maximum value",
|
||||
&appl::widget::ProgressBar::onChangePropertyMaximum) {
|
||||
addObjectType("appl::widget::ProgressBar");
|
||||
|
||||
m_textColorFg = etk::color::orange;
|
||||
m_textColorLoaded = etk::color::red;
|
||||
m_textColorDone = etk::color::green;
|
||||
|
||||
m_textColorBg = etk::color::black;
|
||||
m_textColorBg.setA(0x3F);
|
||||
|
||||
propertyCanFocus.setDirectCheck(true);
|
||||
// Limit event at 1:
|
||||
setMouseLimit(1);
|
||||
}
|
||||
|
||||
appl::widget::ProgressBar::~ProgressBar() {
|
||||
|
||||
}
|
||||
|
||||
void appl::widget::ProgressBar::calculateMinMaxSize() {
|
||||
vec2 minTmp = propertyMinSize->getPixel();
|
||||
m_minSize.setValue(std::max(minTmp.x(), 40.0f),
|
||||
std::max(minTmp.y(), dotRadius*2.0f) );
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
void appl::widget::ProgressBar::onDraw() {
|
||||
m_draw.draw();
|
||||
}
|
||||
|
||||
void appl::widget::ProgressBar::onRegenerateDisplay() {
|
||||
if (needRedraw() == false) {
|
||||
return;
|
||||
}
|
||||
// clean the object list ...
|
||||
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()-dotRadius*2.0, m_size.y(), 0));
|
||||
|
||||
// draw all availlable section ...
|
||||
m_draw.setColor(m_textColorLoaded);
|
||||
for (auto &it: m_listAvaillable) {
|
||||
APPL_INFO("plop " << it.first << " " << it.second);
|
||||
m_draw.setPos(vec3(dotRadius+(it.first/propertyMaximum)*(m_size.x()-2*dotRadius), m_size.y()*0.1, 0));
|
||||
m_draw.rectangleWidth(vec3((it.second/propertyMaximum)*(m_size.x()-2*dotRadius), m_size.y()*0.8, 0) );
|
||||
}
|
||||
|
||||
m_draw.setColor(m_textColorDone);
|
||||
m_draw.setPos(vec3(dotRadius, m_size.y()*0.3, 0));
|
||||
m_draw.rectangleWidth(vec3((propertyValue/propertyMaximum)*(m_size.x()-2*dotRadius), m_size.y()*0.4, 0) );
|
||||
|
||||
|
||||
|
||||
|
||||
etk::Color<> borderDot = m_textColorFg;
|
||||
borderDot.setA(borderDot.a()/2);
|
||||
m_draw.setPos(vec3(4+(propertyValue/propertyMaximum)*(m_size.x()-2*dotRadius), m_size.y()/2, 0) );
|
||||
m_draw.setColorBg(borderDot);
|
||||
m_draw.circle(dotRadius);
|
||||
m_draw.setColorBg(m_textColorFg);
|
||||
m_draw.circle(dotRadius/1.6);
|
||||
}
|
||||
|
||||
bool appl::widget::ProgressBar::onEventInput(const ewol::event::Input& _event) {
|
||||
vec2 relativePos = relativePosition(_event.getPos());
|
||||
//EWOL_DEBUG("Event on ProgressBar ..." << _event);
|
||||
if (1 == _event.getId()) {
|
||||
if( gale::key::status::pressSingle == _event.getStatus()
|
||||
|| gale::key::status::move == _event.getStatus()) {
|
||||
// get the new position :
|
||||
EWOL_VERBOSE("Event on ProgressBar (" << relativePos.x() << "," << relativePos.y() << ")");
|
||||
float oldValue = *propertyValue;
|
||||
updateValue((float)(relativePos.x() - dotRadius) / (m_size.x()-2*dotRadius) * (*propertyMaximum));
|
||||
if (oldValue != *propertyValue) {
|
||||
EWOL_VERBOSE(" new value : " << *propertyValue << " in [0.." << *propertyMaximum << "]");
|
||||
signalChange.emit(*propertyValue);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void appl::widget::ProgressBar::updateValue(float _newValue) {
|
||||
_newValue = std::max(std::min(_newValue, *propertyMaximum), 0.0f);
|
||||
propertyValue.setDirect(_newValue);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
||||
void appl::widget::ProgressBar::onChangePropertyValue() {
|
||||
updateValue(*propertyValue);
|
||||
return;
|
||||
}
|
||||
|
||||
void appl::widget::ProgressBar::onChangePropertyMaximum() {
|
||||
updateValue(*propertyValue);
|
||||
return;
|
||||
}
|
||||
|
||||
|
64
tools/player-video/appl/widget/ProgressBar.hpp
Normal file
64
tools/player-video/appl/widget/ProgressBar.hpp
Normal file
@ -0,0 +1,64 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/Color.hpp>
|
||||
#include <appl/debug.hpp>
|
||||
#include <ewol/widget/Widget.hpp>
|
||||
#include <ewol/compositing/Drawing.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
|
||||
namespace appl {
|
||||
namespace widget {
|
||||
class ProgressBar;
|
||||
using ProgressBarShared = ememory::SharedPtr<appl::widget::ProgressBar>;
|
||||
using ProgressBarWeak = ememory::WeakPtr<appl::widget::ProgressBar>;
|
||||
/**
|
||||
* @ingroup ewolWidgetGroup
|
||||
*/
|
||||
class ProgressBar : public ewol::Widget {
|
||||
public: // signals
|
||||
esignal::Signal<float> signalChange;
|
||||
public:
|
||||
//eproperty::Value<std::string> propertyShape; //!< name of the shape used
|
||||
eproperty::Value<float> propertyValue; //!< current value of the ProgressBar
|
||||
eproperty::Value<float> propertyMaximum; //!< maximum value of the ProgressBar
|
||||
protected:
|
||||
ProgressBar();
|
||||
public:
|
||||
DECLARE_WIDGET_FACTORY(ProgressBar, "appl_ProgressBar");
|
||||
virtual ~ProgressBar();
|
||||
public:
|
||||
// TODO : Rewoek the color in the theme ...
|
||||
void setColor(etk::Color<> _newColor) {
|
||||
m_textColorFg = _newColor;
|
||||
};
|
||||
protected:
|
||||
ewol::compositing::Drawing m_draw; //!< drawing tool.
|
||||
etk::Color<> m_textColorFg; //!< Text color
|
||||
etk::Color<> m_textColorBg; //!< Background color
|
||||
etk::Color<> m_textColorDone;
|
||||
etk::Color<> m_textColorLoaded;
|
||||
void updateValue(float _newValue);
|
||||
public: // Derived function
|
||||
void onDraw() override;
|
||||
void calculateMinMaxSize() override;
|
||||
void onRegenerateDisplay() override;
|
||||
bool onEventInput(const ewol::event::Input& _event) override;
|
||||
private:
|
||||
std::vector<std::pair<float,float>> m_listAvaillable;
|
||||
public:
|
||||
void setRangeAvaillable(std::vector<std::pair<float,float>>& _values) {
|
||||
m_listAvaillable = _values;
|
||||
}
|
||||
protected:
|
||||
virtual void onChangePropertyValue();
|
||||
virtual void onChangePropertyMaximum();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -258,12 +258,13 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event)
|
||||
APPL_VERBOSE("tick: " << _event);
|
||||
m_currentTime += _event.getDeltaCallDuration();
|
||||
}
|
||||
|
||||
if (m_decoder == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (m_decoder->m_seekApply >= echrono::Duration(0)) {
|
||||
m_currentTime = m_decoder->m_seekApply;
|
||||
APPL_ERROR("Apply new position : " << m_currentTime);
|
||||
//APPL_ERROR("Apply new position : " << m_currentTime);
|
||||
m_decoder->m_seekApply = echrono::Duration(-1);
|
||||
if (m_audioInterface != nullptr) {
|
||||
m_audioInterface->clearInternalBuffer();
|
||||
|
@ -89,6 +89,12 @@ namespace appl {
|
||||
return echrono::Duration(0);
|
||||
}
|
||||
void seek(const echrono::Duration& _time);
|
||||
std::vector<std::pair<float,float>> getDownloadPart() {
|
||||
if (m_decoder == nullptr) {
|
||||
return std::vector<std::pair<float,float>>();
|
||||
}
|
||||
return m_decoder->getDownloadPart();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
<label name="[{ID}]appl-player-label-time"/>
|
||||
<spacer expand="true,false" fill="true"/>
|
||||
</sizer>
|
||||
<slider name="[{ID}]appl-player-progress-bar" expand="true,false" fill="true" step="0.01" min="0"/>
|
||||
<appl_ProgressBar name="[{ID}]appl-player-progress-bar" expand="true,false" fill="true" step="0.01" min="0"/>
|
||||
<spacer expand="true" fill="true"/>
|
||||
<label name="[{ID}]appl-player-label-fps"/>
|
||||
</sizer>
|
||||
|
@ -38,6 +38,7 @@ def configure(target, my_module):
|
||||
'appl/ClientProperty.cpp',
|
||||
'appl/widget/Connection.cpp',
|
||||
'appl/widget/Player.cpp',
|
||||
'appl/widget/ProgressBar.cpp',
|
||||
])
|
||||
my_module.add_depend([
|
||||
'ffmpeg-libs',
|
||||
|
Loading…
Reference in New Issue
Block a user