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