Skip to content

Commit

Permalink
fix: update
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-pousette committed Feb 20, 2025
1 parent a3d38f8 commit a162f4c
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 188 deletions.
14 changes: 9 additions & 5 deletions packages/live-streaming/frontend/src/media/streamer/Renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -974,11 +974,12 @@ export const Renderer = (args: { stream: MediaStreamDB }) => {
}
}

let frameCounter = 0;
let totalFrameCounter = 0;
let lastFrame: number | undefined = undefined;
let framesSinceLastBackground = 0;
let lastFrameTimestamp = -1;
let firstFrameHighresTimestamp: undefined | number = undefined;

const maxEncoderQueueSize = 30;
const requestFrame = () => {
if (!inBackground && "requestVideoFrameCallback" in videoRef) {
Expand All @@ -1000,6 +1001,7 @@ export const Renderer = (args: { stream: MediaStreamDB }) => {
if (sourceIdOnStart !== sourceId.current) {
return; // new source, expect a reboot of the frame loop cycle
}

const now = domHighRes ?? performance.now();

if (!inBackground) {
Expand Down Expand Up @@ -1124,23 +1126,23 @@ export const Renderer = (args: { stream: MediaStreamDB }) => {
} else {
const droppedFrames = Math.max(
(metadata?.presentedFrames ?? 0) -
frameCounter,
totalFrameCounter,
0
);
/* console.log({ droppedFrames })
if (metadata?.presentedFrames && metadata?.presentedFrames > 10 && droppedFrames / metadata.presentedFrames > 0.1) {
videoRef.playbackRate = 0.3;
} */
console.log({
frameCounter,
frameCounter: totalFrameCounter,
playedFrame:
metadata?.presentedFrames,
droppedFrames,
});
frameCounter++;
totalFrameCounter++;
const insertKeyframe =
Math.round(
frameCounter /
totalFrameCounter /
videoEncoders.current.length
) %
60 ===
Expand Down Expand Up @@ -1180,6 +1182,7 @@ export const Renderer = (args: { stream: MediaStreamDB }) => {
requestFrame();
};
const onEnd = async () => {
console.log("end?");
if (loop || sourceTypeRef.current.type === "noise") {
loopCounter.current++;
videoRef.current.play();
Expand All @@ -1192,6 +1195,7 @@ export const Renderer = (args: { stream: MediaStreamDB }) => {
};

const onPause = async () => {
console.log("pause?");
if (sourceTypeRef.current == null) {
return;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/react-utils/src/usePeer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ export const PeerProvider = (options: PeerOptions) => {
connectionManager: {
maxConnections: 100,
},
connectionMonitor: {
enabled: false,
},

streamMuxers: [yamux()],
...(nodeOptions.network === "local"
Expand Down
Loading

0 comments on commit a162f4c

Please sign in to comment.