insta360: Improve connection handling
Description
Currently, insta360.rtmp.Client is not very resilient to connectivity fluctuations. Connection timeouts and drops can cause the supporting threads (recv, keepalive) threads to continue spinning indefinitely with no way to recover. Some threads are also daemon threads, which makes the usage of this in long-lasting processes a bit unfriendly.
With the direction where streaming is going (context: #461 (closed)), this is going to be crucial to figure out.
rtmp.Client needs to be refactored to better support scenarios like this. Some refactor guidelines:
- no daemon threads
- connection drops should result in threads wrapping up cleanly and stopping
- threads in general should be "tied" to a connection, not
Clientinstance lifetime (start them onopen, wrap them up onclose/disconnects)
Scope
- Refactor
rtmp.Client
Edited by Milos