Search Unity

trouble with Oculus Platform SDK VoIP

Discussion in 'VR' started by JoeStrout, Sep 20, 2018.

Thread Status:
Not open for further replies.
  1. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I'm testing a game on the Oculus Go that uses their Platform SDK for voice chat (VoIP). It works great when only two players are connected. Players A and B can hear each other loud and clear. But when a third player (player C) connects, things break:
    • Player A can hear only player C.
    • Player B can hear only player C.
    • Player C can hear only player B.
    (Nobody can hear player A anymore.)

    I've poured over the logs, and found no clues; all players appear to have valid VoIP connections to the other two players (as judged, for example, from the "Internal state change" logs from the OVRPlatform library).

    It's acting as though each player can only receive/play audio from one other player at a time — specifically, whichever player connected last. But I don't know why that would be. Here's how we handle connections:

    Code (CSharp):
    1.     /// <summary>
    2.     /// Establish a connection to the given user ID, with the playback component
    3.     /// attached to the given game object.
    4.     /// </summary>
    5.     /// <param name="remoteUserID">numeric ID of the user to connect to</param>
    6.     public void ConnectToUser(System.UInt64 remoteUserID, GameObject playbackHost) {
    7.         status[remoteUserID] = "ConnectToUser called";
    8.        
    9.         var audioSource = gameObject.GetComponent<VoipAudioSourceHiLevel>();
    10.         if (audioSource == null) audioSource = gameObject.AddComponent<VoipAudioSourceHiLevel>();
    11.         audioSource.senderID = remoteUserID;
    12.         Debug.Log("Set up VoipAudioSourceHiLevel for user " + remoteUserID + " on " + playbackHost, playbackHost);
    13.        
    14.         Voip.SetVoipConnectRequestCallback((Message<Oculus.Platform.Models.NetworkingPeer> msg) => {
    15.             Debug.Log("Accepting Voip connection request from " + msg.Data.ID);
    16.             status[remoteUserID] = "Accepted";
    17.             Voip.Accept(msg.Data.ID);
    18.         });
    19.        
    20.         Voip.SetVoipStateChangeCallback((Message<Oculus.Platform.Models.NetworkingPeer> msg) => {
    21.             Debug.LogFormat("peer {0} is in state {1}", msg.Data.ID, msg.Data.State);
    22.             status[msg.Data.ID] = "State " + msg.Data.State.ToString();
    23.             if (msg.Data.State == PeerConnectionState.Timeout) {
    24.                 // Keep trying (but remember, the lower ID initiates)
    25.                 if (PlatformSDKIntegration.userID < remoteUserID) {
    26.                     status[msg.Data.ID] = "Restarting (from " + msg.Data.State.ToString() + ")";
    27.                     Voip.Start(remoteUserID);
    28.                 } else {
    29.                     status[msg.Data.ID] = "Waiting (in " + msg.Data.State.ToString() + ")";
    30.                 }
    31.             }
    32.         });
    33.        
    34.         // We compare IDs to decide who initiates and who gets the callback
    35.         if (PlatformSDKIntegration.userID < remoteUserID) {
    36.             Voip.Start(remoteUserID);
    37.             status[remoteUserID] = "Starting";
    38.         } else {
    39.             status[remoteUserID] = "Waiting";
    40.         }
    41.     }
    Pardon all the debug code. It boils down to, we add a VoipAudioSourceHiLevel component (from the Oculus Platform SDK) to the game object that represents the remote player, set up some callbacks, and then whichever end has a lower userID calls Voip.Start.

    Now that I look at it, it does seem a little funny that we're setting those callbacks every time — those are static methods; I'd think it should suffice to call them once. This was based on Oculus sample code, but perhaps I've misapplied it somehow.

    Does anybody have experience with Oculus VoIP? Any idea why I can only hear the most recently-connected player, even though the logs suggest I'm still connected to both?
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    DOH! I think I found it. The code above was intended to add the VoipAudioSourceHiLevel to the passed-in playbackHost object. But instead it's adding it to gameObject (which is a singleton manager).

    Still need to test, but it's definitely wrong and would fit the symptoms! (What is it about posting your problems publicly that makes your IQ suddenly jump 20 points?)
     
  3. Vad3rInHale

    Vad3rInHale

    Joined:
    Apr 19, 2015
    Posts:
    96
    I love you
     
  4. Seth0102

    Seth0102

    Joined:
    Feb 4, 2021
    Posts:
    1
    If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff. Platform SDK Development Discuss development with the Oculus Platform SDK integration here!


    walgreenslistens
     
    Last edited: Feb 12, 2021
Thread Status:
Not open for further replies.