Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Recording + Replay Buffer to Factory API #5344

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cf72bc5
Patch api migration from dual output recording.
michelinewu Mar 4, 2025
7441051
WIP: Migrate replay buffer.
michelinewu Mar 4, 2025
f4f1250
Fix replay buffer signals.
michelinewu Mar 5, 2025
4ce8c63
Refactor to make less DRY and added shutdown for output contexts.
michelinewu Mar 5, 2025
605feec
Refactor destroy contexts.
michelinewu Mar 5, 2025
baf5af6
Advanced recording works.
michelinewu Mar 5, 2025
ab0b68a
Refactor to use new status handler.
michelinewu Mar 5, 2025
6bab263
Handling for dependent output instances.
michelinewu Mar 5, 2025
0873a4c
WIP: Streaming with replay buffer.
michelinewu Mar 5, 2025
aa2def2
Fix Advanced recording. WIP: Replay buffer lag on stop.
michelinewu Mar 7, 2025
aa8cf69
Fixed advanced replay buffer.
michelinewu Mar 7, 2025
32e2d87
Remove unnecessary async.
michelinewu Mar 7, 2025
026d6bb
Move create stream to own function. Fix replay buffer state update is…
michelinewu Mar 11, 2025
2e3934b
Fix using Advanced settings.
michelinewu Mar 12, 2025
d06ce47
Only destroy replay buffer on app close.
michelinewu Mar 12, 2025
539bd97
Merge branch 'master' into mw_v2_migration
michelinewu Mar 21, 2025
9932d37
Added Advanced Recording test.
michelinewu Mar 24, 2025
4d4d247
Fix Advanced Recording.
michelinewu Mar 24, 2025
ffaa50c
Merge branch 'master' into mw_v2_migration
michelinewu Mar 25, 2025
4c0af7f
Fix reference issue with Replay Buffer. WIP: Recording while streaming.
michelinewu Mar 25, 2025
5f26aac
Assign output references directly and remove logs.
michelinewu Mar 25, 2025
501b19c
Fix recording reference issue when switching between simple and advan…
michelinewu Mar 25, 2025
7c73b61
Update replay buffer context duration.
michelinewu Mar 25, 2025
9177013
Merge branch 'mw_v2_migration' of https://github.com/stream-labs/desk…
michelinewu Mar 25, 2025
1498c07
Fix replay buffer properties.
michelinewu Mar 26, 2025
dc35413
Fix extra instances on stream with replay buffer and recording.
michelinewu Mar 28, 2025
ece5456
Fix for replay buffer.
michelinewu Mar 28, 2025
d6b2483
Comment out dual output recording.
michelinewu Mar 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/components-react/pages/RecordingHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,11 @@ export function RecordingHistory() {
<div className={styles.recording} key={recording.timestamp}>
<span style={{ marginRight: '8px' }}>{formattedTimestamp(recording.timestamp)}</span>
<Tooltip title={$t('Show in folder')}>
<span onClick={() => showFile(recording.filename)} className={styles.filename}>
<span
data-test="filename"
onClick={() => showFile(recording.filename)}
className={styles.filename}
>
{recording.filename}
</span>
</Tooltip>
Expand Down
2 changes: 1 addition & 1 deletion app/components-react/root/NotificationsArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class NotificationsModule {

message
.info({
content: <MessageNode notif={notif} />,
content: <MessageNode notif={notif} data-testid="notification" />,
duration: notif.lifeTime === -1 ? 0 : notif.lifeTime / 1000,
key: `${notif.message}${notif.date}`,
onClick: () => this.clickNotif(),
Expand Down
17 changes: 10 additions & 7 deletions app/components-react/root/StudioFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { EStreamQuality } from '../../services/performance';
import { EStreamingState, EReplayBufferState, ERecordingState } from '../../services/streaming';
import { Services } from '../service-provider';
import { $t } from '../../services/i18n';
import { useVuex } from '../hooks';
import { useDebounce, useVuex } from '../hooks';
import styles from './StudioFooter.m.less';
import PerformanceMetrics from '../shared/PerformanceMetrics';
import TestWidgets from './TestWidgets';
Expand Down Expand Up @@ -42,9 +42,12 @@ export default function StudioFooterComponent() {
StreamingService.views.supports('stream-schedule') &&
!RecordingModeService.views.isRecordingModeEnabled,
streamQuality: PerformanceService.views.streamQuality,
replayBufferOffline: StreamingService.state.replayBufferStatus === EReplayBufferState.Offline,
replayBufferStopping: StreamingService.state.replayBufferStatus === EReplayBufferState.Stopping,
replayBufferSaving: StreamingService.state.replayBufferStatus === EReplayBufferState.Saving,
replayBufferOffline:
StreamingService.state.status.horizontal.replayBuffer === EReplayBufferState.Offline,
replayBufferStopping:
StreamingService.state.status.horizontal.replayBuffer === EReplayBufferState.Stopping,
replayBufferSaving:
StreamingService.state.status.horizontal.replayBuffer === EReplayBufferState.Saving,
recordingModeEnabled: RecordingModeService.views.isRecordingModeEnabled,
replayBufferEnabled: SettingsService.views.values.Output.RecRB,
}));
Expand Down Expand Up @@ -83,7 +86,7 @@ export default function StudioFooterComponent() {
}

function toggleReplayBuffer() {
if (StreamingService.state.replayBufferStatus === EReplayBufferState.Offline) {
if (replayBufferOffline) {
StreamingService.actions.startReplayBuffer();
} else {
StreamingService.actions.stopReplayBuffer();
Expand Down Expand Up @@ -197,7 +200,7 @@ function RecordingButton() {
const { StreamingService } = Services;
const { isRecording, recordingStatus } = useVuex(() => ({
isRecording: StreamingService.views.isRecording,
recordingStatus: StreamingService.state.recordingStatus,
recordingStatus: StreamingService.state.status.horizontal.recording,
}));

function toggleRecording() {
Expand All @@ -214,7 +217,7 @@ function RecordingButton() {
>
<button
className={cx(styles.recordButton, 'record-button', { active: isRecording })}
onClick={toggleRecording}
onClick={useDebounce(200, toggleRecording)}
>
<span>
{recordingStatus === ERecordingState.Stopping ? (
Expand Down
2 changes: 2 additions & 0 deletions app/i18n/en-US/streaming.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@
"Issues": "Issues",
"Multistream Error": "Multistream Error",
"One of destinations might have incomplete permissions. Reconnect the destinations in settings and try again.": "One of destinations might have incomplete permissions. Reconnect the destinations in settings and try again.",
"A new Highlight has been saved. Click to edit in the Highlighter": "A new Highlight has been saved. Click to edit in the Highlighter",
"An unknown %{type} error occurred.": "An unknown %{type} error occurred.",
"Failed Checks": "Failed Checks",
"Video Transmission": "Video Transmission",
"Optimized Settings": "Optimized Settings",
Expand Down
6 changes: 6 additions & 0 deletions app/services/api/external-api/streaming/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum ERecordingState {
Starting = 'starting',
Recording = 'recording',
Stopping = 'stopping',
Start = 'start',
Wrote = 'wrote',
}

Expand All @@ -34,6 +35,7 @@ enum EReplayBufferState {
Stopping = 'stopping',
Offline = 'offline',
Saving = 'saving',
Wrote = 'wrote',
}

/**
Expand All @@ -42,9 +44,13 @@ enum EReplayBufferState {
*/
interface IStreamingState {
streamingStatus: EStreamingState;
verticalStreamingStatus: EStreamingState;
streamingStatusTime: string;
verticalStreamingStatusTime: string;
recordingStatus: ERecordingState;
verticalRecordingStatus: ERecordingState;
recordingStatusTime: string;
verticalRecordingStatusTime: string;
replayBufferStatus: EReplayBufferState;
replayBufferStatusTime: string;
streamErrorCreated?: string;
Expand Down
3 changes: 3 additions & 0 deletions app/services/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { DualOutputService } from 'services/dual-output';
import { OS, getOS } from 'util/operating-systems';
import * as remote from '@electron/remote';
import { RealmService } from 'services/realm';
import { StreamingService } from 'services/streaming';

interface IAppState {
loading: boolean;
Expand Down Expand Up @@ -96,6 +97,7 @@ export class AppService extends StatefulService<IAppState> {
@Inject() private videoSettingsService: VideoSettingsService;
@Inject() private dualOutputService: DualOutputService;
@Inject() private realmService: RealmService;
@Inject() private streamingService: StreamingService;

static initialState: IAppState = {
loading: true,
Expand Down Expand Up @@ -192,6 +194,7 @@ export class AppService extends StatefulService<IAppState> {
this.shutdownStarted.next();
this.keyListenerService.shutdown();
this.platformAppsService.unloadAllApps();
this.streamingService.shutdown();
await this.usageStatisticsService.flushEvents();
this.windowsService.shutdown();
this.ipcServerService.stopListening();
Expand Down
16 changes: 16 additions & 0 deletions app/services/highlighter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,18 @@ export class HighlighterService extends PersistentStatefulService<IHighlighterSt
}

this.handleStreamingChanges();

if (!this.userService.isLoggedIn) return;

this.streamingService.replayBufferFileWrite.subscribe(async clipPath => {
const message = $t('A new Highlight has been saved. Click to edit in the Highlighter');

this.notificationsService.push({
type: ENotificationType.SUCCESS,
message,
action: this.jsonrpcService.createRequest(Service.getResourceId(this), 'showHighlighter'),
});
});
}

private handleStreamingChanges() {
Expand Down Expand Up @@ -1544,6 +1556,10 @@ export class HighlighterService extends PersistentStatefulService<IHighlighterSt
return id;
}

showHighlighter() {
this.navigationService.navigate('Highlighter');
}

/**
* Utility function that returns a promise that resolves after a specified delay
* @param ms Delay in milliseconds
Expand Down
4 changes: 2 additions & 2 deletions app/services/platform-apps/api/modules/replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ export class ReplayModule extends Module {

private serializeState(): IReplayBufferState {
return {
status: this.streamingService.state.replayBufferStatus,
statusTime: this.streamingService.state.replayBufferStatusTime,
status: this.streamingService.state.status.horizontal.replayBuffer,
statusTime: this.streamingService.state.status.horizontal.replayBufferTime,
};
}
}
17 changes: 14 additions & 3 deletions app/services/recording-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ELayout, ELayoutElement, LayoutService } from './layout';
import { ScenesService } from './scenes';
import { EObsSimpleEncoder, SettingsService } from './settings';
import { AnchorPoint, ScalableRectangle } from 'util/ScalableRectangle';
import { VideoSettingsService } from './settings-v2/video';
import { TDisplayType, VideoSettingsService } from './settings-v2/video';
import { ENotificationType, NotificationsService } from 'services/notifications';
import { DefaultHardwareService } from './hardware';
import { RunInLoadingMode } from './app/app-decorators';
Expand All @@ -18,6 +18,7 @@ import { NavigationService, UsageStatisticsService, SharedStorageService } from
import { getPlatformService } from 'services/platforms';
import { IYoutubeUploadResponse } from 'services/platforms/youtube/uploader';
import { YoutubeService } from 'services/platforms/youtube';
import { capitalize } from 'lodash';

export interface IRecordingEntry {
timestamp: string;
Expand Down Expand Up @@ -180,12 +181,22 @@ export class RecordingModeService extends PersistentStatefulService<IRecordingMo
}, 10 * 1000);
}

addRecordingEntry(filename: string) {
/**
* Add entry to recording history and show notification
* @param filename - name of file to show in recording history
* @param showNotification - primarily used when recording in dual output mode to only show the notification once
*/
addRecordingEntry(filename: string, display?: TDisplayType) {
const timestamp = moment().format();
this.ADD_RECORDING_ENTRY(timestamp, filename);

const message = display
? $t(`A new ${capitalize(display)} Recording has been completed. Click for more info`)
: $t('A new Recording has been completed. Click for more info');

this.notificationsService.actions.push({
type: ENotificationType.SUCCESS,
message: $t('A new Recording has been completed. Click for more info'),
message,
action: this.jsonrpcService.createRequest(
Service.getResourceId(this),
'showRecordingHistory',
Expand Down
Loading