diff --git a/Jenkinsfile b/Jenkinsfile index 7e54faa..6df64bf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -70,6 +70,7 @@ pipeline { steps { sshagent(credentials: ['ury']) { sh 'scp -v -o StrictHostKeyChecking=no server.py liquidsoap@dolby.ury:/opt/webstudioserver/server.py' + sh 'scp -v -o StrictHostKeyChecking=no requirements.txt liquidsoap@dolby.ury:/opt/webstudioserver/requirements.txt' } } } diff --git a/src/broadcast/state.ts b/src/broadcast/state.ts index 4be03c2..ff8c219 100644 --- a/src/broadcast/state.ts +++ b/src/broadcast/state.ts @@ -7,11 +7,12 @@ import * as NavbarState from "../navbar/state"; import { ConnectionStateEnum, Streamer } from "./streamer"; import { RecordingStreamer } from "./recording_streamer"; -export let streamer: Streamer | null = null; +export let streamer: WebRTCStreamer | null = null; interface BroadcastState { tracklisting: boolean; connectionState: ConnectionStateEnum; + recordingState: ConnectionStateEnum; } const broadcastState = createSlice({ @@ -19,6 +20,7 @@ const broadcastState = createSlice({ initialState: { tracklisting: false, connectionState: "NOT_CONNECTED", + recordingState: "NOT_CONNECTED" } as BroadcastState, reducers: { toggleTracklisting(state) { @@ -27,6 +29,9 @@ const broadcastState = createSlice({ setConnectionState(state, action: PayloadAction) { state.connectionState = action.payload; }, + setRecordingState(state, action: PayloadAction) { + state.recordingState = action.payload; + }, }, }); @@ -71,34 +76,46 @@ export function sendTracklistStart(trackid: number): Promise { }); } -const RECORD = false; - -export const connect = (): AppThunk => async (dispatch, getState) => { - if (RECORD) { - streamer = new RecordingStreamer(MixerState.destination.stream); - } else { - if (!getState().session.userCanBroadcast) { - dispatch( - NavbarState.showAlert({ - color: "warning", - content: "You are not WebStudio Trained and cannot go live.", - closure: 7000, - }) - ); - return; - } - streamer = new WebRTCStreamer(MixerState.destination.stream); +export const startStreaming = (): AppThunk => async (dispatch, getState) => { + if (!getState().session.userCanBroadcast) { + dispatch( + NavbarState.showAlert({ + color: "warning", + content: "You are not WebStudio Trained and cannot go live.", + closure: 7000, + }) + ); + return; } + streamer = new WebRTCStreamer(MixerState.destination.stream); streamer.addConnectionStateListener((state) => { dispatch(broadcastState.actions.setConnectionState(state)); }); await streamer.start(); }; -export const disconnect = (): AppThunk => async (dispatch) => { +export const stopStreaming = (): AppThunk => async (dispatch) => { if (streamer) { await streamer.stop(); } else { console.warn("disconnect called with no streamer!"); } }; + +let recorder: RecordingStreamer; + +export const startRecording = (): AppThunk => async dispatch => { + recorder = new RecordingStreamer(MixerState.destination.stream); + recorder.addConnectionStateListener((state) => { + dispatch(broadcastState.actions.setConnectionState(state)); + }); + await recorder.start(); +} + +export const stopRecording = (): AppThunk => async dispatch => { + if (recorder) { + await recorder.stop(); + } else { + console.warn("stopRecording called with no recorder!"); + } +} diff --git a/src/navbar/index.tsx b/src/navbar/index.tsx index 4a077b7..a70d203 100644 --- a/src/navbar/index.tsx +++ b/src/navbar/index.tsx @@ -12,6 +12,7 @@ export function NavBar() { const dispatch = useDispatch(); const sessionState = useSelector((state: RootState) => state.session); const broadcastState = useSelector((state: RootState) => state.broadcast); + const settings = useSelector((state: RootState) => state.settings); const redirect_url = encodeURIComponent(window.location.toString()); return ( <> @@ -42,6 +43,25 @@ export function NavBar() { : "Not Tracklisting"}{" "} + {settings.enableRecording && ( +
  • + +
  • + )}