package n9m import ( "fmt" "os" ) var ip string = os.Getenv("SERVER_IP") func (e *Package) MediaRequestDownloadVideo(token int, serial string, session string, camNo int, date string, begin_time string, end_time string, recordID string, serverId int) { e.Payload = map[string]any{ "MODULE": "MEDIASTREAMMODEL", "OPERATION": "REQUESTDOWNLOADVIDEO", "PARAMETER": map[string]any{ "PT": 3, "SSRC": 1, "STREAMNAME": "DOWNLOAD" + "_" + serial + "_" + fmt.Sprint(camNo) + "_" + fmt.Sprint(serverId), "STREAMTYPE": 1, // main stream "RECORDID": recordID, "CHANNEL": 1 << (camNo - 1), "STARTTIME": date + begin_time, "ENDTIME": date + end_time, "OFFSETFLAG": 1, "OFFSET": 0, "IPANDPORT": ip + ":12092", "SERIAL": token, "DT": 1, // high speed download }, "SESSION": session, } } // main server util func (e *Package) MediaRequestAliveVideo(token int, camNo int64, Sid string, serial string, quality int64) { channel := 0 if camNo == 1 { channel = 1 } else { channel = 1 << (camNo - 1) } e.Payload = map[string]any{ "MODULE": "MEDIASTREAMMODEL", "OPERATION": "REQUESTALIVEVIDEO", "PARAMETER": map[string]any{ "AUDIOVALID": 1, "CHANNEL": channel, "FRAMEMODE": 0, "IPANDPORT": ip + ":12092", "STREAMNAME": "LIVE" + "_" + serial + "_" + fmt.Sprint(camNo), "STREAMTYPE": quality, "SERIAL": token, }, "SESSION": Sid, } } // main server util func (e *Package) MediaRequestRemotePlayback(token int, serial string, session string, camNo int, date string, begin_time string, end_time string, serverId int) { if end_time == "" { e.Payload = map[string]any{ "MODULE": "MEDIASTREAMMODEL", "OPERATION": "REQUESTREMOTEPLAYBACK", "PARAMETER": map[string]any{ "STREAMNAME": "PLAYBACK" + "_" + fmt.Sprint(serial) + "_" + fmt.Sprint(camNo) + "_" + fmt.Sprint(serverId), "STREAMTYPE": 1, // main stream "VIDEOTYPE": 2, // common files "CHANNEL": 1 << (camNo - 1), "STARTTIME": date + begin_time, "IPANDPORT": ip + ":12092", "SERIAL": token, "PBST": 0, }, "SESSION": session, } } else { e.Payload = map[string]any{ "MODULE": "MEDIASTREAMMODEL", "OPERATION": "REQUESTREMOTEPLAYBACK", "PARAMETER": map[string]any{ "STREAMNAME": "PLAYBACK" + "_" + fmt.Sprint(serial) + "_" + fmt.Sprint(camNo) + "_" + fmt.Sprint(serverId), "STREAMTYPE": 1, // main stream "VIDEOTYPE": 2, // common files "CHANNEL": 1 << (camNo - 1), "STARTTIME": date + begin_time, "ENDTIME": date + end_time, "IPANDPORT": ip + ":12092", "SERIAL": token, "PBST": 0, }, "SESSION": session, } } } // main server util func (e *Package) ControlRemotePlayback(token int, serial string, session string, camNo int, date string, begin_time string, end_time string, serverId int) { e.Payload = map[string]any{ "MODULE": "MEDIASTREAMMODEL", "OPERATION": "CONTROLREMOTEPLAYBACK", "PARAMETER": map[string]any{ "STREAMNAME": fmt.Sprint(serial) + "_" + fmt.Sprint(camNo) + "_" + fmt.Sprint(serverId), "SERIAL": token, "PALYBACKCMD": 5, // main stream "CHANNEL": 268435455, // common files }, "SESSION": session, } }