MCPcopy Create free account
hub / github.com/DexterInd/GoPiGo3 / StreamingOutput

Class StreamingOutput

Projects/RemoteCameraRobot/remote_robot.py:152–171  ·  view source on GitHub ↗

Class to which the video output is written to. The buffer of this class is then read by StreamingHandler continuously.

Source from the content-addressed store, hash-verified

150#############################
151
152class StreamingOutput(object):
153 '''
154 Class to which the video output is written to.
155 The buffer of this class is then read by StreamingHandler continuously.
156 '''
157 def __init__(self):
158 self.frame = None
159 self.buffer = io.BytesIO()
160 self.condition = Condition()
161
162 def write(self, buf):
163 if buf.startswith(b'\xff\xd8'):
164 # New frame, copy the existing buffer's content and notify all
165 # clients it's available
166 self.buffer.truncate()
167 with self.condition:
168 self.frame = self.buffer.getvalue()
169 self.condition.notify_all()
170 self.buffer.seek(0)
171 return self.buffer.write(buf)
172
173class StreamingHandler(server.BaseHTTPRequestHandler):
174 '''

Callers 1

remote_robot.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected