Skip to content

[Proposal] types: simplify types for PlaybackObserver#1589

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

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

Conversation

@Florent-Bouisset
Copy link
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
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
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
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

ObservationPosition,
} from "../../playback_observer";
import type { IReadOnlyPlaybackObserver } from "../../playback_observer";
import type { ICorePlaybackObservation } from "../../playback_observer/types";
Copy link
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

import type { IRepresentationEstimator } from "../../adaptive";
import type { SegmentQueueCreator } from "../../fetchers";
import type { IBufferType, SegmentSink } from "../../segment_sinks";
import type { IPeriodStreamPlaybackObservation } from "../period";
Copy link
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
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
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

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
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
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
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
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
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
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
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: 2 (Medium) This issue or PR has a medium priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants