1. 增加更新节目接口支持, 节目支持文本, 图片, 视频
This commit is contained in:
parent
ac9f3567b2
commit
a1085f62cb
@ -69,4 +69,12 @@ if(ENABLE_DEMO)
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/SDK
|
${CMAKE_CURRENT_SOURCE_DIR}/SDK
|
||||||
)
|
)
|
||||||
target_link_libraries(eth PRIVATE HDSDK)
|
target_link_libraries(eth PRIVATE HDSDK)
|
||||||
|
|
||||||
|
add_executable(sendProgram demo/sendProgram.cpp)
|
||||||
|
target_include_directories(sendProgram PUBLIC
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/Protocol
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/SDK
|
||||||
|
)
|
||||||
|
target_link_libraries(sendProgram PRIVATE HDSDK)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@ -19,6 +19,7 @@ if (ENABLE_SDK)
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/../SDK/Data/HSDKInfo.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/../SDK/Data/HSDKInfo.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../SDK/Data/HSensorInfo.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/../SDK/Data/HSensorInfo.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../SDK/Data/HTimeInfo.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/../SDK/Data/HTimeInfo.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../SDK/Data/HProgramInfo.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
235
SDK/Data/HProgramInfo.cpp
Normal file
235
SDK/Data/HProgramInfo.cpp
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include "HXml.h"
|
||||||
|
#include <Data/HProgramInfo.h>
|
||||||
|
|
||||||
|
void to_xml(HXml &xml, const EffectInfo &node)
|
||||||
|
{
|
||||||
|
xml["effect"] = {
|
||||||
|
{"inSpeed", node.inSpeed},
|
||||||
|
{"outSpeed", node.outSpeed},
|
||||||
|
{"in", node.in},
|
||||||
|
{"out", node.out},
|
||||||
|
{"duration", node.duration},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
void from_xml(const HXml &xml, EffectInfo &node)
|
||||||
|
{
|
||||||
|
node.inSpeed = xml.at("effect").GetAttribute("inSpeed").ToInt();
|
||||||
|
node.outSpeed = xml.at("effect").GetAttribute("outSpeed").ToInt();
|
||||||
|
node.in = xml.at("effect").GetAttribute("in").ToInt();
|
||||||
|
node.out = xml.at("effect").GetAttribute("out").ToInt();
|
||||||
|
node.duration = xml.at("effect").GetAttribute("duration").ToInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_xml(HXml &xml, const FileInfo &node)
|
||||||
|
{
|
||||||
|
xml["file"] = {
|
||||||
|
{"name", node.name},
|
||||||
|
{"md5", node.md5},
|
||||||
|
{"size", node.size},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_xml(const HXml &xml, FileInfo &node)
|
||||||
|
{
|
||||||
|
node.name = xml.at("file").GetAttribute("name");
|
||||||
|
node.md5 = xml.at("file").GetAttribute("md5");
|
||||||
|
node.size = xml.at("file").GetAttribute("size").ToInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_xml(HXml &xml, const TextInfo &node)
|
||||||
|
{
|
||||||
|
xml = {
|
||||||
|
{"guid", node.guid},
|
||||||
|
{"background", node.background},
|
||||||
|
};
|
||||||
|
xml["string"].SetText(node.text);
|
||||||
|
xml["style"] = {
|
||||||
|
{"valign", node.style.valign},
|
||||||
|
{"align", node.style.align},
|
||||||
|
};
|
||||||
|
xml["font"] = {
|
||||||
|
{"name", node.font.name},
|
||||||
|
{"color", node.font.color},
|
||||||
|
{"italic", node.font.italic},
|
||||||
|
{"bold", node.font.bold},
|
||||||
|
{"underline", node.font.underline},
|
||||||
|
{"size", node.font.size},
|
||||||
|
};
|
||||||
|
xml.ToXml(node.effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_xml(const HXml &xml, TextInfo &node)
|
||||||
|
{
|
||||||
|
node.guid = xml.GetAttribute("guid");
|
||||||
|
node.background = xml.GetAttribute("background");
|
||||||
|
node.text.Clear();
|
||||||
|
if (xml.ContainsNodes("string")) {
|
||||||
|
node.text = xml.at("string").GetText();
|
||||||
|
}
|
||||||
|
|
||||||
|
node.style.valign = xml.at("style").GetAttribute("valign");
|
||||||
|
node.style.align = xml.at("style").GetAttribute("align");
|
||||||
|
node.font.name = xml.at("font").GetAttribute("name");
|
||||||
|
node.font.color = xml.at("font").GetAttribute("color");
|
||||||
|
|
||||||
|
if (xml.at("font").ContainsAttribute("italic")) {
|
||||||
|
node.font.italic = xml.at("font").GetAttribute("italic") == "true";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xml.at("font").ContainsAttribute("bold")) {
|
||||||
|
node.font.bold = xml.at("font").GetAttribute("bold") == "true";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xml.at("font").ContainsAttribute("underline")) {
|
||||||
|
node.font.underline = xml.at("font").GetAttribute("underline") == "true";
|
||||||
|
}
|
||||||
|
|
||||||
|
node.font.size = xml.at("font").GetAttribute("size").ToInt();
|
||||||
|
xml.get_to(node.effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_xml(HXml &xml, const PhotoInfo &node)
|
||||||
|
{
|
||||||
|
xml = {
|
||||||
|
{"guid",node.guid},
|
||||||
|
{"fit", node.fit},
|
||||||
|
};
|
||||||
|
xml.ToXml(node.file);
|
||||||
|
xml.ToXml(node.effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_xml(const HXml &xml, PhotoInfo &node)
|
||||||
|
{
|
||||||
|
node.guid = xml.GetAttribute("guid");
|
||||||
|
if (xml.ContainsAttribute("fit")) {
|
||||||
|
node.fit = xml.GetAttribute("fit");
|
||||||
|
}
|
||||||
|
|
||||||
|
xml.get_to(node.file);
|
||||||
|
xml.get_to(node.effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_xml(HXml &xml, const VideoInfo &node)
|
||||||
|
{
|
||||||
|
xml = {
|
||||||
|
{"guid", node.guid},
|
||||||
|
{"aspectRatio", node.aspectRatio ? "true" : "false"},
|
||||||
|
};
|
||||||
|
xml["playParams"] = {
|
||||||
|
{"duration", node.playParams.duration},
|
||||||
|
};
|
||||||
|
xml.ToXml(node.file);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_xml(const HXml &xml, VideoInfo &node)
|
||||||
|
{
|
||||||
|
node.guid = xml.GetAttribute("guid");
|
||||||
|
if (xml.ContainsAttribute("aspectRatio")) {
|
||||||
|
node.aspectRatio = xml.GetAttribute("aspectRatio") == "true";
|
||||||
|
}
|
||||||
|
|
||||||
|
xml.get_to(node.file);
|
||||||
|
if (xml.ContainsNodes("playParams")) {
|
||||||
|
node.playParams.duration = xml.at("playParams").GetAttribute("duration").ToInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_xml(HXml &xml, const ResourcesInfo &node)
|
||||||
|
{
|
||||||
|
for (const auto &i : node.nodeList) {
|
||||||
|
i->ToXml(xml);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_xml(const HXml &xml, ResourcesInfo &node)
|
||||||
|
{
|
||||||
|
node.nodeList.clear();
|
||||||
|
for (const auto &i : xml.at("resources")) {
|
||||||
|
std::shared_ptr<IProgramNode> item;
|
||||||
|
if (i.GetNodeName() == "text") {
|
||||||
|
item.reset(new TextInfo());
|
||||||
|
} else if (i.GetNodeName() == "image") {
|
||||||
|
item.reset(new PhotoInfo());
|
||||||
|
} else if (i.GetNodeName() == "video") {
|
||||||
|
item.reset(new VideoInfo());
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
item->FromXml(i);
|
||||||
|
node.nodeList.emplace_back(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_xml(HXml &xml, const AreaNodeInfo &node)
|
||||||
|
{
|
||||||
|
xml = {
|
||||||
|
{"guid", node.guid},
|
||||||
|
{"alpha", node.alpha},
|
||||||
|
};
|
||||||
|
xml["rectangle"] = {
|
||||||
|
{"x", node.rect.x},
|
||||||
|
{"y", node.rect.y},
|
||||||
|
{"width", node.rect.width},
|
||||||
|
{"height", node.rect.height},
|
||||||
|
};
|
||||||
|
xml["resources"].ToXml(node.resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_xml(const HXml &xml, AreaNodeInfo &node)
|
||||||
|
{
|
||||||
|
node.guid = xml.GetAttribute("guid");
|
||||||
|
node.alpha = xml.GetAttribute("alpha").ToInt();
|
||||||
|
node.rect.x = xml.at("rectangle").GetAttribute("x").ToInt();
|
||||||
|
node.rect.y = xml.at("rectangle").GetAttribute("y").ToInt();
|
||||||
|
node.rect.width = xml.at("rectangle").GetAttribute("width").ToInt();
|
||||||
|
node.rect.height = xml.at("rectangle").GetAttribute("height").ToInt();
|
||||||
|
xml.at("resource").get_to(node.resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_xml(HXml &xml, const ProgramNodeInfo &node)
|
||||||
|
{
|
||||||
|
xml = {
|
||||||
|
{"guid", node.guid},
|
||||||
|
};
|
||||||
|
for (const auto &i : node.areaList) {
|
||||||
|
xml.NewChild("area").ToXml(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_xml(const HXml &xml, ProgramNodeInfo &node) {
|
||||||
|
node.guid = xml.at("program").GetAttribute("guid");
|
||||||
|
for (const auto &i : xml.at("program").at("area")) {
|
||||||
|
AreaNodeInfo item;
|
||||||
|
if (i.get_to(item) == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
node.areaList.emplace_back(std::move(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_xml(HXml &xml, const ScreenNodeInfo &node) {
|
||||||
|
xml["screen"] = {
|
||||||
|
{"timeStamps", node.timeStamps},
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const auto &i : node.programList) {
|
||||||
|
xml["screen"].NewChild("program").ToXml(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void from_xml(const HXml &xml, ScreenNodeInfo &node) {
|
||||||
|
node.timeStamps = xml.at("screen").GetAttribute("timeStamps").ToInt();
|
||||||
|
for (const auto &i : xml.at("screen").at("program")) {
|
||||||
|
ProgramNodeInfo item;
|
||||||
|
if (i.get_to(item) == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
node.programList.emplace_back(std::move(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
196
SDK/Data/HProgramInfo.h
Normal file
196
SDK/Data/HProgramInfo.h
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#ifndef HSENSORINFO_H
|
||||||
|
#define HSENSORINFO_H
|
||||||
|
|
||||||
|
#include <HCatBuffer.h>
|
||||||
|
#include <HXml.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
|
class IProgramNode
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IProgramNode() {}
|
||||||
|
|
||||||
|
virtual void ToXml(HXml &xml) = 0;
|
||||||
|
virtual bool FromXml(const HXml &xml) = 0;
|
||||||
|
virtual cat::HCatBuffer GetType() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EffectInfo
|
||||||
|
{
|
||||||
|
int inSpeed; ///< 播放速度
|
||||||
|
int outSpeed; ///< 播放速度
|
||||||
|
int in; ///< 进入特效
|
||||||
|
int out; ///< 退出特效
|
||||||
|
int duration; ///< 播放时长, 0.1s
|
||||||
|
|
||||||
|
EffectInfo() : inSpeed(5), outSpeed(5), in(0), out(0), duration(50) {}
|
||||||
|
};
|
||||||
|
void to_xml(HXml &xml, const EffectInfo &node);
|
||||||
|
void from_xml(const HXml &xml, EffectInfo &node);
|
||||||
|
|
||||||
|
struct FileInfo {
|
||||||
|
cat::HCatBuffer name;
|
||||||
|
cat::HCatBuffer md5;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
FileInfo() : size(0) {}
|
||||||
|
};
|
||||||
|
void to_xml(HXml &xml, const FileInfo &node);
|
||||||
|
void from_xml(const HXml &xml, FileInfo &node);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <text guid="##guid" singleLine="##singleLine" background="##background" calcMode="##calcMode">
|
||||||
|
* <style valign="##valign" align="##align" />
|
||||||
|
* <string>文本内容</string>
|
||||||
|
* <font name="##name" italic="##italic" bold="##bold" underline="##underline" size="##size" color="##color" />
|
||||||
|
* <effect inSpeed="##inSpeed" duration="##duration" in="##in" outSpeed="##outSpeed" out="##out" />
|
||||||
|
* </text>
|
||||||
|
*/
|
||||||
|
///< 文本节目
|
||||||
|
struct TextInfo : public IProgramNode
|
||||||
|
{
|
||||||
|
struct Style {
|
||||||
|
cat::HCatBuffer valign;
|
||||||
|
cat::HCatBuffer align;
|
||||||
|
Style() : valign("middle"), align("center") {}
|
||||||
|
};
|
||||||
|
struct Font {
|
||||||
|
cat::HCatBuffer name;
|
||||||
|
cat::HCatBuffer color;
|
||||||
|
bool italic;
|
||||||
|
bool bold;
|
||||||
|
bool underline;
|
||||||
|
int size;
|
||||||
|
Font() : color("#FF0000"), italic(false), bold(false), underline(false), size(16) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
cat::HCatBuffer guid;
|
||||||
|
cat::HCatBuffer background; ///< 背景颜色
|
||||||
|
bool singleLine; ///< 是否单行显示
|
||||||
|
Style style; ///< 对齐方式
|
||||||
|
Font font; ///< 字体
|
||||||
|
EffectInfo effect; ///< 特效
|
||||||
|
cat::HCatBuffer text; ///< 文本
|
||||||
|
|
||||||
|
TextInfo() : guid("textGuid"), singleLine(false) {}
|
||||||
|
|
||||||
|
virtual void ToXml(HXml &xml) override { xml.NewChild(GetType()).ToXml(*this); }
|
||||||
|
virtual bool FromXml(const HXml &xml) override { return xml.get_to(*this); }
|
||||||
|
virtual cat::HCatBuffer GetType() const override { return "text"; }
|
||||||
|
};
|
||||||
|
void to_xml(HXml &xml, const TextInfo &node);
|
||||||
|
void from_xml(const HXml &xml, TextInfo &node);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <image guid="##guid" fit="##fit">
|
||||||
|
* <file name="name" />
|
||||||
|
* <effect inSpeed="##inSpeed" duration="##duration" in="##in" outSpeed="##outSpeed" out="##out"/>
|
||||||
|
* </image>
|
||||||
|
*/
|
||||||
|
///< 图片节目
|
||||||
|
struct PhotoInfo : public IProgramNode
|
||||||
|
{
|
||||||
|
cat::HCatBuffer guid;
|
||||||
|
cat::HCatBuffer fit; ///< 填充
|
||||||
|
EffectInfo effect; ///< 特效
|
||||||
|
FileInfo file; ///< 图片文件
|
||||||
|
|
||||||
|
PhotoInfo() : guid("photoGuid"), fit("stretch") {}
|
||||||
|
virtual void ToXml(HXml &xml) override { xml.NewChild(GetType()).ToXml(*this); }
|
||||||
|
virtual bool FromXml(const HXml &xml) override { return xml.get_to(*this); }
|
||||||
|
virtual cat::HCatBuffer GetType() const override { return "image"; }
|
||||||
|
};
|
||||||
|
void to_xml(HXml &xml, const PhotoInfo &node);
|
||||||
|
void from_xml(const HXml &xml, PhotoInfo &node);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <video guid="##guid" aspectRatio="##aspectRatio">
|
||||||
|
* <file name="##name" />
|
||||||
|
* <playParams duration="##duration"/>
|
||||||
|
* </video>
|
||||||
|
*/
|
||||||
|
///< 视频节目
|
||||||
|
struct VideoInfo : public IProgramNode
|
||||||
|
{
|
||||||
|
struct PlayParams {
|
||||||
|
int duration;
|
||||||
|
|
||||||
|
PlayParams() : duration(500) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
cat::HCatBuffer guid;
|
||||||
|
bool aspectRatio;
|
||||||
|
FileInfo file;
|
||||||
|
PlayParams playParams;
|
||||||
|
|
||||||
|
VideoInfo() : guid("videoGuid"), aspectRatio(false) {}
|
||||||
|
virtual void ToXml(HXml &xml) override { xml.NewChild(GetType()).ToXml(*this); }
|
||||||
|
virtual bool FromXml(const HXml &xml) override { return xml.get_to(*this); }
|
||||||
|
virtual cat::HCatBuffer GetType() const override { return "video"; }
|
||||||
|
};
|
||||||
|
void to_xml(HXml &xml, const VideoInfo &node);
|
||||||
|
void from_xml(const HXml &xml, VideoInfo &node);
|
||||||
|
|
||||||
|
///< 节目资源信息
|
||||||
|
struct ResourcesInfo
|
||||||
|
{
|
||||||
|
std::list<std::shared_ptr<IProgramNode>> nodeList; ///< 节目列表
|
||||||
|
};
|
||||||
|
void to_xml(HXml &xml, const ResourcesInfo &node);
|
||||||
|
void from_xml(const HXml &xml, ResourcesInfo &node);
|
||||||
|
|
||||||
|
///< 区域节点信息
|
||||||
|
struct AreaNodeInfo
|
||||||
|
{
|
||||||
|
struct rectangle {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
rectangle() : x(0), y(0), width(8), height(8) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
cat::HCatBuffer guid; ///< 区域guid
|
||||||
|
int alpha; ///< 区域透明度
|
||||||
|
rectangle rect; ///< 区域位置
|
||||||
|
ResourcesInfo resource; ///< 区域资源
|
||||||
|
|
||||||
|
AreaNodeInfo() : guid("areaGuid"), alpha(255) {}
|
||||||
|
};
|
||||||
|
void to_xml(HXml &xml, const AreaNodeInfo &node);
|
||||||
|
void from_xml(const HXml &xml, AreaNodeInfo &node);
|
||||||
|
|
||||||
|
///< 节目节点信息
|
||||||
|
struct ProgramNodeInfo
|
||||||
|
{
|
||||||
|
cat::HCatBuffer guid; ///< 节目guid
|
||||||
|
std::vector<AreaNodeInfo> areaList; ///< 区域列表
|
||||||
|
|
||||||
|
ProgramNodeInfo() : guid("programGuid") {}
|
||||||
|
};
|
||||||
|
void to_xml(HXml &xml, const ProgramNodeInfo &node);
|
||||||
|
void from_xml(const HXml &xml, ProgramNodeInfo &node);
|
||||||
|
|
||||||
|
///< 屏幕节点信息
|
||||||
|
struct ScreenNodeInfo
|
||||||
|
{
|
||||||
|
int timeStamps; ///< 时间戳, 和设备节目不同时清空节目
|
||||||
|
std::vector<ProgramNodeInfo> programList; ///< 节目节点
|
||||||
|
std::list<std::shared_ptr<IProgramNode>> nodeList; ///< 缓存节目列表, 发送节目的时候清空, 避免外部使用者导致内存泄漏
|
||||||
|
|
||||||
|
ScreenNodeInfo() : timeStamps(0) {}
|
||||||
|
|
||||||
|
static bool MatchGet(const cat::HCatBuffer &item) { return item == "GetProgram"; }
|
||||||
|
static bool MatchSet(const cat::HCatBuffer &item) { return item == "AddProgram"; }
|
||||||
|
static cat::HCatBuffer GetMethod() { return "GetProgram"; }
|
||||||
|
static cat::HCatBuffer SetMethod() { return "AddProgram"; }
|
||||||
|
};
|
||||||
|
void to_xml(HXml &xml, const ScreenNodeInfo &node);
|
||||||
|
void from_xml(const HXml &xml, ScreenNodeInfo &node);
|
||||||
|
|
||||||
|
|
||||||
|
#endif // HPROGRAMINFO_H
|
||||||
@ -58,6 +58,7 @@ int HSDKInfo::ParseInfo(tinyxml2::XMLElement *outNode, const cat::HCatBuffer &me
|
|||||||
UPDATE_NODE(relayInfo);
|
UPDATE_NODE(relayInfo);
|
||||||
UPDATE_NODE(timeInfo);
|
UPDATE_NODE(timeInfo);
|
||||||
UPDATE_NODE(switchProgramInfo);
|
UPDATE_NODE(switchProgramInfo);
|
||||||
|
UPDATE_NODE(programInfo);
|
||||||
|
|
||||||
UPDATE_GET_NODE(deviceInfo);
|
UPDATE_GET_NODE(deviceInfo);
|
||||||
UPDATE_GET_NODE(screenShot2);
|
UPDATE_GET_NODE(screenShot2);
|
||||||
|
|||||||
@ -11,9 +11,8 @@
|
|||||||
#include <Data/HScreenFunctionInfo.h>
|
#include <Data/HScreenFunctionInfo.h>
|
||||||
#include <Data/HSensorInfo.h>
|
#include <Data/HSensorInfo.h>
|
||||||
#include <Data/HTimeInfo.h>
|
#include <Data/HTimeInfo.h>
|
||||||
|
#include <Data/HProgramInfo.h>
|
||||||
#include <tinyxml2.h>
|
#include <tinyxml2.h>
|
||||||
#include <memory>
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
|
|
||||||
namespace sdk
|
namespace sdk
|
||||||
@ -35,6 +34,7 @@ struct HSDKInfo
|
|||||||
RelayInfo relayInfo; ///< 继电器
|
RelayInfo relayInfo; ///< 继电器
|
||||||
TimeInfo timeInfo; ///< 时间
|
TimeInfo timeInfo; ///< 时间
|
||||||
SwitchProgramInfo switchProgramInfo; ///< 切换节目和获取当前节目的guid
|
SwitchProgramInfo switchProgramInfo; ///< 切换节目和获取当前节目的guid
|
||||||
|
ScreenNodeInfo programInfo; ///< 节目
|
||||||
|
|
||||||
///< 下面是只有获取项的
|
///< 下面是只有获取项的
|
||||||
DeviceInfo deviceInfo; ///< 设备信息
|
DeviceInfo deviceInfo; ///< 设备信息
|
||||||
|
|||||||
186
SDK/SDKInfo.cpp
186
SDK/SDKInfo.cpp
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "HDSDK.h"
|
#include "HDSDK.h"
|
||||||
|
#include "HProgramInfo.h"
|
||||||
#include "HScreenFunctionInfo.h"
|
#include "HScreenFunctionInfo.h"
|
||||||
#include "HSensorInfo.h"
|
#include "HSensorInfo.h"
|
||||||
#include <SDKInfo.h>
|
#include <SDKInfo.h>
|
||||||
@ -77,6 +78,11 @@ HBool UpdateItem(IHDProtocol protocol, ISDKInfo info, int updateItem)
|
|||||||
return HFalse;
|
return HFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 清空播放节点缓存, 避免用户乱操作导致内存泄漏
|
||||||
|
if (info->programInfo.nodeList.empty() == false) {
|
||||||
|
info->programInfo.nodeList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
HXml xml;
|
HXml xml;
|
||||||
xml["sdk"] = {"guid", "##GUID"};
|
xml["sdk"] = {"guid", "##GUID"};
|
||||||
|
|
||||||
@ -105,7 +111,6 @@ HBool UpdateItem(IHDProtocol protocol, ISDKInfo info, int updateItem)
|
|||||||
GET_ITEM(getItem, obj); \
|
GET_ITEM(getItem, obj); \
|
||||||
SET_ITEM(setItem, obj);
|
SET_ITEM(setItem, obj);
|
||||||
|
|
||||||
|
|
||||||
switch (updateItem) {
|
switch (updateItem) {
|
||||||
GET_SET_ITEM(kGetLightInfo, kSetLightInfo, info->lightInfo);
|
GET_SET_ITEM(kGetLightInfo, kSetLightInfo, info->lightInfo);
|
||||||
GET_SET_ITEM(kGetSystemVolumeInfo, kSetSystemVolumeInfo, info->systemVolumeInfo);
|
GET_SET_ITEM(kGetSystemVolumeInfo, kSetSystemVolumeInfo, info->systemVolumeInfo);
|
||||||
@ -118,6 +123,7 @@ HBool UpdateItem(IHDProtocol protocol, ISDKInfo info, int updateItem)
|
|||||||
GET_SET_ITEM(kGetSwitchTimeInfo, kSetSwitchTimeInfo, info->switchTimeInfo);
|
GET_SET_ITEM(kGetSwitchTimeInfo, kSetSwitchTimeInfo, info->switchTimeInfo);
|
||||||
GET_SET_ITEM(kGetRelayInfo, kSetRelayInfo, info->relayInfo);
|
GET_SET_ITEM(kGetRelayInfo, kSetRelayInfo, info->relayInfo);
|
||||||
GET_SET_ITEM(kGetCurrProgramGuid, kSetCurrProgramGuid, info->switchProgramInfo);
|
GET_SET_ITEM(kGetCurrProgramGuid, kSetCurrProgramGuid, info->switchProgramInfo);
|
||||||
|
GET_SET_ITEM(kGetProgram, kAddProgram, info->programInfo);
|
||||||
|
|
||||||
GET_ITEM(kGetDeviceInfo, info->deviceInfo);
|
GET_ITEM(kGetDeviceInfo, info->deviceInfo);
|
||||||
GET_DATA_ITEM(kGetScreenShot, info->screenShot2);
|
GET_DATA_ITEM(kGetScreenShot, info->screenShot2);
|
||||||
@ -843,3 +849,181 @@ int GetScreenShotSize(sdk::ISDKInfo info)
|
|||||||
{
|
{
|
||||||
return info->screenShot2.rawData.Size();
|
return info->screenShot2.rawData.Size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DLL_CALL SetScreenNode(ISDKInfo info, int timeStamp)
|
||||||
|
{
|
||||||
|
info->programInfo.timeStamps = timeStamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DLL_CALL AddProgramNode(ISDKInfo info, const char *guid)
|
||||||
|
{
|
||||||
|
ProgramNodeInfo node;
|
||||||
|
node.guid = cat::HCatBuffer(guid);
|
||||||
|
info->programInfo.programList.emplace_back(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DLL_CALL AddAreaNode(ISDKInfo info, int programIndex, const char *guid, int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
if (info->programInfo.programList.empty()) {
|
||||||
|
AddProgramNode(info, "DefaultProgramGuid");
|
||||||
|
}
|
||||||
|
|
||||||
|
AreaNodeInfo node;
|
||||||
|
node.guid = cat::HCatBuffer(guid);
|
||||||
|
node.rect.x = x;
|
||||||
|
node.rect.y = y;
|
||||||
|
node.rect.width = width;
|
||||||
|
node.rect.height = height;
|
||||||
|
|
||||||
|
programIndex = programIndex % info->programInfo.programList.size();
|
||||||
|
info->programInfo.programList[programIndex].areaList.emplace_back(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DLL_CALL ModifyAreaNode(ISDKInfo info, int programIndex, int areaIndex, int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
if (info->programInfo.programList.empty()) {
|
||||||
|
AddProgramNode(info, "DefaultProgramGuid");
|
||||||
|
}
|
||||||
|
|
||||||
|
programIndex = programIndex % info->programInfo.programList.size();
|
||||||
|
if (info->programInfo.programList[programIndex].areaList.empty()) {
|
||||||
|
AddAreaNode(info, 0, "DefaultAreaGuid", x, y, width, height);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
areaIndex = areaIndex % info->programInfo.programList.at(programIndex).areaList.size();
|
||||||
|
info->programInfo.programList[programIndex].areaList[areaIndex].rect.x = x;
|
||||||
|
info->programInfo.programList[programIndex].areaList[areaIndex].rect.y = y;
|
||||||
|
info->programInfo.programList[programIndex].areaList[areaIndex].rect.width = width;
|
||||||
|
info->programInfo.programList[programIndex].areaList[areaIndex].rect.height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPlayNode DLL_CALL CreateTextNode(ISDKInfo info, const char *guid, const char *text)
|
||||||
|
{
|
||||||
|
std::shared_ptr<TextInfo> node(new TextInfo());
|
||||||
|
node->guid = cat::HCatBuffer(guid);
|
||||||
|
node->text = cat::HCatBuffer(text);
|
||||||
|
info->programInfo.nodeList.push_back(node);
|
||||||
|
return node.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
HBool DLL_CALL ModifyTextStyle(IPlayNode node, const char *valign, const char *align)
|
||||||
|
{
|
||||||
|
TextInfo *text = dynamic_cast<TextInfo *>(node);
|
||||||
|
if (text == nullptr) {
|
||||||
|
return HFalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
text->style.valign = cat::HCatBuffer(valign);
|
||||||
|
text->style.align = cat::HCatBuffer(align);
|
||||||
|
return HTrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
HBool DLL_CALL ModifyTextFont(IPlayNode node, const char *fontName, int fontSize, const char *color, HBool underline, HBool bold, HBool italic)
|
||||||
|
{
|
||||||
|
TextInfo *text = dynamic_cast<TextInfo *>(node);
|
||||||
|
if (text == nullptr) {
|
||||||
|
return HFalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
text->font.name = cat::HCatBuffer(fontName);
|
||||||
|
text->font.size = fontSize;
|
||||||
|
text->font.color = cat::HCatBuffer(color);
|
||||||
|
text->font.underline = underline;
|
||||||
|
text->font.bold = bold;
|
||||||
|
text->font.italic = italic;
|
||||||
|
return HTrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPlayNode DLL_CALL CreateImageNode(ISDKInfo info, const char *guid, const char *imageName)
|
||||||
|
{
|
||||||
|
std::shared_ptr<PhotoInfo> node(new PhotoInfo());
|
||||||
|
node->guid = cat::HCatBuffer(guid);
|
||||||
|
node->file.name = cat::HCatBuffer(imageName);
|
||||||
|
info->programInfo.nodeList.push_back(node);
|
||||||
|
return node.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
IPlayNode DLL_CALL CreateVideoNode(ISDKInfo info, const char *guid, const char *videoName, HBool aspectRatio)
|
||||||
|
{
|
||||||
|
std::shared_ptr<VideoInfo> node(new VideoInfo());
|
||||||
|
node->guid = cat::HCatBuffer(guid);
|
||||||
|
node->file.name = cat::HCatBuffer(videoName);
|
||||||
|
node->aspectRatio = aspectRatio;
|
||||||
|
info->programInfo.nodeList.push_back(node);
|
||||||
|
return node.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
HBool DLL_CALL ModifyFilePath(IPlayNode node, const char *name, const char *md5, int size)
|
||||||
|
{
|
||||||
|
PhotoInfo *photo = dynamic_cast<PhotoInfo *>(node);
|
||||||
|
if (photo != nullptr) {
|
||||||
|
photo->file.name = cat::HCatBuffer(name);
|
||||||
|
photo->file.md5 = cat::HCatBuffer(md5);
|
||||||
|
photo->file.size = size;
|
||||||
|
return HTrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
VideoInfo *video = dynamic_cast<VideoInfo *>(node);
|
||||||
|
if (video != nullptr) {
|
||||||
|
video->file.name = cat::HCatBuffer(name);
|
||||||
|
video->file.md5 = cat::HCatBuffer(md5);
|
||||||
|
video->file.size = size;
|
||||||
|
return HTrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return HFalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
HBool DLL_CALL ModifyPlayEffect(IPlayNode node, int in, int out, int outSpeed, int inSpeed, int duration)
|
||||||
|
{
|
||||||
|
PhotoInfo *photo = dynamic_cast<PhotoInfo *>(node);
|
||||||
|
if (photo != nullptr) {
|
||||||
|
photo->effect.in = in;
|
||||||
|
photo->effect.out = out;
|
||||||
|
photo->effect.outSpeed = outSpeed;
|
||||||
|
photo->effect.inSpeed = inSpeed;
|
||||||
|
photo->effect.duration = duration;
|
||||||
|
return HTrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextInfo *text = dynamic_cast<TextInfo *>(node);
|
||||||
|
if (text != nullptr) {
|
||||||
|
text->effect.in = in;
|
||||||
|
text->effect.out = out;
|
||||||
|
text->effect.outSpeed = outSpeed;
|
||||||
|
text->effect.inSpeed = inSpeed;
|
||||||
|
text->effect.duration = duration;
|
||||||
|
return HTrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return HFalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
HBool DLL_CALL AddPlayNode(ISDKInfo info, int programIndex, int areaIndex, IPlayNode node)
|
||||||
|
{
|
||||||
|
for (auto it = info->programInfo.nodeList.begin(); it != info->programInfo.nodeList.end(); it++) {
|
||||||
|
auto i = *it;
|
||||||
|
if (i.get() != node) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info->programInfo.programList.empty()) {
|
||||||
|
AddProgramNode(info, "DefaultProgramGuid");
|
||||||
|
}
|
||||||
|
|
||||||
|
programIndex = programIndex % info->programInfo.programList.size();
|
||||||
|
if (info->programInfo.programList.at(programIndex).areaList.empty()) {
|
||||||
|
AddAreaNode(info, programIndex, "DefaultAreaGuid", 0, 0, 8, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
info->programInfo.nodeList.erase(it);
|
||||||
|
|
||||||
|
areaIndex = areaIndex % info->programInfo.programList.at(programIndex).areaList.size();
|
||||||
|
info->programInfo.programList[programIndex].areaList[areaIndex].resource.nodeList.emplace_back(std::move(i));
|
||||||
|
return HTrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return HFalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,9 +10,11 @@
|
|||||||
namespace sdk{
|
namespace sdk{
|
||||||
typedef struct HSDKInfo* ISDKInfo;
|
typedef struct HSDKInfo* ISDKInfo;
|
||||||
}
|
}
|
||||||
|
typedef struct IProgramNode* IPlayNode;
|
||||||
using sdk::ISDKInfo;
|
using sdk::ISDKInfo;
|
||||||
#else
|
#else
|
||||||
typedef void* ISDKInfo;
|
typedef void* ISDKInfo;
|
||||||
|
typedef void* IPlayNode;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -49,6 +51,8 @@ enum eUpdateItem {
|
|||||||
kSetRelayInfo = 0x1019, ///< 设置继电器信息
|
kSetRelayInfo = 0x1019, ///< 设置继电器信息
|
||||||
kGetCurrProgramGuid = 0x1020, ///< 获取当前节目guid
|
kGetCurrProgramGuid = 0x1020, ///< 获取当前节目guid
|
||||||
kSetCurrProgramGuid = 0x1021, ///< 设置当前节目guid
|
kSetCurrProgramGuid = 0x1021, ///< 设置当前节目guid
|
||||||
|
kGetProgram = 0x1022, ///< 获取节目
|
||||||
|
kAddProgram = 0x1023, ///< 发送节目
|
||||||
|
|
||||||
///< 没有设置项, 只有获取项
|
///< 没有设置项, 只有获取项
|
||||||
kGetDeviceInfo = 0x2000, ///< 获取设备信息
|
kGetDeviceInfo = 0x2000, ///< 获取设备信息
|
||||||
@ -255,6 +259,101 @@ HD_API void DLL_CALL SetCurrProgramGuid(ISDKInfo info, const char *guid, int ind
|
|||||||
HD_API const char * DLL_CALL GetCurrProgramGuid(ISDKInfo info);
|
HD_API const char * DLL_CALL GetCurrProgramGuid(ISDKInfo info);
|
||||||
|
|
||||||
|
|
||||||
|
///< 下面是创建节目信息
|
||||||
|
/**
|
||||||
|
* @brief SetScreenNode 配置屏幕节点
|
||||||
|
* @param info 信息体
|
||||||
|
* @param timeStamp 时间戳(和上一次不一致将清空节目)
|
||||||
|
*/
|
||||||
|
HD_API void DLL_CALL SetScreenNode(ISDKInfo info, int timeStamp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief AddProgramNode 添加节目节点
|
||||||
|
* @param info 信息体
|
||||||
|
* @param guid 节目guid
|
||||||
|
*/
|
||||||
|
HD_API void DLL_CALL AddProgramNode(ISDKInfo info, const char *guid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief AddAreaNode 添加区域节点
|
||||||
|
* @param info 信息体
|
||||||
|
* @param programIndex 节目索引
|
||||||
|
* @param guid 区域guid
|
||||||
|
* @param x 区域x坐标
|
||||||
|
* @param y 区域y坐标
|
||||||
|
* @param width 区域宽度
|
||||||
|
* @param height 区域高度
|
||||||
|
*/
|
||||||
|
HD_API void DLL_CALL AddAreaNode(ISDKInfo info, int programIndex, const char *guid, int x, int y, int width, int height);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ModifyAreaNode 修改区域节点
|
||||||
|
* @param info 信息体
|
||||||
|
* @param programIndex 节目索引
|
||||||
|
* @param areaIndex 需要修改的区域索引
|
||||||
|
* @param x 区域x坐标
|
||||||
|
* @param y 区域y坐标
|
||||||
|
* @param width 区域宽度
|
||||||
|
* @param height 区域高度
|
||||||
|
*/
|
||||||
|
HD_API void DLL_CALL ModifyAreaNode(ISDKInfo info, int programIndex, int areaIndex, int x, int y, int width, int height);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief CreateTextNode 创建文本节点
|
||||||
|
* @param info 信息体
|
||||||
|
* @param guid 节点guid
|
||||||
|
* @param text 文本
|
||||||
|
* @return 返回播放节点
|
||||||
|
*/
|
||||||
|
HD_API IPlayNode DLL_CALL CreateTextNode(ISDKInfo info, const char *guid, const char *text);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ModifyTextNode 修改文本节点
|
||||||
|
* @param node 播放节点
|
||||||
|
* @param valign 垂直对齐方式
|
||||||
|
* @param align 水平对齐方式
|
||||||
|
* @return 返回是否成功
|
||||||
|
*/
|
||||||
|
HD_API HBool DLL_CALL ModifyTextStyle(IPlayNode node, const char *valign, const char *align);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ModifyTextFont 修改字体
|
||||||
|
* @param node 播放节点
|
||||||
|
* @param fontName 字体名称
|
||||||
|
* @param fontSize 字体大小
|
||||||
|
* @param color 字体颜色
|
||||||
|
* @param underline 是否下划线
|
||||||
|
* @param bold 是否加粗
|
||||||
|
* @param italic 是否斜体
|
||||||
|
* @return 返回是否成功
|
||||||
|
*/
|
||||||
|
HD_API HBool DLL_CALL ModifyTextFont(IPlayNode node, const char *fontName, int fontSize, const char *color, HBool underline, HBool bold, HBool italic);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief CreateImageNode 创建图片节点
|
||||||
|
* @param info 信息体
|
||||||
|
* @param guid 节点guid
|
||||||
|
* @param imageName 图片文件名
|
||||||
|
* @return 返回播放节点
|
||||||
|
*/
|
||||||
|
HD_API IPlayNode DLL_CALL CreateImageNode(ISDKInfo info, const char *guid, const char *imageName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief CreateVideoNode 创建视频节点
|
||||||
|
* @param info 信息体
|
||||||
|
* @param guid 节点guid
|
||||||
|
* @param videoName 视频文件名
|
||||||
|
* @param aspectRatio 是否保持宽高比(不一定有效, 给默认false)
|
||||||
|
* @return 返回播放节点
|
||||||
|
*/
|
||||||
|
HD_API IPlayNode DLL_CALL CreateVideoNode(ISDKInfo info, const char *guid, const char *videoName, HBool aspectRatio);
|
||||||
|
|
||||||
|
///< 这里播放节点通用操作, 分别是修改文件路径, 修改节目特效, 添加播放节点到当前区域
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
///< 下面是获取
|
///< 下面是获取
|
||||||
|
|
||||||
///< 获取设备信息系列
|
///< 获取设备信息系列
|
||||||
|
|||||||
115
demo/sendProgram.cpp
Normal file
115
demo/sendProgram.cpp
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#include "../SDK/SDKInfo.h"
|
||||||
|
|
||||||
|
|
||||||
|
int IsRead = 0;
|
||||||
|
|
||||||
|
static bool SendData(const char *data, int len, void *userData) {
|
||||||
|
int fd = (int)(intptr_t)userData;
|
||||||
|
printf("send[%s]\n", data + 12);
|
||||||
|
return write(fd, data, len) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ReadXml(const char *xml, int len, int errorCode, void *userData) {
|
||||||
|
(void)len;
|
||||||
|
(void)userData;
|
||||||
|
++IsRead;
|
||||||
|
if (errorCode != 0) {
|
||||||
|
printf("error code[%d]\n", errorCode);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
char **p = (char **)(userData);
|
||||||
|
free(*p);
|
||||||
|
*p = (char *)malloc(len);
|
||||||
|
memcpy(*p, xml, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
printf("a.out ip\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
if (fd < 0) {
|
||||||
|
perror("create socket faild");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sockaddr_in addrSrv;
|
||||||
|
memset(&addrSrv, 0, sizeof(addrSrv));
|
||||||
|
addrSrv.sin_family = AF_INET;
|
||||||
|
addrSrv.sin_port = htons(10001);
|
||||||
|
addrSrv.sin_addr.s_addr = inet_addr(argv[1]);
|
||||||
|
|
||||||
|
int result = connect(fd, reinterpret_cast<struct sockaddr *>(&addrSrv), sizeof(addrSrv));
|
||||||
|
if (result < 0) {
|
||||||
|
close(fd);
|
||||||
|
perror("Not connect client");
|
||||||
|
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);
|
||||||
|
|
||||||
|
RunProtocol(proto);
|
||||||
|
|
||||||
|
UpdateItem(proto, sdkInfo, kGetProgram);
|
||||||
|
|
||||||
|
char buff[1024];
|
||||||
|
for (;;) {
|
||||||
|
int len = read(fd, buff, sizeof(buff));
|
||||||
|
if (len <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateReadData(proto, buff, len);
|
||||||
|
if (IsRead > 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("read xml[\n%s]\n", p_buff);
|
||||||
|
|
||||||
|
IsRead = 0;
|
||||||
|
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));
|
||||||
|
if (len <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateReadData(proto, buff, len);
|
||||||
|
if (IsRead > 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("read xml[\n%s]\n", p_buff);
|
||||||
|
free(p_buff);
|
||||||
|
FreeSDKInfo(sdkInfo);
|
||||||
|
FreeProtocol(proto);
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user