blackuy / react-native-twilio-video-webrtc

Twilio Video (WebRTC) for React Native
https://www.twilio.com/docs/video
MIT License
608 stars 404 forks source link

[android] Room recording status #568

Open kubanac95 opened 3 years ago

kubanac95 commented 3 years ago

This is a work in progress in hopes to close the following issue #566

Just adding onRecordingStarted and onRecordingStopped would have been sufficient in most cases, but, based on Twilio documentation for onRecordingStarted, it looks like it would not cover the case for joining a room that is already being recorded. (In cases of group rooms)

This method is only called when a Room which was not previously recording starts recording. If you've joined a Room which is already recording this event will not be fired.

One way to fix this would be to emit onRecordingStarted event manually on onConnected if room.isRecording() == true

I was also looking into adding isActive() method to the TwilioVideo component, but once I checked the current communication setup in the project, I noticed that there's no Promise based communication between the CustomTwilioVideoViewManager and the react-native code.

I looked into a possible solution inside react-native-camera module since I knew it had a promise-based API for communication with the CameraView, so I wrote the TwilioVideoModule to allow communication with the UI layer

This solution turned out to be working, but it the only the first time you start the video call. After starting the call for the second time I could not reach out to the CustomTwilioVideoView since the view was not properly destroyed previously and resources were not released it seems.

With a bit of help from sir @marqroldan and his PR, the view is properly destroyed

The whole purpose of this PR is not just to add the recording callbacks, but to actually establish a better solution for communicating with the UI layer.

I will flag this as a WIP since it still lacks iOS implementation, but any feedback is welcome on the abovementioned topics!

Thanks