Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question What is the point of Vivox/Agora vs. WebRTC? (for purely audio comms)

Discussion in 'General Discussion' started by mikejm_, Jul 4, 2023.

  1. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    I am trying to figure out the best/cheapest/simplest technology for multiplayer voice communication.

    As I understand, Unity WebRTC allows for direct peer to peer audio connections. One could presumably scale the volume of audio connected players or mute/adjust them based on proximity or other factors based on gameplay in Unity via script once connections are made.

    For example doing something like: https://assetstore.unity.com/packages/tools/network/voice-chat-multiplayer-netcode-webrtc-248159

    So if the only need is to get an audio connection between your users, what is the point of something like Vivox/Agora?

    Specifically on a tech level for audio chat what is Vivox/Agora doing? Is it just facilitating peer to peer WebRTC connections just like I described? Or is it sending all the audio to a single server and the server is mixing the individual streams per player (or forwarding all the individual streams again to each player)?

    From a cost perspective, peer to peer audio will also save server costs. If it is taking all the audio streams as an intermediary to the server, why? Why pay data charges of sending audio to an intermediary server if one does not need to?

    Thanks for any clarity.
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    I don‘t know about audio but since a WebGL app cannot be a server/host in a network game I would assume there is no peer to peer connectivity possible between two WebGL apps without an intermediate server service.

    WebRTC doesn‘t do peer to peer, it requires a server too:
     
  3. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Thanks. I'm just learning as I go. I found this good summary that explains it:

    https://getstream.io/glossary/turn-server/

    So to the extent that one is able, if your users can connect with STUN you will save on data costs as they will be sending the data directly to one another. But if you need TURN you will have to pay for every player second of audio transmitted in any direction at a time.

    Presumably things like Vivox and Agora are doing TURN by default? I wonder. I wonder also how Unity WebRTC works with either or both. I will have to learn more.

    Anyone know anything about any of this? Thanks.