Skip to content

Commit 95c98b7

Browse files
authored
Merge pull request #39 from hawkeye217/multistream-speed
fixes
2 parents 27779c3 + 581ff3f commit 95c98b7

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

web/src/components/player/JSMpegPlayer.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type JSMpegPlayerProps = {
1414
containerRef: React.MutableRefObject<HTMLDivElement | null>;
1515
playbackEnabled: boolean;
1616
useWebGL: boolean;
17-
setStats: (stats: PlayerStatsType) => void;
17+
setStats?: (stats: PlayerStatsType) => void;
1818
onPlaying?: () => void;
1919
};
2020

@@ -166,7 +166,7 @@ export default function JSMpegPlayer({
166166
const timeDiff = (currentTimestamp - lastTimestampRef.current) / 1000; // in seconds
167167
const bitrate = (bytesReceivedRef.current * 8) / timeDiff / 1000; // in kbps
168168

169-
setStats({
169+
setStats?.({
170170
streamType: "jsmpeg",
171171
bandwidth: Math.round(bitrate),
172172
totalFrames: frameCount,

web/src/components/player/MsePlayer.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ type MSEPlayerProps = {
2222
volume?: number;
2323
playInBackground?: boolean;
2424
pip?: boolean;
25-
getStats: boolean;
26-
setStats: (stats: PlayerStatsType) => void;
25+
getStats?: boolean;
26+
setStats?: (stats: PlayerStatsType) => void;
2727
onPlaying?: () => void;
2828
setFullResolution?: React.Dispatch<SetStateAction<VideoResolutionType>>;
2929
onError?: (error: LivePlayerError) => void;
@@ -37,7 +37,7 @@ function MSEPlayer({
3737
volume,
3838
playInBackground = false,
3939
pip = false,
40-
getStats,
40+
getStats = false,
4141
setStats,
4242
onPlaying,
4343
setFullResolution,
@@ -611,7 +611,7 @@ function MSEPlayer({
611611
? (droppedVideoFrames / totalVideoFrames) * 100
612612
: 0;
613613

614-
setStats({
614+
setStats?.({
615615
streamType: "MSE",
616616
bandwidth,
617617
latency,
@@ -627,7 +627,7 @@ function MSEPlayer({
627627

628628
return () => {
629629
clearInterval(interval);
630-
setStats({
630+
setStats?.({
631631
streamType: "-",
632632
bandwidth: 0,
633633
latency: undefined,

web/src/components/player/WebRTCPlayer.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ type WebRtcPlayerProps = {
1111
microphoneEnabled?: boolean;
1212
iOSCompatFullScreen?: boolean; // ios doesn't support fullscreen divs so we must support the video element
1313
pip?: boolean;
14-
getStats: boolean;
15-
setStats: (stats: PlayerStatsType) => void;
14+
getStats?: boolean;
15+
setStats?: (stats: PlayerStatsType) => void;
1616
onPlaying?: () => void;
1717
onError?: (error: LivePlayerError) => void;
1818
};
@@ -26,7 +26,7 @@ export default function WebRtcPlayer({
2626
microphoneEnabled = false,
2727
iOSCompatFullScreen = false,
2828
pip = false,
29-
getStats,
29+
getStats = false,
3030
setStats,
3131
onPlaying,
3232
onError,
@@ -268,7 +268,7 @@ export default function WebRtcPlayer({
268268
? (bytesReceived - lastBytesReceived) / timeDiff / 1000
269269
: 0; // in kbps
270270

271-
setStats({
271+
setStats?.({
272272
streamType: "WebRTC",
273273
bandwidth: Math.round(bitrate),
274274
latency: roundTripTime,
@@ -286,7 +286,7 @@ export default function WebRtcPlayer({
286286

287287
return () => {
288288
clearInterval(interval);
289-
setStats({
289+
setStats?.({
290290
streamType: "-",
291291
bandwidth: 0,
292292
latency: undefined,

0 commit comments

Comments
 (0)