generation-aware playback statuses
This commit is contained in:
@@ -72,7 +72,8 @@ func (s *stabilityVideoSink) ConsumeVideo(
|
||||
return err
|
||||
}
|
||||
|
||||
func (w *VideoWorker) emit(status Status) {
|
||||
func (w *VideoWorker) emit(ctx context.Context, status Status) {
|
||||
status.Generation = generationFromContext(ctx)
|
||||
if w.observer != nil {
|
||||
w.observer(status)
|
||||
}
|
||||
@@ -99,7 +100,7 @@ func (w *VideoWorker) Run(
|
||||
if attemptNumber > 1 {
|
||||
state = StateReconnecting
|
||||
}
|
||||
w.emit(Status{
|
||||
w.emit(ctx, Status{
|
||||
Unit: UnitVideo,
|
||||
State: state,
|
||||
Attempt: attemptNumber,
|
||||
@@ -108,7 +109,7 @@ func (w *VideoWorker) Run(
|
||||
attemptSink := &stabilityVideoSink{
|
||||
sink: w.sink,
|
||||
onStable: func() {
|
||||
w.emit(Status{
|
||||
w.emit(ctx, Status{
|
||||
Unit: UnitVideo,
|
||||
State: StatePlaying,
|
||||
Attempt: attemptNumber,
|
||||
@@ -134,7 +135,7 @@ func (w *VideoWorker) Run(
|
||||
return
|
||||
}
|
||||
|
||||
w.emit(Status{
|
||||
w.emit(ctx, Status{
|
||||
Unit: UnitVideo,
|
||||
State: StateReconnecting,
|
||||
Attempt: attemptNumber + 1,
|
||||
@@ -154,11 +155,11 @@ func (w *VideoWorker) Run(
|
||||
)
|
||||
|
||||
if ctx.Err() != nil {
|
||||
w.emit(Status{
|
||||
w.emit(ctx, Status{
|
||||
Unit: UnitVideo,
|
||||
State: StateStopping,
|
||||
})
|
||||
w.emit(Status{
|
||||
w.emit(ctx, Status{
|
||||
Unit: UnitVideo,
|
||||
State: StateIdle,
|
||||
})
|
||||
@@ -166,7 +167,7 @@ func (w *VideoWorker) Run(
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
w.emit(Status{
|
||||
w.emit(ctx, Status{
|
||||
Unit: UnitVideo,
|
||||
State: StateFailed,
|
||||
Attempt: attemptNumber,
|
||||
@@ -176,7 +177,7 @@ func (w *VideoWorker) Run(
|
||||
return err
|
||||
}
|
||||
|
||||
w.emit(Status{
|
||||
w.emit(ctx, Status{
|
||||
Unit: UnitVideo,
|
||||
State: StateIdle,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user