OpenVidu / openvidu-tutorials

OpenVidu tutorials to get started
http://openvidu.io/tutorials
Apache License 2.0
228 stars 255 forks source link

Fixed an attempt to publish video after failure to set the local desc… #174

Closed trantako closed 2 years ago

trantako commented 2 years ago

When preparing to publish a video stream from an Android client app to OpenVidu session, it is possible that creating video offer succeeds but then setting it as the local description fails.

An example: Android client is configured to use a hardware video encoder, but a particular device does not have one. As a result, SDP description is created without some necessary video elements, and setting it as the local description fails at runtime.

The original code did not check the result of setting a local description before it went on to attempt publishing video. This resulted to breaking the whole OpenVidu session with rather severe consequences:

This simple fix checks if setting the local description succeeds, and only then attempts to publish video stream.

While this demo application does not configure HW encoder in use, other developers will use it as a basis for their apps. In addition, there can be other reasons why setting local description may fail. Hence, it should be checked.

j1elo commented 2 years ago

There are other places where this can happen, such as here:

https://github.com/OpenVidu/openvidu-tutorials/blob/014de35b94f07e33ffcb541cd1b9481e34132543/openvidu-android/app/src/main/java/io/openvidu/openvidu_android/websocket/CustomWebSocket.java#L390-L391

This change looks good to me, I'll be merging and adding some extra changes wrt. error handling on SDP operations.

Thanks!