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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Build native plugin to get ntp time of audio data

Discussion in 'Unity Render Streaming' started by Bushibenxin, Apr 5, 2023.

  1. Bushibenxin

    Bushibenxin

    Joined:
    Dec 8, 2022
    Posts:
    2
    Package version
    Render Streaming 3.1.0-exp.6
    WebRTC 3.0.0-pre.4
    Environment
    OS windows11
    unity version 2021.3.9
    Android 13
    Question

    I tried to get the ntp time of audio data on the receiving end, and I follow the README to custom native plugin. We have test the official webrtc example, It seems feasible to obtain ntp time using the PullRenderData function.
    I built the new native plugin to get ntp time on windows and android. However, the value of the ntp time get from PullrenderData was always -1 when I run Bidirectional on the windows, and it became elapsed time when I change the platfrom to android. I don't know how the PullRenderData is implemented,since unity.webrtc is using a compiled static library of webrtc. My questions are as follows.
    a. Have you modified the webrtc source code?
    b. Is it possible to replace your static library files(webrtc.lib/ libwebrtc.aar) with our own compiled ones?

    I'm sorry if I didn't make my point clearly. I would love to hear other options to get ntp time of audio data.
     
  2. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    770
    a. We put patch files for libwebrtc on GitHub repository.
    https://github.com/Unity-Technologies/com.unity.webrtc/tree/main/BuildScripts~/patches

    b. Yes, but you need to install a package from local folder.
    https://docs.unity3d.com/Manual/upm-ui-local.html

    I would like to know why you want to use ntp time. If it is useful for every developers, we can add the plan to support the feature.
     
  3. Bushibenxin

    Bushibenxin

    Joined:
    Dec 8, 2022
    Posts:
    2
    Thank you for your reply. I use data channel to transmit avatar data, and I need to synchronize audio with avatar using ntp time.
     
  4. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    770
    I am very interested in your topic.
    If you achieved your project, please share us.