Skip to content

Commit

Permalink
bframes fix (#569)
Browse files Browse the repository at this point in the history
* fix: storage on lvpr.tv

* fix: lvpr.tv

* ci: bump

* fix: localstorage null

* fix: lvpr.tv

* fix: build

* fix: storage

* Deploy lvpr.tv (#529)

* fix: remove element load (#518)

* chore: version packages (#519)

* chore: version packages

* ci: bump

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Chase Adams <c@cadams.io>

* feat: added broadcast config (#521)

* fix: types

* chore: version packages (#522)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Added playing event (#526)

* fix: added playing event listener

* fix: formatting

* fix: tests

* No cache failed playback info (#528)

* fix: no cache failed playback info

* fix: redundant logs

* fix: lvpr.tv

* chore: version packages (#527)

* chore: version packages

* ci: bump

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Chase Adams <c@cadams.io>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Latest (#538)

* Fix boot ms (#533)

* fix: moved boot time into addmediametrics

* chore: changeset

* test: fix tests

* test: fix tests

* test: fix

* test: remove flaky test

* chore: version packages (#534)

* chore: version packages

* ci: bump

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Chase Adams <c@cadams.io>

* fix: resolve issue with onError (#535)

* chore: version packages (#536)

* chore: version packages

* ci: bump

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Chase Adams <c@cadams.io>

* iframe Force Enabled (#537)

* fix: force enabled

* fix: default to true

* fix: added hideEnabled

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* chore: version packages

* ci: bump

* latest (#544)

* chore: version packages (#541)

* chore: version packages

* ci: bump

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Chase Adams <c@cadams.io>

* fix: access key in lvpr.tv (#543)

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* fix: added fallback to HLS only when no tracks have bframes != 1

* chore: changeset

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 2, 2024
1 parent 3a91f1a commit cd68707
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 20 deletions.
8 changes: 8 additions & 0 deletions .changeset/short-experts-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@livepeer/core-react": patch
"@livepeer/core-web": patch
"@livepeer/react": patch
"@livepeer/core": patch
---

**Fix:** added fallback to HLS if webrtc is not possible for one track, or if bframes is 0.
24 changes: 21 additions & 3 deletions packages/core-web/src/media/controls/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,27 @@ const addEffectsToStore = (

if (source.type === "webrtc") {
const unsubscribeBframes = store.subscribe(
(state) => Boolean(state?.__metadata?.bframes),
(bframes) => {
if (bframes && !unmounted) {
(state) => state?.__metadata,
(metadata) => {
let webrtcIsPossibleForOneTrack = false;

// Check if metadata and meta tracks are available
if (metadata?.meta?.tracks) {
// Iterate over each track in the metadata
for (const trackId of Object.keys(metadata.meta.tracks)) {
// Check if the track does not have bframes equal to 1
if (metadata?.meta?.tracks[trackId]?.bframes !== 1) {
webrtcIsPossibleForOneTrack = true;
}
}
}

// Determine if fallback to HLS is necessary
const shouldFallBackToHLS =
!webrtcIsPossibleForOneTrack || metadata?.meta?.bframes !== 0;

// If fallback to HLS is needed and component is not unmounted, handle the error
if (shouldFallBackToHLS && !unmounted) {
onErrorComposed(new Error(BFRAMES_ERROR_MESSAGE));
}
},
Expand Down
58 changes: 56 additions & 2 deletions packages/core/src/media/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,64 @@ export type ElementSize = {
width: number;
height: number;
};
type MetaTrack = {
bps?: number;
channels?: number;
codec?: string;
codecstring?: string;
firstms?: number;
idx?: number;
init?: string;
jitter?: number;
lastms?: number;
maxbps?: number;
rate?: number;
size?: number;
trackid?: number;
type?: string;
height?: number;
width?: number;
fpks?: number;
bframes?: number;
};

export type Metadata = {
type Meta = {
bframes?: number;
bufferWindow?: number;
buffer_window?: number;
jitter?: number;
live?: number;
maxkeepaway?: number;
tracks?: {
[key: string]: MetaTrack;
};
uuid?: string;
version?: number;
};

type Source = {
priority?: number;
relurl?: string;
simul_tracks?: number;
total_matches?: number;
type?: string;
url?: string;
hrn?: string;
player_url?: string;
RTCIceServers?: {
urls?: string;
credential?: string;
username?: string;
}[];
};

export type Metadata = {
height?: number;
meta?: Meta;
selver?: number;
source?: Source[];
type?: string;
unixoffset?: number;
width?: number;
};

export type ClipLength = 90 | 60 | 45 | 30 | 15 | 10;
Expand Down
17 changes: 4 additions & 13 deletions packages/core/src/media/metrics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { MediaControllerStore } from "./controller";
import type { MediaControllerStore, Metadata } from "./controller";
import { getMetricsReportingWebsocketUrl } from "./metrics-utils";
import type { MimeType } from "./mime";

Expand Down Expand Up @@ -526,18 +526,9 @@ export function addLegacyMediaMetricsToStore(
newWebSocket.addEventListener("message", (event) => {
try {
if (event?.data) {
const json = JSON.parse(event.data);

if (json?.meta?.bframes || json?.meta?.buffer_window) {
store.getState().__controlsFunctions.setWebsocketMetadata({
bframes: json?.meta?.bframes
? Number(json?.meta?.bframes)
: undefined,
bufferWindow: json?.meta?.buffer_window
? Number(json?.meta?.buffer_window)
: undefined,
});
}
const json = JSON.parse(event.data) as Metadata;

store.getState().__controlsFunctions.setWebsocketMetadata(json);
}
} catch (e) {
console.warn("Failed to parse metadata from websocket.");
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const core = "@livepeer/core@3.2.0";
const react = "@livepeer/react@4.2.0";
const core = "@livepeer/core@3.2.2";
const react = "@livepeer/react@4.2.2";

export const version = {
core,
Expand Down

0 comments on commit cd68707

Please sign in to comment.