|
@@ -740,11 +740,11 @@ class RtcController(TemplateView):
|
|
# 请求go2rtc创建流
|
|
# 请求go2rtc创建流
|
|
rtsp = GO2RTC_RTSP.format(uid)
|
|
rtsp = GO2RTC_RTSP.format(uid)
|
|
rtc_url = GO2RTC_API.format('api/streams')
|
|
rtc_url = GO2RTC_API.format('api/streams')
|
|
- data = {
|
|
|
|
|
|
+ params = {
|
|
'src': rtsp,
|
|
'src': rtsp,
|
|
'name': uid,
|
|
'name': uid,
|
|
}
|
|
}
|
|
- r = requests.put(url=rtc_url, data=data, timeout=30)
|
|
|
|
|
|
+ r = requests.put(url=rtc_url, data=params, timeout=30)
|
|
assert r.status_code == 200
|
|
assert r.status_code == 200
|
|
|
|
|
|
# mqtt下发推流指令
|
|
# mqtt下发推流指令
|
|
@@ -785,9 +785,10 @@ class RtcController(TemplateView):
|
|
res = r.json()
|
|
res = r.json()
|
|
# 遍历producers数组,查找包含sdp字段的对象
|
|
# 遍历producers数组,查找包含sdp字段的对象
|
|
sdp = ''
|
|
sdp = ''
|
|
- for producer in data['producers']:
|
|
|
|
|
|
+ for producer in res['producers']:
|
|
if 'sdp' in producer:
|
|
if 'sdp' in producer:
|
|
sdp = producer['sdp']
|
|
sdp = producer['sdp']
|
|
|
|
+ break
|
|
res_json = {
|
|
res_json = {
|
|
'SDP': sdp
|
|
'SDP': sdp
|
|
}
|
|
}
|
|
@@ -818,6 +819,8 @@ class VesseTest(TemplateView):
|
|
return self.get_user_id(request_dict, response, request)
|
|
return self.get_user_id(request_dict, response, request)
|
|
elif operation == 'get-user-info': # 获取用户信息
|
|
elif operation == 'get-user-info': # 获取用户信息
|
|
return self.get_user_info(request_dict, response, request)
|
|
return self.get_user_info(request_dict, response, request)
|
|
|
|
+ elif operation == 'rtc': # rtc测试
|
|
|
|
+ return self.rtc(request_dict, response, request)
|
|
|
|
|
|
def get_token(self, response):
|
|
def get_token(self, response):
|
|
data = {
|
|
data = {
|
|
@@ -900,3 +903,38 @@ class VesseTest(TemplateView):
|
|
except Exception as e:
|
|
except Exception as e:
|
|
print(e)
|
|
print(e)
|
|
return response.json(500, repr(e))
|
|
return response.json(500, repr(e))
|
|
|
|
+
|
|
|
|
+ @staticmethod
|
|
|
|
+ def rtc(request_dict, response, request):
|
|
|
|
+ uid = request_dict.get('uid', None)
|
|
|
|
+ try:
|
|
|
|
+ # 请求go2rtc创建流
|
|
|
|
+ # rtsp = GO2RTC_RTSP.format(uid)
|
|
|
|
+ rtc_url = GO2RTC_API.format('api/streams')
|
|
|
|
+ # params = {
|
|
|
|
+ # 'src': rtsp,
|
|
|
|
+ # 'name': uid,
|
|
|
|
+ # }
|
|
|
|
+ # r = requests.put(url=rtc_url, params=params, timeout=30)
|
|
|
|
+ # assert r.status_code == 200
|
|
|
|
+
|
|
|
|
+ # 获取SDP
|
|
|
|
+ params = {
|
|
|
|
+ 'src': uid,
|
|
|
|
+ }
|
|
|
|
+ r = requests.get(url=rtc_url, params=params, timeout=30)
|
|
|
|
+ assert r.status_code == 200
|
|
|
|
+ res = r.json()
|
|
|
|
+ # 遍历producers数组,查找包含sdp字段的对象
|
|
|
|
+ sdp = ''
|
|
|
|
+ for producer in res['producers']:
|
|
|
|
+ if 'sdp' in producer:
|
|
|
|
+ sdp = producer['sdp']
|
|
|
|
+ break
|
|
|
|
+ res_json = {
|
|
|
|
+ 'SDP': sdp
|
|
|
|
+ }
|
|
|
|
+ return response.json(0)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ print(e)
|
|
|
|
+ return response.json(500, repr(e))
|