Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

[MV-391] Add screencast support #83

Merged
merged 18 commits into from
Apr 6, 2023
Merged

[MV-391] Add screencast support #83

merged 18 commits into from
Apr 6, 2023

Conversation

skyman503
Copy link
Contributor

No description provided.

@skyman503 skyman503 changed the title @skyman503/mv 391 v1 [MV-391] Add screencast support Apr 4, 2023
Copy link
Collaborator

@graszka22 graszka22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general the code in the Room screen is too complicated and too nested.
Consider doing it like this:
Move the participants part to another component.

Then calculate participantsWithTracks like you're doing it now and keep the focused participant+track in state.
Now you have two cases:

  1. If there is a focused track then return the rendered focused track+non-focused participants (you can have multiple return statements in one component!)
  2. Else return the participants in a grid.

And extract the logic of getting the tracks etc from the views to functions. That should take care of most of the nesting.

Also it would be nice if the RoomParticipant just took the whole available space and didn't care about aspect ratios etc.

About my Android device bug: the focused participant takes the whole width of the screen and the height according to aspect ratio. Then the not focused participants take the available height and they have aspect ration set to 1 so they take the same width. Probably my device is taller than yours. RN reports window size 411x936px, my model is xperia 10 III.
In my opinion the non focused participants should have 128x128px and the the focused participant takes the rest of available space. I'd fix that but right now the code is too complicated for me :D

example/src/screens/Room.tsx Outdated Show resolved Hide resolved
example/src/screens/Room.tsx Outdated Show resolved Hide resolved
example/src/screens/Room.tsx Outdated Show resolved Hide resolved
example/src/screens/Room.tsx Outdated Show resolved Hide resolved
example/src/screens/Room.tsx Outdated Show resolved Hide resolved
example/src/screens/Room.tsx Outdated Show resolved Hide resolved
example/src/components/StopScrencastingWithFocus.tsx Outdated Show resolved Hide resolved
example/src/components/StopScrencastingWithFocus.tsx Outdated Show resolved Hide resolved
example/src/components/RoomParticipant.tsx Outdated Show resolved Hide resolved
@@ -171,6 +190,13 @@ const styles = StyleSheet.create({
aspectRatio: 1,
alignSelf: 'center',
},
videoTrackScreencast: {
flex: 1,
aspectRatio: 1,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we manage the aspect ratio in the parent component? that way would be simpler and we can get rid of the focused prop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The focused prop will have to stay either way since it is used to determine not only the style but also pin button behaviour and moving it to the parent would make it less readable in my opinion. Also managing aspect ratio in the parent isn't as simple as it may seem, since I want to keep the displayName / muted / pin icons in fixed positions whatever the aspect ratio is, and managing thet from the parent would affect that. That's also why I don't like the idea of room participant taking the entire space as it would depend on the parent aspect ratio.

@skyman503
Copy link
Contributor Author

In general the code in the Room screen is too complicated and too nested. Consider doing it like this: Move the participants part to another component.

Then calculate participantsWithTracks like you're doing it now and keep the focused participant+track in state. Now you have two cases:

  1. If there is a focused track then return the rendered focused track+non-focused participants (you can have multiple return statements in one component!)
  2. Else return the participants in a grid.

And extract the logic of getting the tracks etc from the views to functions. That should take care of most of the nesting.

Also it would be nice if the RoomParticipant just took the whole available space and didn't care about aspect ratios etc.

About my Android device bug: the focused participant takes the whole width of the screen and the height according to aspect ratio. Then the not focused participants take the available height and they have aspect ration set to 1 so they take the same width. Probably my device is taller than yours. RN reports window size 411x936px, my model is xperia 10 III. In my opinion the non focused participants should have 128x128px and the the focused participant takes the rest of available space. I'd fix that but right now the code is too complicated for me :D

I did a fair bit of refactoring and in my opinion Room.tsx is looking clean now. I don't like the idea of roomParticipant taking the whole available space, I'll write more on why in response to one of the other comments.

@skyman503 skyman503 requested a review from graszka22 April 5, 2023 13:34
@skyman503 skyman503 marked this pull request as ready for review April 5, 2023 13:35
Copy link
Collaborator

@graszka22 graszka22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a couple of simple code style fixes this time 👍


return (
<View style={styles.focusedParticipantContainer}>
<View style={styles.focusedParticipant}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again those two views can be merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple copy pasting won't work here, so I think it would be best to leave it as it is for now especially since MV-395 will be reworking it's styling anyway.

example/src/components/FocusedParticipant.tsx Outdated Show resolved Hide resolved
example/src/components/Participants.tsx Outdated Show resolved Hide resolved
example/src/components/RoomParticipant.tsx Outdated Show resolved Hide resolved
const videoTrack = tracks.find((t) => t.id === trackId);
const videoTrackType = videoTrack?.metadata.type;
const audioTrack =
!videoTrack || videoTrackType === 'camera'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear what are you doing here: if there is no video track or the videotrack is from camera then search for audio track? Why? You already have a check if the track is screenshared

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never realised I could just that screenshared check from before, good point. Should be simpler now.

@@ -106,74 +113,25 @@ export const Room = () => {
<View style={{ flex: 1 }}>
{shouldShowParticipants && (
<>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer need the outer fragment (<>)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. I tried removing that and it gives an error, which the editor constantly recommends to fix by wrapping in empty jsx tag.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, works for me :p

Screenshot 2023-04-06 at 10 52 31

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@skyman503 skyman503 requested a review from graszka22 April 6, 2023 05:48
const videoTrack = trackId ? tracks.find((t) => t.id === trackId) : null;
const videoTrackType = videoTrack?.metadata.type;
const audioTrack =
videoTrackType !== 'screensharing'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think this check is unecessary (though it's simpler). You literally have the same one lower in the code (videoTrackType !== 'screensharing' &&)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@skyman503
Copy link
Contributor Author

I think useEffect in the Room screen solves the no videoTrack update bug we talked about, it should be all working now.

@skyman503 skyman503 requested a review from graszka22 April 6, 2023 09:49
focusedParticipantData?.participant !== curretStateOfFocusedParticipant
) {
setFocusedParticipantData({
participant: curretStateOfFocusedParticipant!,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if pinned participant exits the call? I've got a crash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks. I haven't realised that the participant that is being focused could disappear.

Copy link
Collaborator

@graszka22 graszka22 Apr 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and get rid of this ! now, it's not necessary
and it caused the crash again, I'm considering adding a lint rule to prohibit using ! :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@skyman503 skyman503 requested a review from graszka22 April 6, 2023 10:39
Copy link
Collaborator

@graszka22 graszka22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok now it looks pretty good 👏
Maybe putting the whole focused participant instead of just id wasn't a good idea after all - now I see we now have kind of double state but we'll think that out and refactor this later. Sorry for that 😅

@skyman503 skyman503 merged commit 5916d14 into master Apr 6, 2023
@skyman503 skyman503 deleted the @skyman503/MV-391-v1 branch April 6, 2023 11:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants