optional stats to fix birdseye player

This commit is contained in:
Josh Hawkins 2024-12-28 11:37:49 -06:00
parent 0a9bf413f6
commit 14acca3a01
3 changed files with 12 additions and 12 deletions

View File

@ -14,7 +14,7 @@ type JSMpegPlayerProps = {
containerRef: React.MutableRefObject<HTMLDivElement | null>; containerRef: React.MutableRefObject<HTMLDivElement | null>;
playbackEnabled: boolean; playbackEnabled: boolean;
useWebGL: boolean; useWebGL: boolean;
setStats: (stats: PlayerStatsType) => void; setStats?: (stats: PlayerStatsType) => void;
onPlaying?: () => void; onPlaying?: () => void;
}; };
@ -166,7 +166,7 @@ export default function JSMpegPlayer({
const timeDiff = (currentTimestamp - lastTimestampRef.current) / 1000; // in seconds const timeDiff = (currentTimestamp - lastTimestampRef.current) / 1000; // in seconds
const bitrate = (bytesReceivedRef.current * 8) / timeDiff / 1000; // in kbps const bitrate = (bytesReceivedRef.current * 8) / timeDiff / 1000; // in kbps
setStats({ setStats?.({
streamType: "jsmpeg", streamType: "jsmpeg",
bandwidth: Math.round(bitrate), bandwidth: Math.round(bitrate),
totalFrames: frameCount, totalFrames: frameCount,

View File

@ -22,8 +22,8 @@ type MSEPlayerProps = {
volume?: number; volume?: number;
playInBackground?: boolean; playInBackground?: boolean;
pip?: boolean; pip?: boolean;
getStats: boolean; getStats?: boolean;
setStats: (stats: PlayerStatsType) => void; setStats?: (stats: PlayerStatsType) => void;
onPlaying?: () => void; onPlaying?: () => void;
setFullResolution?: React.Dispatch<SetStateAction<VideoResolutionType>>; setFullResolution?: React.Dispatch<SetStateAction<VideoResolutionType>>;
onError?: (error: LivePlayerError) => void; onError?: (error: LivePlayerError) => void;
@ -37,7 +37,7 @@ function MSEPlayer({
volume, volume,
playInBackground = false, playInBackground = false,
pip = false, pip = false,
getStats, getStats = false,
setStats, setStats,
onPlaying, onPlaying,
setFullResolution, setFullResolution,
@ -611,7 +611,7 @@ function MSEPlayer({
? (droppedVideoFrames / totalVideoFrames) * 100 ? (droppedVideoFrames / totalVideoFrames) * 100
: 0; : 0;
setStats({ setStats?.({
streamType: "MSE", streamType: "MSE",
bandwidth, bandwidth,
latency, latency,
@ -627,7 +627,7 @@ function MSEPlayer({
return () => { return () => {
clearInterval(interval); clearInterval(interval);
setStats({ setStats?.({
streamType: "-", streamType: "-",
bandwidth: 0, bandwidth: 0,
latency: undefined, latency: undefined,

View File

@ -11,8 +11,8 @@ type WebRtcPlayerProps = {
microphoneEnabled?: boolean; microphoneEnabled?: boolean;
iOSCompatFullScreen?: boolean; // ios doesn't support fullscreen divs so we must support the video element iOSCompatFullScreen?: boolean; // ios doesn't support fullscreen divs so we must support the video element
pip?: boolean; pip?: boolean;
getStats: boolean; getStats?: boolean;
setStats: (stats: PlayerStatsType) => void; setStats?: (stats: PlayerStatsType) => void;
onPlaying?: () => void; onPlaying?: () => void;
onError?: (error: LivePlayerError) => void; onError?: (error: LivePlayerError) => void;
}; };
@ -26,7 +26,7 @@ export default function WebRtcPlayer({
microphoneEnabled = false, microphoneEnabled = false,
iOSCompatFullScreen = false, iOSCompatFullScreen = false,
pip = false, pip = false,
getStats, getStats = false,
setStats, setStats,
onPlaying, onPlaying,
onError, onError,
@ -268,7 +268,7 @@ export default function WebRtcPlayer({
? (bytesReceived - lastBytesReceived) / timeDiff / 1000 ? (bytesReceived - lastBytesReceived) / timeDiff / 1000
: 0; // in kbps : 0; // in kbps
setStats({ setStats?.({
streamType: "WebRTC", streamType: "WebRTC",
bandwidth: Math.round(bitrate), bandwidth: Math.round(bitrate),
latency: roundTripTime, latency: roundTripTime,
@ -286,7 +286,7 @@ export default function WebRtcPlayer({
return () => { return () => {
clearInterval(interval); clearInterval(interval);
setStats({ setStats?.({
streamType: "-", streamType: "-",
bandwidth: 0, bandwidth: 0,
latency: undefined, latency: undefined,