lang 4 лет назад
Родитель
Сommit
7f093eda1f
2 измененных файлов с 16 добавлено и 2 удалено
  1. 12 2
      controller/deviceStatus.py
  2. 4 0
      controller/index.py

+ 12 - 2
controller/deviceStatus.py

@@ -3,7 +3,7 @@
 """
 """
 import json
-import time
+import time, datetime
 import requests
 import uuid
 import logging
@@ -321,7 +321,17 @@ class deviceStatus(TemplateView):
             return int(result)
         return int(time.time())
 
-
+    # 本地时间转换为UTC  传入的本地时间戳 1531411200
+    # def local_to_utc(self, local_ts, utc_format='%Y-%m-%dT%H:%MZ'):
+    #     import pytz
+    #     local_tz = pytz.timezone('Asia/Chongqing')    #定义本地时区
+    #     local_format = "%Y-%m-%d %H:%M:%S"               #定义本地时间format
+    #
+    #     time_str = time.strftime(local_format, time.localtime(local_ts))    #首先将本地时间戳转化为时间元组,用strftime格式化成字符串
+    #     dt = datetime.datetime.strptime(time_str, local_format)             #将字符串用strptime 转为为datetime中 datetime格式
+    #     local_dt = local_tz.localize(dt, is_dst=None)                       #给时间添加时区,等价于 dt.replace(tzinfo=pytz.timezone('Asia/Chongqing'))
+    #     utc_dt = local_dt.astimezone(pytz.utc)                              #astimezone切换时区
+    #     return utc_dt.strftime(utc_format)                                  #返回世界时间格式
 
     #触发此方法,让摄像头推流到MSG流地址
     def runSendStop(self, UID, PWD, MSG):

+ 4 - 0
controller/index.py

@@ -306,6 +306,8 @@ class oa2RtspStartView(TemplateView):
             # stream_name = threading.Thread(target=self.runSendStop,args=(UID, PWD, MSG))
             # stream_name.start()
             #----------/新增关闭流的线程
+            stop_time = int(time.time()) + 1*60
+            expirationTime = time.strftime('%Y-%m-%dT%H:%MZ',time.localtime(stop_time))
             res_json = {
                 'endpointId': id,
                 'manufacturerName': 'zosi smart',
@@ -313,6 +315,8 @@ class oa2RtspStartView(TemplateView):
                 'modelName': 'P1425-LE',
                 'friendlyName': nick,
                 'description': 'Camera connected via zosi smart',
+                "expirationTime": expirationTime,
+                "idleTimeoutSeconds": 5,
                 #'resolutions': [{'width': 1280, 'height': 720}],
                 'resolutions': [{'width': 640, 'height': 360}],
                 'videoCodecs': ['H264'],