-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into PBE-5855-feat/react-native-video-design-v2
- Loading branch information
Showing
46 changed files
with
2,704 additions
and
1,414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@stream-io/video-client", | ||
"version": "1.8.2", | ||
"version": "1.8.3", | ||
"packageManager": "[email protected]", | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.es.js", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@stream-io/video-react-bindings", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"packageManager": "[email protected]", | ||
"main": "./dist/index.cjs.js", | ||
"module": "./dist/index.es.js", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@stream-io/video-react-native-sdk", | ||
"version": "1.1.3", | ||
"version": "1.1.5", | ||
"packageManager": "[email protected]", | ||
"main": "dist/commonjs/index.js", | ||
"module": "dist/module/index.js", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { | ||
StreamVideoParticipant, | ||
VideoTrackType, | ||
} from '@stream-io/video-client'; | ||
import { useCall } from '@stream-io/video-react-bindings'; | ||
import { useState, useEffect } from 'react'; | ||
|
||
/** | ||
* This is a utility hook to get the dimensions of the video track of the participant. | ||
* Note: the `tracktype` is used only for local participants. | ||
* `tracktype` should be 'videoTrack' for video track and 'screenShareTrack' for screen share track. | ||
*/ | ||
export function useTrackDimensions( | ||
participant: StreamVideoParticipant, | ||
trackType: VideoTrackType | ||
) { | ||
const [trackDimensions, setTrackDimensions] = useState({ | ||
width: 0, | ||
height: 0, | ||
}); | ||
const call = useCall(); | ||
const { isLocalParticipant, sessionId, videoStream, screenShareStream } = | ||
participant; | ||
|
||
// for local participant we can get from track.getSettings() | ||
useEffect(() => { | ||
if (call && isLocalParticipant) { | ||
const stream = | ||
trackType === 'screenShareTrack' ? screenShareStream : videoStream; | ||
if (!stream) return; | ||
const [track] = stream?.getVideoTracks(); | ||
if (!track) return; | ||
const { width = 0, height = 0 } = track.getSettings(); | ||
setTrackDimensions((prev) => { | ||
if (prev.width !== width || prev.height !== height) { | ||
return { width, height }; | ||
} | ||
return prev; | ||
}); | ||
} | ||
}, [call, isLocalParticipant, screenShareStream, trackType, videoStream]); | ||
|
||
// start reporting stats for the remote participant | ||
useEffect(() => { | ||
if (!call) return; | ||
if (isLocalParticipant) return; | ||
call.startReportingStatsFor(sessionId); | ||
return () => { | ||
call.stopReportingStatsFor(sessionId); | ||
}; | ||
}, [call, sessionId, isLocalParticipant]); | ||
|
||
// for remote participants track.getSettings() is not supported it returns an empty object | ||
// so we need to rely on call stats to get the dimensions | ||
useEffect(() => { | ||
if (!call) return; | ||
const sub = call.state.callStatsReport$.subscribe((report) => { | ||
if (!report) return; | ||
const reportForTracks = report.participants[sessionId]; | ||
const trackStats = reportForTracks | ||
?.flatMap((r) => r.streams) | ||
.filter((track) => track.kind === 'video'); | ||
if (!trackStats) return; | ||
const stat = trackStats[0]; | ||
if (stat) { | ||
const { frameWidth = 0, frameHeight = 0 } = stat; | ||
setTrackDimensions((prev) => { | ||
if (prev.width !== frameWidth || prev.height !== frameHeight) { | ||
return { width: frameWidth, height: frameHeight }; | ||
} | ||
return prev; | ||
}); | ||
} | ||
}); | ||
return () => sub.unsubscribe(); | ||
}, [call, sessionId]); | ||
|
||
return trackDimensions; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@stream-io/video-react-sdk", | ||
"version": "1.6.4", | ||
"version": "1.6.6", | ||
"packageManager": "[email protected]", | ||
"main": "./dist/index.cjs.js", | ||
"module": "./dist/index.es.js", | ||
|
Oops, something went wrong.