|
@@ -284,26 +284,37 @@ class oa2RtspStartView(TemplateView):
|
|
|
else:
|
|
|
return JsonResponse({'msg': 'stop no', 'code': 0})
|
|
|
|
|
|
+ # pushtool指令
|
|
|
+ command = "./pushtool {UID} {PWD} {MSG} 1 {channel}".format(UID=UID, PWD=PWD, MSG=MSG, channel=channel)
|
|
|
# 请求MQTT发布消息
|
|
|
- url = '{}/iot/requestPublishMessage'.format(SERVER_PREFIX_TEST) # 测试服务器
|
|
|
+ url = '{}/iot/requestPublishMessage'.format(SERVER_PREFIX)
|
|
|
requests_data = {'UID': UID, 'rtsp': MSG, 'enable': '1'} # 1: 开始推流,0: 停止推流; channel: 推流通道
|
|
|
r = requests.post(url, requests_data)
|
|
|
- if r.status_code != 200:
|
|
|
- return JsonResponse({'错误': '请求响应异常'})
|
|
|
-
|
|
|
- res = r.json()
|
|
|
- logger.info('请求MQTT发布消息参数:{},result_code: {}'.format(requests_data, res['result_code']))
|
|
|
- if res['result_code'] == 0:
|
|
|
- logger.info('请求MQTT下发指令成功')
|
|
|
+ if r.status_code == 200:
|
|
|
+ res = r.json()
|
|
|
+ logger.info('请求MQTT发布消息参数:{},result_code: {}'.format(requests_data, res['result_code']))
|
|
|
+ if res['result_code'] == 0:
|
|
|
+ logger.info('请求MQTT下发指令成功---正式服')
|
|
|
+ elif res['result_code'] == 10044:
|
|
|
+ url = '{}/iot/requestPublishMessage'.format(SERVER_PREFIX_TEST) # 测试服务器
|
|
|
+ r = requests.post(url, requests_data)
|
|
|
+ if r.status_code == 200:
|
|
|
+ res = r.json()
|
|
|
+ if res['result_code'] == 0:
|
|
|
+ logger.info('请求MQTT下发指令成功---测试服')
|
|
|
+ else:
|
|
|
+ self.runSendRtspMsg(logger, region, command)
|
|
|
+ else:
|
|
|
+ self.runSendRtspMsg(logger, region, command)
|
|
|
+ else:
|
|
|
+ self.runSendRtspMsg(logger, region, command)
|
|
|
else: # 使用pushtool通知设备推流
|
|
|
- command = "./pushtool {UID} {PWD} {MSG} 1 {channel}".format(UID=UID, PWD=PWD, MSG=MSG, channel=channel)
|
|
|
- logger.info('------------推流指令: {}---------------'.format(command))
|
|
|
self.runSendRtspMsg(logger, region, command)
|
|
|
|
|
|
# 拉流地址
|
|
|
rtsp_uri = '{}://{}:443/{}'.format(RTSP_PREFIX, RESP_SERVER_DOMAIN, stream_name)
|
|
|
stop_time = int(time.time()) + 2*60
|
|
|
- expirationTime = time.strftime('%Y-%m-%dT%H:%MZ',time.localtime(stop_time))
|
|
|
+ expirationTime = time.strftime('%Y-%m-%dT%H:%MZ', time.localtime(stop_time))
|
|
|
|
|
|
res_json = {
|
|
|
'uid': UID,
|
|
@@ -337,6 +348,7 @@ class oa2RtspStartView(TemplateView):
|
|
|
|
|
|
# 触发此方法,让摄像头推流到MSG流地址
|
|
|
def runSendRtspMsg(self, logger, region, command):
|
|
|
+ logger.info('------------推流指令: {}---------------'.format(command))
|
|
|
if region == 'CN':
|
|
|
logger.info('------------国内发送推流指令---------------')
|
|
|
url = "http://52.83.252.41:7880/alexa/command?command={command}".format(command=command)
|