(self, basestation, camera)
return self.TriggerAndHandleEvent(basestation, trigger, callback)
This function returns the url of the rtsp video stream.
        This stream needs to be called within 30 seconds or else it becomes invalid.
        It can be streamed with: ffmpeg -re -i 'rtsps://<url>' -acodec copy -vcodec copy test.mp4
        The request to /users/devices/startStream returns: { url:rtsp://<url>:443/vzmodulelive?egressToken=b<xx>&userAgent=iOS&cameraId=<camid>}
This function returns the url of the rtsp video stream.
        This stream needs to be called within 30 seconds or else it becomes invalid.
        It can be streamed with: ffmpeg -re -i 'rtsps://<url>' -acodec copy -vcodec copy test.mp4
        The request to /users/devices/startStream returns: { url:rtsp://<url>:443/vzmodulelive?egressToken=b<xx>&userAgent=iOS&cameraId=<camid>}
This function returns the url of the rtsp video stream . This stream needs to be called within 30 seconds or else it becomes invalid . It can be streamed with : ffmpeg - re - i rtsps : // <url > - acodec copy - vcodec copy test . mp4 The request to / users / devices / startStream returns : { url : rtsp : // <url > : 443 / vzmodulelive?egressToken = b<xx > &userAgent = iOS&cameraId = <camid > }
def StartStream(self, basestation, camera):
        """
        This function returns the url of the rtsp video stream.
        This stream needs to be called within 30 seconds or else it becomes invalid.
        It can be streamed with: ffmpeg -re -i 'rtsps://<url>' -acodec copy -vcodec copy test.mp4
        The request to /users/devices/startStream returns: { url:rtsp://<url>:443/vzmodulelive?egressToken=b<xx>&userAgent=iOS&cameraId=<camid>}
        """
        # nonlocal variable hack for Python 2.x.
        class nl:
            stream_url_dict = None

        def trigger(self):
            nl.stream_url_dict = self.request.post(f'https://{self.BASE_URL}/hmsweb/users/devices/startStream', {"to":camera.get('parentId'),"from":self.user_id+"_web","resource":"cameras/"+camera.get('deviceId'),"action":"set","responseUrl":"", "publishResponse":True,"transId":self.genTransId(),"properties":{"activityState":"startUserStream","cameraId":camera.get('deviceId')}}, headers={"xcloudId":camera.get('xCloudId')})

        def callback(self, event):
            if event.get("from") == basestation.get("deviceId") and event.get("resource") == "cameras/"+camera.get("deviceId") and event.get("properties", {}).get("activityState") == "userStreamActive":
                return nl.stream_url_dict['url'].replace("rtsp://", "rtsps://")

            return None

        return self.TriggerAndHandleEvent(basestation, trigger, callback)
def StartStream ( self , basestation , camera ) : # nonlocal variable hack for Python 2.x. class nl : stream_url_dict = None def trigger ( self ) : nl . stream_url_dict = self . request . post ( f'https://{self.BASE_URL}/hmsweb/users/devices/startStream' , { "to" : camera . get ( 'parentId' ) , "from" : self . user_id + "_web" , "resource" : "cameras/" + camera . get ( 'deviceId' ) , "action" : "set" , "responseUrl" : "" , "publishResponse" : True , "transId" : self . genTransId ( ) , "properties" : { "activityState" : "startUserStream" , "cameraId" : camera . get ( 'deviceId' ) } } , headers = { "xcloudId" : camera . get ( 'xCloudId' ) } ) def callback ( self , event ) : if event . get ( "from" ) == basestation . get ( "deviceId" ) and event . get ( "resource" ) == "cameras/" + camera . get ( "deviceId" ) and event . get ( "properties" , { } ) . get ( "activityState" ) == "userStreamActive" : return nl . stream_url_dict [ 'url' ] . replace ( "rtsp://" , "rtsps://" ) return None return self . TriggerAndHandleEvent ( basestation , trigger , callback )