From c3c68e103265ced8bb9414ef0e2c1c67874de9fa Mon Sep 17 00:00:00 2001 From: Pengfei Qu Date: Tue, 3 Nov 2020 12:03:18 -0500 Subject: [PATCH] fix the ip camera with webrtc --- sensor/webrtc/owtapi.py | 4 ++-- sensor/webrtc/sensors.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sensor/webrtc/owtapi.py b/sensor/webrtc/owtapi.py index 550a55060..1d2a1e09b 100755 --- a/sensor/webrtc/owtapi.py +++ b/sensor/webrtc/owtapi.py @@ -71,11 +71,11 @@ def list_participants(self,room): r=self._request(requests.get,uri,headers=self._headers()) return len(r.json()) - def start_streaming_ins(self,room,rtsp_url): + def start_streaming_ins(self,room,rtsp_url,protocol="tcp"): options={ "connection": { "url":str(rtsp_url), - "transportProtocol": "udp", + "transportProtocol": protocol, "bufferSize":212992, }, "media": { diff --git a/sensor/webrtc/sensors.py b/sensor/webrtc/sensors.py index dbea0df5b..e03ef28f7 100755 --- a/sensor/webrtc/sensors.py +++ b/sensor/webrtc/sensors.py @@ -42,6 +42,7 @@ def _create_room(self, sensor): if not r: return (404, "Sensor Not Found") location=r[0]["_source"]["location"] + protocol= "udp" if 'simsn' in r[0]['_source'].keys() else "tcp" name="{},{} - {}".format(location["lat"],location["lon"], sensor) room,stream=watcher.get(name) if room and stream: @@ -49,7 +50,7 @@ def _create_room(self, sensor): room=self._owt.create_room(name=name, p_limit=streaming_limit) rtsp_url=r[0]["_source"]["url"] - stream=self._owt.start_streaming_ins(room=room,rtsp_url=rtsp_url) if room else None + stream=self._owt.start_streaming_ins(room=room,rtsp_url=rtsp_url,protocol=protocol) if room else None if not stream: return (503, "Exception when post") watcher.set(name, room, stream)