Skip to content

Commit

Permalink
cockpit-actions: Allow starting the recording of all available streams
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl committed Feb 21, 2024
1 parent d000292 commit 7090f17
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/libs/joystick/protocols/cockpit-actions.ts
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ export enum CockpitActionsFunction {
mavlink_arm = 'mavlink_arm',
mavlink_disarm = 'mavlink_disarm',
toggle_bottom_bar = 'toggle_bottom_bar',
start_recording_all_streams = 'start_recording_all_streams',
}

/**
@@ -40,6 +41,7 @@ export const availableCockpitActions: { [key in CockpitActionsFunction]: Cockpit
[CockpitActionsFunction.mavlink_arm]: new CockpitAction(CockpitActionsFunction.mavlink_arm, 'Mavlink arm'),
[CockpitActionsFunction.mavlink_disarm]: new CockpitAction(CockpitActionsFunction.mavlink_disarm, 'Mavlink disarm'),
[CockpitActionsFunction.toggle_bottom_bar]: new CockpitAction(CockpitActionsFunction.toggle_bottom_bar, 'Toggle bottom bar'),
[CockpitActionsFunction.start_recording_all_streams]: new CockpitAction(CockpitActionsFunction.start_recording_all_streams, 'Start recording all streams'),
}

export type CockpitActionCallback = () => void
29 changes: 29 additions & 0 deletions src/stores/video.ts
Original file line number Diff line number Diff line change
@@ -11,14 +11,20 @@ import adapter from 'webrtc-adapter'

import { WebRTCManager } from '@/composables/webRTC'
import { getIpsInformationFromVehicle } from '@/libs/blueos'
import { availableCockpitActions, registerActionCallback } from '@/libs/joystick/protocols/cockpit-actions'
import { datalogger } from '@/libs/sensors-logging'
import { isEqual } from '@/libs/utils'
import { useMainVehicleStore } from '@/stores/mainVehicle'
import { useMissionStore } from '@/stores/mission'
import { Alert, AlertLevel } from '@/types/alert'
import type { StreamData } from '@/types/video'

import { useAlertStore } from './alert'

export const useVideoStore = defineStore('video', () => {
const missionStore = useMissionStore()
const alertStore = useAlertStore()

const { globalAddress, rtcConfiguration, webRTCSignallingURI } = useMainVehicleStore()
console.debug('[WebRTC] Using webrtc-adapter for', adapter.browserDetails)

@@ -350,6 +356,29 @@ export const useVideoStore = defineStore('video', () => {
}
}, 5000)

// Video recording actions
const startRecordingAllStreams = (): void => {
const streamsThatStarted: string[] = []

namesAvailableStreams.value.forEach((streamName) => {
if (!isRecording(streamName)) {
startRecording(streamName)
streamsThatStarted.push(streamName)
}
})

if (streamsThatStarted.isEmpty()) {
alertStore.pushAlert(new Alert(AlertLevel.Error, 'No streams available to be recorded.'))
return
}
alertStore.pushAlert(new Alert(AlertLevel.Success, `Started recording streams: ${streamsThatStarted.join(', ')}.`))
}

registerActionCallback(
availableCockpitActions.start_recording_all_streams,
useThrottleFn(startRecordingAllStreams, 3000)
)

return {
availableIceIps,
allowedIceIps,

0 comments on commit 7090f17

Please sign in to comment.