From 11b19333e1e83f406e48b89f03cd3e923b0b66a7 Mon Sep 17 00:00:00 2001 From: Alexander Lazarenko Date: Sat, 6 Jan 2024 14:56:42 +0300 Subject: [PATCH] Refactor MediaRequestRemotePlayback function to handle end_time parameter --- mediastreammodel.go | 48 +++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/mediastreammodel.go b/mediastreammodel.go index 5c52857..de7dc1f 100644 --- a/mediastreammodel.go +++ b/mediastreammodel.go @@ -58,21 +58,39 @@ func (e *Package) MediaRequestAliveVideo(token int, camNo int64, Sid string, ser // 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) { - 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, + 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, + } } }