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. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Question Using WebRTC package as a client for Unity Render Streaming

Discussion in 'Unity Render Streaming' started by dtaddis, Jan 15, 2021.

  1. dtaddis

    dtaddis

    Joined:
    Oct 17, 2019
    Posts:
    16
    Hello,

    Apologies if this is a stupid question, but is the WebRTC package appropriate to be used as a client for remotely viewing another Unity app, using Unity Render Streaming? We would like to use it for Edge Rendering, i.e. render a scene on a PC then view it on an Android/iOS device running our client app.

    We can't just use a browser because we want to add extra details on the client, and make the whole process invisible to the user.

    If so, what is the sample in the WebRTC package closest to being able to do that (I don't see any that obviously set up a remote URL)?

    Thanks,
    David
     
  2. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    543
    About the WebRTC package, the mobile device support has been worked on since last month. iOS platform support is already published as version 2.3 and Android support will be released in February or March.
     
    salvolannister, LostPanda and dtaddis like this.
  3. dtaddis

    dtaddis

    Joined:
    Oct 17, 2019
    Posts:
    16
    Hi Kazuki, thanks very much for your reply.

    The Android support coming is great news - we are looking for a cross-platform solution.

    I was more asking if this is an appropriate use of WebRTC - is it already compatible with Unity Render Streaming out of the box? Which of the WebRTC sample scenes would be a good starting point for that?
     
  4. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    543
    Currently, we are preparing the new version of Unity Render Streaming which supports iOS platform. It should be released in February.
    The "VideoReceive" scene in the WebRTC sample is the simplest to demonstrate video streaming. But this sample works locally only, you need to implement the signaling process yourself.

    https://docs.unity3d.com/Packages/com.unity.webrtc@2.3/manual/index.html#samples
     
  5. dtaddis

    dtaddis

    Joined:
    Oct 17, 2019
    Posts:
    16
    Ok, that's good to know, thank you.

    I'm looking for a bit of guidance on how to do exactly that (implement the signaling) - half of it will have been done already by Unity Render Streaming's webserver, right? So I would need to know what to get and push to start getting the video stream from there?
     
  6. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    543
  7. aksik_

    aksik_

    Joined:
    Sep 14, 2020
    Posts:
    3
    Hello, I see there aren't any official builds with android support, but there is an experimental branch. Can I somehow use it?

    EDIT: I managed to use the experimental plugin, but on my android device I get an exception "Unable to load dll 'webRTC': the specified module could not be found". Is there anything I can do about it?
     
    Last edited: May 10, 2021
  8. gtk2k

    gtk2k

    Joined:
    Aug 13, 2014
    Posts:
    231
    @krystianjablonski3
    * Set Player-> Android-> Other Settings-> Scripting Backend in Project Settings to IL2CPP
    * Set Player-> Android-> Other Settings-> Target Architectures in Project Settings to ARM64
    * Make sure you have the libwebrtc.aar file in Plugins / Android
    Unity Render Streaming currently only supports ARM64.
     
  9. aksik_

    aksik_

    Joined:
    Sep 14, 2020
    Posts:
    3
    That worked! Thank you so much!
     
  10. mrSaig

    mrSaig

    Joined:
    Jan 14, 2010
    Posts:
    68
    Will there also be webGl support? Soon or later?
     
  11. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    543
    Currently, we don't have a plan to support WebGL.
    But it would be possible to change the priority if we get requests from more users.
     
    mrSaig likes this.
  12. w_adams

    w_adams

    Joined:
    Apr 7, 2016
    Posts:
    17
    I would like to lodge a request for WebGL support.. :)
     
    Stexe and mrSaig like this.
  13. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    543
    Stexe likes this.
  14. simu3105

    simu3105

    Joined:
    May 22, 2020
    Posts:
    1
    Hi,
    I want to followup on "dtaddis" request here.
    I have more or less the same request and I hope that someone can guide me.
    My goal is to create an app which has AR on client-A and streams this to client-B. In the same time client-B should be able to stream his cam to client-A and bidrectional on both clients with Audio. client-A should receive events from client-B. Client-B should be Browser or WebGL, client-A IOS/Android.
    Basically it seems that Unity-WebRTC Package does match the requirements, but I cannot read if it is compatible with AR and signaling process is missing. If I screen Unity-Render-Streaming, I'm confused and not 100% sure if bidrectional Video/Audio Browser<>iOS/Android is working.
    Does anyone knows more about these two packages and may guide me to the right solution?
     
  15. mfgcto

    mfgcto

    Joined:
    Dec 18, 2019
    Posts:
    1
    Hi ,
    Could you please let me know, if AR screen sharing is possible using webrtc in unity for Android and if it's available.
    I am stuck with the signalling server part of the webrtc could someone provide me an implementation example which I could use as a starting guide
     
    CloudyVR likes this.
  16. RawanShehata

    RawanShehata

    Joined:
    Sep 19, 2021
    Posts:
    1
    Is it possible to create an android game and play it on an android phone while streaming on another phone ?
     
  17. TropicalCyborg

    TropicalCyborg

    Joined:
    Mar 19, 2014
    Posts:
    25
  18. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    654
    Can I stream a camera from one Unity project and see the rendered image in another Unity project? I can't figure out how to make render streaming work and keep seeing "Signaling: WS connection closed, code: 1006" appear repeatedly.

    I've searched for hours and can't find any explanation or documentation that shows how to get any of the examples working.
     
  19. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    543
    You need to launth the webapp with "w" option to use WebSocket protocol.
    https://docs.unity3d.com/Packages/com.unity.renderstreaming@3.1/manual/webapp.html
     
    CloudyVR likes this.
  20. qskakar

    qskakar

    Joined:
    Dec 21, 2017
    Posts:
    4
    I want to do almost the same thing as @simu3105 but haven't found any tutorial/sample on the web. I want to create a cross platform video chat app between IOS/Android and Browser using WebRTC. I have already implemented the browser's implementation and the Unity implementation using video streaming with WebRTC but I am confused about how to connect them both using a signaling server / Unity render streaming.

    @simu3105 did you solve your problem? If yes, then can you provide any solution on how you did this? Thanks.
     
  21. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    543
    qskakar likes this.
  22. DinostabOMG

    DinostabOMG

    Joined:
    Jan 4, 2014
    Posts:
    24
    I am wondering if you have any information about how to get started with the networking aspects of the signaling process, that you mention we have to implement ourselves. Going through the WebRTC tutorials and samples, they always have two local instances of RTCPeerConnection but I have seen no indication of how this would look in a networked environment of any kind. Is there any sample available anywhere of a Unity WebRTC app running on two different computers? In our case we want to have in-game voice chat that includes an arbitrary data channel.
     
  23. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    543
    Please read this document.
    https://docs.unity3d.com/Packages/com.unity.renderstreaming@3.1/manual/index.html
     
  24. mohammedshetaya

    mohammedshetaya

    Joined:
    Feb 3, 2022
    Posts:
    8
    Does this mean that I am able to build the unity app with render streaming on android?
     
  25. gtk2k

    gtk2k

    Joined:
    Aug 13, 2014
    Posts:
    231
    yes
     
  26. mohammedshetaya

    mohammedshetaya

    Joined:
    Feb 3, 2022
    Posts:
    8
    That is great. So I can share with you what I am seeking to achieve. I need to build a unity application with ARFoundation and stream that app to the browser. so is this achievable?
     
  27. gtk2k

    gtk2k

    Joined:
    Aug 13, 2014
    Posts:
    231
    I think you can use the ScreenStreamSender component.
     
  28. mohammedshetaya

    mohammedshetaya

    Joined:
    Feb 3, 2022
    Posts:
    8
    I have added a render streaming, broadcast, and a ScreenStreamSender components to the ar camera. It does not work and I am getting a black screen on the browser.
     
  29. mohammedshetaya

    mohammedshetaya

    Joined:
    Feb 3, 2022
    Posts:
    8
    Now it works only if I make the ar camera to render in a target texture, so I need the ar foundation camera to render to both a target texture and the screen. Any ideas?
     
  30. kannan-xiao4

    kannan-xiao4

    Unity Technologies

    Joined:
    Nov 5, 2020
    Posts:
    43
    Copy to another RenderTexture in the OnPostRenderMethod on arcamera.
    and sending that copied RenderTexture. How is it?
     
  31. mohammedshetaya

    mohammedshetaya

    Joined:
    Feb 3, 2022
    Posts:
    8
    I am using the following script in order to blit the camera frames to a render texture. the only problem here is that it does not show the rendered image it only shows the camera with no rendering. to explain this more if I am having a 3d cube in the ARFoundation scene, this script will show the camera without the cube on the render texture, although the scene is rendered on the screen normally. what I need to do is to render on both the camera and the rendered texture.

    Code (CSharp):
    1. public class CameraTextureMixer : MonoBehaviour
    2. {
    3.  
    4.     [SerializeField]
    5.     private RenderTexture ARTexture;
    6.  
    7.     private void Awake()
    8.     {
    9.         ARCameraManager cameraManager = GetComponent<ARCameraManager>();
    10.         ARCameraBackground ARBackground = GetComponent<ARCameraBackground>();
    11.  
    12.         cameraManager.frameReceived += (e) =>
    13.         {
    14.             foreach (var t in e.textures)
    15.             {
    16.                 Graphics.Blit(t, ARTexture, ARBackground.material);
    17.             }
    18.         };
    19.  
    20.     }
    21.  
     
  32. kannan-xiao4

    kannan-xiao4

    Unity Technologies

    Joined:
    Nov 5, 2020
    Posts:
    43

    I think it's better to ask in the AR Forum about how to correctly Bilt the display contents of the AR camera to the Render Texture.
    https://forum.unity.com/forums/ar.161/
    (I've tried it in the past, but I've experienced that it doesn't work like Bilt on a Normal camera...)
     
  33. teripak2

    teripak2

    Joined:
    Feb 26, 2021
    Posts:
    1
    I am using WebRTC 2.4.0-exp.7 rather than using Render Streaming. It works on Android app on WIFI but it does not work when one of client is on cellular. I am using google stun server as below.
    {'iceServers': [{'urls': 'stun:stun.l.google.com:19302'}]}

    Do I have to use a TURN server to make it done?
     
  34. kannan-xiao4

    kannan-xiao4

    Unity Technologies

    Joined:
    Nov 5, 2020
    Posts:
    43
    Probably yes, please try use a TURN server.
     
  35. qngnht

    qngnht

    Joined:
    Jan 24, 2022
    Posts:
    4
    Can we have a sample how to join a room between 2 devices in Unity please ? I'm not expert on networking ... I tried WebRTC on Browser in another place before: Step 1. Type the name of Room ; Step 2. Click Join : Which device joined in this Room first will be the Host ( Local ) , other devices join after will be Clients (Remote) . I don't understand how Clients join in the Host in Webrtc Unity Sample... I'm trying com.unity.webrtc@2.4.0-exp.8
     
  36. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    543
    Have you tried the multiplay sample?
    https://docs.unity3d.com/Packages/com.unity.renderstreaming@3.1/manual/sample-multiplay.html
     
  37. qngnht

    qngnht

    Joined:
    Jan 24, 2022
    Posts:
    4
  38. qngnht

    qngnht

    Joined:
    Jan 24, 2022
    Posts:
    4
    kazuki_unity729 likes this.
  39. oliverEllmers

    oliverEllmers

    Joined:
    Feb 24, 2014
    Posts:
    2
    Can we please have a very simple example demonstrating how to connect to a remote WebRTC stream to be able to access a video stream?

    I am trying to figure out how I can stream WebRTC video over network into Unity to be applied as a video texture. It would be great if there was a simple example detailing how to connect to an external IP or URL to access a stream/track.
     
    CloudyVR likes this.
  40. kazuki_unity729

    kazuki_unity729

    Unity Technologies

    Joined:
    Aug 2, 2018
    Posts:
    543
    You mean we need to make the web server publicly to test connection over network?
    I would like to share the document to describe how to integrate it with third party services.