1. 修复读取节目转换的问题
This commit is contained in:
parent
bc672478fa
commit
ba96705e86
@ -146,20 +146,28 @@ void to_xml(HXml &xml, const ResourcesInfo &node)
|
|||||||
void from_xml(const HXml &xml, ResourcesInfo &node)
|
void from_xml(const HXml &xml, ResourcesInfo &node)
|
||||||
{
|
{
|
||||||
node.nodeList.clear();
|
node.nodeList.clear();
|
||||||
for (const auto &i : xml.at("resources")) {
|
auto *xmlNode = xml.GetNode()->FirstChildElement();
|
||||||
|
while (xmlNode != nullptr) {
|
||||||
std::shared_ptr<IProgramNode> item;
|
std::shared_ptr<IProgramNode> item;
|
||||||
if (i.GetNodeName() == "text") {
|
const cat::HCatBuffer name(xmlNode->Name());
|
||||||
|
if (name == "text") {
|
||||||
item.reset(new TextInfo());
|
item.reset(new TextInfo());
|
||||||
} else if (i.GetNodeName() == "image") {
|
} else if (name == "image") {
|
||||||
item.reset(new PhotoInfo());
|
item.reset(new PhotoInfo());
|
||||||
} else if (i.GetNodeName() == "video") {
|
} else if (name == "video") {
|
||||||
item.reset(new VideoInfo());
|
item.reset(new VideoInfo());
|
||||||
} else {
|
} else {
|
||||||
|
printf("Not suuport node[%s]\n", name.ConstData());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item->FromXml(HXml(xmlNode)) == false) {
|
||||||
|
xmlNode = xmlNode->NextSiblingElement();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
item->FromXml(i);
|
|
||||||
node.nodeList.emplace_back(item);
|
node.nodeList.emplace_back(item);
|
||||||
|
xmlNode = xmlNode->NextSiblingElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,8 +208,8 @@ void to_xml(HXml &xml, const ProgramNodeInfo &node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void from_xml(const HXml &xml, ProgramNodeInfo &node) {
|
void from_xml(const HXml &xml, ProgramNodeInfo &node) {
|
||||||
node.guid = xml.at("program").GetAttribute("guid");
|
node.guid = xml.GetAttribute("guid");
|
||||||
for (const auto &i : xml.at("program").at("area")) {
|
for (const auto &i : xml.at("area")) {
|
||||||
AreaNodeInfo item;
|
AreaNodeInfo item;
|
||||||
if (i.get_to(item) == false) {
|
if (i.get_to(item) == false) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -1027,3 +1027,7 @@ HBool DLL_CALL AddPlayNode(ISDKInfo info, int programIndex, int areaIndex, IPlay
|
|||||||
return HFalse;
|
return HFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DLL_CALL ClearNode(ISDKInfo info)
|
||||||
|
{
|
||||||
|
info->programInfo.programList.clear();
|
||||||
|
}
|
||||||
|
|||||||
@ -352,6 +352,7 @@ HD_API IPlayNode DLL_CALL CreateVideoNode(ISDKInfo info, const char *guid, const
|
|||||||
HD_API HBool DLL_CALL ModifyFilePath(IPlayNode node, const char *name, const char *md5, int size);
|
HD_API HBool DLL_CALL ModifyFilePath(IPlayNode node, const char *name, const char *md5, int size);
|
||||||
HD_API HBool DLL_CALL ModifyPlayEffect(IPlayNode node, int in, int out, int outSpeed, int inSpeed, int duration);
|
HD_API HBool DLL_CALL ModifyPlayEffect(IPlayNode node, int in, int out, int outSpeed, int inSpeed, int duration);
|
||||||
HD_API HBool DLL_CALL AddPlayNode(ISDKInfo info, int programIndex, int areaIndex, IPlayNode node);
|
HD_API HBool DLL_CALL AddPlayNode(ISDKInfo info, int programIndex, int areaIndex, IPlayNode node);
|
||||||
|
HD_API void DLL_CALL ClearNode(ISDKInfo info);
|
||||||
|
|
||||||
|
|
||||||
///< 下面是获取
|
///< 下面是获取
|
||||||
|
|||||||
@ -15,7 +15,10 @@ int IsRead = 0;
|
|||||||
|
|
||||||
static bool SendData(const char *data, int len, void *userData) {
|
static bool SendData(const char *data, int len, void *userData) {
|
||||||
int fd = (int)(intptr_t)userData;
|
int fd = (int)(intptr_t)userData;
|
||||||
|
if (len > 12) {
|
||||||
printf("send[%s]\n", data + 12);
|
printf("send[%s]\n", data + 12);
|
||||||
|
}
|
||||||
|
|
||||||
return write(fd, data, len) > 0;
|
return write(fd, data, len) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,10 +31,9 @@ static void ReadXml(const char *xml, int len, int errorCode, void *userData) {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
char **p = (char **)(userData);
|
ISDKInfo sdkInfo = (ISDKInfo)userData;
|
||||||
free(*p);
|
ParseXml(sdkInfo, xml, len);
|
||||||
*p = (char *)malloc(len);
|
printf("read[%s]\n", xml);
|
||||||
memcpy(*p, xml, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -62,14 +64,12 @@ int main(int argc, char *argv[])
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *p_buff = NULL;
|
|
||||||
|
|
||||||
ISDKInfo sdkInfo = CreateSDKInfo();
|
ISDKInfo sdkInfo = CreateSDKInfo();
|
||||||
IHDProtocol proto = CreateProtocol();
|
IHDProtocol proto = CreateProtocol();
|
||||||
SetProtocolFunc(proto, kSetSendFunc, (void *)SendData);
|
SetProtocolFunc(proto, kSetSendFunc, (void *)SendData);
|
||||||
SetProtocolFunc(proto, kSetSendFuncData, (void *)(intptr_t)(fd));
|
SetProtocolFunc(proto, kSetSendFuncData, (void *)(intptr_t)(fd));
|
||||||
SetProtocolFunc(proto, kSetReadXml, (void *)ReadXml);
|
SetProtocolFunc(proto, kSetReadXml, (void *)ReadXml);
|
||||||
SetProtocolFunc(proto, kSetReadXmlData, &p_buff);
|
SetProtocolFunc(proto, kSetReadXmlData, sdkInfo);
|
||||||
|
|
||||||
RunProtocol(proto);
|
RunProtocol(proto);
|
||||||
|
|
||||||
@ -87,12 +87,13 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("read xml[\n%s]\n", p_buff);
|
|
||||||
|
|
||||||
|
//ClearNode(sdkInfo);
|
||||||
|
SetScreenNode(sdkInfo, 0);
|
||||||
IsRead = 0;
|
IsRead = 0;
|
||||||
AddAreaNode(sdkInfo, 0, "AreaGuid", 0, 0, 160, 80);
|
//AddAreaNode(sdkInfo, 0, "AreaGuid", 0, 0, 160, 80);
|
||||||
auto node = CreateTextNode(sdkInfo, "Text", "Text");
|
//auto node = CreateTextNode(sdkInfo, "Text", "Text");
|
||||||
AddPlayNode(sdkInfo, 0, 0, node);
|
//AddPlayNode(sdkInfo, 0, 0, node);
|
||||||
UpdateItem(proto, sdkInfo, kAddProgram);
|
UpdateItem(proto, sdkInfo, kAddProgram);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int len = read(fd, buff, sizeof(buff));
|
int len = read(fd, buff, sizeof(buff));
|
||||||
@ -106,8 +107,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("read xml[\n%s]\n", p_buff);
|
|
||||||
free(p_buff);
|
|
||||||
FreeSDKInfo(sdkInfo);
|
FreeSDKInfo(sdkInfo);
|
||||||
FreeProtocol(proto);
|
FreeProtocol(proto);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user