You're really getting into the area of customisable algorithms.
I'm not sure I'd want an app on my smart phone trying to do all that processing.
I kinda feel like I want a smart relay to do this. It would require that the relay behaves like a client & also a relay. My smartphone client would then connect only to that trusted relay.