[DEBUG] correct IDL generation
This commit is contained in:
parent
ec9f88fccb
commit
61022b00df
@ -53,28 +53,71 @@ def validate_type(data):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def zeus_object_to_dictionary(name):
|
||||||
|
out = {}
|
||||||
|
if type(name) == str:
|
||||||
|
name = name.split("-")
|
||||||
|
debug.warning("transform: " + str(name))
|
||||||
|
# set first capital of the class name
|
||||||
|
if len(name) != 0:
|
||||||
|
name[-1] = capital_first(name[-1])
|
||||||
|
|
||||||
|
out["namespace"] = ""
|
||||||
|
for elem in name[:-1]:
|
||||||
|
out["namespace"] += elem + "::"
|
||||||
|
|
||||||
|
out["name_class"] = out["namespace"] + name[-1]
|
||||||
|
out["name_class_short"] = name[-1]
|
||||||
|
|
||||||
|
out["name_class_proxy"] = out["namespace"] + "Proxy" + name[-1]
|
||||||
|
out["name_class_proxy_short"] = "Proxy" + name[-1]
|
||||||
|
|
||||||
|
out["name_class_register"] = out["namespace"] + "register" + name[-1]
|
||||||
|
out["name_class_register_short"] = "register" + name[-1]
|
||||||
|
|
||||||
|
|
||||||
|
out["name_class_macro"] = ""
|
||||||
|
for elem in name:
|
||||||
|
out["name_class_macro"] += elem.upper() + "_"
|
||||||
|
|
||||||
|
base_path = ""
|
||||||
|
for elem in name[:-1]:
|
||||||
|
base_path += elem + "/"
|
||||||
|
out["file_name_class_src"] = base_path + name[-1] + ".cpp";
|
||||||
|
out["file_name_class_header"] = base_path + name[-1] + ".hpp"
|
||||||
|
out["file_name_class_proxy_src"] = base_path + "Proxy" + name[-1] + ".cpp";
|
||||||
|
out["file_name_class_proxy_header"] = base_path + "Proxy" + name[-1] + ".hpp"
|
||||||
|
out["file_name_class_register_src"] = base_path + "register" + name[-1] + ".cpp";
|
||||||
|
out["file_name_class_register_header"] = base_path + "register" + name[-1] + ".hpp"
|
||||||
|
|
||||||
|
debug.warning(" class name : " + out["name_class"])
|
||||||
|
debug.warning(" class Proxy name : " + out["name_class_proxy"])
|
||||||
|
debug.warning(" path class name src : " + out["file_name_class_src"])
|
||||||
|
debug.warning(" path class name header : " + out["file_name_class_header"])
|
||||||
|
debug.warning(" path class Proxy name src : " + out["file_name_class_proxy_src"])
|
||||||
|
debug.warning(" path class Proxy name header : " + out["file_name_class_proxy_header"])
|
||||||
|
debug.warning(" path class Proxy name src : " + out["file_name_class_register_src"])
|
||||||
|
debug.warning(" path class Proxy name header : " + out["file_name_class_register_header"])
|
||||||
|
return out
|
||||||
|
|
||||||
def convert_type_in_cpp(data, proxy=False, argument=False):
|
def convert_type_in_cpp(data, proxy=False, argument=False):
|
||||||
for elem in list_of_known_type:
|
for elem in list_of_known_type:
|
||||||
if data == elem[0]:
|
if data == elem[0]:
|
||||||
return elem[1]
|
return elem[1]
|
||||||
val = data.split(":")
|
val = data.split(":")
|
||||||
if val[0] == "obj":
|
if val[0] == "obj":
|
||||||
# this is a generated object:
|
prop = zeus_object_to_dictionary(val[1])
|
||||||
listElem = val[1].split("-")
|
|
||||||
out = ""
|
|
||||||
for elem in listElem[:-1]:
|
|
||||||
out += elem + "::"
|
|
||||||
if proxy == True:
|
if proxy == True:
|
||||||
if argument == False:
|
if argument == False:
|
||||||
out += "Proxy" + listElem[-1]
|
return prop["name_class_proxy"]
|
||||||
else:
|
else:
|
||||||
out = "ememory::SharedPtr<" + out + listElem[-1] + ">"
|
return "ememory::SharedPtr<" + prop["name_class_proxy"] + ">"
|
||||||
else:
|
else:
|
||||||
if argument == True:
|
if argument == True:
|
||||||
out += "Proxy" + listElem[-1]
|
return prop["name_class_proxy"]
|
||||||
else:
|
else:
|
||||||
out = "ememory::SharedPtr<" + out + listElem[-1] + ">"
|
return "ememory::SharedPtr<" + prop["name_class_proxy"] + ">"
|
||||||
return out
|
|
||||||
debug.error(" can not find type in IDL : '" + data + "'")
|
debug.error(" can not find type in IDL : '" + data + "'")
|
||||||
|
|
||||||
|
|
||||||
@ -292,10 +335,10 @@ class FunctionDefinition:
|
|||||||
space = space[:-1]
|
space = space[:-1]
|
||||||
return out;
|
return out;
|
||||||
|
|
||||||
|
|
||||||
class ServiceDefinition:
|
class ServiceDefinition:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.name = [""];
|
self.name = [""];
|
||||||
|
self.name_prop = {}
|
||||||
self.brief = "";
|
self.brief = "";
|
||||||
self.version = "";
|
self.version = "";
|
||||||
self.api = "";
|
self.api = "";
|
||||||
@ -305,11 +348,18 @@ class ServiceDefinition:
|
|||||||
self.factories = []
|
self.factories = []
|
||||||
self.tools = []
|
self.tools = []
|
||||||
self.imports = []
|
self.imports = []
|
||||||
|
|
||||||
|
self.licence_header = "/** @file\n"
|
||||||
|
self.licence_header += " * @note Generated file !!! Do not modify !!!\n"
|
||||||
|
self.licence_header += " * @license MPL-2\n"
|
||||||
|
self.licence_header += " * @copyright none\n"
|
||||||
|
self.licence_header += " */\n"
|
||||||
|
|
||||||
def set_name(self, value):
|
def set_name(self, value):
|
||||||
self.name = value
|
self.name = value
|
||||||
# TODO : Check range ...
|
# TODO : Check range ...
|
||||||
self.name[-1] = capital_first(self.name[-1])
|
self.prop = zeus_object_to_dictionary(self.name)
|
||||||
|
|
||||||
|
|
||||||
def set_brief(self, value):
|
def set_brief(self, value):
|
||||||
self.brief = remove_start_stop_spacer(value).replace("\"", "\\\"")
|
self.brief = remove_start_stop_spacer(value).replace("\"", "\\\"")
|
||||||
@ -353,18 +403,13 @@ class ServiceDefinition:
|
|||||||
for elem in self.functions:
|
for elem in self.functions:
|
||||||
elem.display();
|
elem.display();
|
||||||
|
|
||||||
|
##
|
||||||
|
## CLASS.hpp
|
||||||
|
##
|
||||||
def generate_header(self):
|
def generate_header(self):
|
||||||
filename = ""
|
|
||||||
for elem in self.name[:-1]:
|
|
||||||
filename += elem + "/"
|
|
||||||
filename += self.name[-1] + ".hpp";
|
|
||||||
out = ""
|
out = ""
|
||||||
# TODO: add global header:
|
# TODO: add global header:
|
||||||
out += "/** @file\n"
|
out += self.licence_header
|
||||||
out += " * @note Generated file !!! Do not modify !!!\n"
|
|
||||||
out += " * @license MPL-2\n"
|
|
||||||
out += " * @copyright none\n"
|
|
||||||
out += " */\n"
|
|
||||||
out += "#pragma once\n"
|
out += "#pragma once\n"
|
||||||
out += "\n"
|
out += "\n"
|
||||||
out += "#include <etk/types.hpp>\n"
|
out += "#include <etk/types.hpp>\n"
|
||||||
@ -374,18 +419,16 @@ class ServiceDefinition:
|
|||||||
out += "#include <vector>\n"
|
out += "#include <vector>\n"
|
||||||
out += "#include <ememory/memory.hpp>\n"
|
out += "#include <ememory/memory.hpp>\n"
|
||||||
for elem in self.imports:
|
for elem in self.imports:
|
||||||
out += "#include <" + elem.replace("-","/") + ".hpp>\n"
|
prop = zeus_object_to_dictionary(elem)
|
||||||
out += "#include <" + elem.replace("-","/Proxy") + ".hpp>\n"
|
out += "#include <" + prop["file_name_class_header"] + ">\n"
|
||||||
|
out += "#include <" + prop["file_name_class_proxy_header"] + ">\n"
|
||||||
out += "\n"
|
out += "\n"
|
||||||
space = ""
|
space = ""
|
||||||
class_name = ""
|
|
||||||
for elem in self.name[:-1]:
|
for elem in self.name[:-1]:
|
||||||
out += space + "namespace " + elem + " {\n"
|
out += space + "namespace " + elem + " {\n"
|
||||||
space += " "
|
space += " "
|
||||||
class_name += elem + "::"
|
|
||||||
class_name += self.name[-1]
|
|
||||||
|
|
||||||
out += space + "class Proxy" + self.name[-1] + ";\n"
|
out += space + "class " + self.prop["name_class_proxy_short"] + ";\n"
|
||||||
out += space + " /**\n"
|
out += space + " /**\n"
|
||||||
if self.brief != "":
|
if self.brief != "":
|
||||||
out += space + " * @brief " + self.brief + " \n"
|
out += space + " * @brief " + self.brief + " \n"
|
||||||
@ -396,7 +439,7 @@ class ServiceDefinition:
|
|||||||
for elem in self.authors:
|
for elem in self.authors:
|
||||||
out += space + " * authors:" + elem + "\n"
|
out += space + " * authors:" + elem + "\n"
|
||||||
out += space + " */\n"
|
out += space + " */\n"
|
||||||
out += space + "class " + self.name[-1] + " {\n"
|
out += space + "class " + self.prop["name_class_short"] + " {\n"
|
||||||
space += " "
|
space += " "
|
||||||
out += space + "public:\n"
|
out += space + "public:\n"
|
||||||
space += " "
|
space += " "
|
||||||
@ -405,15 +448,15 @@ class ServiceDefinition:
|
|||||||
out += space + " * @brief generic factory, pay attention when set arguments...\n"
|
out += space + " * @brief generic factory, pay attention when set arguments...\n"
|
||||||
out += space + " */\n"
|
out += space + " */\n"
|
||||||
out += space + "template<typename ... ZEUS_OBJECT_CREATE>\n"
|
out += space + "template<typename ... ZEUS_OBJECT_CREATE>\n"
|
||||||
out += space + "static ememory::SharedPtr<" + class_name + "> create(ZEUS_OBJECT_CREATE ...);\n"
|
out += space + "static ememory::SharedPtr<" + self.prop["name_class"] + "> create(ZEUS_OBJECT_CREATE ...);\n"
|
||||||
else:
|
else:
|
||||||
for elem in self.factories:
|
for elem in self.factories:
|
||||||
out += elem.generate_cpp(space, class_name)
|
out += elem.generate_cpp(space, self.prop["name_class"])
|
||||||
|
|
||||||
out += space + "/**\n"
|
out += space + "/**\n"
|
||||||
out += space + " * @brief Generic virtual destructor\n"
|
out += space + " * @brief Generic virtual destructor\n"
|
||||||
out += space + " */\n"
|
out += space + " */\n"
|
||||||
out += space + "virtual ~" + self.name[-1] + "() = default;\n"
|
out += space + "virtual ~" + self.prop["name_class_short"] + "() = default;\n"
|
||||||
|
|
||||||
for elem in self.attributes:
|
for elem in self.attributes:
|
||||||
out += elem.generate_cpp(space)
|
out += elem.generate_cpp(space)
|
||||||
@ -430,36 +473,18 @@ class ServiceDefinition:
|
|||||||
for elem in self.name[:-1]:
|
for elem in self.name[:-1]:
|
||||||
space = space[:-1]
|
space = space[:-1]
|
||||||
out += space + "}\n"
|
out += space + "}\n"
|
||||||
return [filename, out]
|
return [self.prop["file_name_class_header"], out]
|
||||||
|
|
||||||
|
##
|
||||||
|
## CLASS.cpp
|
||||||
|
##
|
||||||
def generate_source(self):
|
def generate_source(self):
|
||||||
filename = ""
|
|
||||||
for elem in self.name[:-1]:
|
|
||||||
filename += elem + "/"
|
|
||||||
register_filename = filename + "register" + self.name[-1] + ".hpp";
|
|
||||||
register_filename_proxy = filename + "Proxy" + self.name[-1] + ".hpp";
|
|
||||||
filename += self.name[-1] + ".cpp";
|
|
||||||
out = ""
|
out = ""
|
||||||
|
out += self.licence_header
|
||||||
class_name = ""
|
|
||||||
for elem in self.name[:-1]:
|
|
||||||
class_name += "" + elem + "::"
|
|
||||||
class_name_proxy = class_name + "Proxy" + self.name[-1];
|
|
||||||
class_name += self.name[-1];
|
|
||||||
|
|
||||||
namespace = ""
|
|
||||||
for elem in self.name[:-1]:
|
|
||||||
namespace += elem + "::"
|
|
||||||
|
|
||||||
out += "/** @file\n"
|
|
||||||
out += " * @note Generated file !!! Do not modify !!!\n"
|
|
||||||
out += " * @license MPL-2\n"
|
|
||||||
out += " * @copyright none\n"
|
|
||||||
out += " */\n"
|
|
||||||
out += "\n"
|
out += "\n"
|
||||||
out += "#include <" + filename.replace(".cpp",".hpp") + ">\n"
|
out += "#include <" + self.prop["file_name_class_register_header"] + ">\n"
|
||||||
out += "#include <" + register_filename + ">\n"
|
out += "#include <" + self.prop["file_name_class_header"] + ">\n"
|
||||||
out += "#include <" + register_filename_proxy + ">\n"
|
out += "#include <" + self.prop["file_name_class_proxy_header"] + ">\n"
|
||||||
out += "#include <etk/types.hpp>\n"
|
out += "#include <etk/types.hpp>\n"
|
||||||
out += "#include <zeus/debug.hpp>\n"
|
out += "#include <zeus/debug.hpp>\n"
|
||||||
out += "#include <zeus/message/Message.hpp>\n"
|
out += "#include <zeus/message/Message.hpp>\n"
|
||||||
@ -478,23 +503,23 @@ class ServiceDefinition:
|
|||||||
# now gebnerate the get and set parameter object ...
|
# now gebnerate the get and set parameter object ...
|
||||||
out += "namespace zeus {\n"
|
out += "namespace zeus {\n"
|
||||||
out += " namespace message {\n"
|
out += " namespace message {\n"
|
||||||
out += " template<> const zeus::message::ParamType& createType<ememory::SharedPtr<" + class_name + ">>() {\n"
|
out += " template<> const zeus::message::ParamType& createType<ememory::SharedPtr<" + self.prop["name_class"] + ">>() {\n"
|
||||||
out += " static zeus::message::ParamType type(\"obj:" + class_name + "\", zeus::message::paramTypeObject, false, false);\n"
|
out += " static zeus::message::ParamType type(\"obj:" + self.prop["name_class"] + "\", zeus::message::paramTypeObject, false, false);\n"
|
||||||
out += " return type;\n"
|
out += " return type;\n"
|
||||||
out += " }\n"
|
out += " }\n"
|
||||||
out += " \n"
|
out += " \n"
|
||||||
out += " template<> const zeus::message::ParamType& createType<" + class_name_proxy + ">() {\n"
|
out += " template<> const zeus::message::ParamType& createType<" + self.prop["name_class_proxy"] + ">() {\n"
|
||||||
out += " static zeus::message::ParamType type(\"obj:" + class_name + "\", zeus::message::paramTypeObject, false, false);\n"
|
out += " static zeus::message::ParamType type(\"obj:" + self.prop["name_class"] + "\", zeus::message::paramTypeObject, false, false);\n"
|
||||||
out += " return type;\n"
|
out += " return type;\n"
|
||||||
out += " }\n"
|
out += " }\n"
|
||||||
out += " \n"
|
out += " \n"
|
||||||
out += " template<>\n"
|
out += " template<>\n"
|
||||||
out += " void Parameter::addParameter<ememory::SharedPtr<" + class_name + ">>(uint16_t _paramId, const ememory::SharedPtr<" + class_name + ">& _value) {\n"
|
out += " void Parameter::addParameter<ememory::SharedPtr<" + self.prop["name_class"] + ">>(uint16_t _paramId, const ememory::SharedPtr<" + self.prop["name_class"] + ">& _value) {\n"
|
||||||
out += " std::vector<uint8_t> data;\n"
|
out += " std::vector<uint8_t> data;\n"
|
||||||
"""
|
"""
|
||||||
out += " addType(data, createType<" + class_name + ">());\n"
|
out += " addType(data, createType<" + class_name + ">());\n"
|
||||||
"""
|
"""
|
||||||
out += " addTypeObject(data, \"obj:" + class_name + "\");\n"
|
out += " addTypeObject(data, \"obj:" + self.prop["name_class"] + "\");\n"
|
||||||
out += " int32_t currentOffset = data.size();\n"
|
out += " int32_t currentOffset = data.size();\n"
|
||||||
out += " int32_t startOffset = data.size();\n"
|
out += " int32_t startOffset = data.size();\n"
|
||||||
out += " data.resize(data.size()+4);\n"
|
out += " data.resize(data.size()+4);\n"
|
||||||
@ -503,8 +528,8 @@ class ServiceDefinition:
|
|||||||
out += " if (m_iface != nullptr) {\n"
|
out += " if (m_iface != nullptr) {\n"
|
||||||
out += " uint16_t id = m_iface->getAddress();\n"
|
out += " uint16_t id = m_iface->getAddress();\n"
|
||||||
out += " uint16_t idObj = m_iface->getNewObjectId();\n"
|
out += " uint16_t idObj = m_iface->getNewObjectId();\n"
|
||||||
out += " ememory::SharedPtr<zeus::ObjectType<" + class_name + ">> obj = ememory::makeShared<zeus::ObjectType<" + class_name + ">>(m_iface, idObj, _value);\n"
|
out += " ememory::SharedPtr<zeus::ObjectType<" + self.prop["name_class"] + ">> obj = ememory::makeShared<zeus::ObjectType<" + self.prop["name_class"] + ">>(m_iface, idObj, _value);\n"
|
||||||
out += " " + namespace + "register" + self.name[-1] + "(*obj);\n"
|
out += " " + self.prop["name_class_register"] + "(*obj);\n"
|
||||||
out += " obj->addRemote(getDestination());\n"
|
out += " obj->addRemote(getDestination());\n"
|
||||||
out += " m_iface->addWebObj(obj);\n"
|
out += " m_iface->addWebObj(obj);\n"
|
||||||
out += " ZEUS_DEBUG(\"Create object ID : \" << idObj);\n"
|
out += " ZEUS_DEBUG(\"Create object ID : \" << idObj);\n"
|
||||||
@ -516,14 +541,14 @@ class ServiceDefinition:
|
|||||||
out += " }\n"
|
out += " }\n"
|
||||||
out += " \n"
|
out += " \n"
|
||||||
out += " template<>\n"
|
out += " template<>\n"
|
||||||
out += " " + class_name_proxy + " Parameter::getParameter<" + class_name_proxy + ">(int32_t _id) const {\n"
|
out += " " + self.prop["name_class_proxy"] + " Parameter::getParameter<" + self.prop["name_class_proxy"] + ">(int32_t _id) const {\n"
|
||||||
out += " ememory::SharedPtr<zeus::ObjectRemoteBase> out;\n"
|
out += " ememory::SharedPtr<zeus::ObjectRemoteBase> out;\n"
|
||||||
out += " out = zeus::message::Parameter::getParameter<ememory::SharedPtr<zeus::ObjectRemoteBase>>(_id);\n"
|
out += " out = zeus::message::Parameter::getParameter<ememory::SharedPtr<zeus::ObjectRemoteBase>>(_id);\n"
|
||||||
out += " return zeus::ObjectRemote(out);\n"
|
out += " return zeus::ObjectRemote(out);\n"
|
||||||
out += " }\n"
|
out += " }\n"
|
||||||
out += " }\n"
|
out += " }\n"
|
||||||
out += " \n"
|
out += " \n"
|
||||||
out += " template<> " + class_name_proxy + " zeus::Future<" + class_name_proxy + ">::get() {\n"
|
out += " template<> " + self.prop["name_class_proxy"] + " zeus::Future<" + self.prop["name_class_proxy"] + ">::get() {\n"
|
||||||
out += " ememory::SharedPtr<zeus::ObjectRemoteBase> out;\n"
|
out += " ememory::SharedPtr<zeus::ObjectRemoteBase> out;\n"
|
||||||
out += " if ( m_promise == nullptr\n"
|
out += " if ( m_promise == nullptr\n"
|
||||||
out += " || m_promise->getRaw() == nullptr) {\n"
|
out += " || m_promise->getRaw() == nullptr) {\n"
|
||||||
@ -540,101 +565,65 @@ class ServiceDefinition:
|
|||||||
out += " \n"
|
out += " \n"
|
||||||
out += "}\n"
|
out += "}\n"
|
||||||
|
|
||||||
return [filename, out]
|
return [self.prop["file_name_class_src"], out]
|
||||||
|
|
||||||
|
##
|
||||||
|
## registerClass.hpp
|
||||||
|
##
|
||||||
def generate_register_header(self):
|
def generate_register_header(self):
|
||||||
filename = ""
|
out = self.licence_header
|
||||||
for elem in self.name[:-1]:
|
|
||||||
filename += elem + "/"
|
|
||||||
filename += "register" + self.name[-1] + ".hpp";
|
|
||||||
|
|
||||||
class_name = ""
|
|
||||||
for elem in self.name[:-1]:
|
|
||||||
class_name += "" + elem + "::"
|
|
||||||
class_name += self.name[-1];
|
|
||||||
|
|
||||||
out = ""
|
|
||||||
out += "/** @file\n"
|
|
||||||
out += " * @note Generated file !!! Do not modify !!!\n"
|
|
||||||
out += " * @license MPL-2\n"
|
|
||||||
out += " * @copyright none\n"
|
|
||||||
out += " */\n"
|
|
||||||
out += "#pragma once\n"
|
out += "#pragma once\n"
|
||||||
out += "\n"
|
out += "\n"
|
||||||
out += "#include <etk/types.hpp>\n"
|
out += "#include <etk/types.hpp>\n"
|
||||||
out += "#include <zeus/Object.hpp>\n"
|
out += "#include <zeus/Object.hpp>\n"
|
||||||
out += "#include <zeus/Client.hpp>\n"
|
out += "#include <zeus/Client.hpp>\n"
|
||||||
out += "#include <" + class_name.replace("::","/") + ".hpp>\n"
|
out += "#include <" + self.prop["file_name_class_header"] + ">\n"
|
||||||
out += "#include <string>\n"
|
out += "#include <string>\n"
|
||||||
out += "#include <vector>\n"
|
out += "#include <vector>\n"
|
||||||
out += "\n"
|
out += "\n"
|
||||||
space = ""
|
space = ""
|
||||||
namespace = ""
|
|
||||||
for elem in self.name[:-1]:
|
for elem in self.name[:-1]:
|
||||||
out += space + "namespace " + elem + " {\n"
|
out += space + "namespace " + elem + " {\n"
|
||||||
namespace += elem + "::"
|
|
||||||
space += " "
|
space += " "
|
||||||
|
|
||||||
MACRO_BASE_NAME = ""
|
|
||||||
for elem in self.name:
|
|
||||||
MACRO_BASE_NAME += elem.upper() + "_"
|
|
||||||
|
|
||||||
out += space + "\n"
|
out += space + "\n"
|
||||||
out += space + "void register" + self.name[-1] + "(zeus::ObjectType<" + class_name + ">& _interface);\n"
|
out += space + "void " + self.prop["name_class_register_short"] + "(zeus::ObjectType<" + self.prop["name_class"] + ">& _interface);\n"
|
||||||
out += space + "\n"
|
out += space + "\n"
|
||||||
for elem in self.name[:-1]:
|
for elem in self.name[:-1]:
|
||||||
space = space[:-1]
|
space = space[:-1]
|
||||||
out += space + "}\n"
|
out += space + "}\n"
|
||||||
out += space + "\n"
|
out += space + "\n"
|
||||||
out += space + "#define " + MACRO_BASE_NAME + "DECLARE(type) \\\n"
|
out += space + "#define " + self.prop["name_class_macro"] + "DECLARE(type) \\\n"
|
||||||
out += space + " ETK_EXPORT_API void SERVICE_IO_instanciate(uint32_t _transactionId, ememory::SharedPtr<zeus::WebServer>& _iface, uint32_t _destination) { \\\n"
|
out += space + " ETK_EXPORT_API void SERVICE_IO_instanciate(uint32_t _transactionId, ememory::SharedPtr<zeus::WebServer>& _iface, uint32_t _destination) { \\\n"
|
||||||
out += space + " ememory::SharedPtr<type> tmp; \\\n"
|
out += space + " ememory::SharedPtr<type> tmp; \\\n"
|
||||||
out += space + " tmp = ememory::makeShared<type>(_destination>>16); \\\n"
|
out += space + " tmp = ememory::makeShared<type>(_destination>>16); \\\n"
|
||||||
out += space + " ememory::SharedPtr<" + class_name + "> tmp2 = tmp; \\\n"
|
out += space + " ememory::SharedPtr<" + self.prop["name_class"] + "> tmp2 = tmp; \\\n"
|
||||||
out += space + " _iface->answerValue(_transactionId, uint32_t(_iface->getAddress())<<16, _destination, tmp2); \\\n"
|
out += space + " _iface->answerValue(_transactionId, uint32_t(_iface->getAddress())<<16, _destination, tmp2); \\\n"
|
||||||
out += space + " }\n"
|
out += space + " }\n"
|
||||||
out += space + "\n"
|
out += space + "\n"
|
||||||
|
|
||||||
|
return [self.prop["file_name_class_register_header"], out]
|
||||||
return [filename, out]
|
|
||||||
|
|
||||||
|
##
|
||||||
|
## registerClass.cpp
|
||||||
|
##
|
||||||
def generate_register_code(self):
|
def generate_register_code(self):
|
||||||
filename = ""
|
out = self.licence_header
|
||||||
for elem in self.name[:-1]:
|
for elem in self.imports:
|
||||||
filename += elem + "/"
|
prop = zeus_object_to_dictionary(elem)
|
||||||
filename += "register" + self.name[-1] + ".cpp";
|
out += "#include <" + prop["file_name_class_header"] + ">\n"
|
||||||
|
out += "#include <" + prop["file_name_class_proxy_header"] + ">\n"
|
||||||
class_name = ""
|
out += "#include <" + self.prop["file_name_class_register_header"] + ">\n"
|
||||||
for elem in self.name[:-1]:
|
|
||||||
class_name += "" + elem + "::"
|
|
||||||
class_name += self.name[-1];
|
|
||||||
|
|
||||||
out = ""
|
|
||||||
out += "/** @file\n"
|
|
||||||
out += " * @note Generated file !!! Do not modify !!!\n"
|
|
||||||
out += " * @license MPL-2\n"
|
|
||||||
out += " * @copyright none\n"
|
|
||||||
out += " */\n"
|
|
||||||
out += "\n"
|
|
||||||
out += "#include <" + filename.replace(".cpp", ".hpp") + ">\n"
|
|
||||||
out += "#include <zeus/debug.hpp>\n"
|
out += "#include <zeus/debug.hpp>\n"
|
||||||
out += "\n"
|
out += "\n"
|
||||||
space = ""
|
space = ""
|
||||||
function_name = ""
|
|
||||||
for elem in self.name[:-1]:
|
|
||||||
function_name += "" + elem + "::"
|
|
||||||
function_name += "register" + self.name[-1];
|
|
||||||
|
|
||||||
class_name = ""
|
out += space + "void " + self.prop["name_class_register_short"] + "(zeus::ObjectType<" + self.prop["name_class"] + ">& _interface) {\n"
|
||||||
for elem in self.name[:-1]:
|
|
||||||
class_name += "" + elem + "::"
|
|
||||||
class_name += self.name[-1];
|
|
||||||
out += space + "void " + function_name + "(zeus::ObjectType<" + class_name + ">& _interface) {\n"
|
|
||||||
|
|
||||||
space += " "
|
space += " "
|
||||||
|
|
||||||
out += space + 'ZEUS_VERBOSE("===========================================================");\n';
|
out += space + 'ZEUS_VERBOSE("===========================================================");\n';
|
||||||
out += space + 'ZEUS_VERBOSE("== Instanciate service: ' + self.name[-1] + '");\n';
|
out += space + 'ZEUS_VERBOSE("== Instanciate service: ' + self.prop["name_class"] + '");\n';
|
||||||
out += space + 'ZEUS_VERBOSE("===========================================================");\n';
|
out += space + 'ZEUS_VERBOSE("===========================================================");\n';
|
||||||
#out += space + '_serviceInterface.propertyNameService.set("' + self.name[-1].lower() + '");\n'
|
#out += space + '_serviceInterface.propertyNameService.set("' + self.name[-1].lower() + '");\n'
|
||||||
if self.brief != "":
|
if self.brief != "":
|
||||||
@ -649,18 +638,18 @@ class ServiceDefinition:
|
|||||||
or len(self.attributes) != 0:
|
or len(self.attributes) != 0:
|
||||||
out += space + "zeus::AbstractFunction* func = nullptr;\n"
|
out += space + "zeus::AbstractFunction* func = nullptr;\n"
|
||||||
for elem in self.attributes:
|
for elem in self.attributes:
|
||||||
out += space + 'func = _interface.advertise("' + elem.name + '.set", &' + class_name + '::_internalWrapperProperty_set' + capital_first(elem.name) + ');\n'
|
out += space + 'func = _interface.advertise("' + elem.name + '.set", &' + self.prop["name_class"] + '::_internalWrapperProperty_set' + capital_first(elem.name) + ');\n'
|
||||||
out += space + 'if (func != nullptr) {\n'
|
out += space + 'if (func != nullptr) {\n'
|
||||||
if elem.brief != "":
|
if elem.brief != "":
|
||||||
out += space + ' func->setDescription("Set parameter ' + elem.brief + '");\n'
|
out += space + ' func->setDescription("Set parameter ' + elem.brief + '");\n'
|
||||||
out += space + '}\n'
|
out += space + '}\n'
|
||||||
out += space + 'func = _interface.advertise("' + elem.name + '.get", &' + class_name + '::_internalWrapperProperty_get' + capital_first(elem.name) + ');\n'
|
out += space + 'func = _interface.advertise("' + elem.name + '.get", &' + self.prop["name_class"] + '::_internalWrapperProperty_get' + capital_first(elem.name) + ');\n'
|
||||||
out += space + 'if (func != nullptr) {\n'
|
out += space + 'if (func != nullptr) {\n'
|
||||||
if elem.brief != "":
|
if elem.brief != "":
|
||||||
out += space + ' func->setDescription("Get parameter ' + elem.brief + '");\n'
|
out += space + ' func->setDescription("Get parameter ' + elem.brief + '");\n'
|
||||||
out += space + '}\n'
|
out += space + '}\n'
|
||||||
for elem in self.functions:
|
for elem in self.functions:
|
||||||
out += space + 'func = _interface.advertise("' + elem.name + '", &' + class_name + '::' + elem.name + ');\n'
|
out += space + 'func = _interface.advertise("' + elem.name + '", &' + self.prop["name_class"] + '::' + elem.name + ');\n'
|
||||||
out += space + 'if (func != nullptr) {\n'
|
out += space + 'if (func != nullptr) {\n'
|
||||||
space += " "
|
space += " "
|
||||||
if elem.brief != "":
|
if elem.brief != "":
|
||||||
@ -681,25 +670,19 @@ class ServiceDefinition:
|
|||||||
space = space[:-1]
|
space = space[:-1]
|
||||||
out += space + '}\n'
|
out += space + '}\n'
|
||||||
out += space + 'ZEUS_VERBOSE("===========================================================");\n';
|
out += space + 'ZEUS_VERBOSE("===========================================================");\n';
|
||||||
out += space + 'ZEUS_VERBOSE("== Instanciate service: ' + self.name[-1] + ' [DONE]");\n';
|
out += space + 'ZEUS_VERBOSE("== Instanciate service: ' + self.prop["name_class"] + ' [DONE]");\n';
|
||||||
out += space + 'ZEUS_VERBOSE("===========================================================");\n';
|
out += space + 'ZEUS_VERBOSE("===========================================================");\n';
|
||||||
|
|
||||||
out += "}\n"
|
out += "}\n"
|
||||||
out += "\n"
|
out += "\n"
|
||||||
return [filename, out]
|
return [self.prop["file_name_class_register_src"], out]
|
||||||
|
|
||||||
|
##
|
||||||
|
## ProxyClass.hpp
|
||||||
|
##
|
||||||
def generate_proxy_header(self):
|
def generate_proxy_header(self):
|
||||||
filename = ""
|
|
||||||
for elem in self.name[:-1]:
|
|
||||||
filename += elem + "/"
|
|
||||||
filename += "Proxy" + self.name[-1] + ".hpp";
|
|
||||||
out = ""
|
out = ""
|
||||||
|
out += self.licence_header
|
||||||
out += "/** @file\n"
|
|
||||||
out += " * @note Generated file !!! Do not modify !!!\n"
|
|
||||||
out += " * @license MPL-2\n"
|
|
||||||
out += " * @copyright none\n"
|
|
||||||
out += " */\n"
|
|
||||||
out += "#pragma once\n"
|
out += "#pragma once\n"
|
||||||
out += "\n"
|
out += "\n"
|
||||||
out += "#include <zeus/ObjectRemote.hpp>\n"
|
out += "#include <zeus/ObjectRemote.hpp>\n"
|
||||||
@ -707,6 +690,10 @@ class ServiceDefinition:
|
|||||||
out += "#include <zeus/RemoteProperty.hpp>\n"
|
out += "#include <zeus/RemoteProperty.hpp>\n"
|
||||||
out += "#include <string>\n"
|
out += "#include <string>\n"
|
||||||
out += "#include <vector>\n"
|
out += "#include <vector>\n"
|
||||||
|
for elem in self.imports:
|
||||||
|
prop = zeus_object_to_dictionary(elem)
|
||||||
|
#out += "#include <" + prop["file_name_class_header"] + ">\n"
|
||||||
|
out += "#include <" + prop["file_name_class_proxy_header"] + ">\n"
|
||||||
out += "\n"
|
out += "\n"
|
||||||
space = ""
|
space = ""
|
||||||
for elem in self.name[:-1]:
|
for elem in self.name[:-1]:
|
||||||
@ -723,20 +710,19 @@ class ServiceDefinition:
|
|||||||
for elem in self.authors:
|
for elem in self.authors:
|
||||||
out += space + " * authors:" + elem + "\n"
|
out += space + " * authors:" + elem + "\n"
|
||||||
out += space + " */\n"
|
out += space + " */\n"
|
||||||
#out += space + "class Proxy" + self.name[-1] + " : public " + self.name[-1] + " {\n"
|
out += space + "class " + self.prop["name_class_proxy_short"] + " :public zeus::Proxy {\n"
|
||||||
out += space + "class Proxy" + self.name[-1] + " :public zeus::Proxy {\n"
|
|
||||||
space += " "
|
space += " "
|
||||||
out += space + "public:\n"
|
out += space + "public:\n"
|
||||||
out += space + " const Proxy" + self.name[-1] + "& operator= (const zeus::ObjectRemote& _srv) {\n"
|
out += space + " const " + self.prop["name_class_proxy_short"] + "& operator= (const zeus::ObjectRemote& _srv) {\n"
|
||||||
out += space + " m_obj = _srv;\n"
|
out += space + " m_obj = _srv;\n"
|
||||||
out += space + " return *this;\n"
|
out += space + " return *this;\n"
|
||||||
out += space + " }\n"
|
out += space + " }\n"
|
||||||
out += space + " const Proxy" + self.name[-1] + "& operator= (const Proxy" + self.name[-1] + "& _obj) {\n"
|
out += space + " const " + self.prop["name_class_proxy_short"] + "& operator= (const " + self.prop["name_class_proxy_short"] + "& _obj) {\n"
|
||||||
out += space + " m_obj = _obj.m_obj;\n"
|
out += space + " m_obj = _obj.m_obj;\n"
|
||||||
out += space + " return *this;\n"
|
out += space + " return *this;\n"
|
||||||
out += space + " }\n"
|
out += space + " }\n"
|
||||||
out += space + " ~Proxy" + self.name[-1] + "() = default;\n"
|
out += space + " ~" + self.prop["name_class_proxy_short"] + "() = default;\n"
|
||||||
out += space + " Proxy" + self.name[-1] + "()"
|
out += space + " " + self.prop["name_class_proxy_short"] + "()"
|
||||||
if len(self.attributes) != 0:
|
if len(self.attributes) != 0:
|
||||||
out += ": \n"
|
out += ": \n"
|
||||||
first = True
|
first = True
|
||||||
@ -747,7 +733,7 @@ class ServiceDefinition:
|
|||||||
first = False
|
first = False
|
||||||
out += " {}\n"
|
out += " {}\n"
|
||||||
|
|
||||||
out += space + " Proxy" + self.name[-1] + "(const zeus::ObjectRemote& _srv) :\n"
|
out += space + " " + self.prop["name_class_proxy_short"] + "(const zeus::ObjectRemote& _srv) :\n"
|
||||||
out += space + " zeus::Proxy(_srv)"
|
out += space + " zeus::Proxy(_srv)"
|
||||||
for elem in self.attributes:
|
for elem in self.attributes:
|
||||||
out += ",\n"
|
out += ",\n"
|
||||||
@ -780,39 +766,26 @@ class ServiceDefinition:
|
|||||||
for elem in self.name[:-1]:
|
for elem in self.name[:-1]:
|
||||||
space = space[:-1]
|
space = space[:-1]
|
||||||
out += space + "}\n"
|
out += space + "}\n"
|
||||||
return [filename, out]
|
return [self.prop["file_name_class_proxy_header"], out]
|
||||||
|
|
||||||
|
##
|
||||||
|
## ProxyClass.cpp
|
||||||
|
##
|
||||||
def generate_proxy_code(self):
|
def generate_proxy_code(self):
|
||||||
filename = ""
|
|
||||||
for elem in self.name[:-1]:
|
|
||||||
filename += elem + "/"
|
|
||||||
filename += "Proxy" + self.name[-1] + ".cpp";
|
|
||||||
out = ""
|
out = ""
|
||||||
|
|
||||||
proxy_class_name = ""
|
out += self.licence_header
|
||||||
class_name = ""
|
|
||||||
for elem in self.name[:-1]:
|
|
||||||
proxy_class_name += "" + elem + "::"
|
|
||||||
class_name += "" + elem + "::"
|
|
||||||
proxy_class_name += "Proxy" + self.name[-1];
|
|
||||||
class_name += self.name[-1];
|
|
||||||
|
|
||||||
out += "/** @file\n"
|
|
||||||
out += " * @note Generated file !!! Do not modify !!!\n"
|
|
||||||
out += " * @license MPL-2\n"
|
|
||||||
out += " * @copyright none\n"
|
|
||||||
out += " */\n"
|
|
||||||
out += "\n"
|
out += "\n"
|
||||||
out += "#include <" + filename.replace(".cpp",".hpp") + ">\n"
|
out += "#include <" + self.prop["file_name_class_proxy_header"] + ">\n"
|
||||||
out += "\n"
|
out += "\n"
|
||||||
|
|
||||||
for elem in self.attributes:
|
for elem in self.attributes:
|
||||||
out += elem.generate_cpp_proxy("", proxy_class_name)
|
out += elem.generate_cpp_proxy("", self.prop["name_class_proxy"])
|
||||||
|
|
||||||
for elem in self.functions:
|
for elem in self.functions:
|
||||||
out += elem.generate_cpp_proxy("", proxy_class_name)
|
out += elem.generate_cpp_proxy("", self.prop["name_class_proxy"])
|
||||||
|
|
||||||
return [filename, out]
|
return [self.prop["file_name_class_proxy_src"], out]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -766,8 +766,9 @@ bool appl::MediaDecoder::onThreadCall() {
|
|||||||
if (m_seek >= echrono::Duration(0)) {
|
if (m_seek >= echrono::Duration(0)) {
|
||||||
// seek requested (create a copy to permit to update it in background):
|
// seek requested (create a copy to permit to update it in background):
|
||||||
echrono::Duration tmpSeek = m_seek;
|
echrono::Duration tmpSeek = m_seek;
|
||||||
m_seek = echrono::Duration(-1);
|
m_seek = echrono::Duration(-2);
|
||||||
applySeek(tmpSeek);
|
applySeek(tmpSeek);
|
||||||
|
m_seek = echrono::Duration(-1);
|
||||||
}
|
}
|
||||||
// Need to wait at lease 1MB
|
// Need to wait at lease 1MB
|
||||||
if (m_remote->sizeReadable() < APPL_BUFFER_SIZE_FOR_FFMPEG) {
|
if (m_remote->sizeReadable() < APPL_BUFFER_SIZE_FOR_FFMPEG) {
|
||||||
|
@ -98,6 +98,9 @@ namespace appl {
|
|||||||
std::vector<MessageElementVideo> m_videoPool;
|
std::vector<MessageElementVideo> m_videoPool;
|
||||||
echrono::Duration m_currentVideoTime;
|
echrono::Duration m_currentVideoTime;
|
||||||
bool m_updateVideoTimeStampAfterSeek;
|
bool m_updateVideoTimeStampAfterSeek;
|
||||||
|
bool getSeekDone() {
|
||||||
|
return m_updateVideoTimeStampAfterSeek;
|
||||||
|
}
|
||||||
int32_t audioGetOlderSlot();
|
int32_t audioGetOlderSlot();
|
||||||
int32_t videoGetOlderSlot();
|
int32_t videoGetOlderSlot();
|
||||||
private:
|
private:
|
||||||
|
@ -83,10 +83,6 @@ void appl::Windows::init() {
|
|||||||
m_listViewer = ememory::dynamicPointerCast<appl::widget::ListViewer>(m_composer->getSubObjectNamed("ws-name-list-viewer"));
|
m_listViewer = ememory::dynamicPointerCast<appl::widget::ListViewer>(m_composer->getSubObjectNamed("ws-name-list-viewer"));
|
||||||
m_listViewer->signalSelect.connect(sharedFromThis(), &appl::Windows::onCallbackSelectMedia);
|
m_listViewer->signalSelect.connect(sharedFromThis(), &appl::Windows::onCallbackSelectMedia);
|
||||||
|
|
||||||
subBind(appl::widget::VideoDisplay, "displayer", signalFps, sharedFromThis(), &appl::Windows::onCallbackFPS);
|
|
||||||
subBind(appl::widget::VideoDisplay, "displayer", signalPosition, sharedFromThis(), &appl::Windows::onCallbackPosition);
|
|
||||||
subBind(ewol::widget::Slider, "progress-bar", signalChange, sharedFromThis(), &appl::Windows::onCallbackSeekRequest);
|
|
||||||
|
|
||||||
|
|
||||||
subBind(ewol::widget::Button, "bt-film-picture", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSelectFilms);
|
subBind(ewol::widget::Button, "bt-film-picture", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSelectFilms);
|
||||||
subBind(ewol::widget::Button, "bt-film-draw", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSelectAnnimation);
|
subBind(ewol::widget::Button, "bt-film-draw", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSelectAnnimation);
|
||||||
@ -256,10 +252,6 @@ void appl::Windows::onCallbackNext() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void appl::Windows::onCallbackFPS(const int32_t& _fps) {
|
|
||||||
APPL_DEBUG("FPS = " << _fps);
|
|
||||||
propertySetOnWidgetNamed("lb-fps", "value", "FPS=<font color='orangered'>" + etk::to_string(_fps) + "</font>");
|
|
||||||
}
|
|
||||||
|
|
||||||
void appl::Windows::addFile(const std::string& _file) {
|
void appl::Windows::addFile(const std::string& _file) {
|
||||||
APPL_DEBUG("Add file : " << _file);
|
APPL_DEBUG("Add file : " << _file);
|
||||||
@ -277,19 +269,6 @@ void appl::Windows::addFile(const std::string& _file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void appl::Windows::onCallbackPosition(const echrono::Duration& _time) {
|
|
||||||
APPL_DEBUG("time = " << _time);
|
|
||||||
propertySetOnWidgetNamed("lb-time", "value", "<font color='green'>" + etk::to_string(_time) + "</font>");
|
|
||||||
propertySetOnWidgetNamed("progress-bar", "value", etk::to_string(_time.toSeconds()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void appl::Windows::onCallbackSeekRequest(const float& _value) {
|
|
||||||
ememory::SharedPtr<appl::widget::VideoDisplay> tmpDisp = ememory::dynamicPointerCast<appl::widget::VideoDisplay>(getSubObjectNamed("displayer"));
|
|
||||||
if (tmpDisp != nullptr) {
|
|
||||||
tmpDisp->seek(echrono::Duration(_value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void appl::Windows::onCallbackSelectFilms() {
|
void appl::Windows::onCallbackSelectFilms() {
|
||||||
ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer");
|
ewol::propertySetOnObjectNamed("view-selection", "select", "ws-name-list-viewer");
|
||||||
m_listViewer->searchElements("film");
|
m_listViewer->searchElements("film");
|
||||||
|
@ -29,8 +29,6 @@ namespace appl {
|
|||||||
void onCallbackPrevious();
|
void onCallbackPrevious();
|
||||||
void onCallbackPlay(const bool& _isPressed);
|
void onCallbackPlay(const bool& _isPressed);
|
||||||
void onCallbackNext();
|
void onCallbackNext();
|
||||||
void onCallbackFPS(const int32_t& _fps);
|
|
||||||
void onCallbackPosition(const echrono::Duration& _time);
|
|
||||||
void addFile(const std::string& _file);
|
void addFile(const std::string& _file);
|
||||||
void onCallbackSeekRequest(const float& _value);
|
void onCallbackSeekRequest(const float& _value);
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <ewol/widget/ListFileSystem.hpp>
|
#include <ewol/widget/ListFileSystem.hpp>
|
||||||
#include <ewol/widget/Entry.hpp>
|
#include <ewol/widget/Entry.hpp>
|
||||||
#include <ewol/widget/Spacer.hpp>
|
#include <ewol/widget/Spacer.hpp>
|
||||||
|
#include <ewol/widget/Slider.hpp>
|
||||||
#include <ewol/widget/Image.hpp>
|
#include <ewol/widget/Image.hpp>
|
||||||
#include <ewol/widget/Composer.hpp>
|
#include <ewol/widget/Composer.hpp>
|
||||||
#include <ewol/widget/Manager.hpp>
|
#include <ewol/widget/Manager.hpp>
|
||||||
@ -39,6 +40,12 @@ void appl::widget::Player::init() {
|
|||||||
subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]appl-player-bt-play", signalValue, sharedFromThis(), &appl::widget::Player::onCallbackButtonPlay);
|
subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]appl-player-bt-play", signalValue, sharedFromThis(), &appl::widget::Player::onCallbackButtonPlay);
|
||||||
subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]appl-player-bt-next", signalPressed, sharedFromThis(), &appl::widget::Player::onCallbackButtonNext);
|
subBind(ewol::widget::Button, "[" + etk::to_string(getId()) + "]appl-player-bt-next", signalPressed, sharedFromThis(), &appl::widget::Player::onCallbackButtonNext);
|
||||||
|
|
||||||
|
subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalPosition, sharedFromThis(), &appl::widget::Player::onCallbackPosition);
|
||||||
|
subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalDuration, sharedFromThis(), &appl::widget::Player::onCallbackDuration);
|
||||||
|
|
||||||
|
subBind(appl::widget::VideoDisplay, "[" + etk::to_string(getId()) + "]appl-player-display", signalFps, sharedFromThis(), &appl::widget::Player::onCallbackFPS);
|
||||||
|
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_display = ememory::dynamicPointerCast<appl::widget::VideoDisplay>(getSubObjectNamed("[" + etk::to_string(getId()) + "]appl-player-display"));
|
||||||
propertyCanFocus.set(true);
|
propertyCanFocus.set(true);
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
@ -64,13 +71,35 @@ void appl::widget::Player::playStream(ememory::SharedPtr<appl::ClientProperty> _
|
|||||||
// Set new file:
|
// Set new file:
|
||||||
m_display->setZeusMedia(_property, _mediaId);
|
m_display->setZeusMedia(_property, _mediaId);
|
||||||
m_display->play();
|
m_display->play();
|
||||||
//echrono::Duration time = tmpDisp->getDuration();
|
|
||||||
//APPL_DEBUG("duration = " << time << " " << etk::to_string(time.toSeconds()));
|
|
||||||
//propertySetOnWidgetNamed("progress-bar", "value", "0");
|
|
||||||
//propertySetOnWidgetNamed("progress-bar", "max", etk::to_string(time.toSeconds()));
|
|
||||||
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "true");
|
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void appl::widget::Player::onCallbackSeekRequest(const float& _value) {
|
||||||
|
//APPL_ERROR("seek at = " << echrono::Duration(_value));
|
||||||
|
if (m_display != nullptr) {
|
||||||
|
m_display->seek(echrono::Duration(_value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void appl::widget::Player::onCallbackFPS(const int32_t& _fps) {
|
||||||
|
APPL_DEBUG("FPS = " << _fps);
|
||||||
|
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-label-fps", "value", "FPS=<font color='orangered'>" + etk::to_string(_fps) + "</font>");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void appl::widget::Player::suspend() {
|
void appl::widget::Player::suspend() {
|
||||||
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "false");
|
propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]appl-player-bt-play", "value", "false");
|
||||||
if (m_display == nullptr) {
|
if (m_display == nullptr) {
|
||||||
|
@ -43,6 +43,10 @@ namespace appl {
|
|||||||
void onCallbackButtonPrevious();
|
void onCallbackButtonPrevious();
|
||||||
void onCallbackButtonNext();
|
void onCallbackButtonNext();
|
||||||
void onCallbackButtonPlay(const bool& _value);
|
void onCallbackButtonPlay(const bool& _value);
|
||||||
|
void onCallbackPosition(const echrono::Duration& _value);
|
||||||
|
void onCallbackDuration(const echrono::Duration& _value);
|
||||||
|
void onCallbackSeekRequest(const float& _value);
|
||||||
|
void onCallbackFPS(const int32_t& _fps);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -106,6 +106,7 @@ void appl::widget::VideoDisplay::setZeusMedia(ememory::SharedPtr<ClientProperty>
|
|||||||
APPL_ERROR("Can not create sharedPtr on decoder ...");
|
APPL_ERROR("Can not create sharedPtr on decoder ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
m_haveDuration = false;
|
||||||
m_decoder->init(_property, _mediaId);
|
m_decoder->init(_property, _mediaId);
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
}
|
}
|
||||||
@ -262,6 +263,7 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event)
|
|||||||
}
|
}
|
||||||
if (m_decoder->m_seekApply >= echrono::Duration(0)) {
|
if (m_decoder->m_seekApply >= echrono::Duration(0)) {
|
||||||
m_currentTime = m_decoder->m_seekApply;
|
m_currentTime = m_decoder->m_seekApply;
|
||||||
|
APPL_ERROR("Apply new position : " << m_currentTime);
|
||||||
m_decoder->m_seekApply = echrono::Duration(-1);
|
m_decoder->m_seekApply = echrono::Duration(-1);
|
||||||
if (m_audioInterface != nullptr) {
|
if (m_audioInterface != nullptr) {
|
||||||
m_audioInterface->clearInternalBuffer();
|
m_audioInterface->clearInternalBuffer();
|
||||||
@ -308,6 +310,10 @@ void appl::widget::VideoDisplay::periodicEvent(const ewol::event::Time& _event)
|
|||||||
//m_currentTime -= _event.getDeltaCallDuration();
|
//m_currentTime -= _event.getDeltaCallDuration();
|
||||||
} else {
|
} else {
|
||||||
signalPosition.emit(m_currentTime);
|
signalPosition.emit(m_currentTime);
|
||||||
|
if (m_haveDuration == false) {
|
||||||
|
signalDuration.emit(m_decoder->getDuration());
|
||||||
|
m_haveDuration = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// TODO : Chek if this is needed, the display configuration not change too much ...
|
// TODO : Chek if this is needed, the display configuration not change too much ...
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
|
@ -25,6 +25,8 @@ namespace appl {
|
|||||||
public:
|
public:
|
||||||
esignal::Signal<int32_t> signalFps;
|
esignal::Signal<int32_t> signalFps;
|
||||||
esignal::Signal<echrono::Duration> signalPosition; //!< signal the current duration of the video duration
|
esignal::Signal<echrono::Duration> signalPosition; //!< signal the current duration of the video duration
|
||||||
|
esignal::Signal<echrono::Duration> signalDuration; //!< signal the current duration of the video duration
|
||||||
|
bool m_haveDuration;
|
||||||
private:
|
private:
|
||||||
mat4 m_matrixApply;
|
mat4 m_matrixApply;
|
||||||
ememory::SharedPtr<appl::MediaDecoder> m_decoder;
|
ememory::SharedPtr<appl::MediaDecoder> m_decoder;
|
||||||
|
@ -1,21 +1,27 @@
|
|||||||
<layer fill="true" expand="true">
|
<layer fill="true" expand="true">
|
||||||
<sizer mode="vert" fill="true" expand="true">
|
<sizer mode="vert" fill="true" expand="true">
|
||||||
<sizer mode="hori" fill="true" expand="true,false">
|
<sizer mode="hori" fill="true" expand="true,false">
|
||||||
|
<spacer expand="true,false" fill="true"/>
|
||||||
|
<spacer expand="true,false" fill="true"/>
|
||||||
<button name="[{ID}]appl-player-bt-previous">
|
<button name="[{ID}]appl-player-bt-previous">
|
||||||
<label>_T{Previous}</label>
|
<label>_T{Previous}</label>
|
||||||
</button>
|
</button>
|
||||||
|
<spacer expand="true,false" fill="true"/>
|
||||||
<button name="[{ID}]appl-player-bt-play" toggle="true">
|
<button name="[{ID}]appl-player-bt-play" toggle="true">
|
||||||
<label>_T{Play}</label>
|
<label>_T{Play}</label>
|
||||||
<label>_T{Pause}</label>
|
<label>_T{Pause}</label>
|
||||||
</button>
|
</button>
|
||||||
|
<spacer expand="true,false" fill="true"/>
|
||||||
<button name="[{ID}]appl-player-bt-next">
|
<button name="[{ID}]appl-player-bt-next">
|
||||||
<label>_T{Next}</label>
|
<label>_T{Next}</label>
|
||||||
</button>
|
</button>
|
||||||
<spacer expand="true,false" fill="true"/>
|
<spacer expand="true,false" fill="true"/>
|
||||||
<label name="[{ID}]appl-player-lb-time"/>
|
<label name="[{ID}]appl-player-label-time"/>
|
||||||
|
<spacer expand="true,false" fill="true"/>
|
||||||
</sizer>
|
</sizer>
|
||||||
<slider name="progress-bar" expand="true,false" fill="true" step="0.01" min="0"/>
|
<slider name="[{ID}]appl-player-progress-bar" expand="true,false" fill="true" step="0.01" min="0"/>
|
||||||
<spacer expand="true" fill="true"/>
|
<spacer expand="true" fill="true"/>
|
||||||
|
<label name="[{ID}]appl-player-label-fps"/>
|
||||||
</sizer>
|
</sizer>
|
||||||
<VideoDisplay name="[{ID}]appl-player-display" expand="true" fill="true"/>
|
<VideoDisplay name="[{ID}]appl-player-display" expand="true" fill="true"/>
|
||||||
</layer>
|
</layer>
|
Loading…
x
Reference in New Issue
Block a user