-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathxml_record.go
68 lines (60 loc) · 2.19 KB
/
xml_record.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"context"
"encoding/xml"
"fmt"
"github.com/ghettovoice/gosip/sip"
)
const (
QueryRecordFormat = "<?xml version=\"1.0\"?>\r\n" +
"<Query>\r\n" +
"<CmdType>RecordInfo</CmdType>\r\n" +
"<SN>%d</SN>\r\n" +
"<DeviceID>%s</DeviceID>\r\n" +
"<StartTime>%s</StartTime>\r\n" +
"<EndTime>%s</EndTime>\r\n" +
"<Type>%s</Type>\r\n" +
"</Query>\r\n"
SeekBodyFormat = "PLAY RTSP/1.0\r\n" + "CSeq: %d\r\n" + "Range: npt=%d-\r\n"
)
var (
RtspMessageType sip.ContentType = "application/RTSP"
)
type QueryRecordInfoResponse struct {
XMLName xml.Name `xml:"Response"`
CmdType string `xml:"CmdType"`
SN int `xml:"SN"`
DeviceID string `xml:"DeviceID"`
SumNum int `xml:"SumNum"`
DeviceList RecordList `xml:"RecordList"`
}
type RecordList struct {
Num int `xml:"Num,attr"`
Devices []RecordInfo `xml:"Item"`
cancelFunction *context.CancelFunc
}
type RecordInfo struct {
FileSize uint64 `xml:"FileSize" json:"fileSize"`
StartTime string `xml:"StartTime" json:"startTime"`
EndTime string `xml:"EndTime" json:"endTime"`
FilePath string `xml:"FilePath" json:"filePath"`
ResourceType string `xml:"ResourceType" json:"type"`
ResourceId string `xml:"ResourceId" json:"resourceId"`
RecorderId string `xml:"RecorderId" json:"recorderId"`
UserId string `xml:"UserId" json:"userId"`
UserName string `xml:"UserName" json:"userName"`
ResourceName string `xml:"ResourceName" json:"resourceName"`
ResourceLength string `xml:"ResourceLength" json:"resourceLength"`
ImportTime string `xml:"ImportTime" json:"importTime"`
ResourceUrl string `xml:"ResourceUrl" json:"resourceUrl"`
Remark string `xml:"Remark" json:"remark"`
Level string `xml:"Level" json:"level"`
BootTime string `xml:"BootTime" json:"bootTime"`
ShutdownTime string `xml:"ShutdownTime" json:"shutdownTime"`
}
func (d *Device) DoQueryRecordList(channelId, startTime, endTime string, sn int, type_ string) error {
body := fmt.Sprintf(QueryRecordFormat, sn, channelId, startTime, endTime, type_)
request := d.BuildMessageRequest(channelId, body)
SipUA.SendRequest(request)
return nil
}