This commit is contained in:
haibo.chen
2025-10-15 10:05:52 +08:00
parent d9709f61a5
commit 156f07644d
18 changed files with 1222 additions and 1227 deletions

View File

@ -1,106 +1,106 @@
package models
import "encoding/xml"
type Record struct {
DeviceID string `xml:"DeviceID" json:"device_id"`
Name string `xml:"Name" json:"name"`
FilePath string `xml:"FilePath" json:"file_path"`
Address string `xml:"Address" json:"address"`
StartTime string `xml:"StartTime" json:"start_time"`
EndTime string `xml:"EndTime" json:"end_time"`
Secrecy int `xml:"Secrecy" json:"secrecy"`
Type string `xml:"Type" json:"type"`
}
// Example XML structure for channel info:
//
// <Item>
// <DeviceID>34020000001320000002</DeviceID>
// <Name>209</Name>
// <Manufacturer>UNIVIEW</Manufacturer>
// <Model>HIC6622-IR@X33-VF</Model>
// <Owner>IPC-B2202.7.11.230222</Owner>
// <CivilCode>CivilCode</CivilCode>
// <Address>Address</Address>
// <Parental>1</Parental>
// <ParentID>75015310072008100002</ParentID>
// <SafetyWay>0</SafetyWay>
// <RegisterWay>1</RegisterWay>
// <Secrecy>0</Secrecy>
// <Status>ON</Status>
// <Longitude>0.0000000</Longitude>
// <Latitude>0.0000000</Latitude>
// <Info>
// <PTZType>1</PTZType>
// <Resolution>6/4/2</Resolution>
// <DownloadSpeed>0</DownloadSpeed>
// </Info>
// </Item>
type ChannelInfo struct {
DeviceID string `json:"device_id"`
ParentID string `json:"parent_id"`
Name string `json:"name"`
Manufacturer string `json:"manufacturer"`
Model string `json:"model"`
Owner string `json:"owner"`
CivilCode string `json:"civil_code"`
Address string `json:"address"`
Port int `json:"port"`
Parental int `json:"parental"`
SafetyWay int `json:"safety_way"`
RegisterWay int `json:"register_way"`
Secrecy int `json:"secrecy"`
IPAddress string `json:"ip_address"`
Status ChannelStatus `json:"status"`
Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"`
Info struct {
PTZType int `json:"ptz_type"`
Resolution string `json:"resolution"`
DownloadSpeed string `json:"download_speed"` // Speed levels: 1/2/4/8
} `json:"info"`
// Custom fields
Ssrc string `json:"ssrc"`
}
type ChannelStatus string
// BasicParam
// <! -- 基本参数配置(可选)-->
// <elementname="BasicParam"minOccurs="0">
// <complexType>
// <sequence>
// <! -- 设备名称(可选)-->
// <elementname="Name"type="string" minOccurs="0"/>
// <! -- 注册过期时间(可选)-->
// <elementname="Expiration"type="integer" minOccurs="0"/>
// <! -- 心跳间隔时间(可选)-->
// <elementname="HeartBeatInterval"type="integer" minOccurs="0"/>
// <! -- 心跳超时次数(可选)-->
// <elementname="HeartBeatCount"type="integer" minOccurs="0"/>
// </sequence>
// </complexType>
type BasicParam struct {
Name string `xml:"Name"`
Expiration int `xml:"Expiration"`
HeartBeatInterval int `xml:"HeartBeatInterval"`
HeartBeatCount int `xml:"HeartBeatCount"`
}
type XmlMessageInfo struct {
XMLName xml.Name
CmdType string
SN int
DeviceID string
DeviceName string
Manufacturer string
Model string
Channel string
DeviceList []ChannelInfo `xml:"DeviceList>Item"`
RecordList []*Record `xml:"RecordList>Item"`
BasicParam BasicParam `xml:"BasicParam"`
SumNum int
}
package models
import "encoding/xml"
type Record struct {
DeviceID string `xml:"DeviceID" json:"device_id"`
Name string `xml:"Name" json:"name"`
FilePath string `xml:"FilePath" json:"file_path"`
Address string `xml:"Address" json:"address"`
StartTime string `xml:"StartTime" json:"start_time"`
EndTime string `xml:"EndTime" json:"end_time"`
Secrecy int `xml:"Secrecy" json:"secrecy"`
Type string `xml:"Type" json:"type"`
}
// Example XML structure for channel info:
//
// <Item>
// <DeviceID>34020000001320000002</DeviceID>
// <Name>209</Name>
// <Manufacturer>UNIVIEW</Manufacturer>
// <Model>HIC6622-IR@X33-VF</Model>
// <Owner>IPC-B2202.7.11.230222</Owner>
// <CivilCode>CivilCode</CivilCode>
// <Address>Address</Address>
// <Parental>1</Parental>
// <ParentID>75015310072008100002</ParentID>
// <SafetyWay>0</SafetyWay>
// <RegisterWay>1</RegisterWay>
// <Secrecy>0</Secrecy>
// <Status>ON</Status>
// <Longitude>0.0000000</Longitude>
// <Latitude>0.0000000</Latitude>
// <Info>
// <PTZType>1</PTZType>
// <Resolution>6/4/2</Resolution>
// <DownloadSpeed>0</DownloadSpeed>
// </Info>
// </Item>
type ChannelInfo struct {
DeviceID string `json:"device_id"`
ParentID string `json:"parent_id"`
Name string `json:"name"`
Manufacturer string `json:"manufacturer"`
Model string `json:"model"`
Owner string `json:"owner"`
CivilCode string `json:"civil_code"`
Address string `json:"address"`
Port int `json:"port"`
Parental int `json:"parental"`
SafetyWay int `json:"safety_way"`
RegisterWay int `json:"register_way"`
Secrecy int `json:"secrecy"`
IPAddress string `json:"ip_address"`
Status ChannelStatus `json:"status"`
Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"`
Info struct {
PTZType int `json:"ptz_type"`
Resolution string `json:"resolution"`
DownloadSpeed string `json:"download_speed"` // Speed levels: 1/2/4/8
} `json:"info"`
// Custom fields
Ssrc string `json:"ssrc"`
}
type ChannelStatus string
// BasicParam
// <! -- 基本参数配置(可选)-->
// <elementname="BasicParam"minOccurs="0">
// <complexType>
// <sequence>
// <! -- 设备名称(可选)-->
// <elementname="Name"type="string" minOccurs="0"/>
// <! -- 注册过期时间(可选)-->
// <elementname="Expiration"type="integer" minOccurs="0"/>
// <! -- 心跳间隔时间(可选)-->
// <elementname="HeartBeatInterval"type="integer" minOccurs="0"/>
// <! -- 心跳超时次数(可选)-->
// <elementname="HeartBeatCount"type="integer" minOccurs="0"/>
// </sequence>
// </complexType>
type BasicParam struct {
Name string `xml:"Name"`
Expiration int `xml:"Expiration"`
HeartBeatInterval int `xml:"HeartBeatInterval"`
HeartBeatCount int `xml:"HeartBeatCount"`
}
type XmlMessageInfo struct {
XMLName xml.Name
CmdType string
SN int
DeviceID string
DeviceName string
Manufacturer string
Model string
Channel string
DeviceList []ChannelInfo `xml:"DeviceList>Item"`
RecordList []*Record `xml:"RecordList>Item"`
BasicParam BasicParam `xml:"BasicParam"`
SumNum int
}

View File

@ -1,80 +1,80 @@
package models
type BaseRequest struct {
DeviceID string `json:"device_id"`
ChannelID string `json:"channel_id"`
}
type InviteRequest struct {
BaseRequest
MediaServerId int `json:"media_server_id"`
PlayType int `json:"play_type"` // 0: live, 1: playback, 2: download
SubStream int `json:"sub_stream"`
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
}
type InviteResponse struct {
ChannelID string `json:"channel_id"`
URL string `json:"url"`
}
type SessionRequest struct {
BaseRequest
URL string `json:"url"`
}
type ByeRequest struct {
SessionRequest
}
type PauseRequest struct {
SessionRequest
}
type ResumeRequest struct {
SessionRequest
}
type SpeedRequest struct {
SessionRequest
Speed float32 `json:"speed"`
}
type PTZControlRequest struct {
BaseRequest
PTZ string `json:"ptz"`
Speed string `json:"speed"`
}
type QueryRecordRequest struct {
BaseRequest
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
}
type MediaServer struct {
Name string `json:"name"`
Type string `json:"type"`
IP string `json:"ip"`
Port int `json:"port"`
Username string `json:"username"`
Password string `json:"password"`
Secret string `json:"secret"`
IsDefault int `json:"is_default"`
}
type MediaServerRequest struct {
MediaServer
}
type MediaServerResponse struct {
MediaServer
ID int `json:"id"`
CreatedAt string `json:"created_at"`
}
type CommonResponse struct {
Code int `json:"code"`
Data interface{} `json:"data"`
}
package models
type BaseRequest struct {
DeviceID string `json:"device_id"`
ChannelID string `json:"channel_id"`
}
type InviteRequest struct {
BaseRequest
MediaServerId int `json:"media_server_id"`
PlayType int `json:"play_type"` // 0: live, 1: playback, 2: download
SubStream int `json:"sub_stream"`
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
}
type InviteResponse struct {
ChannelID string `json:"channel_id"`
URL string `json:"url"`
}
type SessionRequest struct {
BaseRequest
URL string `json:"url"`
}
type ByeRequest struct {
SessionRequest
}
type PauseRequest struct {
SessionRequest
}
type ResumeRequest struct {
SessionRequest
}
type SpeedRequest struct {
SessionRequest
Speed float32 `json:"speed"`
}
type PTZControlRequest struct {
BaseRequest
PTZ string `json:"ptz"`
Speed string `json:"speed"`
}
type QueryRecordRequest struct {
BaseRequest
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
}
type MediaServer struct {
Name string `json:"name"`
Type string `json:"type"`
IP string `json:"ip"`
Port int `json:"port"`
Username string `json:"username"`
Password string `json:"password"`
Secret string `json:"secret"`
IsDefault int `json:"is_default"`
}
type MediaServerRequest struct {
MediaServer
}
type MediaServerResponse struct {
MediaServer
ID int `json:"id"`
CreatedAt string `json:"created_at"`
}
type CommonResponse struct {
Code int `json:"code"`
Data interface{} `json:"data"`
}

View File

@ -335,4 +335,3 @@ func TestCommonResponseWithDifferentDataTypes(t *testing.T) {
})
}
}