Skip to content

[Proposal] types: simplify types for PlaybackObserver - #1589

Open
Florent-Bouisset wants to merge 7 commits into
devfrom
refactor/simplify-observer
Open

[Proposal] types: simplify types for PlaybackObserver#1589
Florent-Bouisset wants to merge 7 commits into
devfrom
refactor/simplify-observer

Conversation

@Florent-Bouisset

Copy link
Copy Markdown
Collaborator

Part of the code relies on the PlaybackObserver and redefines the properties needed in the PlaybackObservation it's listening to.

The types

  • IRepresentationEstimatorPlaybackObservation
  • IWorkerPlaybackObservation
  • ICmcdDataBuilderPlaybackObservation

Are all subsets of ICorePlaybackObservation, I propose to remove those types and replace them with ICorePlaybackObservation

Similarly I removed the type IRepresentationStreamPlaybackObservation to only use IAdaptationStreamPlaybackObservation

@peaBerberian

Copy link
Copy Markdown
Collaborator

As the AdaptationStream is the one that has a dependency on the RepresentationStream, shouldn't the type be coming from the RepresentationStream to the AdaptationStream and not the reverse?

@@ -1,76 +1,21 @@
import type { ICorePlaybackObservation } from "../main_thread/init/utils/create_core_playback_observer";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency also looks kind of wrong to me.
The PlaybackObserver shouldn't be dependent on main_thread to me, the reverse should.

@Florent-Bouisset
Florent-Bouisset force-pushed the refactor/simplify-observer branch from f60ae8c to 0e1208a Compare November 4, 2024 10:51
import type { CancellationSignal } from "../../utils/task_canceller";
import TaskCanceller from "../../utils/task_canceller";
import type { IBufferType } from "../segment_sinks";
import type { IAdaptationStreamPlaybackObservation } from "../stream/adaptation";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it weird that the ABR rely on a type defined inside another module it does not care about?

Maybe we should put that type in a more neutral place

Comment thread src/core/cmcd/cmcd_data_builder.ts Outdated
ObservationPosition,
} from "../../playback_observer";
import type { IReadOnlyPlaybackObserver } from "../../playback_observer";
import type { ICorePlaybackObservation } from "../../playback_observer/types";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could maybe just re-export it just from the playback_observer path

Comment thread src/core/stream/adaptation/types.ts Outdated
import type { IRepresentationEstimator } from "../../adaptive";
import type { SegmentQueueCreator } from "../../fetchers";
import type { IBufferType, SegmentSink } from "../../segment_sinks";
import type { IPeriodStreamPlaybackObservation } from "../period";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me the PeriodStream depends on the AdaptationStream, not the other way around

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that they don't overlap well, IAdaptationStreamPlaybackObservation has bufferGap attribute in addition of the other attributes that as IPeriodStreamPlaybackObservation.
But they both defines the buffered attribute in a different way.

I will just define them as both types with no extends nor Omit

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also use different property names to explicit that difference

Comment thread src/core/stream/representation/types.ts Outdated
import type { IReadOnlySharedReference } from "../../../utils/reference";
import type { SegmentQueue } from "../../fetchers";
import type { IBufferType, SegmentSink } from "../../segment_sinks";
import type { IAdaptationStreamPlaybackObservation } from "../adaptation";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote it as a comment but you may have not seen it:

As the AdaptationStream is the one that has a dependency on the RepresentationStream, shouldn't the type be coming from the RepresentationStream to the AdaptationStream and not the reverse?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IAdaptationStreamPlaybackObservation and IRepresentationStreamPlaybackObservation are the same so I deleted the Representation one.
Yeah name is a bit off because of that, should I rename it? Any idea of a name that would fit for both? Or I can duplicate it but I'm not fan of..

SegmentSink,
} from "../../../segment_sinks";
import type { IRepresentationStreamPlaybackObservation } from "../types";
import type { IAdaptationStreamPlaybackObservation } from "../../adaptation";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

IRepresentationStreamPlaybackObservation,
IQueuedSegment,
} from "../types";
import type { IAdaptationStreamPlaybackObservation } from "../../adaptation";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

IRepresentationStreamPlaybackObservation,
IStreamEventAddedSegmentPayload,
} from "../types";
import type { IAdaptationStreamPlaybackObservation } from "../../adaptation";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

IRepresentationStreamPlaybackObservation,
IStreamEventAddedSegmentPayload,
} from "../types";
import type { IAdaptationStreamPlaybackObservation } from "../../adaptation";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

import sendMessage from "./send_message";
import type { ITextDisplayerOptions } from "./types";
import { ContentInitializer } from "./types";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that blank line wanted?

@peaBerberian peaBerberian added this to the 4.3.0 milestone Nov 6, 2024
* loading (and thus paused) but with autoPlay enabled.
*/
pending: boolean | undefined;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me the PlaybackObserver has no concept of what the AdaptationStream or RepresentationStream is.

For "core" I'm ok with.

This is mainly a naming issue for me.

@peaBerberian peaBerberian added code Priority: 2 (Medium) This issue or PR has a medium priority. labels Nov 22, 2024
@peaBerberian peaBerberian removed the code label Mar 4, 2025
@peaBerberian peaBerberian modified the milestones: 4.3.0, 4.4.0 Apr 7, 2025
@peaBerberian
peaBerberian force-pushed the dev branch 2 times, most recently from 00fc806 to b7216b4 Compare April 15, 2025 18:14
@peaBerberian peaBerberian modified the milestones: 4.4.0, 4.5.0 Sep 19, 2025
@peaBerberian
peaBerberian force-pushed the dev branch 3 times, most recently from 6d4fed2 to 9b856a5 Compare September 25, 2025 15:56
@peaBerberian
peaBerberian force-pushed the dev branch 4 times, most recently from 6cfd206 to 1e55170 Compare October 13, 2025 20:54
@peaBerberian
peaBerberian force-pushed the dev branch 2 times, most recently from d4be192 to 9ad6758 Compare December 19, 2025 19:49
@peaBerberian
peaBerberian force-pushed the dev branch 9 times, most recently from 0142e34 to 1fd9df3 Compare January 27, 2026 11:59
@peaBerberian peaBerberian removed this from the 4.5.0 milestone Apr 9, 2026
@peaBerberian
peaBerberian force-pushed the dev branch 7 times, most recently from 470c3f8 to 3dde189 Compare June 4, 2026 16:11
@peaBerberian peaBerberian removed the Priority: 2 (Medium) This issue or PR has a medium priority. label Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants