source-aware playback statuses.

This commit is contained in:
Dmitry Sergeev
2026-09-01 21:22:30 +03:00
parent d3ea99233d
commit cd0298b136
10 changed files with 151 additions and 41 deletions
+9 -8
View File
@@ -72,8 +72,9 @@ func (s *stabilityVideoSink) ConsumeVideo(
return err
}
func (w *VideoWorker) emit(ctx context.Context, status Status) {
func (w *VideoWorker) emit(ctx context.Context, config FeedConfig, status Status) {
status.Generation = generationFromContext(ctx)
status.Feed = config
if w.observer != nil {
w.observer(status)
}
@@ -100,7 +101,7 @@ func (w *VideoWorker) Run(
if attemptNumber > 1 {
state = StateReconnecting
}
w.emit(ctx, Status{
w.emit(ctx, config, Status{
Unit: UnitVideo,
State: state,
Attempt: attemptNumber,
@@ -109,7 +110,7 @@ func (w *VideoWorker) Run(
attemptSink := &stabilityVideoSink{
sink: w.sink,
onStable: func() {
w.emit(ctx, Status{
w.emit(ctx, config, Status{
Unit: UnitVideo,
State: StatePlaying,
Attempt: attemptNumber,
@@ -135,7 +136,7 @@ func (w *VideoWorker) Run(
return
}
w.emit(ctx, Status{
w.emit(ctx, config, Status{
Unit: UnitVideo,
State: StateReconnecting,
Attempt: attemptNumber + 1,
@@ -155,11 +156,11 @@ func (w *VideoWorker) Run(
)
if ctx.Err() != nil {
w.emit(ctx, Status{
w.emit(ctx, config, Status{
Unit: UnitVideo,
State: StateStopping,
})
w.emit(ctx, Status{
w.emit(ctx, config, Status{
Unit: UnitVideo,
State: StateIdle,
})
@@ -167,7 +168,7 @@ func (w *VideoWorker) Run(
}
if err != nil {
w.emit(ctx, Status{
w.emit(ctx, config, Status{
Unit: UnitVideo,
State: StateFailed,
Attempt: attemptNumber,
@@ -177,7 +178,7 @@ func (w *VideoWorker) Run(
return err
}
w.emit(ctx, Status{
w.emit(ctx, config, Status{
Unit: UnitVideo,
State: StateIdle,
})