Пример #1
0
    def stopTracking(self):
        if settings.PYRAPTORD_SERVICE is True:
            pyraptord = getPyraptordClient()
            serviceName = self.vehicle.name + "TrackListener"
            stopPyraptordServiceIfRunning(pyraptord, serviceName)

        #TODO remove the current position for that track
        if self.track:
            if self.track.currentposition_set:
                try:
                    position = self.track.currentposition_set.first()
                    if position:
                        position.delete()
                except:
                    pass
Пример #2
0
def stopRecording(source, endTime):
    if settings.PYRAPTORD_SERVICE is True:
        pyraptord = getPyraptordClient('pyraptord')
    assetName = source.shortName
    vlcSvc = '%s_vlc' % assetName

    # we need to set the endtime
    unended_segments = source.videosegment_set.filter(endTime=None)
    for segment in unended_segments:
        segment.endTime = endTime
        segment.save()

    if settings.PYRAPTORD_SERVICE is True:
        stopPyraptordServiceIfRunning(pyraptord, vlcSvc)
        return 'STOPPED PYCRORAPTOR SERVICES: ' + vlcSvc
    return 'NO PYRAPTORD: ' + vlcSvc
Пример #3
0
    def startTracking(self):
        resource = self.getResource()

        #Create the track if it does not exist
        if not self.track:
            TRACK_MODEL = LazyGetModelByName(settings.GEOCAM_TRACK_TRACK_MODEL)
            try:
                track = TRACK_MODEL.get().objects.get(name=self.name)
            except ObjectDoesNotExist:
                timezone = settings.TIME_ZONE
                if self.plans:
                    timezone = str(self.plans[0].plan.jsonPlan.site.
                                   alternateCrs.properties.timezone)
                    self.timezone = timezone
                track = TRACK_MODEL.get()(
                    name=self.name,
                    resource=resource,
                    timezone=timezone,
                    iconStyle=geocamTrackModels.IconStyle.objects.get(
                        uuid=resource.name),
                    lineStyle=geocamTrackModels.LineStyle.objects.get(
                        uuid=resource.name),
                    dataType=DataType.objects.get(name="RawGPSLocation"))
                track.save()
                self.track = track

                # this is for archival purposes; make sure remoteDelay is set for the other server's delay.
                delayConstant = Constant.objects.get(name="remoteDelay")
                self.delaySeconds = int(delayConstant.value)
                self.save()

        if settings.PYRAPTORD_SERVICE is True:
            pyraptord = getPyraptordClient()
            serviceName = self.vehicle.name + "TrackListener"
            ipAddress = Constant.objects.get(name=resource.name +
                                             "_TRACKING_IP")
            protocol = Constant.objects.get(name=resource.name +
                                            "_TRACKING_PROTO")
            scriptPath = os.path.join(settings.PROJ_ROOT, 'apps', 'basaltApp',
                                      'scripts', 'evaTrackListener.py')
            command = "%s -o %s -p %d -n %s --proto=%s -t %s" % (
                scriptPath, ipAddress.value, resource.port,
                self.vehicle.name[-1:], protocol.value, self.name)
            stopPyraptordServiceIfRunning(pyraptord, serviceName)
            time.sleep(2)
            pyraptord.updateServiceConfig(serviceName, {'command': command})
            pyraptord.startService(serviceName)
Пример #4
0
    def runRecordingLoop(self):
        while not self.stopRecording:
            self.recordNextBlock()
            self.stopRecording = _cache.get("recordHLS:%s:stopRecording" %
                                            self.recorderId)

        # When done, mark xGDS segment end time and write final copy of index with end tag
        # **TODO** SUPER IMPORTANT read the end time from the ts file of the last m3u8 segment somehow
        endTime = datetime.datetime.now(pytz.utc)
        self.saveM3U8ToFile(addEndTag=True)
        print 'CALLING END SEGMENT'
        reconnect_db()  # Make sure we have an active MySQL connection
        endSegment(self.xgdsSegment, endTime)
        print 'DONE CALLING END SEGMENT'

        if settings.PYRAPTORD_SERVICE is True:
            print 'COMMIT SUICIDE'
            pyraptord = getPyraptordClient('pyraptord')
            recorderService = '%s_recorder' % self.xgdsSegment.source.shortName
            stopPyraptordServiceIfRunning(pyraptord, recorderService)
Пример #5
0
def stopRecording(source, endTime):
    assetName = source.shortName
    recorderService = '%s_recorder' % assetName

    if settings.XGDS_VIDEO_RECORDING_METHOD == 'HLS':
        # set the persistent flag to stop.
        # TODO make this better
        _cache.set("recordHLS:%s:stopRecording" % assetName, True)
        return 'SET MEMCACHE TO STOP HLS RECORDING FOR %s' % (assetName)

    else:
        # we need to set the endtime
        unended_segments = source.videosegment_set.filter(endTime=None)
        for segment in unended_segments:
            endSegment(segment, endTime)

        if settings.PYRAPTORD_SERVICE is True:
            pyraptord = getPyraptordClient('pyraptord')
            stopPyraptordServiceIfRunning(pyraptord, recorderService)
            return 'STOPPED PYCRORAPTOR SERVICES: ' + recorderService
    return 'NO PYRAPTORD: ' + recorderService
Пример #6
0
    def stopFlightExtras(self, request):
        #stop the eva track listener
        if settings.GEOCAM_TRACK_SERVER_TRACK_PROVIDER:
            self.stopTracking()
            if self.vehicle.name in settings.COMPASS_EQUIPPED_VEHICLES:
                pyraptord = getPyraptordClient()
                serviceName = self.vehicle.name + "CompassListener"
                stopPyraptordServiceIfRunning(pyraptord, serviceName)

        # See if we're the last running flight and end episode if we are
        if settings.XGDS_VIDEO_ON:
            print "Checking if we're last active flight"
            oaf = flight.active.otherActiveFlights()
            if oaf:
                print "Other active flight count:", oaf.count()
            if oaf.count() == 0:
                endEpisode = True
            else:
                endEpisode = False

            stopFlightRecording(request, self.name, endEpisode)

        self.manageRemoteFlights(request, False)
Пример #7
0
    def startTracking(self):
        vehicle = self.getVehicle()

        protocol = None
        try:
            protocol = Constant.objects.get(name=vehicle.name +
                                            "_TRACKING_PROTO")
        except:
            # if there is no protocol, there should be no track.
            return

        #Create the track if it does not exist
        if not getattr(self, 'track'):
            TRACK_MODEL = LazyGetModelByName(settings.GEOCAM_TRACK_TRACK_MODEL)
            try:
                track = TRACK_MODEL.get().objects.get(name=self.name)
            except ObjectDoesNotExist:
                timezone = settings.TIME_ZONE
                if self.plans:
                    timezone = str(self.plans[0].plan.jsonPlan.site.
                                   alternateCrs.properties.timezone)
                    self.timezone = timezone
                track = TRACK_MODEL.get()(
                    name=self.name,
                    vehicle=vehicle,
                    timezone=timezone,
                    iconStyle=geocamTrackModels.IconStyle.objects.get(
                        uuid=vehicle.name),
                    lineStyle=geocamTrackModels.LineStyle.objects.get(
                        uuid=vehicle.name),
                    dataType=DataType.objects.get(name="RawGPSLocation"))
                track.save()
                self.track = track

                # this is for archival purposes; make sure remoteDelay is set for the other server's delay.
                delayConstant = Constant.objects.get(name="remoteDelay")
                self.delaySeconds = int(delayConstant.value)
                self.save()

        if settings.PYRAPTORD_SERVICE is True and protocol:
            pyraptord = getPyraptordClient()
            serviceName = self.vehicle.name + "TrackListener"
            ipAddress = Constant.objects.get(name=vehicle.name +
                                             "_TRACKING_IP")
            scriptPath = os.path.join(settings.PROJ_ROOT, 'apps', 'basaltApp',
                                      'scripts', 'evaTrackListener.py')
            command = "%s -o %s -p %d -n %s --proto=%s -t %s" % (
                scriptPath, ipAddress.value, vehicle.port,
                self.vehicle.name[-1:], protocol.value, self.name)
            stopPyraptordServiceIfRunning(pyraptord, serviceName)
            time.sleep(2)
            pyraptord.updateServiceConfig(serviceName, {'command': command})
            pyraptord.startService(serviceName)

            if self.vehicle.name in settings.COMPASS_EQUIPPED_VEHICLES:
                serviceName = self.vehicle.name + "CompassListener"
                port = Constant.objects.get(name="%s_COMPASS_PORT" %
                                            self.vehicle.name).value
                scriptPath = os.path.join(settings.PROJ_ROOT, 'apps',
                                          'basaltApp', 'scripts',
                                          'evaTrackListener.py')
                command = "%s -p %s -n %s -d compass --proto=%s -t %s" % (
                    scriptPath, port, self.vehicle.name[-1:], 'UDP', self.name)
                print "COMPASS: %s" % command
                stopPyraptordServiceIfRunning(pyraptord, serviceName)
                time.sleep(2)
                pyraptord.updateServiceConfig(serviceName,
                                              {'command': command})
                pyraptord.startService(serviceName)
Пример #8
0
def startRecording(source, recordingDir, recordingUrl, startTime,
                   maxFlightDuration, episode):
    if not source.videofeed_set.all():
        logging.info("video feeds set is empty")
        return
    videoFeed = source.videofeed_set.all()[0]

    # figure out next segment number for this source and episode
    try:
        maxSegmentNumber = SEGMENT_MODEL.get().objects.filter(
            episode=episode, source=source).aggregate(Max('segNumber'))
        segmentNumber = maxSegmentNumber['segNumber__max']
        recordedVideoDir = os.path.join(recordingDir,
                                        'Segment%03d' % segmentNumber)
        if not emptySegmentDir(recordedVideoDir):
            segmentNumber = segmentNumber + 1
            recordedVideoDir = os.path.join(recordingDir,
                                            'Segment%03d' % segmentNumber)

        # adjust start and end times for all prio segments
        existingSegments = SEGMENT_MODEL.get().objects.filter(source=source,
                                                              episode=episode)
        for segment in existingSegments:
            segment.adjustSegmentTimes()
    except:
        segmentNumber = 0
        recordedVideoDir = os.path.join(recordingDir,
                                        'Segment%03d' % segmentNumber)

    makedirsIfNeeded(recordedVideoDir)
    try:
        videoSettingses = SETTINGS_MODEL.get().objects.filter(
            width=videoFeed.settings.width, height=videoFeed.settings.height)
        videoSettings = videoSettingses.first()
    except:
        # make a new one
        videoSettings = SETTINGS_MODEL.get()()
        videoSettings.width = videoFeed.settings.width
        videoSettings.height = videoFeed.settings.height
        videoSettings.save()

    videoSegment, created = SEGMENT_MODEL.get().objects.get_or_create(
        directoryName="Segment",
        segNumber=segmentNumber,
        indexFileName="prog_index.m3u8",
        endTime=None,
        settings=videoSettings,
        source=source,
        episode=episode)
    videoSegment.startTime = startTime
    videoSegment.save()

    if settings.PYRAPTORD_SERVICE is True:
        pyraptord = getPyraptordClient()

    assetName = source.shortName
    vlcSvc = '%s_vlc' % assetName
    vlcCmd = (
        "%s %s --sout='#duplicate{dst=std{access=livehttp{seglen=6,splitanywhere=false,delsegs=false,numsegs=0,index=prog_index.m3u8,index-url=prog_index-#####.ts},mux=ts,dst=prog_index-#####.ts}}'"
        % (settings.XGDS_VIDEO_VLC_PATH, videoFeed.url))
    #     print vlcCmd
    if settings.PYRAPTORD_SERVICE is True:
        (pyraptord, vlcSvc)
        stopPyraptordServiceIfRunning(pyraptord, vlcSvc)
        pyraptord.updateServiceConfig(vlcSvc, {
            'command': vlcCmd,
            'cwd': recordedVideoDir
        })
        pyraptord.restart(vlcSvc)
        return vlcCmd
    return 'NO PYRAPTORD: ' + vlcCmd
Пример #9
0
 def stopTracking(self):
     if settings.PYRAPTORD_SERVICE is True:
         pyraptord = getPyraptordClient()
         serviceName = self.vehicle.name + "TrackListener"
         stopPyraptordServiceIfRunning(pyraptord, serviceName)