Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # When we grab a WebRTC offer from out browser client for single camera.
- @app.route('/rtcoffer/<cam>', methods=['GET', 'POST'])
- @login_required
- def webRTCOFFER(cam):
- thisUUID = str(uuid.uuid4()) # Generate a UUID for this session.
- # Get current user (Static currently)
- thisUser = current_user.username
- global webRTCThread
- # Get Docker IP
- # Get Name's Docker IP with username and password
- myCursor.execute("Select dockerIP from localcameras where name='{0}'".format(cam))
- dockerIP = myCursor.fetchone()
- dockerIPString = ''.join(dockerIP)
- # Always create a new event loop for this session.
- rtcloop = asyncio.new_event_loop()
- # Add generated info to userUUIDAssociation
- # UUID, user[0], pingtime[1], rtcloopObject[2], userInTrackControl[3], camName[4], rtcPeer[5], microphoneStreamFuture[6] (6 appended)
- # MODIFY SO 5 BECOMES the WEBRTC PEER and 6 is MICROPHONE
- userUUIDAssociations[thisUUID] = [thisUser, 0, rtcloop, False, cam]
- # Get SDP from client and set set objects
- parsedSDP = userUUIDAssociations[thisUUID][2].run_until_complete(singleWebRtcStart(thisUUID, dockerIPString, cam, request))
- # Continue running that loop forever to keep AioRTC Objects In Memory Executing, while shifting it to
- # Another thread so we don't block the code.
- webRTCThread = Thread(target=userUUIDAssociations[thisUUID][2].run_forever)
- webRTCThread.start()
- print("Creating watchdog task")
- # # asyncio.run(startWatchdog(thisUUID))
- rtcWatchDogThread = Thread(target=asyncio.run, args=(startWatchdog(thisUUID), ))
- rtcWatchDogThread.start()
- print("Watchdog task created")
- # Return Our Parsed SDP to the client
- return parsedSDP.encode()
Advertisement
Add Comment
Please, Sign In to add comment