|
@ -147,6 +147,8 @@ class WebRTCCamera(Thread): |
|
|
self.close_global_pipeline() |
|
|
self.close_global_pipeline() |
|
|
else: |
|
|
else: |
|
|
print("%d clients left" % self._num_clients) |
|
|
print("%d clients left" % self._num_clients) |
|
|
|
|
|
elif item['job'] == "emit": |
|
|
|
|
|
sio.emit(item['event'], item['data']) |
|
|
else: |
|
|
else: |
|
|
print("unknown job: %s" % item['job']) |
|
|
print("unknown job: %s" % item['job']) |
|
|
self._queue.task_done() |
|
|
self._queue.task_done() |
|
@ -167,10 +169,17 @@ class WebRTCCamera(Thread): |
|
|
print('camera sid is', sio.sid) |
|
|
print('camera sid is', sio.sid) |
|
|
self.sid = sio.sid |
|
|
self.sid = sio.sid |
|
|
self.connected = True |
|
|
self.connected = True |
|
|
|
|
|
from roberto import serial |
|
|
|
|
|
serial.add_callback('B', self.send_battery, None) |
|
|
|
|
|
|
|
|
def disconnect(self): |
|
|
def disconnect(self): |
|
|
print("camera.disconnect()") |
|
|
print("camera.disconnect()") |
|
|
self.connected = False |
|
|
self.connected = False |
|
|
|
|
|
from roberto import serial |
|
|
|
|
|
try: |
|
|
|
|
|
serial.del_callback('B', self.send_battery, None) |
|
|
|
|
|
except: |
|
|
|
|
|
pass |
|
|
sio.disconnect() |
|
|
sio.disconnect() |
|
|
|
|
|
|
|
|
def connect_client(self, sid, room): |
|
|
def connect_client(self, sid, room): |
|
@ -184,6 +193,13 @@ class WebRTCCamera(Thread): |
|
|
return |
|
|
return |
|
|
self._queue.put({'job':'disconnect_client', 'sid':sid}) |
|
|
self._queue.put({'job':'disconnect_client', 'sid':sid}) |
|
|
|
|
|
|
|
|
|
|
|
def emit_async(self, event, data): |
|
|
|
|
|
self._queue.put({'job':'emit', 'event':event, 'data':data}) |
|
|
|
|
|
|
|
|
|
|
|
def send_battery(val, arg=None): |
|
|
|
|
|
print("sending battery value %s" % val) |
|
|
|
|
|
self.emit_async('battery', val) |
|
|
|
|
|
|
|
|
def start_global_pipeline(self): |
|
|
def start_global_pipeline(self): |
|
|
print("STARTING PIPELINE") |
|
|
print("STARTING PIPELINE") |
|
|
desc = PIPELINE_DESC |
|
|
desc = PIPELINE_DESC |
|
|