Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen Share and render shared screen [iOS] #27

Closed
BhavinBhadani opened this issue Feb 11, 2022 · 10 comments
Closed

Screen Share and render shared screen [iOS] #27

BhavinBhadani opened this issue Feb 11, 2022 · 10 comments

Comments

@BhavinBhadani
Copy link

I am trying to figure out how can I display screen shared by web app to my device as I don't find anything into doc and it just crashed in iOS app when it shared from web app?. The other question is when can we expect screen share feature from iOS side as well?

@gzerad
Copy link
Member

gzerad commented Feb 11, 2022

There is no special handling required to render screen share on iOS. You will get a HMSVideoTrack just like for regualr video, and the track source will be equal to screen. Could you attach a crash log perhaps? Regarding sharing screen from ios there is no fixed date atm, but most likely end of feb / early march.

@BhavinBhadani
Copy link
Author

Hi, Here is the screenshot for the crash
Screenshot 2022-02-11 at 3 44 09 PM

@gzerad
Copy link
Member

gzerad commented Feb 11, 2022

This does not look screen share specific to me. Seems like this is due to improper configuration of UIDiffableDataSource cant tell more without looking at the code.

@BhavinBhadani
Copy link
Author

BhavinBhadani commented Feb 11, 2022

@gzerad I'm using DiffableDataSource with HMSPeer and not with HMSViewModel because I want some kind of filters which is not worked with HMSViewModel. So, here the code that creates the issue

 private func applySnapshot(animatingDifferences: Bool = true) {
    guard let diffableDataSource = diffableDataSource else { return }
    let sections = dataSource.sections
    var snapshot = Snapshot()
    snapshot.appendSections(sections)
    sections.forEach { section in
        if let activePeers = getActivePeers() {
            var spectators: [HMSPeer] = []
            var mutableSpectators: [HMSPeer] = []

            section.models.forEach { model in
                if let customerId = model.peer.customerUserID {
                    if activePeers.contains(customerId) {
                        spectators.append(model.peer)
                    } else {
                        mutableSpectators.append(model.peer)
                    }
                }
            }

            mutableSpectators.forEach { spectator in
                if let remoteAudio = spectator.audioTrack as? HMSRemoteAudioTrack {
                    remoteAudio.setVolume(0)
                }
            }
            
            spectators.forEach { spectator in
                if let remoteAudio = spectator.audioTrack as? HMSRemoteAudioTrack {
                    remoteAudio.setVolume(1)
                }
            }

            snapshot.appendItems(spectators, toSection: section)
        }
    }
    diffableDataSource.apply(snapshot, animatingDifferences: animatingDifferences)
}

@gzerad
Copy link
Member

gzerad commented Feb 14, 2022

UIDiffableDataSource needs all the elements to be unique, if you are using HMSPeer instead of HMSViewModel you need to make sure that single HMSPeer can't be added twice. The default behavior of HMSDataSource is to create a HMSViewModel for each video track that HMSPeer is currently publishing. So if you just loop over and extract HMSPeer you will get that peer two times in case peer is sharing both video and screen tracks.
Can you describe what was the filters you wanted to create? Have you tried setting filter property on HMSDataSource with a filtering closure?

@gzerad
Copy link
Member

gzerad commented Feb 14, 2022

Also I have noticed that you are trying to manually mute some users. Using "roles" might work better for you, see this guide for reference.

@BhavinBhadani
Copy link
Author

@gzerad Regarding filter, I am doing some filtering based on firebase data which we set for different purpose and based on that I am filtering data. I first tried to do that using HMSViewModel but it didn't work. So, I have to achive that using HMSPeer. I already post a issue recently for the filter as well

@BhavinBhadani
Copy link
Author

@gzerad How to render a screen share cell in to mobile?

@ygit
Copy link
Member

ygit commented Mar 12, 2022

@BhavinBhadani a screen share is akin to any other video track. Set it to an instance of HMSVideoView.

A screen share track comes in as an HMSRemoteVideoTrack within auxiliaryTracks of the HMSPeer object.

You can get this either from the onTrackUpdate or just check for this in the HMSPeer who is sharing the screen.

Ensure to set videoContentMode of HMSVideoView to UIViewContentModeScaleAspectFit so that there's no clipping of the screen share.

@StackHelp
Copy link

@gzerad When we rotate spectators, the video view hangs and sometimes displays a black screen when rotating from landscape to portrait. Do you know how to resolve it?

@gzerad gzerad closed this as completed May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants