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)
|
||||
{
|
||||
node.nodeList.clear();
|
||||
for (const auto &i : xml.at("resources")) {
|
||||
auto *xmlNode = xml.GetNode()->FirstChildElement();
|
||||
while (xmlNode != nullptr) {
|
||||
std::shared_ptr<IProgramNode> item;
|
||||
if (i.GetNodeName() == "text") {
|
||||
const cat::HCatBuffer name(xmlNode->Name());
|
||||
if (name == "text") {
|
||||
item.reset(new TextInfo());
|
||||
} else if (i.GetNodeName() == "image") {
|
||||
} else if (name == "image") {
|
||||
item.reset(new PhotoInfo());
|
||||
} else if (i.GetNodeName() == "video") {
|
||||
} else if (name == "video") {
|
||||
item.reset(new VideoInfo());
|
||||
} else {
|
||||
printf("Not suuport node[%s]\n", name.ConstData());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item->FromXml(HXml(xmlNode)) == false) {
|
||||
xmlNode = xmlNode->NextSiblingElement();
|
||||
continue;
|
||||
}
|
||||
|
||||
item->FromXml(i);
|
||||
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) {
|
||||
node.guid = xml.at("program").GetAttribute("guid");
|
||||
for (const auto &i : xml.at("program").at("area")) {
|
||||
node.guid = xml.GetAttribute("guid");
|
||||
for (const auto &i : xml.at("area")) {
|
||||
AreaNodeInfo item;
|
||||
if (i.get_to(item) == false) {
|
||||
continue;
|
||||
|
||||
@ -1027,3 +1027,7 @@ HBool DLL_CALL AddPlayNode(ISDKInfo info, int programIndex, int areaIndex, IPlay
|
||||
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 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 void DLL_CALL ClearNode(ISDKInfo info);
|
||||
|
||||
|
||||
///< 下面是获取
|
||||
|
||||
@ -15,7 +15,10 @@ int IsRead = 0;
|
||||
|
||||
static bool SendData(const char *data, int len, void *userData) {
|
||||
int fd = (int)(intptr_t)userData;
|
||||
if (len > 12) {
|
||||
printf("send[%s]\n", data + 12);
|
||||
}
|
||||
|
||||
return write(fd, data, len) > 0;
|
||||
}
|
||||
|
||||
@ -28,10 +31,9 @@ static void ReadXml(const char *xml, int len, int errorCode, void *userData) {
|
||||
return ;
|
||||
}
|
||||
|
||||
char **p = (char **)(userData);
|
||||
free(*p);
|
||||
*p = (char *)malloc(len);
|
||||
memcpy(*p, xml, len);
|
||||
ISDKInfo sdkInfo = (ISDKInfo)userData;
|
||||
ParseXml(sdkInfo, xml, len);
|
||||
printf("read[%s]\n", xml);
|
||||
}
|
||||
|
||||
|
||||
@ -62,14 +64,12 @@ int main(int argc, char *argv[])
|
||||
return 2;
|
||||
}
|
||||
|
||||
char *p_buff = NULL;
|
||||
|
||||
ISDKInfo sdkInfo = CreateSDKInfo();
|
||||
IHDProtocol proto = CreateProtocol();
|
||||
SetProtocolFunc(proto, kSetSendFunc, (void *)SendData);
|
||||
SetProtocolFunc(proto, kSetSendFuncData, (void *)(intptr_t)(fd));
|
||||
SetProtocolFunc(proto, kSetReadXml, (void *)ReadXml);
|
||||
SetProtocolFunc(proto, kSetReadXmlData, &p_buff);
|
||||
SetProtocolFunc(proto, kSetReadXmlData, sdkInfo);
|
||||
|
||||
RunProtocol(proto);
|
||||
|
||||
@ -87,12 +87,13 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("read xml[\n%s]\n", p_buff);
|
||||
|
||||
//ClearNode(sdkInfo);
|
||||
SetScreenNode(sdkInfo, 0);
|
||||
IsRead = 0;
|
||||
AddAreaNode(sdkInfo, 0, "AreaGuid", 0, 0, 160, 80);
|
||||
auto node = CreateTextNode(sdkInfo, "Text", "Text");
|
||||
AddPlayNode(sdkInfo, 0, 0, node);
|
||||
//AddAreaNode(sdkInfo, 0, "AreaGuid", 0, 0, 160, 80);
|
||||
//auto node = CreateTextNode(sdkInfo, "Text", "Text");
|
||||
//AddPlayNode(sdkInfo, 0, 0, node);
|
||||
UpdateItem(proto, sdkInfo, kAddProgram);
|
||||
for (;;) {
|
||||
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);
|
||||
FreeProtocol(proto);
|
||||
close(fd);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user