[DEV] play video from server ==> copy and play... (TODO: copy by part)

This commit is contained in:
Edouard DUPIN 2017-01-30 00:23:27 +01:00
parent 6792ab72c8
commit 557545b74a
8 changed files with 182 additions and 95 deletions

View File

@ -9,6 +9,9 @@
#include <zeus/service/ProxyVideo.hpp>
#include <zeus/ProxyFile.hpp>
#include <appl/debug.hpp>
#include <appl/widget/VideoPlayer.hpp>
#include <ewol/object/Manager.hpp>
@ -310,6 +313,38 @@ double appl::MediaDecoder::getFps(AVCodecContext *_avctx) {
return 1.0 / av_q2d(_avctx->time_base) / FFMAX(_avctx->ticks_per_frame, 1);
}
void appl::MediaDecoder::init(ememory::SharedPtr<ClientProperty> _property, uint32_t _mediaId) {
// TODO : Correct this later ... We first download the media and after we play it
// TODO : We need to down load only a small part ...
// get the requested node:
if (_property == nullptr) {
APPL_ERROR("Request play of not handle property ==> nullptr");
return;
}
if (_property->connection.isAlive() == false) {
APPL_ERROR("Request play of not connected handle ==> 'not alive'");
return;
}
zeus::service::ProxyVideo remoteServiceVideo = _property->connection.getService("video");
// remove all media (for test)
if (remoteServiceVideo.exist() == false) {
APPL_ERROR("Vide servie is ==> 'not alive'");
return;
}
// TODO : Do it better ...
zeus::ProxyFile dataFile = remoteServiceVideo.mediaGet(_mediaId).wait().get();
std::string mimeType = dataFile.getMineType().wait().get();
// create temporary file:
etk::FSNode tmpFile("CACHE:videoPlayer." + zeus::getExtention(mimeType));
APPL_WARNING("Store in tmpFile : " << tmpFile << " ==> " << tmpFile.getName());
std::string sha512String = zeus::storeInFile(dataFile, tmpFile.getName());
APPL_WARNING("Store in tmpFile : " << tmpFile << " ==> " << tmpFile.getFileSystemName() << " DONE");
init(tmpFile.getFileSystemName());
// TODO : init(tmpFile);
}
void appl::MediaDecoder::init(const std::string& _filename) {
m_updateVideoTimeStampAfterSeek = false;
m_sourceFilename = _filename;

View File

@ -9,6 +9,7 @@
#include <gale/Thread.hpp>
#include <audio/channel.hpp>
#include <audio/format.hpp>
#include <appl/widget/ListViewer.hpp>
extern "C" {
#include <libavutil/imgutils.h>
@ -104,6 +105,7 @@ namespace appl {
int open_codec_context(int *_streamId, AVFormatContext *_formatContext, enum AVMediaType _type);
double getFps(AVCodecContext *_avctx);
void init(const std::string& _filename);
void init(ememory::SharedPtr<appl::ClientProperty> _property, uint32_t _mediaId);
bool onThreadCall() override;
void uninit();

View File

@ -226,8 +226,9 @@ void appl::Windows::onCallbackConnectConnect() {
m_clientProp->fromUser = login;
m_clientProp->toUser = login;
m_clientProp->pass = m_password;
bool ret = client1.connect(login, m_password);
if (ret == false) {
m_clientProp->connect();
if (m_clientProp->connection.isAlive() == false) {
APPL_ERROR(" ==> NOT Authentify to '" << login << "'");
ewol::tools::message::displayError("Can not connect the server with <br/>'" + login + "'");
} else {

View File

@ -24,6 +24,38 @@
#include <zeus/FutureGroup.hpp>
#include <etk/stdTools.hpp>
#include <ejson/ejson.hpp>
void appl::ClientProperty::connect() {
// Generate IP and Port in the client interface
connection.propertyIp.set(address);
connection.propertyPort.set(port);
// Connection depending on the mode requested
if (fromUser == toUser) {
bool ret = connection.connect(fromUser, pass);
if (ret == false) {
APPL_ERROR(" ==> NOT Authentify with '" << toUser << "'");
return;
} else {
APPL_INFO(" ==> Authentify with '" << toUser << "'");
}
} else if (fromUser != "") {
bool ret = connection.connect(fromUser, toUser, pass);
if (ret == false) {
APPL_ERROR(" ==> NOT Connected to '" << toUser << "' with '" << fromUser << "'");
return;
} else {
APPL_INFO(" ==> Connected with '" << toUser << "'");
}
} else {
bool ret = connection.connect(toUser);
if (ret == false) {
APPL_ERROR(" ==> NOT Connected with 'anonymous' to '" << toUser << "'");
return;
} else {
APPL_INFO(" ==> Connected with 'anonymous' to '" << toUser << "'");
}
}
}
appl::widget::ListViewer::ListViewer() :
signalSelect(this, "select", "Select a media to view") {
@ -68,39 +100,13 @@ void appl::widget::ListViewer::searchElements(std::string _filter) {
_filter = "";
}
// check connection is correct:
zeus::Client client1;
// Generate IP and Port in the client interface
client1.propertyIp.set(m_clientProp->address);
client1.propertyPort.set(m_clientProp->port);
// Connection depending on the mode requested
if (m_clientProp->fromUser == m_clientProp->toUser) {
bool ret = client1.connect(m_clientProp->fromUser, m_clientProp->pass);
if (ret == false) {
APPL_ERROR(" ==> NOT Authentify with '" << m_clientProp->toUser << "'");
return;
} else {
APPL_INFO(" ==> Authentify with '" << m_clientProp->toUser << "'");
}
} else if (m_clientProp->fromUser != "") {
bool ret = client1.connect(m_clientProp->fromUser, m_clientProp->toUser, m_clientProp->pass);
if (ret == false) {
APPL_ERROR(" ==> NOT Connected to '" << m_clientProp->toUser << "' with '" << m_clientProp->fromUser << "'");
return;
} else {
APPL_INFO(" ==> Connected with '" << m_clientProp->toUser << "'");
}
} else {
bool ret = client1.connect(m_clientProp->toUser);
if (ret == false) {
APPL_ERROR(" ==> NOT Connected with 'anonymous' to '" << m_clientProp->toUser << "'");
return;
} else {
APPL_INFO(" ==> Connected with 'anonymous' to '" << m_clientProp->toUser << "'");
}
if (m_clientProp->connection.isAlive() == false) {
APPL_ERROR("Conection is not alive anymore ...");
return;
}
// get all the data:
zeus::service::ProxyVideo remoteServiceVideo = client1.getService("video");
zeus::service::ProxyVideo remoteServiceVideo = m_clientProp->connection.getService("video");
// remove all media (for test)
if (remoteServiceVideo.exist() == false) {
APPL_ERROR(" ==> Service does not exist : 'video'");

View File

@ -13,6 +13,8 @@
#include <ewol/widget/Manager.hpp>
#include <esignal/Signal.hpp>
#include <zeus/Client.hpp>
namespace appl {
class ClientProperty {
public:
@ -21,6 +23,9 @@ namespace appl {
std::string pass;
std::string address;
uint16_t port;
zeus::Client connection;
void connect();
void disconnect();
};
class ElementProperty {
public:

View File

@ -88,6 +88,21 @@ void appl::widget::VideoDisplay::setFile(const std::string& _filename) {
markToRedraw();
}
void appl::widget::VideoDisplay::setZeusMedia(ememory::SharedPtr<ClientProperty> _property, uint32_t _mediaId) {
// Stop playing in all case...
stop();
// Clear the old interface
m_decoder.reset();
// Create a new interface
m_decoder = ememory::makeShared<appl::MediaDecoder>();
if (m_decoder == nullptr) {
APPL_ERROR("Can not create sharedPtr on decoder ...");
return;
}
m_decoder->init(_property, _mediaId);
markToRedraw();
}
bool appl::widget::VideoDisplay::isPlaying() {
return m_isPalying;
}

View File

@ -17,6 +17,7 @@
#include <audio/river/Manager.hpp>
#include <audio/river/Interface.hpp>
#include <appl/MediaDecoder.hpp>
#include <appl/widget/ListViewer.hpp>
namespace appl {
namespace widget {
@ -62,7 +63,7 @@ namespace appl {
void onRegenerateDisplay() override;
public:
void setFile(const std::string& _fileName);
void setZeusMedia(ememory::SharedPtr<ClientProperty> _property, uint32_t _mediaId) { };
void setZeusMedia(ememory::SharedPtr<ClientProperty> _property, uint32_t _mediaId);
protected:
bool m_isPalying;
public:

View File

@ -1,66 +1,88 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<wslider name="view-selection" fill="true,true" expand="true,true">
<PopUp name="ws-name-connect" >
<sizer mode="vert" fill="true,true" expand="false,false" lock="true,true" addmode="invert" min-size="45,10%">
<label>login</label>
<entry name="connect-login" fill="true,false" expand="true,false"/>
<label>password</label>
<entry name="connect-password" fill="true,false" expand="true,false"/>
<button name="connect-bt" toggle="false" fill="false,false" expand="true,false" gravity="right">
<label>Connect</label>
</button>
</sizer>
</PopUp>
<sizer mode="vert" name="ws-name-list" fill="true,true" expand="true,true" addmode="invert">
<button name="bt-film-picture" expand="true,false" fill="true,true">
<label>Films</label>
<sizer mode="vert" fill="true,true" expand="true,true" addmode="invert">
<sizer mode="hori" fill="true,true" expand="true,false">
<button name="menu-bt">
<image src="DATA:List.svg" size='8,8mm'/>
</button>
<button name="bt-film-draw" expand="true,false" fill="true,true">
<label>Annimated films</label>
<entry name="search-entry" fill="true,false" expand="true,false"/>
<button name="search-bt">
<image src="DATA:Search.svg" size='8,8mm' />
</button>
<button name="bt-tv-picture" expand="true,false" fill="true,true">
<label>TV Show</label>
</button>
<button name="bt-tv-draw" expand="true,false" fill="true,true">
<label>Annimated TV Show</label>
</button>
<button name="bt-theater" expand="true,false" fill="true,true">
<label>Teather</label>
</button>
<button name="bt-one-man-show" expand="true,false" fill="true,true">
<label>One-man show</label>
</button>
<button name="bt-courses" expand="true,false" fill="true,true">
<label>Courses</label>
</button>
<spacer fill="true,true" expand="true,true"/>
</sizer>
<ListViewer name="ws-name-list-viewer" fill="true,true" expand="true,true"/>
<sizer mode="vert" name="ws-name-player" fill="true,true" expand="true,true">
<sizer mode="hori" fill="true,true" expand="true,true">
<button name="bt-previous">
<label>
previous
</label>
</button>
<button name="bt-play" toggle="true">
<label>play</label>
<label>pause</label>
</button>
<button name="bt-next">
<label>
Next
</label>
</button>
<label name="lb-fps"/>
<label name="lb-time"/>
<button name="bt-back">
<label>
back
</label>
</button>
</sizer>
<slider name="progress-bar" expand="true,false" fill="true" step="0.01" min="0"/>
<VideoDisplay name="displayer" expand="true" fill="true"/>
<sizer mode="hori" fill="true,true" expand="true,false">
<button name="access-fast-home">
<image src="DATA:Home.svg" size='8,8mm' />
</button>
<button name="access-fast-page-previous">
<image src="DATA:Previous.svg" size='8,8mm' />
</button>
<button name="access-fast-page-next">
<image src="DATA:Next.svg" size='8,8mm' />
</button>
</sizer>
</wslider>
<wslider name="view-selection" fill="true,true" expand="true,true">
<PopUp name="ws-name-connect" >
<sizer mode="vert" fill="true,true" expand="false,false" lock="true,true" addmode="invert" min-size="45,10%">
<label>login</label>
<entry name="connect-login" fill="true,false" expand="true,false"/>
<label>password</label>
<entry name="connect-password" fill="true,false" expand="true,false"/>
<button name="connect-bt" toggle="false" fill="false,false" expand="true,false" gravity="right">
<label>Connect</label>
</button>
</sizer>
</PopUp>
<sizer mode="vert" name="ws-name-list" fill="true,true" expand="true,true" addmode="invert">
<button name="bt-film-picture" expand="true,false" fill="true,true">
<label>Films</label>
</button>
<button name="bt-film-draw" expand="true,false" fill="true,true">
<label>Annimated films</label>
</button>
<button name="bt-tv-picture" expand="true,false" fill="true,true">
<label>TV Show</label>
</button>
<button name="bt-tv-draw" expand="true,false" fill="true,true">
<label>Annimated TV Show</label>
</button>
<button name="bt-theater" expand="true,false" fill="true,true">
<label>Teather</label>
</button>
<button name="bt-one-man-show" expand="true,false" fill="true,true">
<label>One-man show</label>
</button>
<button name="bt-courses" expand="true,false" fill="true,true">
<label>Courses</label>
</button>
<spacer fill="true,true" expand="true,true"/>
</sizer>
<ListViewer name="ws-name-list-viewer" fill="true,true" expand="true,true"/>
<sizer mode="vert" name="ws-name-player" fill="true,true" expand="true,true">
<sizer mode="hori" fill="true,true" expand="true,true">
<button name="bt-previous">
<label>
previous
</label>
</button>
<button name="bt-play" toggle="true">
<label>play</label>
<label>pause</label>
</button>
<button name="bt-next">
<label>
Next
</label>
</button>
<label name="lb-fps"/>
<label name="lb-time"/>
<button name="bt-back">
<label>
back
</label>
</button>
</sizer>
<slider name="progress-bar" expand="true,false" fill="true" step="0.01" min="0"/>
<VideoDisplay name="displayer" expand="true" fill="true"/>
</sizer>
</wslider>
</sizer>