[DEV] keep aspect ratio & add log in the stdout for router

This commit is contained in:
Edouard DUPIN 2017-04-16 16:26:21 +02:00
parent 88af61bc85
commit 9f72146bf2
9 changed files with 68 additions and 29 deletions

View File

@ -116,6 +116,11 @@ namespace appl {
AVCodecContext* m_videoDecoderContext;
AVCodecContext* m_audioDecoderContext;
ivec2 m_size;
public:
ivec2 getSize() {
return m_size;
}
private:
enum AVPixelFormat m_pixelFormat;
AVStream *m_videoStream;
AVStream *m_audioStream;

View File

@ -208,26 +208,27 @@ void appl::widget::VideoDisplay::onDraw() {
m_GLprogram->unUse();
}
void appl::widget::VideoDisplay::printPart(const vec2& _size,
void appl::widget::VideoDisplay::printPart(const vec2& _displayStart,
const vec2& _size,
const vec2& _sourcePosStart,
const vec2& _sourcePosStop) {
//EWOL_ERROR("Debug image " << m_filename << " ==> " << m_position << " " << _size << " " << _sourcePosStart << " " << _sourcePosStop);
vec3 point = m_position;
vec3 point(_displayStart.x(),_displayStart.y(), 0.0f);
vec2 tex(_sourcePosStart.x(),_sourcePosStop.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color);
tex.setValue(_sourcePosStop.x(),_sourcePosStop.y());
point.setX(m_position.x() + _size.x());
point.setY(m_position.y());
point.setX(_displayStart.x() + _size.x());
point.setY(_displayStart.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color);
tex.setValue(_sourcePosStop.x(),_sourcePosStart.y());
point.setX(m_position.x() + _size.x());
point.setY(m_position.y() + _size.y());
point.setX(_displayStart.x() + _size.x());
point.setY(_displayStart.y() + _size.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color);
@ -237,15 +238,15 @@ void appl::widget::VideoDisplay::printPart(const vec2& _size,
m_VBO->pushOnBuffer(m_vboIdColor, m_color);
tex.setValue(_sourcePosStart.x(),_sourcePosStart.y());
point.setX(m_position.x());
point.setY(m_position.y() + _size.y());
point.setX(_displayStart.x());
point.setY(_displayStart.y() + _size.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color);
tex.setValue(_sourcePosStart.x(),_sourcePosStop.y());
point.setX(m_position.x());
point.setY(m_position.y());
point.setX(_displayStart.x());
point.setY(_displayStart.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color);
@ -261,7 +262,32 @@ void appl::widget::VideoDisplay::onRegenerateDisplay() {
m_VBO->clear();
// set the somposition properties :
m_position = vec3(0,0,0);
printPart(m_size, vec2(0,0), vec2(float(m_videoSize.x())/float(m_imageSize.x()), float(m_videoSize.y())/float(m_imageSize.y())));
if (m_decoder != nullptr) {
ivec2 tmp = m_decoder->getSize();
vec2 realSize(tmp.x(), tmp.y());
vec2 displaySize = m_size;
float aspectRatioReal = realSize.x() / realSize.y();
float displayRatioReal = displaySize.x() / displaySize.y();
vec2 startPos(0,0);
if (aspectRatioReal == displayRatioReal) {
// nothing to do ...
} else if (aspectRatioReal < displayRatioReal) {
// the display is more width than the video
displaySize.setX(displaySize.y()*realSize.x()/realSize.y());
startPos.setX((m_size.x()-displaySize.x())*0.5f);
} else {
// The display is more height than the video
displaySize.setY(displaySize.x()*realSize.y()/realSize.x());
startPos.setY((m_size.y()-displaySize.y())*0.5f);
}
printPart(startPos,
displaySize,
vec2(0,0),
vec2(float(m_videoSize.x())/float(m_imageSize.x()), float(m_videoSize.y())/float(m_imageSize.y())));
} else {
// nothing to display ...
}
}
void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event) {

View File

@ -77,7 +77,7 @@ namespace appl {
public:
void periodicEvent(const ewol::event::Time& _event);
private:
void printPart(const vec2& _size, const vec2& _sourcePosStart, const vec2& _sourcePosStop);
void printPart(const vec2& _displayStart,const vec2& _size, const vec2& _sourcePosStart, const vec2& _sourcePosStop);
void loadProgram();
private: // Audio Property:
ememory::SharedPtr<audio::river::Manager> m_audioManager; //!< River manager interface

View File

@ -134,6 +134,7 @@ void appl::Router::newClient(enet::Tcp _connection) {
appl::Router::Router() :
m_clientUID(2),
propertyStdOut(this, "stdout", false, "Set the Log of the output"),
propertyClientIp(this, "client-ip", "127.0.0.1", "Ip to listen client", &appl::Router::onPropertyChangeClientIp),
propertyClientPort(this, "client-port", 1983, "Port to listen client", &appl::Router::onPropertyChangeClientPort),
propertyClientMax(this, "client-max", 8000, "Maximum of client at the same time", &appl::Router::onPropertyChangeClientMax),
@ -222,10 +223,9 @@ ememory::SharedPtr<appl::GateWayInterface> appl::Router::get(const std::string&
std::string binary = etk::FSNodeGetApplicationPath() + "/zeus-gateway";
std::string userConf = "--user=" + it.m_name;
std::string basePath = "--base-path=" + it.m_basePath;
#if 0
std::string logFile = "--elog-file=\"/tmp/zeus.gateway." + it.m_name + ".log\"";
#else
std::string logFile = it.m_basePath + "/log/gateway.log";
std::string logFile;
if (*propertyStdOut == false) {
logFile = it.m_basePath + "/log/gateway.log";
if ( logFile.size() != 0
&& logFile[0] == '~') {
logFile = etk::FSNodeGetHomePath() + &logFile[1];
@ -234,7 +234,7 @@ ememory::SharedPtr<appl::GateWayInterface> appl::Router::get(const std::string&
//std::string logFile = "--elog-file=/home/heero/.local/share/zeus-DATA/SDFGHTHBSDFGSQDHZSRDFGSDFGSDFGSDFG/log/gateway.log";
//std::string logFile = " ";
APPL_INFO("New Child log in = " << logFile);
#endif
}
std::string delay = "--router-delay=" + etk::to_string(*propertyDelayToStop);
int ret = execlp( binary.c_str(),
binary.c_str(), // must repeate the binary name to have the name as first argument ...

View File

@ -21,6 +21,7 @@ namespace appl {
ememory::SharedPtr<appl::TcpServerInput> m_interfaceGateWayServer;
ejson::Document m_listUser;
public:
eproperty::Value<bool> propertyStdOut; //!< not set the log in the stdout or in the local file
eproperty::Value<std::string> propertyClientIp;
eproperty::Value<uint16_t> propertyClientPort;
eproperty::Value<uint16_t> propertyClientMax;

View File

@ -22,7 +22,9 @@ int main(int _argc, const char *_argv[]) {
appl::Router basicRouter;
for (int32_t iii=0; iii<_argc ; ++iii) {
std::string data = _argv[iii];
if (etk::start_with(data, "--client-ip=") == true) {
if (data == "--stdout") {
basicRouter.propertyStdOut.set(true);
} else if (etk::start_with(data, "--client-ip=") == true) {
basicRouter.propertyClientIp.set(std::string(&data[12]));
} else if (etk::start_with(data, "--client-port=") == true) {
basicRouter.propertyClientPort.set(etk::string_to_uint16_t(std::string(&data[14])));
@ -40,10 +42,11 @@ int main(int _argc, const char *_argv[]) {
|| data == "--help") {
APPL_PRINT(etk::getApplicationName() << " - help : ");
APPL_PRINT(" " << _argv[0] << " [options]");
APPL_PRINT(" --client-ip=XXX Client connection IP (default: 1.7.0.0.1)");
APPL_PRINT(" --stdout stdout log");
APPL_PRINT(" --client-ip=XXX Client connection IP (default: 127.0.0.1)");
APPL_PRINT(" --client-port=XXX Client connection PORT (default: 1983)");
APPL_PRINT(" --client-max=XXX Client Maximum parallele connection (default: 80)");
APPL_PRINT(" --gw-ip=XXX Gateway connection IP (default: 1.7.0.0.1)");
APPL_PRINT(" --gw-ip=XXX Gateway connection IP (default: 127.0.0.1)");
APPL_PRINT(" --gw-port=XXX Gateway connection PORT (default: 1984)");
APPL_PRINT(" --gw-max=XXX Gateway Maximum IO (default: 15)");
APPL_PRINT(" --delay-stop-user=XXX Delay before the client stop the connection in second (default: 0=automatic set by the gateway; -1=never disconnect; other the time )");

View File

@ -214,7 +214,6 @@ namespace appl {
std::vector<uint32_t> getSQL(std::string _sqlLikeRequest) override {
std::vector<uint32_t> out;
/*
if (_sqlLikeRequest == "") {
throw std::invalid_argument("empty request");
}
@ -243,11 +242,14 @@ namespace appl {
}
std::unique_lock<std::mutex> lock(g_mutex);
for (auto &it : m_listFile) {
if (it == nullptr) {
continue;
}
bool isCorrectElement = true;
for (auto &itCheck : listAndParsed) {
// find matadataValue:
auto itM = it.m_metadata.find(itCheck[0]);
if (itM == it.m_metadata.end()) {
auto itM = it->getMetadataDirect().find(itCheck[0]);
if (itM == it->getMetadataDirect().end()) {
// not find key ==> no check to do ...
isCorrectElement = false;
break;
@ -285,17 +287,16 @@ namespace appl {
}
}
if (isCorrectElement == true) {
out.push_back(it.m_id);
out.push_back(it->getUniqueId());
}
}
*/
return out;
}
std::vector<std::string> getMetadataValuesWhere(std::string _keyName, std::string _sqlLikeRequest) override {
std::unique_lock<std::mutex> lock(g_mutex);
std::vector<std::string> out;
// 'type' == 'film' AND 'production-methode' == 'picture'
return out;
}

View File

@ -34,9 +34,9 @@ void remove(uint32)
/*
The SQL-like is now: ['AND','='] only...
'serie-name' = 'stargate'
AND 'saison' = '2'
The SQL-like is now: ['AND', ==,!=,<=,>=,<,>] only...
'serie-name' == 'stargate'
AND 'saison' <= '2'
*/
#brief:Get a meta-data research elements with a SQL-like request
#param:sqlLikeRequest:A string containing the request on the data

View File

@ -48,6 +48,9 @@ namespace zeus {
return m_fileName;
}
bool erase();
const std::map<std::string, std::string>& getMetadataDirect() {
return m_metadata;
}
};
}