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

Actually stop the track when the broadcast extension socket is closed #520

Merged
merged 8 commits into from
Dec 5, 2024

Conversation

bcherry
Copy link
Contributor

@bcherry bcherry commented Dec 4, 2024

This closes #446

Two fixes:

1. It seems that stopping the broadcast via tapping on the system indicator and choosing "stop broadcast" calls the broadcastPaused method instead of the broadcastFinished method on the SampleHandler. The only way I could trigger broadcastFinished in testing was by locking my device. I could not find a way to trigger broadcastResumed so I just went ahead and treated "pause" as final, and close the socket (I think maybe this is vestigial from older iterations of ReplayKit? not sure, it's not an area I'm super familiar with)
2. When the socket closes the frame reader stops but never notified the BroadcastScreenCapturer that owns it, so the track would stay published even as it stopped being updated. This fix adds a new callback method to pass the closure up the stack and stop the track.

Not sure what happened in original testing but actually broadcastFinished is called as expected, and broadcastPaused is called when you open the "stop capture" dialog, not when you finish it. I also fixed it to properly unpublish the track, not sure why initial testing showed simply ending capture to be enough.

@bcherry
Copy link
Contributor Author

bcherry commented Dec 4, 2024

@davidzhao the original version was incomplete, can you take another look?

@bcherry bcherry requested a review from davidzhao December 4, 2024 17:53
Copy link
Member

@davidzhao davidzhao left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@davidliu davidliu left a comment

Choose a reason for hiding this comment

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

LGTM, will need to update on flutter and react-native as well.

@hiroshihorie hiroshihorie merged commit acde14a into main Dec 5, 2024
12 checks passed
@hiroshihorie hiroshihorie deleted the bcherry/stop-broadcast-stop-track branch December 5, 2024 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants