Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ it:
Stream (./core/stream) │ │ └──────┐
┌────────────────────────┼────────────────────────────────┐ │ │
│ ▼ │ └─────────┐ │
│ Create PeriodStreams ┌────────────────────────────┐ │ Ask to │ │
│ Create TrackSelectorStreams ┌────────────────────────────┐ │ Ask to │ │
│ based on the position │ StreamOrchestrator │ │ load │ │
│ and settings │(./core/stream/orchestrator)│ │ and │ │
│ └────────────────────────────┘ │ parse │ │
Expand All @@ -100,7 +100,7 @@ Stream (./core/stream) │ │ └─
│ │ │ │ │ │ │
│ (audio) ▼ (video) ▼ (text) ▼ │ │ │
│ Create the right ┌────────┐ ┌────────┐ ┌────────┐ uses┌────────────┐ │ │
AdaptationStream │ │ │ │ │ │────>│SegmentSinks│ │ │
RepresentationSelector │ │ │ │ │ │────>│SegmentSinks│ │ │
│ depending on the │ Period │─┐ │ Period │─┐ │ Period │─┐ │ │ Store │ │ │
│ wanted track │ Stream │ │ │ Stream │ │ │ Stream │ │ │ │(./core/segm│ │ │
│ (One per Period │ │ │ │ │ │ │ │ │ │ │ent_sinks) │ │ │
Expand Down
11 changes: 5 additions & 6 deletions src/core/entry/core_entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,7 @@ function loadPreparedContent(

/**
* Stores last discontinuity update sent to the Core for each Period and type
* combinations, at least until the corresponding `PeriodStreamCleared`
* message.
* combinations, at least until the corresponding `StreamCleared` message.
*
* This is an optimization to avoid sending too much discontinuity messages to
* the main thread when it is not needed because nothing changed.
Expand Down Expand Up @@ -842,7 +841,7 @@ function loadPreparedContent(
});
},

periodStreamReady(value) {
streamReady(value) {
if (preparedContent === null) {
return;
}
Expand All @@ -852,13 +851,13 @@ function loadPreparedContent(
value.adaptationRef,
);
sendMessage({
type: CoreMessageType.PeriodStreamReady,
type: CoreMessageType.StreamReady,
contentId,
value: { periodId: value.period.id, bufferType: value.type },
});
},

periodStreamCleared(value) {
streamCleared(value) {
if (preparedContent === null) {
return;
}
Expand All @@ -879,7 +878,7 @@ function loadPreparedContent(
value.type,
);
sendMessage({
type: CoreMessageType.PeriodStreamCleared,
type: CoreMessageType.StreamCleared,
contentId,
value: { periodId: value.period.id, bufferType: value.type },
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ less permissive way than custom ones:
- An error coming from one of them will lead us to completely stop the content on a fatal
error

## PeriodStreams
## TrackSelectorStreams

The _DASH_ streaming technology has a concept called _Period_. Simply put, it allows to
set various types of content successively in the same manifest.
Expand Down Expand Up @@ -126,11 +126,11 @@ As such, they have to be considered separately - in a different Period:
TV Show Italian Film American film
```

In the RxPlayer, we create one _PeriodStream_ per Period **and** per type.
In the RxPlayer, we create one _TrackSelectorStream_ per Period **and** per type.

_PeriodStreams_ are automatically created/destroyed during playback. The job of a single
_PeriodStream_ is to process and download optimally the content linked to a single
_Period_ and to a single type:
_TrackSelectorStreams_ are automatically created/destroyed during playback. The job of a
single _TrackSelectorStream_ is to process and download optimally the content linked to a
single _Period_ and to a single type:

```
- VIDEO BUFFER -
Expand Down Expand Up @@ -159,7 +159,7 @@ _Period_ and to a single type:

To allow smooth transitions between them, we also might want to preload content defined by
a subsequent _Period_ once we lean towards the end of the content described by the
previous one. Thus, multiple _PeriodStreams_ might be active at the same time:
previous one. Thus, multiple _TrackSelectorStreams_ might be active at the same time:

```
+---------------------------- AUDIO ----------------------------------+
Expand Down Expand Up @@ -189,16 +189,16 @@ previous one. Thus, multiple _PeriodStreams_ might be active at the same time:

### Multi-Period management

The creation/destruction of _PeriodStreams_ is actually done in a very precise and optimal
way, which gives a higher priority to immediate content.
The creation/destruction of _TrackSelectorStreams_ is actually done in a very precise and
optimal way, which gives a higher priority to immediate content.

To better grasp how it works, let's imagine a regular use-case, with two periods for a
single type of buffer:

---

Let's say that the _PeriodStream_ for the first _Period_ (named P1) is currently actively
downloading segments (the "^" sign is the current position):
Let's say that the _TrackSelectorStream_ for the first _Period_ (named P1) is currently
actively downloading segments (the "^" sign is the current position):

```
P1
Expand All @@ -214,7 +214,7 @@ Once P1 is full (it has no segment left to download):
^
```

We will be able to create a new _PeriodStream_, P2, for the second _Period_:
We will be able to create a new _TrackSelectorStream_, P2, for the second _Period_:

```
P1 P2
Expand Down Expand Up @@ -259,15 +259,15 @@ Once P1, goes full again, we re-create P2:
_Note that we still have the segment pushed to P2 available in the corresponding media
buffer_

When the current position go ahead of a _PeriodStream_ (here ahead of P1):
When the current position go ahead of a _TrackSelectorStream_ (here ahead of P1):

```
P1 P2
|======|=== |
^
```

This _PeriodStream_ is destroyed to free up resources:
This _TrackSelectorStream_ is destroyed to free up resources:

```
P2
Expand All @@ -277,15 +277,15 @@ This _PeriodStream_ is destroyed to free up resources:

---

When the current position goes behind the first currently defined _PeriodStream_:
When the current position goes behind the first currently defined _TrackSelectorStream_:

```
P2
|=== |
^
```

Then we destroy all previous _PeriodStreams_ and [re-]create the one needed:
Then we destroy all previous _TrackSelectorStreams_ and [re-]create the one needed:

```
P1
Expand All @@ -305,7 +305,8 @@ re-create P2, which will also keep its already-pushed segments:
---

For multiple types of buffers (example: _audio_ and _video_) the same logic is repeated
(and separated) as many times. An _audio_ _PeriodStream_ will not influence a _video_ one:
(and separated) as many times. An _audio_ _TrackSelectorStream_ will not influence a
_video_ one:

```
--------------------------- AUDIO --------------------------------
Expand All @@ -324,13 +325,14 @@ For multiple types of buffers (example: _audio_ and _video_) the same logic is r
^
```

At the end, we should only have _PeriodStream[s]_ for consecutive Period[s]:
At the end, we should only have _TrackSelectorStream[s]_ for consecutive Period[s]:

- The first chronological one is the one currently seen by the user.
- The last chronological one is the only one downloading content.
- In between, we only have full consecutive _PeriodStreams_.
- In between, we only have full consecutive _TrackSelectorStreams_.

### Communication with the API

Any "Stream" communicates to the API about creations and destructions of _PeriodStreams_
respectively through `"periodStreamReady"` and `"periodStreamCleared"` callbacks.
Any "Stream" communicates to the API about creations and destructions of
_TrackSelectorStreams_ respectively through `"streamReady"` and `"streamCleared"`
callbacks.
Loading
Loading